Skip to main content

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, execute

    echo $OMP_NUM_THREADS
    

Learn more:

We suggest you investigate OpenMP more after completing this week.