Hi all,
I have tested this code on a machine with an Intel Dual Core processor:
omp_set_num_threads(1);
start=omp_get_wtime();
#pragma omp parallel for
for (i=1; i<1000000; ++i)
for (j=0; j<500; ++j)
b[i]=(a[j]+b[j])/2.0;
end=omp_get_wtime();
printf ("Elapsed time is: %f seconds\n", end-start);
and it will be run in ~7.5 seconds. Now when I change first line of
code to:
omp_set_num_threads(2);
elapsed time will be ~15 seconds which is almost twice. I except exactly reverse
behavior since my system is Dual Core and expect that elapsed time to be half and not
twice! Is there something that I am doing wrong? I use g++ 4.2 to compile my code.
Thanks!
Danesh
