diff options
Diffstat (limited to 'libgomp/env.c')
-rw-r--r-- | libgomp/env.c | 270 |
1 files changed, 2 insertions, 268 deletions
diff --git a/libgomp/env.c b/libgomp/env.c index ac05c3b7b75..7ba7663da9a 100644 --- a/libgomp/env.c +++ b/libgomp/env.c @@ -23,8 +23,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ -/* This file defines the OpenMP internal control variables, and arranges - for them to be initialized from environment variables at startup. */ +/* This file arranges for OpenMP internal control variables to be initialized + from environment variables at startup. */ #include "libgomp.h" #include "libgomp_f.h" @@ -55,35 +55,6 @@ # define strtoull(ptr, eptr, base) strtoul (ptr, eptr, base) #endif -struct gomp_task_icv gomp_global_icv = { - .nthreads_var = 1, - .thread_limit_var = UINT_MAX, - .run_sched_var = GFS_DYNAMIC, - .run_sched_chunk_size = 1, - .default_device_var = 0, - .dyn_var = false, - .nest_var = false, - .bind_var = omp_proc_bind_false, - .target_data = NULL -}; - -unsigned long gomp_max_active_levels_var = INT_MAX; -bool gomp_cancel_var = false; -int gomp_max_task_priority_var = 0; -#ifndef HAVE_SYNC_BUILTINS -gomp_mutex_t gomp_managed_threads_lock; -#endif -unsigned long gomp_available_cpus = 1, gomp_managed_threads = 1; -unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var; -unsigned long *gomp_nthreads_var_list, gomp_nthreads_var_list_len; -char *gomp_bind_var_list; -unsigned long gomp_bind_var_list_len; -void **gomp_places_list; -unsigned long gomp_places_list_len; -int gomp_debug_var; -char *goacc_device_type; -int goacc_device_num; - /* Parse the OMP_SCHEDULE environment variable. */ static void @@ -1302,240 +1273,3 @@ initialize_env (void) goacc_runtime_initialize (); } - - -/* The public OpenMP API routines that access these variables. */ - -void -omp_set_num_threads (int n) -{ - struct gomp_task_icv *icv = gomp_icv (true); - icv->nthreads_var = (n > 0 ? n : 1); -} - -void -omp_set_dynamic (int val) -{ - struct gomp_task_icv *icv = gomp_icv (true); - icv->dyn_var = val; -} - -int -omp_get_dynamic (void) -{ - struct gomp_task_icv *icv = gomp_icv (false); - return icv->dyn_var; -} - -void -omp_set_nested (int val) -{ - struct gomp_task_icv *icv = gomp_icv (true); - icv->nest_var = val; -} - -int -omp_get_nested (void) -{ - struct gomp_task_icv *icv = gomp_icv (false); - return icv->nest_var; -} - -void -omp_set_schedule (omp_sched_t kind, int chunk_size) -{ - struct gomp_task_icv *icv = gomp_icv (true); - switch (kind) - { - case omp_sched_static: - if (chunk_size < 1) - chunk_size = 0; - icv->run_sched_chunk_size = chunk_size; - break; - case omp_sched_dynamic: - case omp_sched_guided: - if (chunk_size < 1) - chunk_size = 1; - icv->run_sched_chunk_size = chunk_size; - break; - case omp_sched_auto: - break; - default: - return; - } - icv->run_sched_var = kind; -} - -void -omp_get_schedule (omp_sched_t *kind, int *chunk_size) -{ - struct gomp_task_icv *icv = gomp_icv (false); - *kind = icv->run_sched_var; - *chunk_size = icv->run_sched_chunk_size; -} - -int -omp_get_max_threads (void) -{ - struct gomp_task_icv *icv = gomp_icv (false); - return icv->nthreads_var; -} - -int -omp_get_thread_limit (void) -{ - struct gomp_task_icv *icv = gomp_icv (false); - return icv->thread_limit_var > INT_MAX ? INT_MAX : icv->thread_limit_var; -} - -void -omp_set_max_active_levels (int max_levels) -{ - if (max_levels >= 0) - gomp_max_active_levels_var = max_levels; -} - -int -omp_get_max_active_levels (void) -{ - return gomp_max_active_levels_var; -} - -int -omp_get_cancellation (void) -{ - return gomp_cancel_var; -} - -int -omp_get_max_task_priority (void) -{ - return gomp_max_task_priority_var; -} - -omp_proc_bind_t -omp_get_proc_bind (void) -{ - struct gomp_task_icv *icv = gomp_icv (false); - return icv->bind_var; -} - -void -omp_set_default_device (int device_num) -{ - struct gomp_task_icv *icv = gomp_icv (true); - icv->default_device_var = device_num >= 0 ? device_num : 0; -} - -int -omp_get_default_device (void) -{ - struct gomp_task_icv *icv = gomp_icv (false); - return icv->default_device_var; -} - -int -omp_get_num_devices (void) -{ - return gomp_get_num_devices (); -} - -int -omp_get_num_teams (void) -{ - /* Hardcoded to 1 on host, MIC, HSAIL? Maybe variable on PTX. */ - return 1; -} - -int -omp_get_team_num (void) -{ - /* Hardcoded to 0 on host, MIC, HSAIL? Maybe variable on PTX. */ - return 0; -} - -int -omp_is_initial_device (void) -{ - /* Hardcoded to 1 on host, should be 0 on MIC, HSAIL, PTX. */ - return 1; -} - -int -omp_get_initial_device (void) -{ - return GOMP_DEVICE_HOST_FALLBACK; -} - -int -omp_get_num_places (void) -{ - return gomp_places_list_len; -} - -int -omp_get_place_num (void) -{ - if (gomp_places_list == NULL) - return -1; - - struct gomp_thread *thr = gomp_thread (); - if (thr->place == 0) - gomp_init_affinity (); - - return (int) thr->place - 1; -} - -int -omp_get_partition_num_places (void) -{ - if (gomp_places_list == NULL) - return 0; - - struct gomp_thread *thr = gomp_thread (); - if (thr->place == 0) - gomp_init_affinity (); - - return thr->ts.place_partition_len; -} - -void -omp_get_partition_place_nums (int *place_nums) -{ - if (gomp_places_list == NULL) - return; - - struct gomp_thread *thr = gomp_thread (); - if (thr->place == 0) - gomp_init_affinity (); - - unsigned int i; - for (i = 0; i < thr->ts.place_partition_len; i++) - *place_nums++ = thr->ts.place_partition_off + i; -} - -ialias (omp_set_dynamic) -ialias (omp_set_nested) -ialias (omp_set_num_threads) -ialias (omp_get_dynamic) -ialias (omp_get_nested) -ialias (omp_set_schedule) -ialias (omp_get_schedule) -ialias (omp_get_max_threads) -ialias (omp_get_thread_limit) -ialias (omp_set_max_active_levels) -ialias (omp_get_max_active_levels) -ialias (omp_get_cancellation) -ialias (omp_get_proc_bind) -ialias (omp_set_default_device) -ialias (omp_get_default_device) -ialias (omp_get_num_devices) -ialias (omp_get_num_teams) -ialias (omp_get_team_num) -ialias (omp_is_initial_device) -ialias (omp_get_initial_device) -ialias (omp_get_max_task_priority) -ialias (omp_get_num_places) -ialias (omp_get_place_num) -ialias (omp_get_partition_num_places) -ialias (omp_get_partition_place_nums) |