1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
double time1=(double)clock();
for(int i=0;i<1000;i++){
auto as1 = async(loop_kernel, L_d,0,asv1);
//start row and end row, from 0 to asv1
auto as2 = async(loop_kernel, L_d,asv1,asv2);
auto as3 = async(loop_kernel, L_d,asv2,asv3);
auto as4 = async(loop_kernel, L_d,asv3,asv4);
auto as5 = async(loop_kernel, L_d,asv4,asv5);
auto as6 = async(loop_kernel, L_d,asv5,asv6);
auto as7 = async(loop_kernel, L_d,asv6,asv7);
loop_kernel(L_d,asv7,*L_d.M);//use main processor
as1.get();
as2.get();
as3.get();
as4.get();
as5.get();
as6.get();
as7.get();
}
double timediff=(double)(clock()-time1)/CLOCKS_PER_SEC;
cout<<"time for 8 threads: "<<timediff<<endl;
time1=(double)clock();
for (int i=0;i<1000;i++)
loop_kernel(L_d,0,M);//no syncs
timediff=(double)(clock()-time1)/CLOCKS_PER_SEC;
cout<<"time for serial: "<<timediff<<endl;
|