void runtest(size_t n) { std::vector<char> a1(n); std::vector<char> a11(n); std::vector<char> a12(n); std::vector<char> a21(n); std::vector<char> a22(n); memset(&a1[0], 0, n * sizeof(char)); auto func = [&] (char v, char *p1, char *p2) { volatile char *p = &a1[0]; for (size_t i = 0;i < n;i++) { f(&p[i], v, &p1[i], &p2[i]); } }; std::thread t1(func, (char)1, &a11[0], &a12[0]); std::thread t2(func, (char)2, &a21[0], &a22[0]); t1.join(); t2.join(); for (size_t i = 0;i < n;i++) { assert(a1[i] == 1 || a1[i] == 2); if (a1[i] == 1) { check(1, 2, a11[i], a12[i], a21[i], a22[i]); } else { assert(a1[i] == 2); check(2, 1, a21[i], a22[i], a11[i], a12[i]); } } }
void level_two() { vector<DPipe> DPIPES(44); vector<DoublePipe> DOUBPIPES(18); vector<CrossPipe> CROSSPIPES(3); DPipe background(600,400,1200,800); DPipe a0(50,750,100,40); DPipe a1(150,650,100,40); DPipe a2(150,550,100,40); DPipe a3(650,450,100,40); DPipe a4(550,550,100,40); DPipe a5(450,350,100,40); DPipe a6(550,250,100,40); DPipe a7(650,250,100,40); DPipe a8(750,350,100,40); DPipe a9(750,450,100,40); DPipe a10(750,550,100,40); DPipe a11(650,650,100,40); DPipe a12(550,650,100,40); DPipe a13(450,650,100,40); DPipe a14(350,550,100,40); DPipe a15(350,350,100,40); DPipe a16(350,250,100,40); DPipe a17(450,150,100,40); DPipe a18(550,150,100,40); DPipe a19(650,150,100,40); DPipe a20(750,150,100,40); DPipe a21(850,250,100,40); DPipe a22(850,350,100,40); DPipe a23(850,450,100,40); DPipe a24(850,550,100,40); DPipe a25(850,650,100,40); DPipe a26(750,750,100,40); DPipe a27(650,750,100,40); DPipe a28(550,750,100,40); DPipe a29(450,750,100,40); DPipe a30(350,750,100,40); DPipe a31(250,650,100,40); DPipe a32(250,550,100,40); DPipe a33(250,350,100,40); DPipe a34(250,250,100,40); DPipe a35(250,150,100,40); DPipe a36(350,50,100,40); DPipe a37(450,50,100,40); DPipe a38(550,50,100,40); DPipe a39(650,50,100,40); DPipe a40(750,50,100,40); DPipe a41(850,50,100,40); DPipe a42(950,150,100,40); DPipe a43(950,250,100,40); DoublePipe b0(150,750,70,40); DoublePipe b1(150,450,70,40); DoublePipe b2(550,450,70,40); DoublePipe b3(550,350,70,40); DoublePipe b4(650,350,70,40); DoublePipe b5(650,550,70,40); DoublePipe b6(450,550,70,40); DoublePipe b7(450,250,70,40); DoublePipe b8(750,250,70,40); DoublePipe b9(750,650,70,40); DoublePipe b10(350,650,70,40); DoublePipe b11(350,150,70,40); DoublePipe b12(850,150,70,40); DoublePipe b13(850,750,70,40); DoublePipe b14(250,750,70,40); DoublePipe b15(250,50,70,40); DoublePipe b16(950,50,70,40); DoublePipe b17(950,350,70,40); CrossPipe c0(250,450,100,40); CrossPipe c1(350,450,100,40); CrossPipe c2(450,450,100,40); DPIPES[0]=a0; DPIPES[1]=a1; DPIPES[2]=a2; DPIPES[3]=a3; DPIPES[4]=a4; DPIPES[5]=a5; DPIPES[6]=a6; DPIPES[7]=a7; DPIPES[8]=a8; DPIPES[9]=a9; DPIPES[10]=a10; DPIPES[11]=a11; DPIPES[12]=a12; DPIPES[13]=a13; DPIPES[14]=a14; DPIPES[15]=a15; DPIPES[16]=a16; DPIPES[17]=a17; DPIPES[18]=a18; DPIPES[19]=a19; DPIPES[20]=a20; DPIPES[21]=a21; DPIPES[22]=a22; DPIPES[23]=a23; DPIPES[24]=a24; DPIPES[25]=a25; DPIPES[26]=a26; DPIPES[27]=a27; DPIPES[28]=a28; DPIPES[29]=a29; DPIPES[30]=a30; DPIPES[31]=a31; DPIPES[32]=a32; DPIPES[33]=a33; DPIPES[34]=a34; DPIPES[35]=a35; DPIPES[36]=a36; DPIPES[37]=a37; DPIPES[38]=a38; DPIPES[39]=a39; DPIPES[40]=a40; DPIPES[41]=a41; DPIPES[42]=a42; DPIPES[43]=a43; DOUBPIPES[0]=b0; DOUBPIPES[1]=b1; DOUBPIPES[2]=b2; DOUBPIPES[3]=b3; DOUBPIPES[4]=b4; DOUBPIPES[5]=b5; DOUBPIPES[6]=b6; DOUBPIPES[7]=b7; DOUBPIPES[8]=b8; DOUBPIPES[9]=b9; DOUBPIPES[10]=b10; DOUBPIPES[11]=b11; DOUBPIPES[12]=b12; DOUBPIPES[13]=b13; DOUBPIPES[14]=b14; DOUBPIPES[15]=b15; DOUBPIPES[16]=b16; DOUBPIPES[17]=b17; CROSSPIPES[0]=c0; CROSSPIPES[1]=c1; CROSSPIPES[2]=c2; }