Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleSetting OMP_NUM_THREADS environment variable
Code Block
# Create an interactive session with 8 cores:
[]$ salloc -A <your project> -t 2:00:00 -c 8

[]$ module load gcc/12.2.0

# Although the session has 8 cores, we can limit our application to only use 4:
[salexan5@mtest2 src]$ export OMP_NUM_THREADS=4
[salexan5@mtest2 src]$ ./openmp_ex01
Ths is OMP thread = 0
Ths is OMP thread = 1
Ths is OMP thread = 2
Ths is OMP thread = 3

[salexan5@mtest2 src]$ unset OMP_NUM_THREADS
[salexan5@mtest2 src]$ ./openmp_ex01
Ths is OMP thread = 0
Ths is OMP thread = 5
Ths is OMP thread = 7
Ths is OMP thread = 6
Ths is OMP thread = 4
Ths is OMP thread = 3
Ths is OMP thread = 2
Ths is OMP thread = 1

...