Index: runtime/src/kmp_dispatch.cpp =================================================================== --- runtime/src/kmp_dispatch.cpp +++ runtime/src/kmp_dispatch.cpp @@ -49,34 +49,6 @@ /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ -// template for type limits -template< typename T > -struct i_maxmin { - static const T mx; - static const T mn; -}; -template<> -struct i_maxmin< int > { - static const int mx = 0x7fffffff; - static const int mn = 0x80000000; -}; -template<> -struct i_maxmin< unsigned int > { - static const unsigned int mx = 0xffffffff; - static const unsigned int mn = 0x00000000; -}; -template<> -struct i_maxmin< long long > { - static const long long mx = 0x7fffffffffffffffLL; - static const long long mn = 0x8000000000000000LL; -}; -template<> -struct i_maxmin< unsigned long long > { - static const unsigned long long mx = 0xffffffffffffffffLL; - static const unsigned long long mn = 0x0000000000000000LL; -}; -//------------------------------------------------------------------------- - #if KMP_STATIC_STEAL_ENABLED // replaces dispatch_private_info{32,64} structures and dispatch_private_info{32,64}_t types @@ -612,7 +584,6 @@ typedef typename traits_t< T >::unsigned_t UT; typedef typename traits_t< T >::signed_t ST; typedef typename traits_t< T >::floating_t DBL; - static const int ___kmp_size_type = sizeof( UT ); int active; T tc; @@ -688,7 +659,7 @@ } else { pr->nomerge = FALSE; } - pr->type_size = ___kmp_size_type; // remember the size of variables + pr->type_size = traits_t::type_size; // remember the size of variables if ( kmp_ord_lower & schedule ) { pr->ordered = TRUE; schedule = (enum sched_type)(((int)schedule) - (kmp_ord_lower - kmp_sch_lower)); @@ -869,7 +840,7 @@ //pr->pfields.parm3 = 0; // it's not used in static_steal pr->u.p.parm4 = (id + 1) % nproc; // remember neighbour tid pr->u.p.st = st; - if ( ___kmp_size_type > 4 ) { + if ( traits_t::type_size > 4 ) { // AC: TODO: check if 16-byte CAS available and use it to // improve performance (probably wait for explicit request // before spending time on this). @@ -1438,9 +1409,6 @@ typedef typename traits_t< T >::unsigned_t UT; typedef typename traits_t< T >::signed_t ST; typedef typename traits_t< T >::floating_t DBL; -#if ( KMP_STATIC_STEAL_ENABLED ) - static const int ___kmp_size_type = sizeof( UT ); -#endif // This is potentially slightly misleading, schedule(runtime) will appear here even if the actual runtme schedule // is static. (Which points out a disadavantage of schedule(runtime): even when static scheduling is used it costs @@ -1607,7 +1575,7 @@ trip = pr->u.p.tc - 1; - if ( ___kmp_size_type > 4 ) { + if ( traits_t::type_size > 4 ) { // use lock for 8-byte and CAS for 4-byte induction // variable. TODO (optional): check and use 16-byte CAS kmp_lock_t * lck = th->th.th_dispatch->th_steal_lock; @@ -2224,7 +2192,7 @@ if ( (ST)num_done == th->th.th_team_nproc - 1 ) { #if ( KMP_STATIC_STEAL_ENABLED ) - if( pr->schedule == kmp_sch_static_steal && ___kmp_size_type > 4 ) { + if( pr->schedule == kmp_sch_static_steal && traits_t::type_size > 4 ) { int i; kmp_info_t **other_threads = team->t.t_threads; // loop complete, safe to destroy locks used for stealing @@ -2400,14 +2368,14 @@ // Check/correct bounds if needed if( incr > 0 ) { if( *pupper < *plower ) - *pupper = i_maxmin< T >::mx; + *pupper = traits_t::max_value; if( plastiter != NULL ) *plastiter = *plower <= upper && *pupper > upper - incr; if( *pupper > upper ) *pupper = upper; // tracker C73258 } else { if( *pupper > *plower ) - *pupper = i_maxmin< T >::mn; + *pupper = traits_t::min_value; if( plastiter != NULL ) *plastiter = *plower >= upper && *pupper < upper - incr; if( *pupper < upper ) Index: runtime/src/kmp_os.h =================================================================== --- runtime/src/kmp_os.h +++ runtime/src/kmp_os.h @@ -188,12 +188,7 @@ // template for debug prints specification ( d, u, lld, llu ), and to obtain // signed/unsigned flavors of a type template< typename T > - struct traits_t { - typedef T signed_t; - typedef T unsigned_t; - typedef T floating_t; - static char const * spec; - }; + struct traits_t { }; // int template<> struct traits_t< signed int > { @@ -201,6 +196,9 @@ typedef unsigned int unsigned_t; typedef double floating_t; static char const * spec; + static const signed_t max_value = 0x7fffffff; + static const signed_t min_value = 0x80000000; + static const int type_size = sizeof(signed_t); }; // unsigned int template<> @@ -209,6 +207,9 @@ typedef unsigned int unsigned_t; typedef double floating_t; static char const * spec; + static const unsigned_t max_value = 0xffffffff; + static const unsigned_t min_value = 0x00000000; + static const int type_size = sizeof(unsigned_t); }; // long long template<> @@ -217,6 +218,9 @@ typedef unsigned long long unsigned_t; typedef long double floating_t; static char const * spec; + static const signed_t max_value = 0x7fffffffffffffffLL; + static const signed_t min_value = 0x8000000000000000LL; + static const int type_size = sizeof(signed_t); }; // unsigned long long template<> @@ -225,6 +229,9 @@ typedef unsigned long long unsigned_t; typedef long double floating_t; static char const * spec; + static const unsigned_t max_value = 0xffffffffffffffffLL; + static const unsigned_t min_value = 0x0000000000000000LL; + static const int type_size = sizeof(unsigned_t); }; //------------------------------------------------------------------------- #endif // __cplusplus Index: runtime/src/kmp_sched.cpp =================================================================== --- runtime/src/kmp_sched.cpp +++ runtime/src/kmp_sched.cpp @@ -33,33 +33,6 @@ #include "ompt-specific.h" #endif -// template for type limits -template< typename T > -struct i_maxmin { - static const T mx; - static const T mn; -}; -template<> -struct i_maxmin< int > { - static const int mx = 0x7fffffff; - static const int mn = 0x80000000; -}; -template<> -struct i_maxmin< unsigned int > { - static const unsigned int mx = 0xffffffff; - static const unsigned int mn = 0x00000000; -}; -template<> -struct i_maxmin< long long > { - static const long long mx = 0x7fffffffffffffffLL; - static const long long mn = 0x8000000000000000LL; -}; -template<> -struct i_maxmin< unsigned long long > { - static const unsigned long long mx = 0xffffffffffffffffLL; - static const unsigned long long mn = 0x0000000000000000LL; -}; -//------------------------------------------------------------------------- #ifdef KMP_DEBUG //------------------------------------------------------------------------- // template for debug prints specification ( d, u, lld, llu ) @@ -295,13 +268,13 @@ *pupper = *plower + big_chunk_inc_count - incr; if ( incr > 0 ) { if( *pupper < *plower ) - *pupper = i_maxmin< T >::mx; + *pupper = traits_t::max_value; if( plastiter != NULL ) *plastiter = *plower <= old_upper && *pupper > old_upper - incr; if ( *pupper > old_upper ) *pupper = old_upper; // tracker C73258 } else { if( *pupper > *plower ) - *pupper = i_maxmin< T >::mn; + *pupper = traits_t::min_value; if( plastiter != NULL ) *plastiter = *plower >= old_upper && *pupper < old_upper - incr; if ( *pupper < old_upper ) *pupper = old_upper; // tracker C73258 @@ -511,7 +484,7 @@ // Check/correct bounds if needed if( incr > 0 ) { if( *pupperDist < *plower ) - *pupperDist = i_maxmin< T >::mx; + *pupperDist = traits_t::max_value; if( plastiter != NULL ) *plastiter = *plower <= upper && *pupperDist > upper - incr; if( *pupperDist > upper ) @@ -522,7 +495,7 @@ } } else { if( *pupperDist > *plower ) - *pupperDist = i_maxmin< T >::mn; + *pupperDist = traits_t::min_value; if( plastiter != NULL ) *plastiter = *plower >= upper && *pupperDist < upper - incr; if( *pupperDist < upper ) @@ -580,7 +553,7 @@ *pupper = *plower + chunk_inc_count - incr; if( incr > 0 ) { if( *pupper < *plower ) - *pupper = i_maxmin< T >::mx; + *pupper = traits_t::max_value; if( plastiter != NULL ) if( *plastiter != 0 && !(*plower <= upper && *pupper > upper - incr) ) *plastiter = 0; @@ -588,7 +561,7 @@ *pupper = upper;//tracker C73258 } else { if( *pupper > *plower ) - *pupper = i_maxmin< T >::mn; + *pupper = traits_t::min_value; if( plastiter != NULL ) if( *plastiter != 0 && !(*plower >= upper && *pupper < upper - incr) ) *plastiter = 0; @@ -729,12 +702,12 @@ // Correct upper bound if needed if( incr > 0 ) { if( *p_ub < *p_lb ) // overflow? - *p_ub = i_maxmin< T >::mx; + *p_ub = traits_t::max_value; if( *p_ub > upper ) *p_ub = upper; // tracker C73258 } else { // incr < 0 if( *p_ub > *p_lb ) - *p_ub = i_maxmin< T >::mn; + *p_ub = traits_t::min_value; if( *p_ub < upper ) *p_ub = upper; // tracker C73258 }