Exercise 3
- Log into kong.njit.edu
- cd to HPC_Workshop directory in your home directory.
- mkdir openMP
- cd to openMP
- Copy hello_omp.c to your openMP subdirectory.
- Use the commands below to display available compilers on kong
- module avail gcc
- module avail intel
- To invoke OpenMP, you need to use the appropriate compiler flag:
- Compile the hello_omp.c; for gcc:
$ gcc -o hello_omp -fopenmp hello_omp.c
- and for icc
$ icc -o hello_omp -qopenmp hello_omp.c
- Run the code by
$ ./hello_omp
and notice its output.
- How many threads were created? Why?
- Vary the number of threads by
$ export OMP_NUM_THREADS=4
and re-run the code.
- Re-run the code several times; can you explain why the order of output is
more or less random.
- Use the OpenMP script file and submit your job to the cluster queue:
https://web.njit.edu/~shahriar/class_home/HPC/omp_script.sh
- Change the number of threads and re-run your code.
____________________________________________________________