[Omp] Speed of Example A.1.1.c

Brad Bell bradbell at seanet.com
Mon Apr 2 07:02:47 PDT 2007


I do not understand why Example A.1.1c (page 25 of the OpenMP 2.5 
specifications) does not get faster when I use multiple OpenMP threads 
on an 8 processor machine.

Attached you will find a bash script that demonstrates the problem. The 
C++ complier, its OpenMP flag,  number of threads, number of elements in 
the arrays, and number of repeats, are all parameters to the script and 
can be modified; see the comments at the beginning of the script.

Are better speed results (better than the result below) possible with 
other systems; i.e., results that are faster when using OpenMP and keep 
getting faster as the number of threads increases ?

If I run the script on an 8 processor machine, I get the following results:

    g++ example_a11c.cpp -o example_a11c -DNDEBUG -O2
    n_thread=1, n_element=50000, n_repeat=10000, seconds=0.80645
    g++ example_a11c.cpp -o example_a11c -fopenmp -DNDEBUG -O2
    n_thread=8, n_element=50000, n_repeat=10000, seconds=2.2064
    n_thread=1, n_element=50000, n_repeat=10000, seconds=0.832911
    n_thread=2, n_element=50000, n_repeat=10000, seconds=0.959674
    n_thread=3, n_element=50000, n_repeat=10000, seconds=0.930901
    n_thread=4, n_element=50000, n_repeat=10000, seconds=0.834077

The first line is the compilation command for not using OpenMP .

The second line is the timing result without OpenMP. To be specific, it 
took 0.80645 seconds of wall clock time to run example A11c =10,000  
times with arrays of size 50,000.

The third is the compilation command for using OpenMP.

The fourth line is the OpenMP test result where the number of threads is 
dynamically adjusted.
.
The other lines are the OpenMP test results were the number of threads 
is specified with
    omp_set_dynamic(0);
    omp_set_num_threads(n_thread);
command.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: example_a11c.sh
Url: http://openmp.org/pipermail/omp/attachments/20070402/b73e9203/attachment.pl 


More information about the Omp mailing list