which openmp schedule am I running?
multiprocessing, multithreading, openmp
Solution
I downloaded http://www.openmp.org/wp-content/uploads/openmp-4.5.pdf
Then went to the section "C/C++ Stub Routines" and found this
void omp_get_schedule(omp_sched_t *kind, int *chunk_size)
{
*kind = omp_sched_static;
*chunk_size = 0;
}
Then made this test
/*
typedef enum omp_sched_t {
omp_sched_static = 1,
omp_sched_dynamic = 2,
omp_sched_guided = 3,
omp_sched_auto = 4
} omp_sched_t;
*/
#include <omp.h>
#include <stdio.h>
int main(void) {
omp_sched_t kind;
int chunk;
omp_get_schedule(&kind, &chunk);
printf("%d %d\n", kind, chunk);
}
and compiled
gcc -fopenmp -O3 foo.c
and then
export OMP_SCHEDULE=static,50
./a.out
1 50
export OMP_SCHEDULE=dynamic,100
2 100
Note that `omp_get_schedule` only reports the runtime scheduling definition `OMP_SCHEDULE`. If you change the scheduling with e.g.
#pragma omp parallel for schedule(static,1)
and define `OMP_SCHEDULE=dynamic,100` then `omp_get_schedule` still reports dynamic scheduling and chunk size 100.
Problem
How to check in runtime the openmp schedule? I compile my code with a parallel loop and runtime scheduele ``` #pragma omp parallel for schedule(runtime) collapse(2) for(j=1;j>-2;j-=2){ for(i=0;i<n;i++){ //nested loop code here } } ``` and I specify the environment variable `OMP_SCHEDULE=dynamic,50`. How can I check in runtime that my program actually took the `OMP_SCHEDULE`variable ? I am using openmp 3.1 with gcc 4.7.3