1/* 2 * Copyright (c) 2014 ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#ifndef _LIBBOMP_ICV_H 11#define _LIBBOMP_ICV_H 12 13/* 14 * --------------------------------------------------------------------------- 15 * 2.3 Internal Control Variables 16 * --------------------------------------------------------------------------- 17 * 18 * An OpenMP implementation must act as if there are internal control variables 19 * (ICVs) that control the behavior of an OpenMP program. 20 * They are initialized by the implementation itself and may be given values 21 * through OpenMP environment variables and through calls to OpenMP API routines. 22 */ 23 24/** 25 * \brief 26 */ 27struct omp_icv_task 28{ 29 /** 30 * controls whether dynamic adjustment of the number of threads is enabled 31 * for encountered parallel regions. 32 * 33 * Scope: Data Environment 34 * Initialization: OMP_DYNAMIC 35 * Accessed: omp_set_dynamic(), omp_get_dyamic() 36 */ 37 uint8_t dynamic; 38 39 /** 40 * controls whether nested parallelism is enabled for encountered parallel 41 * regions 42 * 43 * Scope: Data Environment 44 * Initialization: OMP_NESTED, set to false 45 * Accessed: omp_set_nested(), omp_get_nested() 46 */ 47 uint8_t nested; 48 49 /** 50 * controls the number of threads requested for encountered parallel regions 51 * 52 * Scope: Data Environment 53 * Initialization: OMP_NUM_THREADS 54 * Accessed: omp_set_num_threads(), omp_get_num_threads() 55 */ 56 uint32_t nthreads; 57 58 /** 59 * controls the maximum number of threads participating in the contention group 60 * 61 * Scope: Data Environment 62 * Initialization: OMP_THREAD_LIMIT 63 * Accessed: thread_limit (clause), omp_get_thread_limit() 64 */ 65 uint32_t thread_limit; 66 67 /** 68 * controls the place partition available to the execution environment for 69 * encountered parallel regions. 70 * 71 * Scope: Data Environment 72 * Initialization: OMP_PLACES 73 */ 74 uint32_t place_partition; 75 76 /** 77 * the number of nested, active parallel regions enclosing the current ask 78 * such that all of the parallel regions are enclosed by the outermost initial 79 * task region on the current device. 80 * 81 * Scope: Data Environment 82 * Initialization: set to zero 83 * Accessed: omp_get_active_levels() 84 */ 85 uint8_t active_levels; 86 87 /** 88 * the number of nested parallel regions enclosing the current task such that 89 * all of the parallel regions are enclosed by the outermost initial task region 90 * on the current device. 91 * 92 * Scope: Data Environment 93 * Initialization: set to zero 94 * Accessed: omp_get_level() 95 */ 96 uint8_t levels; 97 98#if OMP_VERSION >= OMP_VERSION_40 99 /** 100 * Controls the binding of OpenMP threads to places. When binding is requested, 101 * the variable indicates that the execution environment is advised not to 102 * move threads between places. The variable can also provide default thread 103 * affinity policies. 104 * 105 * Scope: Data Environment 106 * Initialization: OMP_PROC_BIND 107 * Accessed: omp_get_proc_bind() 108 */ 109 uint8_t bind; 110 111 /** 112 * controls the default target device. 113 * 114 * Scope: Data Environment 115 * Initialization: OMP_DEFAULT_DEVICE 116 * Accessed: omp_set_default_device(), omp_get_default_device() 117 */ 118 uint8_t default_device; 119#endif 120 121 /** 122 * controls the schedule that the runtime schedule clause uses for loop regions 123 * 124 * Scope: Data Environment 125 * Initialization: OMP_SCHEDULE 126 * Accessed: omp_set_schedule(), omp_get_schedule() 127 */ 128 omp_sched_t run_sched; 129 int run_sched_modifier; 130}; 131 132/** 133 * 134 */ 135struct omp_icv_device 136{ 137 /** 138 * controls the implementation defined default scheduling of loop loop regions 139 * 140 * Scope: Device 141 * Initialization: (none) 142 */ 143 uint8_t dev_sched; 144 145 /** 146 * controls the stack size for threads that the OpenMP implementation creates 147 * 148 * Scope: Device 149 * Initialization: OMP_STACKSIZE 150 */ 151 uint32_t stack_size; 152 153 /** 154 * controls the desired behavior of waiting threads. 155 * 156 * Scope: Device 157 * Initialization: OMP_WAIT_POLICY 158 */ 159 uint8_t wait_policy; 160 161#if OMP_VERSION >= OMP_VERSION_40 162 /** 163 * controls the desired behavior of the cancel construct and cancellation points 164 * 165 * Scope: Device 166 * Initialization: OMP_CANCELLATION 167 * Accessed: omp_get_cancellation() 168 */ 169 uint8_t cancel; 170#endif 171 172 /** 173 * The number of nested, active parallel regions enclosing the current ask 174 * such that all of the parallel regions are enclosed by the outermost initial 175 * task region on the current device. 176 * 177 * Scope: Device 178 * Initialization: OMP_MAX_ACTIVE_LEVELS 179 * Accessed: omp_set_max_active_levels(), omp_get_max_active_levels() 180 */ 181 uint8_t max_active_levels; 182}; 183 184struct omp_icv_task *bomp_icv_new(void); 185void bomp_icv_init_from_parent(struct omp_icv_task *icv_task); 186void bomp_icv_init_from_env(struct omp_icv_task *icv_task); 187void bomp_icv_dev_init_from_env(struct omp_icv_device *icv_dev); 188 189 190#define OMP_SET_ICV_DEV(_var, _val) bomp_get_icv_device()->_var = (_val) 191#define OMP_GET_ICV_DEV(_var) (bomp_get_icv_device()->_var) 192#define OMP_SET_ICV_TASK(_var, _val) (bomp_get_icv_task())->_var = (_val) 193#define OMP_GET_ICV_TASK(_var) ((bomp_get_icv_task())->_var) 194 195 196#endif /* _LIBBOMP_ENVIRONEMNT_H */ 197