Basic OpenMP functions

openmp machine learning

Reading time: 15 minutes

Functions

• omp_get_thread_num() - get the thread rank in a parallel region (0- omp_get_num_threads() -1)
• omp_set_num_threads(nthreads) - set the number of threads used in a parallel region
• omp_get_num_threads() - get the number of threads used in a parallel region

Example


#include <omp.h>
# pragma omp parallel
{
}


Output

Note that the thread rank is not in order: