OpenMP: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
===Compiling OpenMP code on | ===Compiling OpenMP code on Sapelo2=== | ||
The compilers installed on | The compilers installed on Sapelo2 support shared memory applications using OpenMP. Here are the compiler options to include when using OpenMP: | ||
{| width="100%" border="1" cellspacing="0" cellpadding="2" align="center" class="wikitable unsortable" | {| width="100%" border="1" cellspacing="0" cellpadding="2" align="center" class="wikitable unsortable" | ||
Line 20: | Line 20: | ||
|} | |} | ||
For more information about the compilers on | For more information about the compilers on Sapelo2, please see [[Code Compilation on Sapelo2]]. | ||
===Defining number of OpenMP threads=== | ===Defining number of OpenMP threads=== | ||
Line 39: | Line 39: | ||
===Sample script to run a shared memory job using OpenMP=== | ===Sample script to run a shared memory job using OpenMP=== | ||
Sample script (sub.sh) to run a program that uses 4 OpenMP threads: | |||
Sample job submission script (sub.sh) to run a program that uses 4 OpenMP threads: | |||
<pre class="gscript"> | <pre class="gscript"> | ||
# | #PBS -S /bin/bash | ||
cd | #PBS -q batch | ||
#PBS -N testjob | |||
#PBS -l nodes=1:ppn=4 | |||
#PBS -l walltime=48:00:00 | |||
#PBS -l mem=30gb | |||
#PBS -M username@uga.edu | |||
#PBS -m abe | |||
cd $PBS_O_WORKDIR | |||
export OMP_NUM_THREADS=4 | export OMP_NUM_THREADS=4 | ||
time ./ | |||
echo | |||
echo "Job ID: $PBS_JOBID" | |||
echo "Queue: $PBS_QUEUE" | |||
echo "Cores: $PBS_NP" | |||
echo "Nodes: $(cat $PBS_NODEFILE | sort -u | tr '\n' ' ')" | |||
echo | |||
time ./a.out > outputfile | |||
</pre> | </pre> | ||
===Sample job submission command on | |||
To submit a shared memory job that uses 4 OpenMP threads | ===Sample job submission command on Sapelo2=== | ||
To submit a shared memory job that uses 4 OpenMP threads: | |||
<pre class="gcommand"> | <pre class="gcommand"> | ||
qsub | qsub sub.sh | ||
</pre> | </pre> | ||
For more information about running jobs on | For more information about running jobs on Sapelo2, please see [[Running Jobs on Sapelo2]]. |
Revision as of 15:27, 14 June 2018
Compiling OpenMP code on Sapelo2
The compilers installed on Sapelo2 support shared memory applications using OpenMP. Here are the compiler options to include when using OpenMP:
Compiler | Commands | Option |
---|---|---|
PGI | pgcc, pgCC, pgf90, etc. | -mp |
Intel | icc, ifort | -openmp |
GNU | gcc, gfortran, g++, gcc44, etc. | -fopenmp |
For more information about the compilers on Sapelo2, please see Code Compilation on Sapelo2.
Defining number of OpenMP threads
The number of OpenMP threads can be specified using the environment variable OMP_NUM_THREADS. For example, to define 4 threads:
For bash/sh:
export OMP_NUM_THREADS=4
For csh/tcsh:
setenv OMP_NUM_THREADS 4
Sample job submission script (sub.sh) to run a program that uses 4 OpenMP threads:
#PBS -S /bin/bash #PBS -q batch #PBS -N testjob #PBS -l nodes=1:ppn=4 #PBS -l walltime=48:00:00 #PBS -l mem=30gb #PBS -M username@uga.edu #PBS -m abe cd $PBS_O_WORKDIR export OMP_NUM_THREADS=4 echo echo "Job ID: $PBS_JOBID" echo "Queue: $PBS_QUEUE" echo "Cores: $PBS_NP" echo "Nodes: $(cat $PBS_NODEFILE | sort -u | tr '\n' ' ')" echo time ./a.out > outputfile
Sample job submission command on Sapelo2
To submit a shared memory job that uses 4 OpenMP threads:
qsub sub.sh
For more information about running jobs on Sapelo2, please see Running Jobs on Sapelo2.