Home > OS >  why does omp_get_schedule() return a monotonic schedule when OMP_SCHEDULE=static?
why does omp_get_schedule() return a monotonic schedule when OMP_SCHEDULE=static?

Time:04-29

I am compiling my code with g 8.5 on redhat8 and I notice that when I set OMP_SCHEDULE=static, then inside my application omp_get_schedule() returns a "monotonic" schedule instead of a "static" schedule. Why could this be happening? If I set OMP_SCHEDULE to something else such as "dynamic" then my application recognizes it as "dynamic". Here is the code in question. Any ideas? Thanks

             omp_sched_t kind;                 
             int chunk_size;
             omp_get_schedule(&kind, &chunk_size);
             
             switch(kind)
             {
               case omp_sched_static:
               {
                 schedule_msg = schedule_msg   "schedule=static, chunk_size=" std::to_string(chunk_size);
                 break;
               }
               case omp_sched_dynamic:
               {                     
                 schedule_msg = schedule_msg   "schedule=dynamic, chunk_size=" std::to_string(chunk_size);
                 break;
               }
               case omp_sched_guided:
               {
                 schedule_msg = schedule_msg   "schedule=guided, chunk_size=" std::to_string(chunk_size);                     
                 break;
               }
               case omp_sched_auto:
               {
                 schedule_msg = schedule_msg   "schedule=auto, chunk_size=" std::to_string(chunk_size);                     
                 break;
               }
               default:
               {
                 schedule_msg = schedule_msg   "schedule=monotonic, chunk_size=" std::to_string(chunk_size); 
                 break;
               }
             }   

CodePudding user response:

omp_sched_t is defined as:

    typedef enum omp_sched_t {
        omp_sched_static  = 1,
        omp_sched_dynamic = 2,
        omp_sched_guided  = 3,
        omp_sched_auto    = 4,
        omp_sched_monotonic = 0x80000000
    } omp_sched_t;

Note that omp_sched_monotonic is a modifier not a type, so monotonic:static is expressed as omp_sched_monotonic | omp_sched_static (and its value is 0x80000001).

According to OpenMP standard:

If the static schedule kind is specified or if the ordered clause is specified, and if no monotonic modifier is specified, the effect will be as if the monotonic modifier was specified.

Therefore, if OMP_SCHEDULE is set to static the return value of omp_get_schedule() is 0x80000001, but your code is not handling properly the monotonic modifier.

  • Related