Shared Memory
OpenMP - most popular shared memory API
Already included in the compiler module
Serial
#include <iostream>
int main()
{
std::count << “\nHello World”
return 0;
}
icc fooOMP.c -o fooOMP.x
gcc fooOMP.c -o fooOMP.x
Parallel OpenMP
#include <iostream>
#include “omp.h”
int main() {
#pragma omp parallel
{
std::count << “\nHello World”
}
return 0;
}
icc -openmp fooOMP.c -o fooOMP.x
gcc -fopenmp fooOMP.c -o fooOMP.x
Sets up number of threads
[ ccp 00 51@t3 - log in2 scripts]$ cat test.job #!/bin/bash
#SBATCH -N 1 ### Num of compute nodes
#SBATCH -n 28 ##* Num of CPUs/cores
#SBATCH -p compute #*#paraition (always compute)
#SBATCH --qos general **#QOS (debug,general, large)
#SBATCH -J hello### Jobname
#SBATCH --mail-user=charles.peterson@unt.edu #SBATCH --mail-type=begin
#SBATCH --mail-type=end
module load intel/PS2017-17.0.4-legacy
##SETTING UP OMP VARIABLES
export OMP_NUM_THREADS=l6
##Running code
/home/ccp00Sl/apps/fooOMP.x
[ccp0051@t3-login2 scripts]$ sbatch test.job