Unit 4.2.2 Basics
¶OpenMP is a standardized API (Application Programming Interface) for creating multiple threads of execution from a single program. For our purposes, you need to know very little:
There is a header file to include in the file(s):
#include <omp.h>
Directives to the compiler (pragmas):
#pragma omp parallel #pragma omp parallel for
A library of routines that can, for example, be used to inquire about the execution environment:
omp_get_max_threads() omp_get_num_threads() omp_get_thread_num()
Environment parameters that can be set before executing the program:
export OMP_NUM_THREADS=4
If you want to see what the value of this environment parameter is, executeecho $OMP_NUM_THREADS
Learn more:
Search for "OpenMP" on Wikipedia.
-
Tim Mattson’s (Intel) “Introduction to OpenMP” (2013) on YouTube.
Slides: Intro_To_OpenMP_Mattson.pdf
Exercise files: Mattson_OMP_exercises.zip
We suggest you investigate OpenMP more after completing this week.