Text-only | Table of Contents (frame/ no frame) |
(9) How to Compile and Run An OpenMP Program |
Compiler | Compiler Options | Default behavior for # of threads (OMP_NUM_THREADS not set) |
GNU (gcc, g++, gfortran) | -fopenmp | as many threads as available cores |
Intel (icc ifort) | -openmp | as many threads as available cores |
Portland Group (pgcc,pgCC,pgf77,pgf90) | -mp | one thread |
$ gcc -o omp_helloc -fopenmp omp_hello.c
$ export OMP_NUM_THREADS=2
$ ./omp_helloc
Hello World from thread = 0
Hello World from thread = 1
Number of threads = 2
$
$ gfortran -o omp_hellof -fopenmp omp_hello.f
$ export OMP_NUM_THREADS=4
$ ./omp_hellof
Hello World from thread = 2
Hello World from thread = 1
Hello World from thread = 3
Hello World from thread = 0
Number of threads = 4
$ icc -o omp_helloc -openmp omp_hello.c
omp_hello.c(22): (col. 1) remark: OpenMP DEFINED REGION WAS PARALLELIZED.
$ export OMP_NUM_THREADS=3
$ ./omp_helloc
Hello World from thread = 0
Hello World from thread = 2
Hello World from thread = 1
Number of threads = 3
$
$ ifort -o omp_hellof -openmp omp_hello.f
omp_hello.f(20): (col. 7) remark: OpenMP DEFINED REGION WAS PARALLELIZED.
$ export OMP_NUM_THREADS=2
$ ./omp_hellof
Hello World from thread = 0
Number of threads = 2
Hello World from thread = 1
[sas@discovery intro_openmp]$ pgcc -o omp_helloc -mp omp_hello.c
[sas@discovery intro_openmp]$ export OMP_NUM_THREADS=2
[sas@discovery intro_openmp]$ ./omp_helloc
Hello World from thread = 0
Number of threads = 2
Hello World from thread = 1
$
$ pgf90 -o omp_hellof -mp omp_hello.f
$ export OMP_NUM_THREADS=2
$ ./omp_hellof
Hello World from thread = 0
Number of threads = 2
Hello World from thread = 1
compile_run.src last modified Mar 23, 2009 | Introduction | Table of Contents (frame/no frame) |
Printable (single file) |
© Dartmouth College |