OpenMP: Difference between revisions
Jump to navigation
Jump to search
(Created page with " ===Compiling OpenMP code on zcluster=== The compilers installed on zcluster support shared memory applications using OpenMP. Here are the compiler options to include when us...") |
No edit summary |
||
Line 34: | Line 34: | ||
<pre class="gcommand"> | <pre class="gcommand"> | ||
setenv OMP_NUM_THREADS 4 | setenv OMP_NUM_THREADS 4 | ||
</pre> | |||
===Sample script to run a shared memory job using OpenMP=== | |||
Sample script to run a program that uses 4 OpenMP threads: | |||
<pre class="gscript"> | |||
#!/bin/bash | |||
cd working_directory | |||
export OMP_NUM_THREADS=4 | |||
time ./myprog | |||
</pre> | </pre> |
Revision as of 15:09, 11 February 2013
Compiling OpenMP code on zcluster
The compilers installed on zcluster 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 |
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 script to run a program that uses 4 OpenMP threads:
#!/bin/bash cd working_directory export OMP_NUM_THREADS=4 time ./myprog