Index: openmp/trunk/runtime/src/kmp.h =================================================================== --- openmp/trunk/runtime/src/kmp.h +++ openmp/trunk/runtime/src/kmp.h @@ -313,8 +313,12 @@ kmp_sch_static_steal = 44, /**< accessible only through KMP_SCHEDULE environment variable */ +#if OMP_41_ENABLED + kmp_sch_static_balanced_chunked = 45, /**< static with chunk adjustment (e.g., simd) */ +#endif + /* accessible only through KMP_SCHEDULE environment variable */ - kmp_sch_upper = 45, /**< upper bound for unordered values */ + kmp_sch_upper = 46, /**< upper bound for unordered values */ kmp_ord_lower = 64, /**< lower bound for ordered values, must be power of 2 */ kmp_ord_static_chunked = 65, Index: openmp/trunk/runtime/src/kmp_sched.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_sched.cpp +++ openmp/trunk/runtime/src/kmp_sched.cpp @@ -324,6 +324,29 @@ *plastiter = (tid == ((trip_count - 1)/( UT )chunk) % nth); break; } +#if OMP_41_ENABLED + case kmp_sch_static_balanced_chunked: + { + register T old_upper = *pupper; + // round up to make sure the chunk is enough to cover all iterations + register UT span = (trip_count+nth-1) / nth; + + // perform chunk adjustment + chunk = (span + chunk - 1) & ~(chunk-1); + + span = chunk * incr; + *plower = *plower + (span * tid); + *pupper = *plower + span - incr; + if ( incr > 0 ) { + if ( *pupper > old_upper ) *pupper = old_upper; + } else + if ( *pupper < old_upper ) *pupper = old_upper; + + if( plastiter != NULL ) + *plastiter = ( tid == ((trip_count - 1)/( UT )chunk) ); + break; + } +#endif default: KMP_ASSERT2( 0, "__kmpc_for_static_init: unknown scheduling type" ); break;