10 #define ABTD_KEY_TABLE_DEFAULT_SIZE 4 11 #define ABTD_THREAD_DEFAULT_STACKSIZE 16384 12 #define ABTD_SCHED_DEFAULT_STACKSIZE (4 * 1024 * 1024) 13 #define ABTD_SCHED_EVENT_FREQ 50 14 #define ABTD_SCHED_SLEEP_NSEC 100 16 #define ABTD_OS_PAGE_SIZE (4 * 1024) 17 #define ABTD_HUGE_PAGE_SIZE (2 * 1024 * 1024) 18 #define ABTD_MEM_PAGE_SIZE (2 * 1024 * 1024) 19 #define ABTD_MEM_STACK_PAGE_SIZE (8 * 1024 * 1024) 20 #define ABTD_MEM_MAX_NUM_STACKS 65536 22 void ABTD_env_init(ABTI_global *p_global)
27 p_global->num_cores = sysconf(_SC_NPROCESSORS_ONLN);
31 env = getenv(
"ABT_SET_AFFINITY");
33 env = getenv(
"ABT_ENV_SET_AFFINITY");
35 if (strcmp(env,
"0") == 0 || strcasecmp(env,
"n") == 0 ||
36 strcasecmp(env,
"no") == 0) {
40 if (p_global->set_affinity ==
ABT_TRUE) {
44 #ifdef ABT_CONFIG_USE_DEBUG_LOG_PRINT 54 env = getenv(
"ABT_USE_LOG");
56 env = getenv(
"ABT_ENV_USE_LOG");
58 if (strcmp(env,
"0") == 0 || strcasecmp(env,
"n") == 0 ||
59 strcasecmp(env,
"no") == 0) {
65 env = getenv(
"ABT_USE_DEBUG");
67 env = getenv(
"ABT_ENV_USE_DEBUG");
69 if (strcmp(env,
"0") == 0 || strcasecmp(env,
"n") == 0 ||
70 strcasecmp(env,
"no") == 0) {
78 env = getenv(
"ABT_MAX_NUM_XSTREAMS");
80 env = getenv(
"ABT_ENV_MAX_NUM_XSTREAMS");
82 p_global->max_xstreams = atoi(env);
84 p_global->max_xstreams = p_global->num_cores;
88 env = getenv(
"ABT_KEY_TABLE_SIZE");
90 env = getenv(
"ABT_ENV_KEY_TABLE_SIZE");
92 p_global->key_table_size = (int)atoi(env);
94 p_global->key_table_size = ABTD_KEY_TABLE_DEFAULT_SIZE;
98 env = getenv(
"ABT_THREAD_STACKSIZE");
100 env = getenv(
"ABT_ENV_THREAD_STACKSIZE");
102 p_global->thread_stacksize = (size_t)atol(env);
103 ABTI_ASSERT(p_global->thread_stacksize >= 512);
105 p_global->thread_stacksize = ABTD_THREAD_DEFAULT_STACKSIZE;
109 env = getenv(
"ABT_SCHED_STACKSIZE");
111 env = getenv(
"ABT_ENV_SCHED_STACKSIZE");
113 p_global->sched_stacksize = (size_t)atol(env);
114 ABTI_ASSERT(p_global->sched_stacksize >= 512);
116 p_global->sched_stacksize = ABTD_SCHED_DEFAULT_STACKSIZE;
120 env = getenv(
"ABT_SCHED_EVENT_FREQ");
122 env = getenv(
"ABT_ENV_SCHED_EVENT_FREQ");
124 p_global->sched_event_freq = (uint32_t)atol(env);
125 ABTI_ASSERT(p_global->sched_event_freq >= 1);
127 p_global->sched_event_freq = ABTD_SCHED_EVENT_FREQ;
131 env = getenv(
"ABT_SCHED_SLEEP_NSEC");
133 env = getenv(
"ABT_ENV_SCHED_SLEEP_NSEC");
135 p_global->sched_sleep_nsec = atol(env);
136 ABTI_ASSERT(p_global->sched_sleep_nsec >= 0);
138 p_global->sched_sleep_nsec = ABTD_SCHED_SLEEP_NSEC;
142 env = getenv(
"ABT_MUTEX_MAX_HANDOVERS");
144 env = getenv(
"ABT_ENV_MUTEX_MAX_HANDOVERS");
146 p_global->mutex_max_handovers = (uint32_t)atoi(env);
147 ABTI_ASSERT(p_global->mutex_max_handovers >= 1);
149 p_global->mutex_max_handovers = 64;
152 env = getenv(
"ABT_MUTEX_MAX_WAKEUPS");
154 env = getenv(
"ABT_ENV_MUTEX_MAX_WAKEUPS");
156 p_global->mutex_max_wakeups = (uint32_t)atoi(env);
157 ABTI_ASSERT(p_global->mutex_max_wakeups >= 1);
159 p_global->mutex_max_wakeups = 1;
163 env = getenv(
"ABT_OS_PAGE_SIZE");
165 env = getenv(
"ABT_ENV_OS_PAGE_SIZE");
167 p_global->os_page_size = (uint32_t)atol(env);
169 p_global->os_page_size = ABTD_OS_PAGE_SIZE;
173 env = getenv(
"ABT_HUGE_PAGE_SIZE");
175 env = getenv(
"ABT_ENV_HUGE_PAGE_SIZE");
177 p_global->huge_page_size = (uint32_t)atol(env);
179 p_global->huge_page_size = ABTD_HUGE_PAGE_SIZE;
182 #ifdef ABT_CONFIG_USE_MEM_POOL 184 env = getenv(
"ABT_MEM_PAGE_SIZE");
186 env = getenv(
"ABT_ENV_MEM_PAGE_SIZE");
188 p_global->mem_page_size = (uint32_t)atol(env);
190 p_global->mem_page_size = ABTD_MEM_PAGE_SIZE;
194 env = getenv(
"ABT_MEM_STACK_PAGE_SIZE");
196 env = getenv(
"ABT_ENV_MEM_STACK_PAGE_SIZE");
198 p_global->mem_sp_size = (size_t)atol(env);
200 p_global->mem_sp_size = ABTD_MEM_STACK_PAGE_SIZE;
204 env = getenv(
"ABT_MEM_MAX_NUM_STACKS");
206 env = getenv(
"ABT_ENV_MEM_MAX_NUM_STACKS");
208 p_global->mem_max_stacks = (uint32_t)atol(env);
210 p_global->mem_max_stacks = ABTD_MEM_MAX_NUM_STACKS;
216 env = getenv(
"ABT_MEM_LP_ALLOC");
218 env = getenv(
"ABT_ENV_MEM_LP_ALLOC");
219 #if defined(HAVE_MAP_ANONYMOUS) || defined(HAVE_MAP_ANON) 220 #if defined(__x86_64__) 221 int lp_alloc = ABTI_MEM_LP_MMAP_HP_RP;
234 int lp_alloc = ABTI_MEM_LP_MALLOC;
237 int lp_alloc = ABTI_MEM_LP_MALLOC;
240 if (strcasecmp(env,
"malloc") == 0) {
241 lp_alloc = ABTI_MEM_LP_MALLOC;
242 #if defined(HAVE_MAP_ANONYMOUS) || defined(HAVE_MAP_ANON) 243 }
else if (strcasecmp(env,
"mmap_rp") == 0) {
244 lp_alloc = ABTI_MEM_LP_MMAP_RP;
245 }
else if (strcasecmp(env,
"mmap_hp_rp") == 0) {
246 lp_alloc = ABTI_MEM_LP_MMAP_HP_RP;
247 }
else if (strcasecmp(env,
"mmap_hp_thp") == 0) {
248 lp_alloc = ABTI_MEM_LP_MMAP_HP_THP;
250 }
else if (strcasecmp(env,
"thp") == 0) {
251 lp_alloc = ABTI_MEM_LP_THP;
256 if (lp_alloc != ABTI_MEM_LP_MALLOC) {
257 p_global->mem_lp_alloc = ABTI_mem_check_lp_alloc(lp_alloc);
259 p_global->mem_lp_alloc = lp_alloc;
264 env = getenv(
"ABT_PRINT_CONFIG");
266 env = getenv(
"ABT_ENV_PRINT_CONFIG");
268 if (strcmp(env,
"1") == 0 || strcasecmp(env,
"yes") == 0 ||
269 strcasecmp(env,
"y") == 0) {