3.2.2 Parallel loop with chunks of one with 2 methods of random number streams

You should study the code for this version, focusing on the for loop and how it differs from the previous version.

Note

Rule of thumb: splitting a for loop into equal chunks requires the #pragma omp for syntax. You do not use this syntax if you move forward the proper amount per thread yourself in the code. Note how this is how we accomplish “chunks of one” in the loop on line 117 by incrementing the loop counter by the number of threads (i+=numThreads).

As a reference, here is the set of numbers when using one thread, which is the same as the sequential version:

t 0( 0):83
t 0( 1):63
t 0( 2):97
t 0( 3):21
t 0( 4):62
t 0( 5):54
t 0( 6):14
t 0( 7):46

Now try different setups for this code, as you did for the equal chunks version:

['-c', '-n 8', '-d block', '-t 2']
['-c', '-n 8', '-d block', '-t 4']
['-c', '-n 8', '-d leapfrog', '-t 2']
['-c', '-n 8', '-d leapfrog', '-t 4']
['-c', '-n 8', '-d leapfrog', '-t 3']

Note that the output is explaining how it is running. You should be able to observe the following:

Command line code for reference

This code block below has code for handling the command line arguments for the parallel versions in this subsection and the previous one.

You have attempted of activities on this page