summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src
diff options
context:
space:
mode:
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r--openmp/runtime/src/kmp.h12
-rw-r--r--openmp/runtime/src/kmp_csupport.c6
-rw-r--r--openmp/runtime/src/kmp_global.c4
-rw-r--r--openmp/runtime/src/kmp_runtime.c46
-rw-r--r--openmp/runtime/src/kmp_settings.c34
-rw-r--r--openmp/runtime/src/z_Linux_util.c4
6 files changed, 48 insertions, 58 deletions
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index c5de3d7a12e..a8c600b9c86 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -754,10 +754,10 @@ typedef struct kmp_nested_proc_bind_t {
extern kmp_nested_proc_bind_t __kmp_nested_proc_bind;
-# if (KMP_OS_WINDOWS || KMP_OS_LINUX)
+# if KMP_AFFINITY_SUPPORTED
# define KMP_PLACE_ALL (-1)
# define KMP_PLACE_UNDEFINED (-2)
-# endif /* (KMP_OS_WINDOWS || KMP_OS_LINUX) */
+# endif /* KMP_AFFINITY_SUPPORTED */
extern int __kmp_affinity_num_places;
@@ -2153,7 +2153,7 @@ typedef struct KMP_ALIGN_CACHE kmp_base_info {
kmp_internal_control_t th_fixed_icvs; /* Initial ICVs for the thread */
-#if KMP_OS_WINDOWS || KMP_OS_LINUX
+#if KMP_AFFINITY_SUPPORTED
kmp_affin_mask_t *th_affin_mask; /* thread's current affinity mask */
#endif
@@ -2165,7 +2165,7 @@ typedef struct KMP_ALIGN_CACHE kmp_base_info {
#if OMP_40_ENABLED
int th_set_nth_teams; /* number of threads in parallel nested in teams construct */
kmp_proc_bind_t th_set_proc_bind; /* if != proc_bind_default, use request for next fork */
-# if (KMP_OS_WINDOWS || KMP_OS_LINUX)
+# if KMP_AFFINITY_SUPPORTED
int th_current_place; /* place currently bound to */
int th_new_place; /* place to bind to in par reg */
int th_first_place; /* first place in partition */
@@ -2383,12 +2383,12 @@ typedef struct KMP_ALIGN_CACHE kmp_base_team {
int t_active_level; /* nested active parallel level */
kmp_r_sched_t t_sched; /* run-time schedule for the team */
#endif // OMP_30_ENABLED
-#if OMP_40_ENABLED && (KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED
int t_first_place; /* first & last place in */
int t_last_place; /* parent thread's partition. */
/* Restore these values to */
/* master after par region. */
-#endif // OMP_40_ENABLED && (KMP_OS_WINDOWS || KMP_OS_LINUX)
+#endif // OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED
#if KMP_MIC
int t_size_changed; /* team size was changed?: 0 - no, 1 - yes, -1 - changed via omp_set_num_threads() call */
#endif
diff --git a/openmp/runtime/src/kmp_csupport.c b/openmp/runtime/src/kmp_csupport.c
index 17cc5347fa2..18b6c359adb 100644
--- a/openmp/runtime/src/kmp_csupport.c
+++ b/openmp/runtime/src/kmp_csupport.c
@@ -1419,7 +1419,7 @@ kmpc_set_defaults( char const * str )
int
kmpc_set_affinity_mask_proc( int proc, void **mask )
{
-#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
return -1;
#else
if ( ! TCR_4(__kmp_init_middle) ) {
@@ -1432,7 +1432,7 @@ kmpc_set_affinity_mask_proc( int proc, void **mask )
int
kmpc_unset_affinity_mask_proc( int proc, void **mask )
{
-#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
return -1;
#else
if ( ! TCR_4(__kmp_init_middle) ) {
@@ -1445,7 +1445,7 @@ kmpc_unset_affinity_mask_proc( int proc, void **mask )
int
kmpc_get_affinity_mask_proc( int proc, void **mask )
{
-#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
return -1;
#else
if ( ! TCR_4(__kmp_init_middle) ) {
diff --git a/openmp/runtime/src/kmp_global.c b/openmp/runtime/src/kmp_global.c
index 583e299bea6..aa1f8e3fad3 100644
--- a/openmp/runtime/src/kmp_global.c
+++ b/openmp/runtime/src/kmp_global.c
@@ -199,7 +199,7 @@ enum clock_function_type __kmp_clock_function;
int __kmp_clock_function_param;
#endif /* KMP_OS_LINUX */
-#if KMP_OS_LINUX || KMP_OS_WINDOWS
+#if KMP_AFFINITY_SUPPORTED
# if KMP_OS_WINDOWS && KMP_ARCH_X86_64
@@ -229,7 +229,7 @@ unsigned __kmp_affinity_num_masks = 0;
char const * __kmp_cpuinfo_file = NULL;
-#endif /* KMP_OS_LINUX || KMP_OS_WINDOWS */
+#endif /* KMP_AFFINITY_SUPPORTED */
#if OMP_40_ENABLED
kmp_nested_proc_bind_t __kmp_nested_proc_bind = { NULL, 0, 0 };
diff --git a/openmp/runtime/src/kmp_runtime.c b/openmp/runtime/src/kmp_runtime.c
index a56e59b54fa..fea41d0d9ae 100644
--- a/openmp/runtime/src/kmp_runtime.c
+++ b/openmp/runtime/src/kmp_runtime.c
@@ -2374,7 +2374,7 @@ __kmp_fork_team_threads( kmp_root_t *root, kmp_team_t *team,
}
}
-#if OMP_40_ENABLED && (KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED
__kmp_partition_places( team );
#endif
@@ -3090,7 +3090,7 @@ __kmp_join_call(ident_t *loc, int gtid
__kmp_pop_current_task_from_thread( master_th );
#endif // OMP_30_ENABLED
-#if OMP_40_ENABLED && (KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED
//
// Restore master thread's partition.
//
@@ -4718,7 +4718,7 @@ __kmp_initialize_info( kmp_info_t *this_thr, kmp_team_t *team, int tid, int gtid
this_thr->th.th_set_nproc = 0;
#if OMP_40_ENABLED
this_thr->th.th_set_proc_bind = proc_bind_default;
-# if (KMP_OS_WINDOWS || KMP_OS_LINUX)
+# if KMP_AFFINITY_SUPPORTED
this_thr->th.th_new_place = this_thr->th.th_current_place;
# endif
#endif
@@ -4981,7 +4981,7 @@ __kmp_allocate_thread( kmp_root_t *root, kmp_team_t *team, int new_tid )
new_thr->th.th_spin_here = FALSE;
new_thr->th.th_next_waiting = 0;
-#if OMP_40_ENABLED && (KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED
new_thr->th.th_current_place = KMP_PLACE_UNDEFINED;
new_thr->th.th_new_place = KMP_PLACE_UNDEFINED;
new_thr->th.th_first_place = KMP_PLACE_UNDEFINED;
@@ -5224,7 +5224,7 @@ __kmp_initialize_team(
KF_TRACE( 10, ( "__kmp_initialize_team: exit: team=%p\n", team ) );
}
-#if KMP_OS_LINUX
+#if KMP_OS_LINUX && KMP_AFFINITY_SUPPORTED
/* Sets full mask for thread and returns old mask, no changes to structures. */
static void
__kmp_set_thread_affinity_mask_full_tmp( kmp_affin_mask_t *old_mask )
@@ -5248,7 +5248,7 @@ __kmp_set_thread_affinity_mask_full_tmp( kmp_affin_mask_t *old_mask )
}
#endif
-#if OMP_40_ENABLED && (KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED
//
// __kmp_partition_places() is the heart of the OpenMP 4.0 affinity mechanism.
@@ -5534,7 +5534,7 @@ __kmp_partition_places( kmp_team_t *team )
KA_TRACE( 20, ("__kmp_partition_places: exit T#%d\n", team->t.t_id ) );
}
-#endif /* OMP_40_ENABLED && (KMP_OS_WINDOWS || KMP_OS_LINUX) */
+#endif /* OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED */
/* allocate a new team data structure to use. take one off of the free pool if available */
kmp_team_t *
@@ -5664,14 +5664,14 @@ __kmp_allocate_team( kmp_root_t *root, int new_nproc, int max_nproc,
#if OMP_40_ENABLED
team->t.t_proc_bind = new_proc_bind;
-# if KMP_OS_WINDOWS || KMP_OS_LINUX
+# if KMP_AFFINITY_SUPPORTED
__kmp_partition_places( team );
# endif
#endif
}
else if ( team -> t.t_nproc < new_nproc ) {
-#if KMP_OS_LINUX
+#if KMP_OS_LINUX && KMP_AFFINITY_SUPPORTED
kmp_affin_mask_t *old_mask;
if ( KMP_AFFINITY_CAPABLE() ) {
KMP_CPU_ALLOC(old_mask);
@@ -5698,7 +5698,7 @@ __kmp_allocate_team( kmp_root_t *root, int new_nproc, int max_nproc,
);
}
-#if KMP_OS_LINUX
+#if KMP_OS_LINUX && KMP_AFFINITY_SUPPORTED
/* Temporarily set full mask for master thread before
creation of workers. The reason is that workers inherit
the affinity from master, so if a lot of workers are
@@ -5729,7 +5729,7 @@ __kmp_allocate_team( kmp_root_t *root, int new_nproc, int max_nproc,
}
}
-#if KMP_OS_LINUX
+#if KMP_OS_LINUX && KMP_AFFINITY_SUPPORTED
if ( KMP_AFFINITY_CAPABLE() ) {
/* Restore initial master thread's affinity mask */
__kmp_set_system_affinity( old_mask, TRUE );
@@ -5773,7 +5773,7 @@ __kmp_allocate_team( kmp_root_t *root, int new_nproc, int max_nproc,
#if OMP_40_ENABLED
team->t.t_proc_bind = new_proc_bind;
-# if KMP_OS_WINDOWS || KMP_OS_LINUX
+# if KMP_AFFINITY_SUPPORTED
__kmp_partition_places( team );
# endif
#endif
@@ -5812,7 +5812,7 @@ __kmp_allocate_team( kmp_root_t *root, int new_nproc, int max_nproc,
#endif
#if OMP_40_ENABLED
-# if (KMP_OS_WINDOWS || KMP_OS_LINUX)
+# if KMP_AFFINITY_SUPPORTED
if ( team->t.t_proc_bind == new_proc_bind ) {
KA_TRACE( 200, ("__kmp_allocate_team: reusing hot team #%d bindings: proc_bind = %d, partition = [%d,%d]\n",
team->t.t_id, new_proc_bind, team->t.t_first_place,
@@ -5826,7 +5826,7 @@ __kmp_allocate_team( kmp_root_t *root, int new_nproc, int max_nproc,
if ( team->t.t_proc_bind != new_proc_bind ) {
team->t.t_proc_bind = new_proc_bind;
}
-# endif /* (KMP_OS_WINDOWS || KMP_OS_LINUX) */
+# endif /* KMP_AFFINITY_SUPPORTED */
#endif /* OMP_40_ENABLED */
}
@@ -6479,7 +6479,7 @@ __kmp_fork_barrier( int gtid, int tid )
#endif /* OMP_30_ENABLED */
-#if OMP_40_ENABLED && (KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED
kmp_proc_bind_t proc_bind = team->t.t_proc_bind;
if ( proc_bind == proc_bind_intel ) {
#endif
@@ -6491,7 +6491,7 @@ __kmp_fork_barrier( int gtid, int tid )
__kmp_balanced_affinity( tid, team->t.t_nproc );
}
#endif
-#if OMP_40_ENABLED && (KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if OMP_40_ENABLED && KMP_AFFINITY_SUPPORTED
}
else if ( ( proc_bind != proc_bind_false )
&& ( proc_bind != proc_bind_disabled )) {
@@ -6784,12 +6784,12 @@ __kmp_reap_thread(
}; // if
#endif
-#if (KMP_OS_WINDOWS || KMP_OS_LINUX)
+#if KMP_AFFINITY_SUPPORTED
if ( thread->th.th_affin_mask != NULL ) {
KMP_CPU_FREE( thread->th.th_affin_mask );
thread->th.th_affin_mask = NULL;
}; // if
-#endif /* (KMP_OS_WINDOWS || KMP_OS_LINUX) */
+#endif /* KMP_AFFINITY_SUPPORTED */
__kmp_reap_team( thread->th.th_serial_team );
thread->th.th_serial_team = NULL;
@@ -7583,7 +7583,7 @@ __kmp_do_middle_initialize( void )
//
prev_dflt_team_nth = __kmp_dflt_team_nth;
-#if KMP_OS_WINDOWS || KMP_OS_LINUX
+#if KMP_AFFINITY_SUPPORTED
//
// __kmp_affinity_initialize() will try to set __kmp_ncores to the
// number of cores on the machine.
@@ -7599,7 +7599,7 @@ __kmp_do_middle_initialize( void )
__kmp_affinity_set_init_mask( i, TRUE );
}
}
-#endif /* KMP_OS_WINDOWS || KMP_OS_LINUX */
+#endif /* KMP_AFFINITY_SUPPORTED */
KMP_ASSERT( __kmp_xproc > 0 );
if ( __kmp_avail_proc == 0 ) {
@@ -8180,10 +8180,10 @@ __kmp_cleanup( void )
__kmp_cleanup_user_locks();
- #if KMP_OS_LINUX || KMP_OS_WINDOWS
+ #if KMP_AFFINITY_SUPPORTED
KMP_INTERNAL_FREE( (void *) __kmp_cpuinfo_file );
__kmp_cpuinfo_file = NULL;
- #endif /* KMP_OS_LINUX || KMP_OS_WINDOWS */
+ #endif /* KMP_AFFINITY_SUPPORTED */
#if KMP_USE_ADAPTIVE_LOCKS
#if KMP_DEBUG_ADAPTIVE_LOCKS
@@ -8475,7 +8475,7 @@ __kmp_determine_reduction_method( ident_t *loc, kmp_int32 global_tid,
#elif KMP_ARCH_X86 || KMP_ARCH_ARM
- #if KMP_OS_LINUX || KMP_OS_WINDOWS
+ #if KMP_AFFINITY_SUPPORTED
// basic tuning
diff --git a/openmp/runtime/src/kmp_settings.c b/openmp/runtime/src/kmp_settings.c
index 24cd4eafff7..54745cb8162 100644
--- a/openmp/runtime/src/kmp_settings.c
+++ b/openmp/runtime/src/kmp_settings.c
@@ -1576,19 +1576,15 @@ __kmp_stg_print_abort_delay( kmp_str_buf_t * buffer, char const * name, void * d
static void
__kmp_stg_parse_cpuinfo_file( char const * name, char const * value, void * data ) {
- #if KMP_OS_LINUX || KMP_OS_WINDOWS
+ #if KMP_AFFINITY_SUPPORTED
__kmp_stg_parse_str( name, value, & __kmp_cpuinfo_file );
K_DIAG( 1, ( "__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file ) );
- #elif !KMP_AFFINITY_SUPPORTED
- // affinity not supported
- #else
- #error "Unknown or unsupported OS"
#endif
} //__kmp_stg_parse_cpuinfo_file
static void
__kmp_stg_print_cpuinfo_file( kmp_str_buf_t * buffer, char const * name, void * data ) {
- #if KMP_OS_LINUX || KMP_OS_WINDOWS
+ #if KMP_AFFINITY_SUPPORTED
if( __kmp_env_format ) {
KMP_STR_BUF_PRINT_NAME;
} else {
@@ -1727,7 +1723,7 @@ __kmp_stg_print_foreign_threads_threadprivate( kmp_str_buf_t * buffer, char cons
// KMP_AFFINITY, GOMP_CPU_AFFINITY, KMP_TOPOLOGY_METHOD
// -------------------------------------------------------------------------------------------------
-#if KMP_OS_LINUX || KMP_OS_WINDOWS
+#if KMP_AFFINITY_SUPPORTED
//
// Parse the proc id list. Return TRUE if successful, FALSE otherwise.
//
@@ -3068,11 +3064,7 @@ __kmp_stg_print_topology_method( kmp_str_buf_t * buffer, char const * name,
# endif /* KMP_DEBUG */
} // __kmp_stg_print_topology_method
-#elif !KMP_AFFINITY_SUPPORTED
- // affinity not supported
-#else
- #error "Unknown or unsupported OS"
-#endif /* KMP_OS_LINUX || KMP_OS_WINDOWS */
+#endif /* KMP_AFFINITY_SUPPORTED */
#if OMP_40_ENABLED
@@ -3118,9 +3110,9 @@ __kmp_stg_parse_proc_bind( char const * name, char const * value, void * data )
if ( __kmp_match_str( "disabled", buf, &next ) ) {
buf = next;
SKIP_WS( buf );
-# if KMP_OS_LINUX || KMP_OS_WINDOWS
+# if KMP_AFFINITY_SUPPORTED
__kmp_affinity_type = affinity_disabled;
-# endif /* KMP_OS_LINUX || KMP_OS_WINDOWS */
+# endif /* KMP_AFFINITY_SUPPORTED */
__kmp_nested_proc_bind.used = 1;
__kmp_nested_proc_bind.bind_types[0] = proc_bind_disabled;
}
@@ -3128,9 +3120,9 @@ __kmp_stg_parse_proc_bind( char const * name, char const * value, void * data )
|| __kmp_match_str( "false", buf, &next ) ) {
buf = next;
SKIP_WS( buf );
-# if KMP_OS_LINUX || KMP_OS_WINDOWS
+# if KMP_AFFINITY_SUPPORTED
__kmp_affinity_type = affinity_none;
-# endif /* KMP_OS_LINUX || KMP_OS_WINDOWS */
+# endif /* KMP_AFFINITY_SUPPORTED */
__kmp_nested_proc_bind.used = 1;
__kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
}
@@ -4413,7 +4405,7 @@ static kmp_setting_t __kmp_stg_table[] = {
{ "KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate, __kmp_stg_print_all_threadprivate, NULL, 0, 0 },
{ "KMP_FOREIGN_THREADS_THREADPRIVATE", __kmp_stg_parse_foreign_threads_threadprivate, __kmp_stg_print_foreign_threads_threadprivate, NULL, 0, 0 },
-#if KMP_OS_LINUX || KMP_OS_WINDOWS
+#if KMP_AFFINITY_SUPPORTED
{ "KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL, 0, 0 },
# ifdef KMP_GOMP_COMPAT
{ "GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL, /* no print */ NULL, 0, 0 },
@@ -4441,7 +4433,7 @@ static kmp_setting_t __kmp_stg_table[] = {
#else
#error "Unknown or unsupported OS"
-#endif // KMP_OS_LINUX || KMP_OS_WINDOWS
+#endif // KMP_AFFINITY_SUPPORTED
{ "KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork, __kmp_stg_print_init_at_fork, NULL, 0, 0 },
{ "KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL, 0, 0 },
@@ -4641,7 +4633,7 @@ __kmp_stg_init( void
}
-#if KMP_OS_LINUX || KMP_OS_WINDOWS
+#if KMP_AFFINITY_SUPPORTED
{ // Initialize KMP_AFFINITY, GOMP_CPU_AFFINITY, and OMP_PROC_BIND data.
kmp_setting_t * kmp_affinity = __kmp_stg_find( "KMP_AFFINITY" ); // 1st priority.
@@ -4686,11 +4678,9 @@ __kmp_stg_init( void
rivals[ i ++ ] = NULL;
}
-#elif !KMP_AFFINITY_SUPPORTED
+#else
// KMP_AFFINITY not supported, so OMP_PROC_BIND has no rivals.
// OMP_PLACES not supported yet.
-#else
- #error "Unknown or unsupported OS"
#endif
{ // Initialize KMP_DETERMINISTIC_REDUCTION and KMP_FORCE_REDUCTION data.
diff --git a/openmp/runtime/src/z_Linux_util.c b/openmp/runtime/src/z_Linux_util.c
index 664fdeafd42..7633f990a73 100644
--- a/openmp/runtime/src/z_Linux_util.c
+++ b/openmp/runtime/src/z_Linux_util.c
@@ -110,7 +110,7 @@ __kmp_print_cond( char *buffer, kmp_cond_align_t *cond )
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
-#if KMP_OS_LINUX
+#if KMP_OS_LINUX && KMP_AFFINITY_SUPPORTED
/*
* Affinity support
@@ -440,7 +440,7 @@ __kmp_change_thread_affinity_mask( int gtid, kmp_affin_mask_t *new_mask,
}
}
-#endif // KMP_OS_LINUX
+#endif // KMP_OS_LINUX && KMP_AFFINITY_SUPPORTED
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
OpenPOWER on IntegriCloud