Index: openmp/trunk/runtime/src/kmp.h =================================================================== --- openmp/trunk/runtime/src/kmp.h +++ openmp/trunk/runtime/src/kmp.h @@ -894,15 +894,19 @@ // HW TSC is used to reduce overhead (clock tick instead of nanosecond). extern double __kmp_ticks_per_nsec; # define KMP_NOW() __kmp_hardware_timestamp() +# define KMP_NOW_MSEC() ((kmp_uint64)(KMP_NOW()/__kmp_ticks_per_nsec)/KMP_USEC_PER_SEC) # define KMP_BLOCKTIME_INTERVAL() (__kmp_dflt_blocktime * KMP_USEC_PER_SEC * __kmp_ticks_per_nsec) # define KMP_BLOCKING(goal, count) ((goal) > KMP_NOW()) # else // System time is retrieved sporadically while blocking. extern kmp_uint64 __kmp_now_nsec(); # define KMP_NOW() __kmp_now_nsec() +# define KMP_NOW_MSEC() (KMP_NOW()/KMP_USEC_PER_SEC) # define KMP_BLOCKTIME_INTERVAL() (__kmp_dflt_blocktime * KMP_USEC_PER_SEC) # define KMP_BLOCKING(goal, count) ((count) % 1000 != 0 || (goal) > KMP_NOW()) # endif +# define KMP_YIELD_NOW() (KMP_NOW_MSEC() / KMP_MAX(__kmp_dflt_blocktime, 1) \ + % (__kmp_yield_on_count + __kmp_yield_off_count) < (kmp_uint32)__kmp_yield_on_count) #endif // KMP_USE_MONITOR #define KMP_MIN_STATSCOLS 40 @@ -2674,10 +2678,10 @@ #if KMP_USE_MONITOR extern kmp_uint32 __kmp_yielding_on; +#endif extern kmp_uint32 __kmp_yield_cycle; extern kmp_int32 __kmp_yield_on_count; extern kmp_int32 __kmp_yield_off_count; -#endif /* ------------------------------------------------------------------------- */ extern int __kmp_allThreadsSpecified; Index: openmp/trunk/runtime/src/kmp_global.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_global.cpp +++ openmp/trunk/runtime/src/kmp_global.cpp @@ -354,6 +354,7 @@ #if KMP_USE_MONITOR kmp_uint32 __kmp_yielding_on = 1; +#endif #if KMP_OS_CNK kmp_uint32 __kmp_yield_cycle = 0; #else @@ -361,7 +362,6 @@ #endif kmp_int32 __kmp_yield_on_count = 10; /* By default, yielding is on for 10 monitor periods. */ kmp_int32 __kmp_yield_off_count = 1; /* By default, yielding is off for 1 monitor periods. */ -#endif /* ----------------------------------------------------- */ Index: openmp/trunk/runtime/src/kmp_settings.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_settings.cpp +++ openmp/trunk/runtime/src/kmp_settings.cpp @@ -3798,7 +3798,6 @@ } } // __kmp_stg_print_par_range_env -#if KMP_USE_MONITOR // ------------------------------------------------------------------------------------------------- // KMP_YIELD_CYCLE, KMP_YIELD_ON, KMP_YIELD_OFF // ------------------------------------------------------------------------------------------------- @@ -3834,7 +3833,6 @@ __kmp_stg_print_yield_off( kmp_str_buf_t * buffer, char const * name, void * data ) { __kmp_stg_print_int( buffer, name, __kmp_yield_off_count ); } // __kmp_stg_print_yield_off -#endif // KMP_USE_MONITOR #endif @@ -4740,11 +4738,9 @@ { "KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL, 0, 0 }, { "KMP_PAR_RANGE", __kmp_stg_parse_par_range_env, __kmp_stg_print_par_range_env, NULL, 0, 0 }, -#if KMP_USE_MONITOR { "KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle, __kmp_stg_print_yield_cycle, NULL, 0, 0 }, { "KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL, 0, 0 }, { "KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off, NULL, 0, 0 }, -#endif #endif // KMP_DEBUG { "KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc, __kmp_stg_print_align_alloc, NULL, 0, 0 }, Index: openmp/trunk/runtime/src/z_Linux_util.cpp =================================================================== --- openmp/trunk/runtime/src/z_Linux_util.cpp +++ openmp/trunk/runtime/src/z_Linux_util.cpp @@ -1812,13 +1812,16 @@ void __kmp_yield( int cond ) { - if (cond + if (!cond) + return; #if KMP_USE_MONITOR - && __kmp_yielding_on + if (!__kmp_yielding_on) + return; +#else + if (__kmp_yield_cycle && !KMP_YIELD_NOW()) + return; #endif - ) { - sched_yield(); - } + sched_yield(); } /* ------------------------------------------------------------------------ */