Now that you have the compiled the
hello_openmp executable, the next
step is to run it. The way to run the executable is the same regardless
of the programming language used to produce it. The first step is to
set the number of threads of execution that you want to run in parallel.
This is achieved by setting the environmental variable
to the desired number of threads, e.g. in the bash shell;
or in the tcsh shell;
setenv OMP_NUM_THREADS 4
Now that you have set the number of threads, run the executable by typing;
You should see the following output.
Hello OpenMP! Hello OpenMP! Hello OpenMP! Hello OpenMP!
Hello OpenMP! is output four times, as the program split
into four threads, and each thread printed
Hello OpenMP!. Play
with the number of threads (by changing
OMP_NUM_THREADS) and see
how that affects the output.