[Openmp-commits] [openmp] r293316 - Cleanup: put i_maxmin members and ___kmp_size_type into traits_t
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Fri Jan 27 10:09:23 PST 2017
Author: jlpeyton
Date: Fri Jan 27 12:09:22 2017
New Revision: 293316
URL: http://llvm.org/viewvc/llvm-project?rev=293316&view=rev
Log:
Cleanup: put i_maxmin members and ___kmp_size_type into traits_t
Put the duplicated i_maxmin into traits_t by adding new members max_value and
min_value. Put ___kmp_size_type into traits_t by adding member type_size.
Differential Revision: https://reviews.llvm.org/D28847
Modified:
openmp/trunk/runtime/src/kmp_dispatch.cpp
openmp/trunk/runtime/src/kmp_os.h
openmp/trunk/runtime/src/kmp_sched.cpp
Modified: openmp/trunk/runtime/src/kmp_dispatch.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_dispatch.cpp?rev=293316&r1=293315&r2=293316&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_dispatch.cpp (original)
+++ openmp/trunk/runtime/src/kmp_dispatch.cpp Fri Jan 27 12:09:22 2017
@@ -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 @@ __kmp_dispatch_init(
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 @@ __kmp_dispatch_init(
} else {
pr->nomerge = FALSE;
}
- pr->type_size = ___kmp_size_type; // remember the size of variables
+ pr->type_size = traits_t<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 @@ __kmp_dispatch_init(
//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<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 @@ __kmp_dispatch_next(
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 @@ __kmp_dispatch_next(
trip = pr->u.p.tc - 1;
- if ( ___kmp_size_type > 4 ) {
+ if ( traits_t<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 @@ __kmp_dispatch_next(
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<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 @@ __kmp_dist_get_bounds(
// Check/correct bounds if needed
if( incr > 0 ) {
if( *pupper < *plower )
- *pupper = i_maxmin< T >::mx;
+ *pupper = traits_t<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<T>::min_value;
if( plastiter != NULL )
*plastiter = *plower >= upper && *pupper < upper - incr;
if( *pupper < upper )
Modified: openmp/trunk/runtime/src/kmp_os.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_os.h?rev=293316&r1=293315&r2=293316&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_os.h (original)
+++ openmp/trunk/runtime/src/kmp_os.h Fri Jan 27 12:09:22 2017
@@ -188,12 +188,7 @@ typedef double kmp_real64;
// 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 double kmp_real64;
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 double kmp_real64;
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 double kmp_real64;
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 double kmp_real64;
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
Modified: openmp/trunk/runtime/src/kmp_sched.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_sched.cpp?rev=293316&r1=293315&r2=293316&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_sched.cpp (original)
+++ openmp/trunk/runtime/src/kmp_sched.cpp Fri Jan 27 12:09:22 2017
@@ -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 @@ __kmp_for_static_init(
*pupper = *plower + big_chunk_inc_count - incr;
if ( incr > 0 ) {
if( *pupper < *plower )
- *pupper = i_maxmin< T >::mx;
+ *pupper = traits_t<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<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 @@ __kmp_dist_for_static_init(
// Check/correct bounds if needed
if( incr > 0 ) {
if( *pupperDist < *plower )
- *pupperDist = i_maxmin< T >::mx;
+ *pupperDist = traits_t<T>::max_value;
if( plastiter != NULL )
*plastiter = *plower <= upper && *pupperDist > upper - incr;
if( *pupperDist > upper )
@@ -522,7 +495,7 @@ __kmp_dist_for_static_init(
}
} else {
if( *pupperDist > *plower )
- *pupperDist = i_maxmin< T >::mn;
+ *pupperDist = traits_t<T>::min_value;
if( plastiter != NULL )
*plastiter = *plower >= upper && *pupperDist < upper - incr;
if( *pupperDist < upper )
@@ -580,7 +553,7 @@ __kmp_dist_for_static_init(
*pupper = *plower + chunk_inc_count - incr;
if( incr > 0 ) {
if( *pupper < *plower )
- *pupper = i_maxmin< T >::mx;
+ *pupper = traits_t<T>::max_value;
if( plastiter != NULL )
if( *plastiter != 0 && !(*plower <= upper && *pupper > upper - incr) )
*plastiter = 0;
@@ -588,7 +561,7 @@ __kmp_dist_for_static_init(
*pupper = upper;//tracker C73258
} else {
if( *pupper > *plower )
- *pupper = i_maxmin< T >::mn;
+ *pupper = traits_t<T>::min_value;
if( plastiter != NULL )
if( *plastiter != 0 && !(*plower >= upper && *pupper < upper - incr) )
*plastiter = 0;
@@ -729,12 +702,12 @@ __kmp_team_static_init(
// Correct upper bound if needed
if( incr > 0 ) {
if( *p_ub < *p_lb ) // overflow?
- *p_ub = i_maxmin< T >::mx;
+ *p_ub = traits_t<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<T>::min_value;
if( *p_ub < upper )
*p_ub = upper; // tracker C73258
}
More information about the Openmp-commits
mailing list