Setting Up Programming Environment¶
1. Load the compiler module¶
We will work with the GNU compiler for compiling and testing OpenMP code.
$ source module.sh
Check if the module is loaded properly
$ module list
Currently Loaded Modules:
1) GCCcore/11.3.0
2) Arm-Forge/22.0.4-GCC-11.3.0
3) AMD-uProf/3.6.449
4) Advisor/2022.1.0
5) VTune/2022.3.0
...
2. Compile your OpenMP application¶
Compilation
$ g++ <source_file>.cc -fopenmp -o <output>
$ gfortran <source_file>.f90 -fopenmp -o <output>
For example:
Example compilation
$ g++ Hello-world.cc -fopenmp -o Hello-World
$ gfortran Hello-world.f90 -fopenmp -o Hello-World
3. Execute your application¶
$ ./<output>
For example:
$ ./Hello-World
Hello world from the master thread
Hello world from thread id 0 from the team size of 5
Hello world from thread id 3 from the team size of 5
Hello world from thread id 1 from the team size of 5
Hello world from thread id 4 from the team size of 5
Hello world from thread id 2 from the team size of 5