File: | projects/openmp/runtime/src/kmp_settings.cpp |
Warning: | line 359, column 3 Assigned value is garbage or undefined |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* | |||
2 | * kmp_settings.cpp -- Initialize environment variables | |||
3 | */ | |||
4 | ||||
5 | //===----------------------------------------------------------------------===// | |||
6 | // | |||
7 | // The LLVM Compiler Infrastructure | |||
8 | // | |||
9 | // This file is dual licensed under the MIT and the University of Illinois Open | |||
10 | // Source Licenses. See LICENSE.txt for details. | |||
11 | // | |||
12 | //===----------------------------------------------------------------------===// | |||
13 | ||||
14 | #include "kmp.h" | |||
15 | #include "kmp_affinity.h" | |||
16 | #include "kmp_atomic.h" | |||
17 | #if KMP_USE_HIER_SCHED0 | |||
18 | #include "kmp_dispatch_hier.h" | |||
19 | #endif | |||
20 | #include "kmp_environment.h" | |||
21 | #include "kmp_i18n.h" | |||
22 | #include "kmp_io.h" | |||
23 | #include "kmp_itt.h" | |||
24 | #include "kmp_lock.h" | |||
25 | #include "kmp_settings.h" | |||
26 | #include "kmp_str.h" | |||
27 | #include "kmp_wrapper_getpid.h" | |||
28 | #include <ctype.h> // toupper() | |||
29 | ||||
30 | static int __kmp_env_toPrint(char const *name, int flag); | |||
31 | ||||
32 | bool __kmp_env_format = 0; // 0 - old format; 1 - new format | |||
33 | ||||
34 | // ----------------------------------------------------------------------------- | |||
35 | // Helper string functions. Subject to move to kmp_str. | |||
36 | ||||
37 | #ifdef USE_LOAD_BALANCE1 | |||
38 | static double __kmp_convert_to_double(char const *s) { | |||
39 | double result; | |||
40 | ||||
41 | if (KMP_SSCANFsscanf(s, "%lf", &result) < 1) { | |||
42 | result = 0.0; | |||
43 | } | |||
44 | ||||
45 | return result; | |||
46 | } | |||
47 | #endif | |||
48 | ||||
49 | #ifdef KMP_DEBUG1 | |||
50 | static unsigned int __kmp_readstr_with_sentinel(char *dest, char const *src, | |||
51 | size_t len, char sentinel) { | |||
52 | unsigned int i; | |||
53 | for (i = 0; i < len; i++) { | |||
54 | if ((*src == '\0') || (*src == sentinel)) { | |||
55 | break; | |||
56 | } | |||
57 | *(dest++) = *(src++); | |||
58 | } | |||
59 | *dest = '\0'; | |||
60 | return i; | |||
61 | } | |||
62 | #endif | |||
63 | ||||
64 | static int __kmp_match_with_sentinel(char const *a, char const *b, size_t len, | |||
65 | char sentinel) { | |||
66 | size_t l = 0; | |||
67 | ||||
68 | if (a == NULL__null) | |||
69 | a = ""; | |||
70 | if (b == NULL__null) | |||
71 | b = ""; | |||
72 | while (*a && *b && *b != sentinel) { | |||
73 | char ca = *a, cb = *b; | |||
74 | ||||
75 | if (ca >= 'a' && ca <= 'z') | |||
76 | ca -= 'a' - 'A'; | |||
77 | if (cb >= 'a' && cb <= 'z') | |||
78 | cb -= 'a' - 'A'; | |||
79 | if (ca != cb) | |||
80 | return FALSE0; | |||
81 | ++l; | |||
82 | ++a; | |||
83 | ++b; | |||
84 | } | |||
85 | return l >= len; | |||
86 | } | |||
87 | ||||
88 | // Expected usage: | |||
89 | // token is the token to check for. | |||
90 | // buf is the string being parsed. | |||
91 | // *end returns the char after the end of the token. | |||
92 | // it is not modified unless a match occurs. | |||
93 | // | |||
94 | // Example 1: | |||
95 | // | |||
96 | // if (__kmp_match_str("token", buf, *end) { | |||
97 | // <do something> | |||
98 | // buf = end; | |||
99 | // } | |||
100 | // | |||
101 | // Example 2: | |||
102 | // | |||
103 | // if (__kmp_match_str("token", buf, *end) { | |||
104 | // char *save = **end; | |||
105 | // **end = sentinel; | |||
106 | // <use any of the __kmp*_with_sentinel() functions> | |||
107 | // **end = save; | |||
108 | // buf = end; | |||
109 | // } | |||
110 | ||||
111 | static int __kmp_match_str(char const *token, char const *buf, | |||
112 | const char **end) { | |||
113 | ||||
114 | KMP_ASSERT(token != NULL)if (!(token != __null)) { __kmp_debug_assert("token != NULL", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 114); }; | |||
115 | KMP_ASSERT(buf != NULL)if (!(buf != __null)) { __kmp_debug_assert("buf != NULL", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 115); }; | |||
116 | KMP_ASSERT(end != NULL)if (!(end != __null)) { __kmp_debug_assert("end != NULL", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 116); }; | |||
117 | ||||
118 | while (*token && *buf) { | |||
119 | char ct = *token, cb = *buf; | |||
120 | ||||
121 | if (ct >= 'a' && ct <= 'z') | |||
122 | ct -= 'a' - 'A'; | |||
123 | if (cb >= 'a' && cb <= 'z') | |||
124 | cb -= 'a' - 'A'; | |||
125 | if (ct != cb) | |||
126 | return FALSE0; | |||
127 | ++token; | |||
128 | ++buf; | |||
129 | } | |||
130 | if (*token) { | |||
131 | return FALSE0; | |||
132 | } | |||
133 | *end = buf; | |||
134 | return TRUE(!0); | |||
135 | } | |||
136 | ||||
137 | #if KMP_OS_DARWIN0 | |||
138 | static size_t __kmp_round4k(size_t size) { | |||
139 | size_t _4k = 4 * 1024; | |||
140 | if (size & (_4k - 1)) { | |||
141 | size &= ~(_4k - 1); | |||
142 | if (size <= KMP_SIZE_T_MAX(0xFFFFFFFFFFFFFFFF) - _4k) { | |||
143 | size += _4k; // Round up if there is no overflow. | |||
144 | } | |||
145 | } | |||
146 | return size; | |||
147 | } // __kmp_round4k | |||
148 | #endif | |||
149 | ||||
150 | /* Here, multipliers are like __kmp_convert_to_seconds, but floating-point | |||
151 | values are allowed, and the return value is in milliseconds. The default | |||
152 | multiplier is milliseconds. Returns INT_MAX only if the value specified | |||
153 | matches "infinit*". Returns -1 if specified string is invalid. */ | |||
154 | int __kmp_convert_to_milliseconds(char const *data) { | |||
155 | int ret, nvalues, factor; | |||
156 | char mult, extra; | |||
157 | double value; | |||
158 | ||||
159 | if (data == NULL__null) | |||
160 | return (-1); | |||
161 | if (__kmp_str_match("infinit", -1, data)) | |||
162 | return (INT_MAX2147483647); | |||
163 | value = (double)0.0; | |||
164 | mult = '\0'; | |||
165 | nvalues = KMP_SSCANFsscanf(data, "%lf%c%c", &value, &mult, &extra); | |||
166 | if (nvalues < 1) | |||
167 | return (-1); | |||
168 | if (nvalues == 1) | |||
169 | mult = '\0'; | |||
170 | if (nvalues == 3) | |||
171 | return (-1); | |||
172 | ||||
173 | if (value < 0) | |||
174 | return (-1); | |||
175 | ||||
176 | switch (mult) { | |||
177 | case '\0': | |||
178 | /* default is milliseconds */ | |||
179 | factor = 1; | |||
180 | break; | |||
181 | case 's': | |||
182 | case 'S': | |||
183 | factor = 1000; | |||
184 | break; | |||
185 | case 'm': | |||
186 | case 'M': | |||
187 | factor = 1000 * 60; | |||
188 | break; | |||
189 | case 'h': | |||
190 | case 'H': | |||
191 | factor = 1000 * 60 * 60; | |||
192 | break; | |||
193 | case 'd': | |||
194 | case 'D': | |||
195 | factor = 1000 * 24 * 60 * 60; | |||
196 | break; | |||
197 | default: | |||
198 | return (-1); | |||
199 | } | |||
200 | ||||
201 | if (value >= ((INT_MAX2147483647 - 1) / factor)) | |||
202 | ret = INT_MAX2147483647 - 1; /* Don't allow infinite value here */ | |||
203 | else | |||
204 | ret = (int)(value * (double)factor); /* truncate to int */ | |||
205 | ||||
206 | return ret; | |||
207 | } | |||
208 | ||||
209 | static int __kmp_strcasecmp_with_sentinel(char const *a, char const *b, | |||
210 | char sentinel) { | |||
211 | if (a == NULL__null) | |||
212 | a = ""; | |||
213 | if (b == NULL__null) | |||
214 | b = ""; | |||
215 | while (*a && *b && *b != sentinel) { | |||
216 | char ca = *a, cb = *b; | |||
217 | ||||
218 | if (ca >= 'a' && ca <= 'z') | |||
219 | ca -= 'a' - 'A'; | |||
220 | if (cb >= 'a' && cb <= 'z') | |||
221 | cb -= 'a' - 'A'; | |||
222 | if (ca != cb) | |||
223 | return (int)(unsigned char)*a - (int)(unsigned char)*b; | |||
224 | ++a; | |||
225 | ++b; | |||
226 | } | |||
227 | return *a | |||
228 | ? (*b && *b != sentinel) | |||
229 | ? (int)(unsigned char)*a - (int)(unsigned char)*b | |||
230 | : 1 | |||
231 | : (*b && *b != sentinel) ? -1 : 0; | |||
232 | } | |||
233 | ||||
234 | // ============================================================================= | |||
235 | // Table structures and helper functions. | |||
236 | ||||
237 | typedef struct __kmp_setting kmp_setting_t; | |||
238 | typedef struct __kmp_stg_ss_data kmp_stg_ss_data_t; | |||
239 | typedef struct __kmp_stg_wp_data kmp_stg_wp_data_t; | |||
240 | typedef struct __kmp_stg_fr_data kmp_stg_fr_data_t; | |||
241 | ||||
242 | typedef void (*kmp_stg_parse_func_t)(char const *name, char const *value, | |||
243 | void *data); | |||
244 | typedef void (*kmp_stg_print_func_t)(kmp_str_buf_t *buffer, char const *name, | |||
245 | void *data); | |||
246 | ||||
247 | struct __kmp_setting { | |||
248 | char const *name; // Name of setting (environment variable). | |||
249 | kmp_stg_parse_func_t parse; // Parser function. | |||
250 | kmp_stg_print_func_t print; // Print function. | |||
251 | void *data; // Data passed to parser and printer. | |||
252 | int set; // Variable set during this "session" | |||
253 | // (__kmp_env_initialize() or kmp_set_defaults() call). | |||
254 | int defined; // Variable set in any "session". | |||
255 | }; // struct __kmp_setting | |||
256 | ||||
257 | struct __kmp_stg_ss_data { | |||
258 | size_t factor; // Default factor: 1 for KMP_STACKSIZE, 1024 for others. | |||
259 | kmp_setting_t **rivals; // Array of pointers to rivals (including itself). | |||
260 | }; // struct __kmp_stg_ss_data | |||
261 | ||||
262 | struct __kmp_stg_wp_data { | |||
263 | int omp; // 0 -- KMP_LIBRARY, 1 -- OMP_WAIT_POLICY. | |||
264 | kmp_setting_t **rivals; // Array of pointers to rivals (including itself). | |||
265 | }; // struct __kmp_stg_wp_data | |||
266 | ||||
267 | struct __kmp_stg_fr_data { | |||
268 | int force; // 0 -- KMP_DETERMINISTIC_REDUCTION, 1 -- KMP_FORCE_REDUCTION. | |||
269 | kmp_setting_t **rivals; // Array of pointers to rivals (including itself). | |||
270 | }; // struct __kmp_stg_fr_data | |||
271 | ||||
272 | static int __kmp_stg_check_rivals( // 0 -- Ok, 1 -- errors found. | |||
273 | char const *name, // Name of variable. | |||
274 | char const *value, // Value of the variable. | |||
275 | kmp_setting_t **rivals // List of rival settings (must include current one). | |||
276 | ); | |||
277 | ||||
278 | // ----------------------------------------------------------------------------- | |||
279 | // Helper parse functions. | |||
280 | ||||
281 | static void __kmp_stg_parse_bool(char const *name, char const *value, | |||
282 | int *out) { | |||
283 | if (__kmp_str_match_true(value)) { | |||
284 | *out = TRUE(!0); | |||
285 | } else if (__kmp_str_match_false(value)) { | |||
286 | *out = FALSE0; | |||
287 | } else { | |||
288 | __kmp_msg(kmp_ms_warning, KMP_MSG(BadBoolValue, name, value)__kmp_msg_format(kmp_i18n_msg_BadBoolValue, name, value), | |||
289 | KMP_HNT(ValidBoolValues)__kmp_msg_format(kmp_i18n_hnt_ValidBoolValues), __kmp_msg_null); | |||
290 | } | |||
291 | } // __kmp_stg_parse_bool | |||
292 | ||||
293 | static void __kmp_stg_parse_size(char const *name, char const *value, | |||
294 | size_t size_min, size_t size_max, | |||
295 | int *is_specified, size_t *out, | |||
296 | size_t factor) { | |||
297 | char const *msg = NULL__null; | |||
298 | #if KMP_OS_DARWIN0 | |||
299 | size_min = __kmp_round4k(size_min); | |||
300 | size_max = __kmp_round4k(size_max); | |||
301 | #endif // KMP_OS_DARWIN | |||
302 | if (value) { | |||
303 | if (is_specified != NULL__null) { | |||
304 | *is_specified = 1; | |||
305 | } | |||
306 | __kmp_str_to_size(value, out, factor, &msg); | |||
307 | if (msg == NULL__null) { | |||
308 | if (*out > size_max) { | |||
309 | *out = size_max; | |||
310 | msg = KMP_I18N_STR(ValueTooLarge)__kmp_i18n_catgets(kmp_i18n_str_ValueTooLarge); | |||
311 | } else if (*out < size_min) { | |||
312 | *out = size_min; | |||
313 | msg = KMP_I18N_STR(ValueTooSmall)__kmp_i18n_catgets(kmp_i18n_str_ValueTooSmall); | |||
314 | } else { | |||
315 | #if KMP_OS_DARWIN0 | |||
316 | size_t round4k = __kmp_round4k(*out); | |||
317 | if (*out != round4k) { | |||
318 | *out = round4k; | |||
319 | msg = KMP_I18N_STR(NotMultiple4K)__kmp_i18n_catgets(kmp_i18n_str_NotMultiple4K); | |||
320 | } | |||
321 | #endif | |||
322 | } | |||
323 | } else { | |||
324 | // If integer overflow occurred, * out == KMP_SIZE_T_MAX. Cut it to | |||
325 | // size_max silently. | |||
326 | if (*out < size_min) { | |||
327 | *out = size_max; | |||
328 | } else if (*out > size_max) { | |||
329 | *out = size_max; | |||
330 | } | |||
331 | } | |||
332 | if (msg != NULL__null) { | |||
333 | // Message is not empty. Print warning. | |||
334 | kmp_str_buf_t buf; | |||
335 | __kmp_str_buf_init(&buf){ (&buf)->str = (&buf)->bulk; (&buf)->size = sizeof((&buf)->bulk); (&buf)->used = 0; (& buf)->bulk[0] = 0; }; | |||
336 | __kmp_str_buf_print_size(&buf, *out); | |||
337 | KMP_WARNING(ParseSizeIntWarn, name, value, msg)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_ParseSizeIntWarn , name, value, msg), __kmp_msg_null); | |||
338 | KMP_INFORM(Using_str_Value, name, buf.str)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_str_Value , name, buf.str), __kmp_msg_null); | |||
339 | __kmp_str_buf_free(&buf); | |||
340 | } | |||
341 | } | |||
342 | } // __kmp_stg_parse_size | |||
343 | ||||
344 | static void __kmp_stg_parse_str(char const *name, char const *value, | |||
345 | char **out) { | |||
346 | __kmp_str_free(out); | |||
347 | *out = __kmp_str_format("%s", value); | |||
348 | } // __kmp_stg_parse_str | |||
349 | ||||
350 | static void __kmp_stg_parse_int( | |||
351 | char const | |||
352 | *name, // I: Name of environment variable (used in warning messages). | |||
353 | char const *value, // I: Value of environment variable to parse. | |||
354 | int min, // I: Miminal allowed value. | |||
355 | int max, // I: Maximum allowed value. | |||
356 | int *out // O: Output (parsed) value. | |||
357 | ) { | |||
358 | char const *msg = NULL__null; | |||
359 | kmp_uint64 uint = *out; | |||
| ||||
360 | __kmp_str_to_uint(value, &uint, &msg); | |||
361 | if (msg == NULL__null) { | |||
362 | if (uint < (unsigned int)min) { | |||
363 | msg = KMP_I18N_STR(ValueTooSmall)__kmp_i18n_catgets(kmp_i18n_str_ValueTooSmall); | |||
364 | uint = min; | |||
365 | } else if (uint > (unsigned int)max) { | |||
366 | msg = KMP_I18N_STR(ValueTooLarge)__kmp_i18n_catgets(kmp_i18n_str_ValueTooLarge); | |||
367 | uint = max; | |||
368 | } | |||
369 | } else { | |||
370 | // If overflow occurred msg contains error message and uint is very big. Cut | |||
371 | // tmp it to INT_MAX. | |||
372 | if (uint < (unsigned int)min) { | |||
373 | uint = min; | |||
374 | } else if (uint > (unsigned int)max) { | |||
375 | uint = max; | |||
376 | } | |||
377 | } | |||
378 | if (msg != NULL__null) { | |||
379 | // Message is not empty. Print warning. | |||
380 | kmp_str_buf_t buf; | |||
381 | KMP_WARNING(ParseSizeIntWarn, name, value, msg)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_ParseSizeIntWarn , name, value, msg), __kmp_msg_null); | |||
382 | __kmp_str_buf_init(&buf){ (&buf)->str = (&buf)->bulk; (&buf)->size = sizeof((&buf)->bulk); (&buf)->used = 0; (& buf)->bulk[0] = 0; }; | |||
383 | __kmp_str_buf_print(&buf, "%" KMP_UINT64_SPEC"llu" "", uint); | |||
384 | KMP_INFORM(Using_uint64_Value, name, buf.str)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_uint64_Value , name, buf.str), __kmp_msg_null); | |||
385 | __kmp_str_buf_free(&buf); | |||
386 | } | |||
387 | *out = uint; | |||
388 | } // __kmp_stg_parse_int | |||
389 | ||||
390 | #if KMP_DEBUG_ADAPTIVE_LOCKS0 | |||
391 | static void __kmp_stg_parse_file(char const *name, char const *value, | |||
392 | const char *suffix, char **out) { | |||
393 | char buffer[256]; | |||
394 | char *t; | |||
395 | int hasSuffix; | |||
396 | __kmp_str_free(out); | |||
397 | t = (char *)strrchr(value, '.'); | |||
398 | hasSuffix = t && __kmp_str_eqf(t, suffix); | |||
399 | t = __kmp_str_format("%s%s", value, hasSuffix ? "" : suffix); | |||
400 | __kmp_expand_file_name(buffer, sizeof(buffer), t); | |||
401 | __kmp_str_free(&t); | |||
402 | *out = __kmp_str_format("%s", buffer); | |||
403 | } // __kmp_stg_parse_file | |||
404 | #endif | |||
405 | ||||
406 | #ifdef KMP_DEBUG1 | |||
407 | static char *par_range_to_print = NULL__null; | |||
408 | ||||
409 | static void __kmp_stg_parse_par_range(char const *name, char const *value, | |||
410 | int *out_range, char *out_routine, | |||
411 | char *out_file, int *out_lb, | |||
412 | int *out_ub) { | |||
413 | size_t len = KMP_STRLENstrlen(value + 1); | |||
414 | par_range_to_print = (char *)KMP_INTERNAL_MALLOC(len + 1)malloc(len + 1); | |||
415 | KMP_STRNCPY_S(par_range_to_print, len + 1, value, len + 1)strncpy(par_range_to_print, value, len + 1); | |||
416 | __kmp_par_range = +1; | |||
417 | __kmp_par_range_lb = 0; | |||
418 | __kmp_par_range_ub = INT_MAX2147483647; | |||
419 | for (;;) { | |||
420 | unsigned int len; | |||
421 | if ((value == NULL__null) || (*value == '\0')) { | |||
422 | break; | |||
423 | } | |||
424 | if (!__kmp_strcasecmp_with_sentinel("routine", value, '=')) { | |||
425 | value = strchr(value, '=') + 1; | |||
426 | len = __kmp_readstr_with_sentinel(out_routine, value, | |||
427 | KMP_PAR_RANGE_ROUTINE_LEN1024 - 1, ','); | |||
428 | if (len == 0) { | |||
429 | goto par_range_error; | |||
430 | } | |||
431 | value = strchr(value, ','); | |||
432 | if (value != NULL__null) { | |||
433 | value++; | |||
434 | } | |||
435 | continue; | |||
436 | } | |||
437 | if (!__kmp_strcasecmp_with_sentinel("filename", value, '=')) { | |||
438 | value = strchr(value, '=') + 1; | |||
439 | len = __kmp_readstr_with_sentinel(out_file, value, | |||
440 | KMP_PAR_RANGE_FILENAME_LEN1024 - 1, ','); | |||
441 | if (len == 0) { | |||
442 | goto par_range_error; | |||
443 | } | |||
444 | value = strchr(value, ','); | |||
445 | if (value != NULL__null) { | |||
446 | value++; | |||
447 | } | |||
448 | continue; | |||
449 | } | |||
450 | if ((!__kmp_strcasecmp_with_sentinel("range", value, '=')) || | |||
451 | (!__kmp_strcasecmp_with_sentinel("incl_range", value, '='))) { | |||
452 | value = strchr(value, '=') + 1; | |||
453 | if (KMP_SSCANFsscanf(value, "%d:%d", out_lb, out_ub) != 2) { | |||
454 | goto par_range_error; | |||
455 | } | |||
456 | *out_range = +1; | |||
457 | value = strchr(value, ','); | |||
458 | if (value != NULL__null) { | |||
459 | value++; | |||
460 | } | |||
461 | continue; | |||
462 | } | |||
463 | if (!__kmp_strcasecmp_with_sentinel("excl_range", value, '=')) { | |||
464 | value = strchr(value, '=') + 1; | |||
465 | if (KMP_SSCANFsscanf(value, "%d:%d", out_lb, out_ub) != 2) { | |||
466 | goto par_range_error; | |||
467 | } | |||
468 | *out_range = -1; | |||
469 | value = strchr(value, ','); | |||
470 | if (value != NULL__null) { | |||
471 | value++; | |||
472 | } | |||
473 | continue; | |||
474 | } | |||
475 | par_range_error: | |||
476 | KMP_WARNING(ParRangeSyntax, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_ParRangeSyntax , name), __kmp_msg_null); | |||
477 | __kmp_par_range = 0; | |||
478 | break; | |||
479 | } | |||
480 | } // __kmp_stg_parse_par_range | |||
481 | #endif | |||
482 | ||||
483 | int __kmp_initial_threads_capacity(int req_nproc) { | |||
484 | int nth = 32; | |||
485 | ||||
486 | /* MIN( MAX( 32, 4 * $OMP_NUM_THREADS, 4 * omp_get_num_procs() ), | |||
487 | * __kmp_max_nth) */ | |||
488 | if (nth < (4 * req_nproc)) | |||
489 | nth = (4 * req_nproc); | |||
490 | if (nth < (4 * __kmp_xproc)) | |||
491 | nth = (4 * __kmp_xproc); | |||
492 | ||||
493 | if (nth > __kmp_max_nth) | |||
494 | nth = __kmp_max_nth; | |||
495 | ||||
496 | return nth; | |||
497 | } | |||
498 | ||||
499 | int __kmp_default_tp_capacity(int req_nproc, int max_nth, | |||
500 | int all_threads_specified) { | |||
501 | int nth = 128; | |||
502 | ||||
503 | if (all_threads_specified) | |||
504 | return max_nth; | |||
505 | /* MIN( MAX (128, 4 * $OMP_NUM_THREADS, 4 * omp_get_num_procs() ), | |||
506 | * __kmp_max_nth ) */ | |||
507 | if (nth < (4 * req_nproc)) | |||
508 | nth = (4 * req_nproc); | |||
509 | if (nth < (4 * __kmp_xproc)) | |||
510 | nth = (4 * __kmp_xproc); | |||
511 | ||||
512 | if (nth > __kmp_max_nth) | |||
513 | nth = __kmp_max_nth; | |||
514 | ||||
515 | return nth; | |||
516 | } | |||
517 | ||||
518 | // ----------------------------------------------------------------------------- | |||
519 | // Helper print functions. | |||
520 | ||||
521 | static void __kmp_stg_print_bool(kmp_str_buf_t *buffer, char const *name, | |||
522 | int value) { | |||
523 | if (__kmp_env_format) { | |||
524 | KMP_STR_BUF_PRINT_BOOL__kmp_str_buf_print(buffer, " %s %s='%s'\n", __kmp_i18n_catgets (kmp_i18n_str_Host), name, (value) ? "TRUE" : "FALSE"); | |||
525 | } else { | |||
526 | __kmp_str_buf_print(buffer, " %s=%s\n", name, value ? "true" : "false"); | |||
527 | } | |||
528 | } // __kmp_stg_print_bool | |||
529 | ||||
530 | static void __kmp_stg_print_int(kmp_str_buf_t *buffer, char const *name, | |||
531 | int value) { | |||
532 | if (__kmp_env_format) { | |||
533 | KMP_STR_BUF_PRINT_INT__kmp_str_buf_print(buffer, " %s %s='%d'\n", __kmp_i18n_catgets (kmp_i18n_str_Host), name, value); | |||
534 | } else { | |||
535 | __kmp_str_buf_print(buffer, " %s=%d\n", name, value); | |||
536 | } | |||
537 | } // __kmp_stg_print_int | |||
538 | ||||
539 | #if USE_ITT_BUILD1 && USE_ITT_NOTIFY1 | |||
540 | static void __kmp_stg_print_uint64(kmp_str_buf_t *buffer, char const *name, | |||
541 | kmp_uint64 value) { | |||
542 | if (__kmp_env_format) { | |||
543 | KMP_STR_BUF_PRINT_UINT64__kmp_str_buf_print(buffer, " %s %s='%" "llu" "'\n", __kmp_i18n_catgets (kmp_i18n_str_Host), name, value);; | |||
544 | } else { | |||
545 | __kmp_str_buf_print(buffer, " %s=%" KMP_UINT64_SPEC"llu" "\n", name, value); | |||
546 | } | |||
547 | } // __kmp_stg_print_uint64 | |||
548 | #endif | |||
549 | ||||
550 | static void __kmp_stg_print_str(kmp_str_buf_t *buffer, char const *name, | |||
551 | char const *value) { | |||
552 | if (__kmp_env_format) { | |||
553 | KMP_STR_BUF_PRINT_STR__kmp_str_buf_print(buffer, " %s %s='%s'\n", __kmp_i18n_catgets (kmp_i18n_str_Host), name, value); | |||
554 | } else { | |||
555 | __kmp_str_buf_print(buffer, " %s=%s\n", name, value); | |||
556 | } | |||
557 | } // __kmp_stg_print_str | |||
558 | ||||
559 | static void __kmp_stg_print_size(kmp_str_buf_t *buffer, char const *name, | |||
560 | size_t value) { | |||
561 | if (__kmp_env_format) { | |||
562 | KMP_STR_BUF_PRINT_NAME_EX(name)__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
563 | __kmp_str_buf_print_size(buffer, value); | |||
564 | __kmp_str_buf_print(buffer, "'\n"); | |||
565 | } else { | |||
566 | __kmp_str_buf_print(buffer, " %s=", name); | |||
567 | __kmp_str_buf_print_size(buffer, value); | |||
568 | __kmp_str_buf_print(buffer, "\n"); | |||
569 | return; | |||
570 | } | |||
571 | } // __kmp_stg_print_size | |||
572 | ||||
573 | // ============================================================================= | |||
574 | // Parse and print functions. | |||
575 | ||||
576 | // ----------------------------------------------------------------------------- | |||
577 | // KMP_DEVICE_THREAD_LIMIT, KMP_ALL_THREADS | |||
578 | ||||
579 | static void __kmp_stg_parse_device_thread_limit(char const *name, | |||
580 | char const *value, void *data) { | |||
581 | kmp_setting_t **rivals = (kmp_setting_t **)data; | |||
582 | int rc; | |||
583 | if (strcmp(name, "KMP_ALL_THREADS") == 0) { | |||
584 | KMP_INFORM(EnvVarDeprecated, name, "KMP_DEVICE_THREAD_LIMIT")__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_EnvVarDeprecated , name, "KMP_DEVICE_THREAD_LIMIT"), __kmp_msg_null); | |||
585 | } | |||
586 | rc = __kmp_stg_check_rivals(name, value, rivals); | |||
587 | if (rc) { | |||
588 | return; | |||
589 | } | |||
590 | if (!__kmp_strcasecmp_with_sentinel("all", value, 0)) { | |||
591 | __kmp_max_nth = __kmp_xproc; | |||
592 | __kmp_allThreadsSpecified = 1; | |||
593 | } else { | |||
594 | __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_max_nth); | |||
595 | __kmp_allThreadsSpecified = 0; | |||
596 | } | |||
597 | K_DIAG(1, ("__kmp_max_nth == %d\n", __kmp_max_nth)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_max_nth == %d\n" , __kmp_max_nth); } }; | |||
598 | ||||
599 | } // __kmp_stg_parse_device_thread_limit | |||
600 | ||||
601 | static void __kmp_stg_print_device_thread_limit(kmp_str_buf_t *buffer, | |||
602 | char const *name, void *data) { | |||
603 | __kmp_stg_print_int(buffer, name, __kmp_max_nth); | |||
604 | } // __kmp_stg_print_device_thread_limit | |||
605 | ||||
606 | // ----------------------------------------------------------------------------- | |||
607 | // OMP_THREAD_LIMIT | |||
608 | static void __kmp_stg_parse_thread_limit(char const *name, char const *value, | |||
609 | void *data) { | |||
610 | __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_cg_max_nth); | |||
611 | K_DIAG(1, ("__kmp_cg_max_nth == %d\n", __kmp_cg_max_nth)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_cg_max_nth == %d\n" , __kmp_cg_max_nth); } }; | |||
612 | ||||
613 | } // __kmp_stg_parse_thread_limit | |||
614 | ||||
615 | static void __kmp_stg_print_thread_limit(kmp_str_buf_t *buffer, | |||
616 | char const *name, void *data) { | |||
617 | __kmp_stg_print_int(buffer, name, __kmp_cg_max_nth); | |||
618 | } // __kmp_stg_print_thread_limit | |||
619 | ||||
620 | // ----------------------------------------------------------------------------- | |||
621 | // KMP_TEAMS_THREAD_LIMIT | |||
622 | static void __kmp_stg_parse_teams_thread_limit(char const *name, | |||
623 | char const *value, void *data) { | |||
624 | __kmp_stg_parse_int(name, value, 1, __kmp_sys_max_nth, &__kmp_teams_max_nth); | |||
625 | } // __kmp_stg_teams_thread_limit | |||
626 | ||||
627 | static void __kmp_stg_print_teams_thread_limit(kmp_str_buf_t *buffer, | |||
628 | char const *name, void *data) { | |||
629 | __kmp_stg_print_int(buffer, name, __kmp_teams_max_nth); | |||
630 | } // __kmp_stg_print_teams_thread_limit | |||
631 | ||||
632 | // ----------------------------------------------------------------------------- | |||
633 | // KMP_BLOCKTIME | |||
634 | ||||
635 | static void __kmp_stg_parse_blocktime(char const *name, char const *value, | |||
636 | void *data) { | |||
637 | __kmp_dflt_blocktime = __kmp_convert_to_milliseconds(value); | |||
638 | if (__kmp_dflt_blocktime < 0) { | |||
639 | __kmp_dflt_blocktime = KMP_DEFAULT_BLOCKTIME(200); | |||
640 | __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidValue, name, value)__kmp_msg_format(kmp_i18n_msg_InvalidValue, name, value), | |||
641 | __kmp_msg_null); | |||
642 | KMP_INFORM(Using_int_Value, name, __kmp_dflt_blocktime)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_int_Value , name, __kmp_dflt_blocktime), __kmp_msg_null); | |||
643 | __kmp_env_blocktime = FALSE0; // Revert to default as if var not set. | |||
644 | } else { | |||
645 | if (__kmp_dflt_blocktime < KMP_MIN_BLOCKTIME(0)) { | |||
646 | __kmp_dflt_blocktime = KMP_MIN_BLOCKTIME(0); | |||
647 | __kmp_msg(kmp_ms_warning, KMP_MSG(SmallValue, name, value)__kmp_msg_format(kmp_i18n_msg_SmallValue, name, value), | |||
648 | __kmp_msg_null); | |||
649 | KMP_INFORM(MinValueUsing, name, __kmp_dflt_blocktime)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_MinValueUsing , name, __kmp_dflt_blocktime), __kmp_msg_null); | |||
650 | } else if (__kmp_dflt_blocktime > KMP_MAX_BLOCKTIME(2147483647)) { | |||
651 | __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME(2147483647); | |||
652 | __kmp_msg(kmp_ms_warning, KMP_MSG(LargeValue, name, value)__kmp_msg_format(kmp_i18n_msg_LargeValue, name, value), | |||
653 | __kmp_msg_null); | |||
654 | KMP_INFORM(MaxValueUsing, name, __kmp_dflt_blocktime)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_MaxValueUsing , name, __kmp_dflt_blocktime), __kmp_msg_null); | |||
655 | } | |||
656 | __kmp_env_blocktime = TRUE(!0); // KMP_BLOCKTIME was specified. | |||
657 | } | |||
658 | #if KMP_USE_MONITOR | |||
659 | // calculate number of monitor thread wakeup intervals corresponding to | |||
660 | // blocktime. | |||
661 | __kmp_monitor_wakeups = | |||
662 | KMP_WAKEUPS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups); | |||
663 | __kmp_bt_intervals = | |||
664 | KMP_INTERVALS_FROM_BLOCKTIME(__kmp_dflt_blocktime, __kmp_monitor_wakeups); | |||
665 | #endif | |||
666 | K_DIAG(1, ("__kmp_env_blocktime == %d\n", __kmp_env_blocktime)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_env_blocktime == %d\n" , __kmp_env_blocktime); } }; | |||
667 | if (__kmp_env_blocktime) { | |||
668 | K_DIAG(1, ("__kmp_dflt_blocktime == %d\n", __kmp_dflt_blocktime)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_dflt_blocktime == %d\n" , __kmp_dflt_blocktime); } }; | |||
669 | } | |||
670 | } // __kmp_stg_parse_blocktime | |||
671 | ||||
672 | static void __kmp_stg_print_blocktime(kmp_str_buf_t *buffer, char const *name, | |||
673 | void *data) { | |||
674 | __kmp_stg_print_int(buffer, name, __kmp_dflt_blocktime); | |||
675 | } // __kmp_stg_print_blocktime | |||
676 | ||||
677 | // ----------------------------------------------------------------------------- | |||
678 | // KMP_DUPLICATE_LIB_OK | |||
679 | ||||
680 | static void __kmp_stg_parse_duplicate_lib_ok(char const *name, | |||
681 | char const *value, void *data) { | |||
682 | /* actually this variable is not supported, put here for compatibility with | |||
683 | earlier builds and for static/dynamic combination */ | |||
684 | __kmp_stg_parse_bool(name, value, &__kmp_duplicate_library_ok); | |||
685 | } // __kmp_stg_parse_duplicate_lib_ok | |||
686 | ||||
687 | static void __kmp_stg_print_duplicate_lib_ok(kmp_str_buf_t *buffer, | |||
688 | char const *name, void *data) { | |||
689 | __kmp_stg_print_bool(buffer, name, __kmp_duplicate_library_ok); | |||
690 | } // __kmp_stg_print_duplicate_lib_ok | |||
691 | ||||
692 | // ----------------------------------------------------------------------------- | |||
693 | // KMP_INHERIT_FP_CONTROL | |||
694 | ||||
695 | #if KMP_ARCH_X860 || KMP_ARCH_X86_641 | |||
696 | ||||
697 | static void __kmp_stg_parse_inherit_fp_control(char const *name, | |||
698 | char const *value, void *data) { | |||
699 | __kmp_stg_parse_bool(name, value, &__kmp_inherit_fp_control); | |||
700 | } // __kmp_stg_parse_inherit_fp_control | |||
701 | ||||
702 | static void __kmp_stg_print_inherit_fp_control(kmp_str_buf_t *buffer, | |||
703 | char const *name, void *data) { | |||
704 | #if KMP_DEBUG1 | |||
705 | __kmp_stg_print_bool(buffer, name, __kmp_inherit_fp_control); | |||
706 | #endif /* KMP_DEBUG */ | |||
707 | } // __kmp_stg_print_inherit_fp_control | |||
708 | ||||
709 | #endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */ | |||
710 | ||||
711 | // Used for OMP_WAIT_POLICY | |||
712 | static char const *blocktime_str = NULL__null; | |||
713 | ||||
714 | // ----------------------------------------------------------------------------- | |||
715 | // KMP_LIBRARY, OMP_WAIT_POLICY | |||
716 | ||||
717 | static void __kmp_stg_parse_wait_policy(char const *name, char const *value, | |||
718 | void *data) { | |||
719 | ||||
720 | kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data; | |||
721 | int rc; | |||
722 | ||||
723 | rc = __kmp_stg_check_rivals(name, value, wait->rivals); | |||
724 | if (rc) { | |||
725 | return; | |||
726 | } | |||
727 | ||||
728 | if (wait->omp) { | |||
729 | if (__kmp_str_match("ACTIVE", 1, value)) { | |||
730 | __kmp_library = library_turnaround; | |||
731 | if (blocktime_str == NULL__null) { | |||
732 | // KMP_BLOCKTIME not specified, so set default to "infinite". | |||
733 | __kmp_dflt_blocktime = KMP_MAX_BLOCKTIME(2147483647); | |||
734 | } | |||
735 | } else if (__kmp_str_match("PASSIVE", 1, value)) { | |||
736 | __kmp_library = library_throughput; | |||
737 | if (blocktime_str == NULL__null) { | |||
738 | // KMP_BLOCKTIME not specified, so set default to 0. | |||
739 | __kmp_dflt_blocktime = 0; | |||
740 | } | |||
741 | } else { | |||
742 | KMP_WARNING(StgInvalidValue, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgInvalidValue , name, value), __kmp_msg_null); | |||
743 | } | |||
744 | } else { | |||
745 | if (__kmp_str_match("serial", 1, value)) { /* S */ | |||
746 | __kmp_library = library_serial; | |||
747 | } else if (__kmp_str_match("throughput", 2, value)) { /* TH */ | |||
748 | __kmp_library = library_throughput; | |||
749 | } else if (__kmp_str_match("turnaround", 2, value)) { /* TU */ | |||
750 | __kmp_library = library_turnaround; | |||
751 | } else if (__kmp_str_match("dedicated", 1, value)) { /* D */ | |||
752 | __kmp_library = library_turnaround; | |||
753 | } else if (__kmp_str_match("multiuser", 1, value)) { /* M */ | |||
754 | __kmp_library = library_throughput; | |||
755 | } else { | |||
756 | KMP_WARNING(StgInvalidValue, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgInvalidValue , name, value), __kmp_msg_null); | |||
757 | } | |||
758 | } | |||
759 | __kmp_aux_set_library(__kmp_library); | |||
760 | ||||
761 | } // __kmp_stg_parse_wait_policy | |||
762 | ||||
763 | static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer, char const *name, | |||
764 | void *data) { | |||
765 | ||||
766 | kmp_stg_wp_data_t *wait = (kmp_stg_wp_data_t *)data; | |||
767 | char const *value = NULL__null; | |||
768 | ||||
769 | if (wait->omp) { | |||
770 | switch (__kmp_library) { | |||
771 | case library_turnaround: { | |||
772 | value = "ACTIVE"; | |||
773 | } break; | |||
774 | case library_throughput: { | |||
775 | value = "PASSIVE"; | |||
776 | } break; | |||
777 | } | |||
778 | } else { | |||
779 | switch (__kmp_library) { | |||
780 | case library_serial: { | |||
781 | value = "serial"; | |||
782 | } break; | |||
783 | case library_turnaround: { | |||
784 | value = "turnaround"; | |||
785 | } break; | |||
786 | case library_throughput: { | |||
787 | value = "throughput"; | |||
788 | } break; | |||
789 | } | |||
790 | } | |||
791 | if (value != NULL__null) { | |||
792 | __kmp_stg_print_str(buffer, name, value); | |||
793 | } | |||
794 | ||||
795 | } // __kmp_stg_print_wait_policy | |||
796 | ||||
797 | #if KMP_USE_MONITOR | |||
798 | // ----------------------------------------------------------------------------- | |||
799 | // KMP_MONITOR_STACKSIZE | |||
800 | ||||
801 | static void __kmp_stg_parse_monitor_stacksize(char const *name, | |||
802 | char const *value, void *data) { | |||
803 | __kmp_stg_parse_size(name, value, __kmp_sys_min_stksize, KMP_MAX_STKSIZE(~((size_t)1 << ((sizeof(size_t) * (1 << 3)) - 1) )), | |||
804 | NULL__null, &__kmp_monitor_stksize, 1); | |||
805 | } // __kmp_stg_parse_monitor_stacksize | |||
806 | ||||
807 | static void __kmp_stg_print_monitor_stacksize(kmp_str_buf_t *buffer, | |||
808 | char const *name, void *data) { | |||
809 | if (__kmp_env_format) { | |||
810 | if (__kmp_monitor_stksize > 0) | |||
811 | KMP_STR_BUF_PRINT_NAME_EX(name)__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
812 | else | |||
813 | KMP_STR_BUF_PRINT_NAME__kmp_str_buf_print(buffer, " %s %s", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
814 | } else { | |||
815 | __kmp_str_buf_print(buffer, " %s", name); | |||
816 | } | |||
817 | if (__kmp_monitor_stksize > 0) { | |||
818 | __kmp_str_buf_print_size(buffer, __kmp_monitor_stksize); | |||
819 | } else { | |||
820 | __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
821 | } | |||
822 | if (__kmp_env_format && __kmp_monitor_stksize) { | |||
823 | __kmp_str_buf_print(buffer, "'\n"); | |||
824 | } | |||
825 | } // __kmp_stg_print_monitor_stacksize | |||
826 | #endif // KMP_USE_MONITOR | |||
827 | ||||
828 | // ----------------------------------------------------------------------------- | |||
829 | // KMP_SETTINGS | |||
830 | ||||
831 | static void __kmp_stg_parse_settings(char const *name, char const *value, | |||
832 | void *data) { | |||
833 | __kmp_stg_parse_bool(name, value, &__kmp_settings); | |||
834 | } // __kmp_stg_parse_settings | |||
835 | ||||
836 | static void __kmp_stg_print_settings(kmp_str_buf_t *buffer, char const *name, | |||
837 | void *data) { | |||
838 | __kmp_stg_print_bool(buffer, name, __kmp_settings); | |||
839 | } // __kmp_stg_print_settings | |||
840 | ||||
841 | // ----------------------------------------------------------------------------- | |||
842 | // KMP_STACKPAD | |||
843 | ||||
844 | static void __kmp_stg_parse_stackpad(char const *name, char const *value, | |||
845 | void *data) { | |||
846 | __kmp_stg_parse_int(name, // Env var name | |||
847 | value, // Env var value | |||
848 | KMP_MIN_STKPADDING(0), // Min value | |||
849 | KMP_MAX_STKPADDING(2 * 1024 * 1024), // Max value | |||
850 | &__kmp_stkpadding // Var to initialize | |||
851 | ); | |||
852 | } // __kmp_stg_parse_stackpad | |||
853 | ||||
854 | static void __kmp_stg_print_stackpad(kmp_str_buf_t *buffer, char const *name, | |||
855 | void *data) { | |||
856 | __kmp_stg_print_int(buffer, name, __kmp_stkpadding); | |||
857 | } // __kmp_stg_print_stackpad | |||
858 | ||||
859 | // ----------------------------------------------------------------------------- | |||
860 | // KMP_STACKOFFSET | |||
861 | ||||
862 | static void __kmp_stg_parse_stackoffset(char const *name, char const *value, | |||
863 | void *data) { | |||
864 | __kmp_stg_parse_size(name, // Env var name | |||
865 | value, // Env var value | |||
866 | KMP_MIN_STKOFFSET(0), // Min value | |||
867 | KMP_MAX_STKOFFSET(~((size_t)1 << ((sizeof(size_t) * (1 << 3)) - 1) )), // Max value | |||
868 | NULL__null, // | |||
869 | &__kmp_stkoffset, // Var to initialize | |||
870 | 1); | |||
871 | } // __kmp_stg_parse_stackoffset | |||
872 | ||||
873 | static void __kmp_stg_print_stackoffset(kmp_str_buf_t *buffer, char const *name, | |||
874 | void *data) { | |||
875 | __kmp_stg_print_size(buffer, name, __kmp_stkoffset); | |||
876 | } // __kmp_stg_print_stackoffset | |||
877 | ||||
878 | // ----------------------------------------------------------------------------- | |||
879 | // KMP_STACKSIZE, OMP_STACKSIZE, GOMP_STACKSIZE | |||
880 | ||||
881 | static void __kmp_stg_parse_stacksize(char const *name, char const *value, | |||
882 | void *data) { | |||
883 | ||||
884 | kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data; | |||
885 | int rc; | |||
886 | ||||
887 | rc = __kmp_stg_check_rivals(name, value, stacksize->rivals); | |||
888 | if (rc) { | |||
889 | return; | |||
890 | } | |||
891 | __kmp_stg_parse_size(name, // Env var name | |||
892 | value, // Env var value | |||
893 | __kmp_sys_min_stksize, // Min value | |||
894 | KMP_MAX_STKSIZE(~((size_t)1 << ((sizeof(size_t) * (1 << 3)) - 1) )), // Max value | |||
895 | &__kmp_env_stksize, // | |||
896 | &__kmp_stksize, // Var to initialize | |||
897 | stacksize->factor); | |||
898 | ||||
899 | } // __kmp_stg_parse_stacksize | |||
900 | ||||
901 | // This function is called for printing both KMP_STACKSIZE (factor is 1) and | |||
902 | // OMP_STACKSIZE (factor is 1024). Currently it is not possible to print | |||
903 | // OMP_STACKSIZE value in bytes. We can consider adding this possibility by a | |||
904 | // customer request in future. | |||
905 | static void __kmp_stg_print_stacksize(kmp_str_buf_t *buffer, char const *name, | |||
906 | void *data) { | |||
907 | kmp_stg_ss_data_t *stacksize = (kmp_stg_ss_data_t *)data; | |||
908 | if (__kmp_env_format) { | |||
909 | KMP_STR_BUF_PRINT_NAME_EX(name)__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
910 | __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024) | |||
911 | ? __kmp_stksize / stacksize->factor | |||
912 | : __kmp_stksize); | |||
913 | __kmp_str_buf_print(buffer, "'\n"); | |||
914 | } else { | |||
915 | __kmp_str_buf_print(buffer, " %s=", name); | |||
916 | __kmp_str_buf_print_size(buffer, (__kmp_stksize % 1024) | |||
917 | ? __kmp_stksize / stacksize->factor | |||
918 | : __kmp_stksize); | |||
919 | __kmp_str_buf_print(buffer, "\n"); | |||
920 | } | |||
921 | } // __kmp_stg_print_stacksize | |||
922 | ||||
923 | // ----------------------------------------------------------------------------- | |||
924 | // KMP_VERSION | |||
925 | ||||
926 | static void __kmp_stg_parse_version(char const *name, char const *value, | |||
927 | void *data) { | |||
928 | __kmp_stg_parse_bool(name, value, &__kmp_version); | |||
929 | } // __kmp_stg_parse_version | |||
930 | ||||
931 | static void __kmp_stg_print_version(kmp_str_buf_t *buffer, char const *name, | |||
932 | void *data) { | |||
933 | __kmp_stg_print_bool(buffer, name, __kmp_version); | |||
934 | } // __kmp_stg_print_version | |||
935 | ||||
936 | // ----------------------------------------------------------------------------- | |||
937 | // KMP_WARNINGS | |||
938 | ||||
939 | static void __kmp_stg_parse_warnings(char const *name, char const *value, | |||
940 | void *data) { | |||
941 | __kmp_stg_parse_bool(name, value, &__kmp_generate_warnings); | |||
942 | if (__kmp_generate_warnings != kmp_warnings_off) { | |||
943 | // AC: only 0/1 values documented, so reset to explicit to distinguish from | |||
944 | // default setting | |||
945 | __kmp_generate_warnings = kmp_warnings_explicit; | |||
946 | } | |||
947 | } // __kmp_stg_parse_warnings | |||
948 | ||||
949 | static void __kmp_stg_print_warnings(kmp_str_buf_t *buffer, char const *name, | |||
950 | void *data) { | |||
951 | // AC: TODO: change to print_int? (needs documentation change) | |||
952 | __kmp_stg_print_bool(buffer, name, __kmp_generate_warnings); | |||
953 | } // __kmp_stg_print_warnings | |||
954 | ||||
955 | // ----------------------------------------------------------------------------- | |||
956 | // OMP_NESTED, OMP_NUM_THREADS | |||
957 | ||||
958 | static void __kmp_stg_parse_nested(char const *name, char const *value, | |||
959 | void *data) { | |||
960 | __kmp_stg_parse_bool(name, value, &__kmp_dflt_nested); | |||
961 | } // __kmp_stg_parse_nested | |||
962 | ||||
963 | static void __kmp_stg_print_nested(kmp_str_buf_t *buffer, char const *name, | |||
964 | void *data) { | |||
965 | __kmp_stg_print_bool(buffer, name, __kmp_dflt_nested); | |||
966 | } // __kmp_stg_print_nested | |||
967 | ||||
968 | static void __kmp_parse_nested_num_threads(const char *var, const char *env, | |||
969 | kmp_nested_nthreads_t *nth_array) { | |||
970 | const char *next = env; | |||
971 | const char *scan = next; | |||
972 | ||||
973 | int total = 0; // Count elements that were set. It'll be used as an array size | |||
974 | int prev_comma = FALSE0; // For correct processing sequential commas | |||
975 | ||||
976 | // Count the number of values in the env. var string | |||
977 | for (;;) { | |||
978 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
979 | ||||
980 | if (*next == '\0') { | |||
981 | break; | |||
982 | } | |||
983 | // Next character is not an integer or not a comma => end of list | |||
984 | if (((*next < '0') || (*next > '9')) && (*next != ',')) { | |||
985 | KMP_WARNING(NthSyntaxError, var, env)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_NthSyntaxError , var, env), __kmp_msg_null); | |||
986 | return; | |||
987 | } | |||
988 | // The next character is ',' | |||
989 | if (*next == ',') { | |||
990 | // ',' is the fisrt character | |||
991 | if (total == 0 || prev_comma) { | |||
992 | total++; | |||
993 | } | |||
994 | prev_comma = TRUE(!0); | |||
995 | next++; // skip ',' | |||
996 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
997 | } | |||
998 | // Next character is a digit | |||
999 | if (*next >= '0' && *next <= '9') { | |||
1000 | prev_comma = FALSE0; | |||
1001 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
1002 | total++; | |||
1003 | const char *tmp = next; | |||
1004 | SKIP_WS(tmp){ while (*(tmp) == ' ' || *(tmp) == '\t') (tmp)++; }; | |||
1005 | if ((*next == ' ' || *next == '\t') && (*tmp >= '0' && *tmp <= '9')) { | |||
1006 | KMP_WARNING(NthSpacesNotAllowed, var, env)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_NthSpacesNotAllowed , var, env), __kmp_msg_null); | |||
1007 | return; | |||
1008 | } | |||
1009 | } | |||
1010 | } | |||
1011 | KMP_DEBUG_ASSERT(total > 0)if (!(total > 0)) { __kmp_debug_assert("total > 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 1011); }; | |||
1012 | if (total <= 0) { | |||
1013 | KMP_WARNING(NthSyntaxError, var, env)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_NthSyntaxError , var, env), __kmp_msg_null); | |||
1014 | return; | |||
1015 | } | |||
1016 | ||||
1017 | // Check if the nested nthreads array exists | |||
1018 | if (!nth_array->nth) { | |||
1019 | // Allocate an array of double size | |||
1020 | nth_array->nth = (int *)KMP_INTERNAL_MALLOC(sizeof(int) * total * 2)malloc(sizeof(int) * total * 2); | |||
1021 | if (nth_array->nth == NULL__null) { | |||
1022 | KMP_FATAL(MemoryAllocFailed)__kmp_fatal(__kmp_msg_format(kmp_i18n_msg_MemoryAllocFailed), __kmp_msg_null); | |||
1023 | } | |||
1024 | nth_array->size = total * 2; | |||
1025 | } else { | |||
1026 | if (nth_array->size < total) { | |||
1027 | // Increase the array size | |||
1028 | do { | |||
1029 | nth_array->size *= 2; | |||
1030 | } while (nth_array->size < total); | |||
1031 | ||||
1032 | nth_array->nth = (int *)KMP_INTERNAL_REALLOC(realloc((nth_array->nth), (sizeof(int) * nth_array->size )) | |||
1033 | nth_array->nth, sizeof(int) * nth_array->size)realloc((nth_array->nth), (sizeof(int) * nth_array->size )); | |||
1034 | if (nth_array->nth == NULL__null) { | |||
1035 | KMP_FATAL(MemoryAllocFailed)__kmp_fatal(__kmp_msg_format(kmp_i18n_msg_MemoryAllocFailed), __kmp_msg_null); | |||
1036 | } | |||
1037 | } | |||
1038 | } | |||
1039 | nth_array->used = total; | |||
1040 | int i = 0; | |||
1041 | ||||
1042 | prev_comma = FALSE0; | |||
1043 | total = 0; | |||
1044 | // Save values in the array | |||
1045 | for (;;) { | |||
1046 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
1047 | if (*scan == '\0') { | |||
1048 | break; | |||
1049 | } | |||
1050 | // The next character is ',' | |||
1051 | if (*scan == ',') { | |||
1052 | // ',' in the beginning of the list | |||
1053 | if (total == 0) { | |||
1054 | // The value is supposed to be equal to __kmp_avail_proc but it is | |||
1055 | // unknown at the moment. | |||
1056 | // So let's put a placeholder (#threads = 0) to correct it later. | |||
1057 | nth_array->nth[i++] = 0; | |||
1058 | total++; | |||
1059 | } else if (prev_comma) { | |||
1060 | // Num threads is inherited from the previous level | |||
1061 | nth_array->nth[i] = nth_array->nth[i - 1]; | |||
1062 | i++; | |||
1063 | total++; | |||
1064 | } | |||
1065 | prev_comma = TRUE(!0); | |||
1066 | scan++; // skip ',' | |||
1067 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
1068 | } | |||
1069 | // Next character is a digit | |||
1070 | if (*scan >= '0' && *scan <= '9') { | |||
1071 | int num; | |||
1072 | const char *buf = scan; | |||
1073 | char const *msg = NULL__null; | |||
1074 | prev_comma = FALSE0; | |||
1075 | SKIP_DIGITS(scan){ while (*(scan) >= '0' && *(scan) <= '9') (scan )++; }; | |||
1076 | total++; | |||
1077 | ||||
1078 | num = __kmp_str_to_int(buf, *scan); | |||
1079 | if (num < KMP_MIN_NTH1) { | |||
1080 | msg = KMP_I18N_STR(ValueTooSmall)__kmp_i18n_catgets(kmp_i18n_str_ValueTooSmall); | |||
1081 | num = KMP_MIN_NTH1; | |||
1082 | } else if (num > __kmp_sys_max_nth) { | |||
1083 | msg = KMP_I18N_STR(ValueTooLarge)__kmp_i18n_catgets(kmp_i18n_str_ValueTooLarge); | |||
1084 | num = __kmp_sys_max_nth; | |||
1085 | } | |||
1086 | if (msg != NULL__null) { | |||
1087 | // Message is not empty. Print warning. | |||
1088 | KMP_WARNING(ParseSizeIntWarn, var, env, msg)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_ParseSizeIntWarn , var, env, msg), __kmp_msg_null); | |||
1089 | KMP_INFORM(Using_int_Value, var, num)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_int_Value , var, num), __kmp_msg_null); | |||
1090 | } | |||
1091 | nth_array->nth[i++] = num; | |||
1092 | } | |||
1093 | } | |||
1094 | } | |||
1095 | ||||
1096 | static void __kmp_stg_parse_num_threads(char const *name, char const *value, | |||
1097 | void *data) { | |||
1098 | // TODO: Remove this option. OMP_NUM_THREADS is a list of positive integers! | |||
1099 | if (!__kmp_strcasecmp_with_sentinel("all", value, 0)) { | |||
1100 | // The array of 1 element | |||
1101 | __kmp_nested_nth.nth = (int *)KMP_INTERNAL_MALLOC(sizeof(int))malloc(sizeof(int)); | |||
1102 | __kmp_nested_nth.size = __kmp_nested_nth.used = 1; | |||
1103 | __kmp_nested_nth.nth[0] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub = | |||
1104 | __kmp_xproc; | |||
1105 | } else { | |||
1106 | __kmp_parse_nested_num_threads(name, value, &__kmp_nested_nth); | |||
1107 | if (__kmp_nested_nth.nth) { | |||
1108 | __kmp_dflt_team_nth = __kmp_nested_nth.nth[0]; | |||
1109 | if (__kmp_dflt_team_nth_ub < __kmp_dflt_team_nth) { | |||
1110 | __kmp_dflt_team_nth_ub = __kmp_dflt_team_nth; | |||
1111 | } | |||
1112 | } | |||
1113 | } | |||
1114 | K_DIAG(1, ("__kmp_dflt_team_nth == %d\n", __kmp_dflt_team_nth)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_dflt_team_nth == %d\n" , __kmp_dflt_team_nth); } }; | |||
1115 | } // __kmp_stg_parse_num_threads | |||
1116 | ||||
1117 | static void __kmp_stg_print_num_threads(kmp_str_buf_t *buffer, char const *name, | |||
1118 | void *data) { | |||
1119 | if (__kmp_env_format) { | |||
1120 | KMP_STR_BUF_PRINT_NAME__kmp_str_buf_print(buffer, " %s %s", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
1121 | } else { | |||
1122 | __kmp_str_buf_print(buffer, " %s", name); | |||
1123 | } | |||
1124 | if (__kmp_nested_nth.used) { | |||
1125 | kmp_str_buf_t buf; | |||
1126 | __kmp_str_buf_init(&buf){ (&buf)->str = (&buf)->bulk; (&buf)->size = sizeof((&buf)->bulk); (&buf)->used = 0; (& buf)->bulk[0] = 0; }; | |||
1127 | for (int i = 0; i < __kmp_nested_nth.used; i++) { | |||
1128 | __kmp_str_buf_print(&buf, "%d", __kmp_nested_nth.nth[i]); | |||
1129 | if (i < __kmp_nested_nth.used - 1) { | |||
1130 | __kmp_str_buf_print(&buf, ","); | |||
1131 | } | |||
1132 | } | |||
1133 | __kmp_str_buf_print(buffer, "='%s'\n", buf.str); | |||
1134 | __kmp_str_buf_free(&buf); | |||
1135 | } else { | |||
1136 | __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
1137 | } | |||
1138 | } // __kmp_stg_print_num_threads | |||
1139 | ||||
1140 | // ----------------------------------------------------------------------------- | |||
1141 | // OpenMP 3.0: KMP_TASKING, OMP_MAX_ACTIVE_LEVELS, | |||
1142 | ||||
1143 | static void __kmp_stg_parse_tasking(char const *name, char const *value, | |||
1144 | void *data) { | |||
1145 | __kmp_stg_parse_int(name, value, 0, (int)tskm_max, | |||
1146 | (int *)&__kmp_tasking_mode); | |||
1147 | } // __kmp_stg_parse_tasking | |||
1148 | ||||
1149 | static void __kmp_stg_print_tasking(kmp_str_buf_t *buffer, char const *name, | |||
1150 | void *data) { | |||
1151 | __kmp_stg_print_int(buffer, name, __kmp_tasking_mode); | |||
1152 | } // __kmp_stg_print_tasking | |||
1153 | ||||
1154 | static void __kmp_stg_parse_task_stealing(char const *name, char const *value, | |||
1155 | void *data) { | |||
1156 | __kmp_stg_parse_int(name, value, 0, 1, | |||
1157 | (int *)&__kmp_task_stealing_constraint); | |||
1158 | } // __kmp_stg_parse_task_stealing | |||
1159 | ||||
1160 | static void __kmp_stg_print_task_stealing(kmp_str_buf_t *buffer, | |||
1161 | char const *name, void *data) { | |||
1162 | __kmp_stg_print_int(buffer, name, __kmp_task_stealing_constraint); | |||
1163 | } // __kmp_stg_print_task_stealing | |||
1164 | ||||
1165 | static void __kmp_stg_parse_max_active_levels(char const *name, | |||
1166 | char const *value, void *data) { | |||
1167 | __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT2147483647, | |||
1168 | &__kmp_dflt_max_active_levels); | |||
1169 | } // __kmp_stg_parse_max_active_levels | |||
1170 | ||||
1171 | static void __kmp_stg_print_max_active_levels(kmp_str_buf_t *buffer, | |||
1172 | char const *name, void *data) { | |||
1173 | __kmp_stg_print_int(buffer, name, __kmp_dflt_max_active_levels); | |||
1174 | } // __kmp_stg_print_max_active_levels | |||
1175 | ||||
1176 | #if OMP_40_ENABLED(50 >= 40) | |||
1177 | // ----------------------------------------------------------------------------- | |||
1178 | // OpenMP 4.0: OMP_DEFAULT_DEVICE | |||
1179 | static void __kmp_stg_parse_default_device(char const *name, char const *value, | |||
1180 | void *data) { | |||
1181 | __kmp_stg_parse_int(name, value, 0, KMP_MAX_DEFAULT_DEVICE_LIMIT2147483647, | |||
1182 | &__kmp_default_device); | |||
1183 | } // __kmp_stg_parse_default_device | |||
1184 | ||||
1185 | static void __kmp_stg_print_default_device(kmp_str_buf_t *buffer, | |||
1186 | char const *name, void *data) { | |||
1187 | __kmp_stg_print_int(buffer, name, __kmp_default_device); | |||
1188 | } // __kmp_stg_print_default_device | |||
1189 | #endif | |||
1190 | ||||
1191 | #if OMP_50_ENABLED(50 >= 50) | |||
1192 | // ----------------------------------------------------------------------------- | |||
1193 | // OpenMP 5.0: OMP_TARGET_OFFLOAD | |||
1194 | static void __kmp_stg_parse_target_offload(char const *name, char const *value, | |||
1195 | void *data) { | |||
1196 | const char *next = value; | |||
1197 | const char *scan = next; | |||
1198 | ||||
1199 | __kmp_target_offload = tgt_default; | |||
1200 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1201 | if (*next == '\0') | |||
1202 | return; | |||
1203 | scan = next; | |||
1204 | if (__kmp_match_str("MANDATORY", scan, &next)) { | |||
1205 | __kmp_target_offload = tgt_mandatory; | |||
1206 | } else if (__kmp_match_str("DISABLED", scan, &next)) { | |||
1207 | __kmp_target_offload = tgt_disabled; | |||
1208 | } else if (__kmp_match_str("DEFAULT", scan, &next)) { | |||
1209 | __kmp_target_offload = tgt_default; | |||
1210 | } else { | |||
1211 | KMP_WARNING(SyntaxErrorUsing, name, "DEFAULT")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , name, "DEFAULT"), __kmp_msg_null); | |||
1212 | } | |||
1213 | ||||
1214 | } // __kmp_stg_parse_target_offload | |||
1215 | ||||
1216 | static void __kmp_stg_print_target_offload(kmp_str_buf_t *buffer, | |||
1217 | char const *name, void *data) { | |||
1218 | const char *value = NULL__null; | |||
1219 | if (__kmp_target_offload == tgt_default) | |||
1220 | value = "DEFAULT"; | |||
1221 | else if (__kmp_target_offload == tgt_mandatory) | |||
1222 | value = "MANDATORY"; | |||
1223 | else if (__kmp_target_offload == tgt_disabled) | |||
1224 | value = "DISABLED"; | |||
1225 | if (value) { | |||
1226 | __kmp_str_buf_print(buffer, " %s=%s\n", name, value); | |||
1227 | } | |||
1228 | } // __kmp_stg_print_target_offload | |||
1229 | #endif | |||
1230 | ||||
1231 | #if OMP_45_ENABLED(50 >= 45) | |||
1232 | // ----------------------------------------------------------------------------- | |||
1233 | // OpenMP 4.5: OMP_MAX_TASK_PRIORITY | |||
1234 | static void __kmp_stg_parse_max_task_priority(char const *name, | |||
1235 | char const *value, void *data) { | |||
1236 | __kmp_stg_parse_int(name, value, 0, KMP_MAX_TASK_PRIORITY_LIMIT2147483647, | |||
1237 | &__kmp_max_task_priority); | |||
1238 | } // __kmp_stg_parse_max_task_priority | |||
1239 | ||||
1240 | static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer, | |||
1241 | char const *name, void *data) { | |||
1242 | __kmp_stg_print_int(buffer, name, __kmp_max_task_priority); | |||
1243 | } // __kmp_stg_print_max_task_priority | |||
1244 | ||||
1245 | // KMP_TASKLOOP_MIN_TASKS | |||
1246 | // taskloop threashold to switch from recursive to linear tasks creation | |||
1247 | static void __kmp_stg_parse_taskloop_min_tasks(char const *name, | |||
1248 | char const *value, void *data) { | |||
1249 | int tmp; | |||
| ||||
1250 | __kmp_stg_parse_int(name, value, 0, INT_MAX2147483647, &tmp); | |||
1251 | __kmp_taskloop_min_tasks = tmp; | |||
1252 | } // __kmp_stg_parse_taskloop_min_tasks | |||
1253 | ||||
1254 | static void __kmp_stg_print_taskloop_min_tasks(kmp_str_buf_t *buffer, | |||
1255 | char const *name, void *data) { | |||
1256 | __kmp_stg_print_int(buffer, name, __kmp_taskloop_min_tasks); | |||
1257 | } // __kmp_stg_print_taskloop_min_tasks | |||
1258 | #endif // OMP_45_ENABLED | |||
1259 | ||||
1260 | // ----------------------------------------------------------------------------- | |||
1261 | // KMP_DISP_NUM_BUFFERS | |||
1262 | static void __kmp_stg_parse_disp_buffers(char const *name, char const *value, | |||
1263 | void *data) { | |||
1264 | if (TCR_4(__kmp_init_serial)(__kmp_init_serial)) { | |||
1265 | KMP_WARNING(EnvSerialWarn, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvSerialWarn , name), __kmp_msg_null); | |||
1266 | return; | |||
1267 | } // read value before serial initialization only | |||
1268 | __kmp_stg_parse_int(name, value, 1, KMP_MAX_NTH2147483647, &__kmp_dispatch_num_buffers); | |||
1269 | } // __kmp_stg_parse_disp_buffers | |||
1270 | ||||
1271 | static void __kmp_stg_print_disp_buffers(kmp_str_buf_t *buffer, | |||
1272 | char const *name, void *data) { | |||
1273 | __kmp_stg_print_int(buffer, name, __kmp_dispatch_num_buffers); | |||
1274 | } // __kmp_stg_print_disp_buffers | |||
1275 | ||||
1276 | #if KMP_NESTED_HOT_TEAMS1 | |||
1277 | // ----------------------------------------------------------------------------- | |||
1278 | // KMP_HOT_TEAMS_MAX_LEVEL, KMP_HOT_TEAMS_MODE | |||
1279 | ||||
1280 | static void __kmp_stg_parse_hot_teams_level(char const *name, char const *value, | |||
1281 | void *data) { | |||
1282 | if (TCR_4(__kmp_init_parallel)(__kmp_init_parallel)) { | |||
1283 | KMP_WARNING(EnvParallelWarn, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvParallelWarn , name), __kmp_msg_null); | |||
1284 | return; | |||
1285 | } // read value before first parallel only | |||
1286 | __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT2147483647, | |||
1287 | &__kmp_hot_teams_max_level); | |||
1288 | } // __kmp_stg_parse_hot_teams_level | |||
1289 | ||||
1290 | static void __kmp_stg_print_hot_teams_level(kmp_str_buf_t *buffer, | |||
1291 | char const *name, void *data) { | |||
1292 | __kmp_stg_print_int(buffer, name, __kmp_hot_teams_max_level); | |||
1293 | } // __kmp_stg_print_hot_teams_level | |||
1294 | ||||
1295 | static void __kmp_stg_parse_hot_teams_mode(char const *name, char const *value, | |||
1296 | void *data) { | |||
1297 | if (TCR_4(__kmp_init_parallel)(__kmp_init_parallel)) { | |||
1298 | KMP_WARNING(EnvParallelWarn, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvParallelWarn , name), __kmp_msg_null); | |||
1299 | return; | |||
1300 | } // read value before first parallel only | |||
1301 | __kmp_stg_parse_int(name, value, 0, KMP_MAX_ACTIVE_LEVELS_LIMIT2147483647, | |||
1302 | &__kmp_hot_teams_mode); | |||
1303 | } // __kmp_stg_parse_hot_teams_mode | |||
1304 | ||||
1305 | static void __kmp_stg_print_hot_teams_mode(kmp_str_buf_t *buffer, | |||
1306 | char const *name, void *data) { | |||
1307 | __kmp_stg_print_int(buffer, name, __kmp_hot_teams_mode); | |||
1308 | } // __kmp_stg_print_hot_teams_mode | |||
1309 | ||||
1310 | #endif // KMP_NESTED_HOT_TEAMS | |||
1311 | ||||
1312 | // ----------------------------------------------------------------------------- | |||
1313 | // KMP_HANDLE_SIGNALS | |||
1314 | ||||
1315 | #if KMP_HANDLE_SIGNALS(1 || 0) | |||
1316 | ||||
1317 | static void __kmp_stg_parse_handle_signals(char const *name, char const *value, | |||
1318 | void *data) { | |||
1319 | __kmp_stg_parse_bool(name, value, &__kmp_handle_signals); | |||
1320 | } // __kmp_stg_parse_handle_signals | |||
1321 | ||||
1322 | static void __kmp_stg_print_handle_signals(kmp_str_buf_t *buffer, | |||
1323 | char const *name, void *data) { | |||
1324 | __kmp_stg_print_bool(buffer, name, __kmp_handle_signals); | |||
1325 | } // __kmp_stg_print_handle_signals | |||
1326 | ||||
1327 | #endif // KMP_HANDLE_SIGNALS | |||
1328 | ||||
1329 | // ----------------------------------------------------------------------------- | |||
1330 | // KMP_X_DEBUG, KMP_DEBUG, KMP_DEBUG_BUF_*, KMP_DIAG | |||
1331 | ||||
1332 | #ifdef KMP_DEBUG1 | |||
1333 | ||||
1334 | #define KMP_STG_X_DEBUG(x) \ | |||
1335 | static void __kmp_stg_parse_##x##_debug(char const *name, char const *value, \ | |||
1336 | void *data) { \ | |||
1337 | __kmp_stg_parse_int(name, value, 0, INT_MAX2147483647, &kmp_##x##_debug); \ | |||
1338 | } /* __kmp_stg_parse_x_debug */ \ | |||
1339 | static void __kmp_stg_print_##x##_debug(kmp_str_buf_t *buffer, \ | |||
1340 | char const *name, void *data) { \ | |||
1341 | __kmp_stg_print_int(buffer, name, kmp_##x##_debug); \ | |||
1342 | } /* __kmp_stg_print_x_debug */ | |||
1343 | ||||
1344 | KMP_STG_X_DEBUG(a) | |||
1345 | KMP_STG_X_DEBUG(b) | |||
1346 | KMP_STG_X_DEBUG(c) | |||
1347 | KMP_STG_X_DEBUG(d) | |||
1348 | KMP_STG_X_DEBUG(e) | |||
1349 | KMP_STG_X_DEBUG(f) | |||
1350 | ||||
1351 | #undef KMP_STG_X_DEBUG | |||
1352 | ||||
1353 | static void __kmp_stg_parse_debug(char const *name, char const *value, | |||
1354 | void *data) { | |||
1355 | int debug = 0; | |||
1356 | __kmp_stg_parse_int(name, value, 0, INT_MAX2147483647, &debug); | |||
1357 | if (kmp_a_debug < debug) { | |||
1358 | kmp_a_debug = debug; | |||
1359 | } | |||
1360 | if (kmp_b_debug < debug) { | |||
1361 | kmp_b_debug = debug; | |||
1362 | } | |||
1363 | if (kmp_c_debug < debug) { | |||
1364 | kmp_c_debug = debug; | |||
1365 | } | |||
1366 | if (kmp_d_debug < debug) { | |||
1367 | kmp_d_debug = debug; | |||
1368 | } | |||
1369 | if (kmp_e_debug < debug) { | |||
1370 | kmp_e_debug = debug; | |||
1371 | } | |||
1372 | if (kmp_f_debug < debug) { | |||
1373 | kmp_f_debug = debug; | |||
1374 | } | |||
1375 | } // __kmp_stg_parse_debug | |||
1376 | ||||
1377 | static void __kmp_stg_parse_debug_buf(char const *name, char const *value, | |||
1378 | void *data) { | |||
1379 | __kmp_stg_parse_bool(name, value, &__kmp_debug_buf); | |||
1380 | // !!! TODO: Move buffer initialization of of this file! It may works | |||
1381 | // incorrectly if KMP_DEBUG_BUF is parsed before KMP_DEBUG_BUF_LINES or | |||
1382 | // KMP_DEBUG_BUF_CHARS. | |||
1383 | if (__kmp_debug_buf) { | |||
1384 | int i; | |||
1385 | int elements = __kmp_debug_buf_lines * __kmp_debug_buf_chars; | |||
1386 | ||||
1387 | /* allocate and initialize all entries in debug buffer to empty */ | |||
1388 | __kmp_debug_buffer = (char *)__kmp_page_allocate(elements * sizeof(char))___kmp_page_allocate((elements * sizeof(char)), "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 1388); | |||
1389 | for (i = 0; i < elements; i += __kmp_debug_buf_chars) | |||
1390 | __kmp_debug_buffer[i] = '\0'; | |||
1391 | ||||
1392 | __kmp_debug_count = 0; | |||
1393 | } | |||
1394 | K_DIAG(1, ("__kmp_debug_buf = %d\n", __kmp_debug_buf)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_debug_buf = %d\n" , __kmp_debug_buf); } }; | |||
1395 | } // __kmp_stg_parse_debug_buf | |||
1396 | ||||
1397 | static void __kmp_stg_print_debug_buf(kmp_str_buf_t *buffer, char const *name, | |||
1398 | void *data) { | |||
1399 | __kmp_stg_print_bool(buffer, name, __kmp_debug_buf); | |||
1400 | } // __kmp_stg_print_debug_buf | |||
1401 | ||||
1402 | static void __kmp_stg_parse_debug_buf_atomic(char const *name, | |||
1403 | char const *value, void *data) { | |||
1404 | __kmp_stg_parse_bool(name, value, &__kmp_debug_buf_atomic); | |||
1405 | } // __kmp_stg_parse_debug_buf_atomic | |||
1406 | ||||
1407 | static void __kmp_stg_print_debug_buf_atomic(kmp_str_buf_t *buffer, | |||
1408 | char const *name, void *data) { | |||
1409 | __kmp_stg_print_bool(buffer, name, __kmp_debug_buf_atomic); | |||
1410 | } // __kmp_stg_print_debug_buf_atomic | |||
1411 | ||||
1412 | static void __kmp_stg_parse_debug_buf_chars(char const *name, char const *value, | |||
1413 | void *data) { | |||
1414 | __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_CHARS_MIN2, INT_MAX2147483647, | |||
1415 | &__kmp_debug_buf_chars); | |||
1416 | } // __kmp_stg_debug_parse_buf_chars | |||
1417 | ||||
1418 | static void __kmp_stg_print_debug_buf_chars(kmp_str_buf_t *buffer, | |||
1419 | char const *name, void *data) { | |||
1420 | __kmp_stg_print_int(buffer, name, __kmp_debug_buf_chars); | |||
1421 | } // __kmp_stg_print_debug_buf_chars | |||
1422 | ||||
1423 | static void __kmp_stg_parse_debug_buf_lines(char const *name, char const *value, | |||
1424 | void *data) { | |||
1425 | __kmp_stg_parse_int(name, value, KMP_DEBUG_BUF_LINES_MIN1, INT_MAX2147483647, | |||
1426 | &__kmp_debug_buf_lines); | |||
1427 | } // __kmp_stg_parse_debug_buf_lines | |||
1428 | ||||
1429 | static void __kmp_stg_print_debug_buf_lines(kmp_str_buf_t *buffer, | |||
1430 | char const *name, void *data) { | |||
1431 | __kmp_stg_print_int(buffer, name, __kmp_debug_buf_lines); | |||
1432 | } // __kmp_stg_print_debug_buf_lines | |||
1433 | ||||
1434 | static void __kmp_stg_parse_diag(char const *name, char const *value, | |||
1435 | void *data) { | |||
1436 | __kmp_stg_parse_int(name, value, 0, INT_MAX2147483647, &kmp_diag); | |||
1437 | } // __kmp_stg_parse_diag | |||
1438 | ||||
1439 | static void __kmp_stg_print_diag(kmp_str_buf_t *buffer, char const *name, | |||
1440 | void *data) { | |||
1441 | __kmp_stg_print_int(buffer, name, kmp_diag); | |||
1442 | } // __kmp_stg_print_diag | |||
1443 | ||||
1444 | #endif // KMP_DEBUG | |||
1445 | ||||
1446 | // ----------------------------------------------------------------------------- | |||
1447 | // KMP_ALIGN_ALLOC | |||
1448 | ||||
1449 | static void __kmp_stg_parse_align_alloc(char const *name, char const *value, | |||
1450 | void *data) { | |||
1451 | __kmp_stg_parse_size(name, value, CACHE_LINE64, INT_MAX2147483647, NULL__null, | |||
1452 | &__kmp_align_alloc, 1); | |||
1453 | } // __kmp_stg_parse_align_alloc | |||
1454 | ||||
1455 | static void __kmp_stg_print_align_alloc(kmp_str_buf_t *buffer, char const *name, | |||
1456 | void *data) { | |||
1457 | __kmp_stg_print_size(buffer, name, __kmp_align_alloc); | |||
1458 | } // __kmp_stg_print_align_alloc | |||
1459 | ||||
1460 | // ----------------------------------------------------------------------------- | |||
1461 | // KMP_PLAIN_BARRIER, KMP_FORKJOIN_BARRIER, KMP_REDUCTION_BARRIER | |||
1462 | ||||
1463 | // TODO: Remove __kmp_barrier_branch_bit_env_name varibale, remove loops from | |||
1464 | // parse and print functions, pass required info through data argument. | |||
1465 | ||||
1466 | static void __kmp_stg_parse_barrier_branch_bit(char const *name, | |||
1467 | char const *value, void *data) { | |||
1468 | const char *var; | |||
1469 | ||||
1470 | /* ---------- Barrier branch bit control ------------ */ | |||
1471 | for (int i = bs_plain_barrier; i < bs_last_barrier; i++) { | |||
1472 | var = __kmp_barrier_branch_bit_env_name[i]; | |||
1473 | if ((strcmp(var, name) == 0) && (value != 0)) { | |||
1474 | char *comma; | |||
1475 | ||||
1476 | comma = CCAST(char *, strchr(value, ','))const_cast<char *>(strchr(value, ',')); | |||
1477 | __kmp_barrier_gather_branch_bits[i] = | |||
1478 | (kmp_uint32)__kmp_str_to_int(value, ','); | |||
1479 | /* is there a specified release parameter? */ | |||
1480 | if (comma == NULL__null) { | |||
1481 | __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt; | |||
1482 | } else { | |||
1483 | __kmp_barrier_release_branch_bits[i] = | |||
1484 | (kmp_uint32)__kmp_str_to_int(comma + 1, 0); | |||
1485 | ||||
1486 | if (__kmp_barrier_release_branch_bits[i] > KMP_MAX_BRANCH_BITS31) { | |||
1487 | __kmp_msg(kmp_ms_warning, | |||
1488 | KMP_MSG(BarrReleaseValueInvalid, name, comma + 1)__kmp_msg_format(kmp_i18n_msg_BarrReleaseValueInvalid, name, comma + 1), | |||
1489 | __kmp_msg_null); | |||
1490 | __kmp_barrier_release_branch_bits[i] = __kmp_barrier_release_bb_dflt; | |||
1491 | } | |||
1492 | } | |||
1493 | if (__kmp_barrier_gather_branch_bits[i] > KMP_MAX_BRANCH_BITS31) { | |||
1494 | KMP_WARNING(BarrGatherValueInvalid, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_BarrGatherValueInvalid , name, value), __kmp_msg_null); | |||
1495 | KMP_INFORM(Using_uint_Value, name, __kmp_barrier_gather_bb_dflt)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_uint_Value , name, __kmp_barrier_gather_bb_dflt), __kmp_msg_null); | |||
1496 | __kmp_barrier_gather_branch_bits[i] = __kmp_barrier_gather_bb_dflt; | |||
1497 | } | |||
1498 | } | |||
1499 | K_DIAG(1, ("%s == %d,%d\n", __kmp_barrier_branch_bit_env_name[i],{ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("%s == %d,%d\n" , __kmp_barrier_branch_bit_env_name[i], __kmp_barrier_gather_branch_bits [i], __kmp_barrier_release_branch_bits[i]); } } | |||
1500 | __kmp_barrier_gather_branch_bits[i],{ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("%s == %d,%d\n" , __kmp_barrier_branch_bit_env_name[i], __kmp_barrier_gather_branch_bits [i], __kmp_barrier_release_branch_bits[i]); } } | |||
1501 | __kmp_barrier_release_branch_bits[i])){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("%s == %d,%d\n" , __kmp_barrier_branch_bit_env_name[i], __kmp_barrier_gather_branch_bits [i], __kmp_barrier_release_branch_bits[i]); } } | |||
1502 | } | |||
1503 | } // __kmp_stg_parse_barrier_branch_bit | |||
1504 | ||||
1505 | static void __kmp_stg_print_barrier_branch_bit(kmp_str_buf_t *buffer, | |||
1506 | char const *name, void *data) { | |||
1507 | const char *var; | |||
1508 | for (int i = bs_plain_barrier; i < bs_last_barrier; i++) { | |||
1509 | var = __kmp_barrier_branch_bit_env_name[i]; | |||
1510 | if (strcmp(var, name) == 0) { | |||
1511 | if (__kmp_env_format) { | |||
1512 | KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_branch_bit_env_name[i])__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), __kmp_barrier_branch_bit_env_name[i]); | |||
1513 | } else { | |||
1514 | __kmp_str_buf_print(buffer, " %s='", | |||
1515 | __kmp_barrier_branch_bit_env_name[i]); | |||
1516 | } | |||
1517 | __kmp_str_buf_print(buffer, "%d,%d'\n", | |||
1518 | __kmp_barrier_gather_branch_bits[i], | |||
1519 | __kmp_barrier_release_branch_bits[i]); | |||
1520 | } | |||
1521 | } | |||
1522 | } // __kmp_stg_print_barrier_branch_bit | |||
1523 | ||||
1524 | // ---------------------------------------------------------------------------- | |||
1525 | // KMP_PLAIN_BARRIER_PATTERN, KMP_FORKJOIN_BARRIER_PATTERN, | |||
1526 | // KMP_REDUCTION_BARRIER_PATTERN | |||
1527 | ||||
1528 | // TODO: Remove __kmp_barrier_pattern_name variable, remove loops from parse and | |||
1529 | // print functions, pass required data to functions through data argument. | |||
1530 | ||||
1531 | static void __kmp_stg_parse_barrier_pattern(char const *name, char const *value, | |||
1532 | void *data) { | |||
1533 | const char *var; | |||
1534 | /* ---------- Barrier method control ------------ */ | |||
1535 | ||||
1536 | for (int i = bs_plain_barrier; i < bs_last_barrier; i++) { | |||
1537 | var = __kmp_barrier_pattern_env_name[i]; | |||
1538 | ||||
1539 | if ((strcmp(var, name) == 0) && (value != 0)) { | |||
1540 | int j; | |||
1541 | char *comma = CCAST(char *, strchr(value, ','))const_cast<char *>(strchr(value, ',')); | |||
1542 | ||||
1543 | /* handle first parameter: gather pattern */ | |||
1544 | for (j = bp_linear_bar; j < bp_last_bar; j++) { | |||
1545 | if (__kmp_match_with_sentinel(__kmp_barrier_pattern_name[j], value, 1, | |||
1546 | ',')) { | |||
1547 | __kmp_barrier_gather_pattern[i] = (kmp_bar_pat_e)j; | |||
1548 | break; | |||
1549 | } | |||
1550 | } | |||
1551 | if (j == bp_last_bar) { | |||
1552 | KMP_WARNING(BarrGatherValueInvalid, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_BarrGatherValueInvalid , name, value), __kmp_msg_null); | |||
1553 | KMP_INFORM(Using_str_Value, name,__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_str_Value , name, __kmp_barrier_pattern_name[bp_linear_bar]), __kmp_msg_null ) | |||
1554 | __kmp_barrier_pattern_name[bp_linear_bar])__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_str_Value , name, __kmp_barrier_pattern_name[bp_linear_bar]), __kmp_msg_null ); | |||
1555 | } | |||
1556 | ||||
1557 | /* handle second parameter: release pattern */ | |||
1558 | if (comma != NULL__null) { | |||
1559 | for (j = bp_linear_bar; j < bp_last_bar; j++) { | |||
1560 | if (__kmp_str_match(__kmp_barrier_pattern_name[j], 1, comma + 1)) { | |||
1561 | __kmp_barrier_release_pattern[i] = (kmp_bar_pat_e)j; | |||
1562 | break; | |||
1563 | } | |||
1564 | } | |||
1565 | if (j == bp_last_bar) { | |||
1566 | __kmp_msg(kmp_ms_warning, | |||
1567 | KMP_MSG(BarrReleaseValueInvalid, name, comma + 1)__kmp_msg_format(kmp_i18n_msg_BarrReleaseValueInvalid, name, comma + 1), | |||
1568 | __kmp_msg_null); | |||
1569 | KMP_INFORM(Using_str_Value, name,__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_str_Value , name, __kmp_barrier_pattern_name[bp_linear_bar]), __kmp_msg_null ) | |||
1570 | __kmp_barrier_pattern_name[bp_linear_bar])__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_str_Value , name, __kmp_barrier_pattern_name[bp_linear_bar]), __kmp_msg_null ); | |||
1571 | } | |||
1572 | } | |||
1573 | } | |||
1574 | } | |||
1575 | } // __kmp_stg_parse_barrier_pattern | |||
1576 | ||||
1577 | static void __kmp_stg_print_barrier_pattern(kmp_str_buf_t *buffer, | |||
1578 | char const *name, void *data) { | |||
1579 | const char *var; | |||
1580 | for (int i = bs_plain_barrier; i < bs_last_barrier; i++) { | |||
1581 | var = __kmp_barrier_pattern_env_name[i]; | |||
1582 | if (strcmp(var, name) == 0) { | |||
1583 | int j = __kmp_barrier_gather_pattern[i]; | |||
1584 | int k = __kmp_barrier_release_pattern[i]; | |||
1585 | if (__kmp_env_format) { | |||
1586 | KMP_STR_BUF_PRINT_NAME_EX(__kmp_barrier_pattern_env_name[i])__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), __kmp_barrier_pattern_env_name[i]); | |||
1587 | } else { | |||
1588 | __kmp_str_buf_print(buffer, " %s='", | |||
1589 | __kmp_barrier_pattern_env_name[i]); | |||
1590 | } | |||
1591 | __kmp_str_buf_print(buffer, "%s,%s'\n", __kmp_barrier_pattern_name[j], | |||
1592 | __kmp_barrier_pattern_name[k]); | |||
1593 | } | |||
1594 | } | |||
1595 | } // __kmp_stg_print_barrier_pattern | |||
1596 | ||||
1597 | // ----------------------------------------------------------------------------- | |||
1598 | // KMP_ABORT_DELAY | |||
1599 | ||||
1600 | static void __kmp_stg_parse_abort_delay(char const *name, char const *value, | |||
1601 | void *data) { | |||
1602 | // Units of KMP_DELAY_ABORT are seconds, units of __kmp_abort_delay is | |||
1603 | // milliseconds. | |||
1604 | int delay = __kmp_abort_delay / 1000; | |||
1605 | __kmp_stg_parse_int(name, value, 0, INT_MAX2147483647 / 1000, &delay); | |||
1606 | __kmp_abort_delay = delay * 1000; | |||
1607 | } // __kmp_stg_parse_abort_delay | |||
1608 | ||||
1609 | static void __kmp_stg_print_abort_delay(kmp_str_buf_t *buffer, char const *name, | |||
1610 | void *data) { | |||
1611 | __kmp_stg_print_int(buffer, name, __kmp_abort_delay); | |||
1612 | } // __kmp_stg_print_abort_delay | |||
1613 | ||||
1614 | // ----------------------------------------------------------------------------- | |||
1615 | // KMP_CPUINFO_FILE | |||
1616 | ||||
1617 | static void __kmp_stg_parse_cpuinfo_file(char const *name, char const *value, | |||
1618 | void *data) { | |||
1619 | #if KMP_AFFINITY_SUPPORTED1 | |||
1620 | __kmp_stg_parse_str(name, value, &__kmp_cpuinfo_file); | |||
1621 | K_DIAG(1, ("__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_cpuinfo_file == %s\n" , __kmp_cpuinfo_file); } }; | |||
1622 | #endif | |||
1623 | } //__kmp_stg_parse_cpuinfo_file | |||
1624 | ||||
1625 | static void __kmp_stg_print_cpuinfo_file(kmp_str_buf_t *buffer, | |||
1626 | char const *name, void *data) { | |||
1627 | #if KMP_AFFINITY_SUPPORTED1 | |||
1628 | if (__kmp_env_format) { | |||
1629 | KMP_STR_BUF_PRINT_NAME__kmp_str_buf_print(buffer, " %s %s", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
1630 | } else { | |||
1631 | __kmp_str_buf_print(buffer, " %s", name); | |||
1632 | } | |||
1633 | if (__kmp_cpuinfo_file) { | |||
1634 | __kmp_str_buf_print(buffer, "='%s'\n", __kmp_cpuinfo_file); | |||
1635 | } else { | |||
1636 | __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
1637 | } | |||
1638 | #endif | |||
1639 | } //__kmp_stg_print_cpuinfo_file | |||
1640 | ||||
1641 | // ----------------------------------------------------------------------------- | |||
1642 | // KMP_FORCE_REDUCTION, KMP_DETERMINISTIC_REDUCTION | |||
1643 | ||||
1644 | static void __kmp_stg_parse_force_reduction(char const *name, char const *value, | |||
1645 | void *data) { | |||
1646 | kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data; | |||
1647 | int rc; | |||
1648 | ||||
1649 | rc = __kmp_stg_check_rivals(name, value, reduction->rivals); | |||
1650 | if (rc) { | |||
1651 | return; | |||
1652 | } | |||
1653 | if (reduction->force) { | |||
1654 | if (value != 0) { | |||
1655 | if (__kmp_str_match("critical", 0, value)) | |||
1656 | __kmp_force_reduction_method = critical_reduce_block; | |||
1657 | else if (__kmp_str_match("atomic", 0, value)) | |||
1658 | __kmp_force_reduction_method = atomic_reduce_block; | |||
1659 | else if (__kmp_str_match("tree", 0, value)) | |||
1660 | __kmp_force_reduction_method = tree_reduce_block; | |||
1661 | else { | |||
1662 | KMP_FATAL(UnknownForceReduction, name, value)__kmp_fatal(__kmp_msg_format(kmp_i18n_msg_UnknownForceReduction , name, value), __kmp_msg_null); | |||
1663 | } | |||
1664 | } | |||
1665 | } else { | |||
1666 | __kmp_stg_parse_bool(name, value, &__kmp_determ_red); | |||
1667 | if (__kmp_determ_red) { | |||
1668 | __kmp_force_reduction_method = tree_reduce_block; | |||
1669 | } else { | |||
1670 | __kmp_force_reduction_method = reduction_method_not_defined; | |||
1671 | } | |||
1672 | } | |||
1673 | K_DIAG(1, ("__kmp_force_reduction_method == %d\n",{ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_force_reduction_method == %d\n" , __kmp_force_reduction_method); } } | |||
1674 | __kmp_force_reduction_method)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_force_reduction_method == %d\n" , __kmp_force_reduction_method); } }; | |||
1675 | } // __kmp_stg_parse_force_reduction | |||
1676 | ||||
1677 | static void __kmp_stg_print_force_reduction(kmp_str_buf_t *buffer, | |||
1678 | char const *name, void *data) { | |||
1679 | ||||
1680 | kmp_stg_fr_data_t *reduction = (kmp_stg_fr_data_t *)data; | |||
1681 | if (reduction->force) { | |||
1682 | if (__kmp_force_reduction_method == critical_reduce_block) { | |||
1683 | __kmp_stg_print_str(buffer, name, "critical"); | |||
1684 | } else if (__kmp_force_reduction_method == atomic_reduce_block) { | |||
1685 | __kmp_stg_print_str(buffer, name, "atomic"); | |||
1686 | } else if (__kmp_force_reduction_method == tree_reduce_block) { | |||
1687 | __kmp_stg_print_str(buffer, name, "tree"); | |||
1688 | } else { | |||
1689 | if (__kmp_env_format) { | |||
1690 | KMP_STR_BUF_PRINT_NAME__kmp_str_buf_print(buffer, " %s %s", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
1691 | } else { | |||
1692 | __kmp_str_buf_print(buffer, " %s", name); | |||
1693 | } | |||
1694 | __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
1695 | } | |||
1696 | } else { | |||
1697 | __kmp_stg_print_bool(buffer, name, __kmp_determ_red); | |||
1698 | } | |||
1699 | ||||
1700 | } // __kmp_stg_print_force_reduction | |||
1701 | ||||
1702 | // ----------------------------------------------------------------------------- | |||
1703 | // KMP_STORAGE_MAP | |||
1704 | ||||
1705 | static void __kmp_stg_parse_storage_map(char const *name, char const *value, | |||
1706 | void *data) { | |||
1707 | if (__kmp_str_match("verbose", 1, value)) { | |||
1708 | __kmp_storage_map = TRUE(!0); | |||
1709 | __kmp_storage_map_verbose = TRUE(!0); | |||
1710 | __kmp_storage_map_verbose_specified = TRUE(!0); | |||
1711 | ||||
1712 | } else { | |||
1713 | __kmp_storage_map_verbose = FALSE0; | |||
1714 | __kmp_stg_parse_bool(name, value, &__kmp_storage_map); // !!! | |||
1715 | } | |||
1716 | } // __kmp_stg_parse_storage_map | |||
1717 | ||||
1718 | static void __kmp_stg_print_storage_map(kmp_str_buf_t *buffer, char const *name, | |||
1719 | void *data) { | |||
1720 | if (__kmp_storage_map_verbose || __kmp_storage_map_verbose_specified) { | |||
1721 | __kmp_stg_print_str(buffer, name, "verbose"); | |||
1722 | } else { | |||
1723 | __kmp_stg_print_bool(buffer, name, __kmp_storage_map); | |||
1724 | } | |||
1725 | } // __kmp_stg_print_storage_map | |||
1726 | ||||
1727 | // ----------------------------------------------------------------------------- | |||
1728 | // KMP_ALL_THREADPRIVATE | |||
1729 | ||||
1730 | static void __kmp_stg_parse_all_threadprivate(char const *name, | |||
1731 | char const *value, void *data) { | |||
1732 | __kmp_stg_parse_int(name, value, | |||
1733 | __kmp_allThreadsSpecified ? __kmp_max_nth : 1, | |||
1734 | __kmp_max_nth, &__kmp_tp_capacity); | |||
1735 | } // __kmp_stg_parse_all_threadprivate | |||
1736 | ||||
1737 | static void __kmp_stg_print_all_threadprivate(kmp_str_buf_t *buffer, | |||
1738 | char const *name, void *data) { | |||
1739 | __kmp_stg_print_int(buffer, name, __kmp_tp_capacity); | |||
1740 | } | |||
1741 | ||||
1742 | // ----------------------------------------------------------------------------- | |||
1743 | // KMP_FOREIGN_THREADS_THREADPRIVATE | |||
1744 | ||||
1745 | static void __kmp_stg_parse_foreign_threads_threadprivate(char const *name, | |||
1746 | char const *value, | |||
1747 | void *data) { | |||
1748 | __kmp_stg_parse_bool(name, value, &__kmp_foreign_tp); | |||
1749 | } // __kmp_stg_parse_foreign_threads_threadprivate | |||
1750 | ||||
1751 | static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer, | |||
1752 | char const *name, | |||
1753 | void *data) { | |||
1754 | __kmp_stg_print_bool(buffer, name, __kmp_foreign_tp); | |||
1755 | } // __kmp_stg_print_foreign_threads_threadprivate | |||
1756 | ||||
1757 | // ----------------------------------------------------------------------------- | |||
1758 | // KMP_AFFINITY, GOMP_CPU_AFFINITY, KMP_TOPOLOGY_METHOD | |||
1759 | ||||
1760 | #if KMP_AFFINITY_SUPPORTED1 | |||
1761 | // Parse the proc id list. Return TRUE if successful, FALSE otherwise. | |||
1762 | static int __kmp_parse_affinity_proc_id_list(const char *var, const char *env, | |||
1763 | const char **nextEnv, | |||
1764 | char **proclist) { | |||
1765 | const char *scan = env; | |||
1766 | const char *next = scan; | |||
1767 | int empty = TRUE(!0); | |||
1768 | ||||
1769 | *proclist = NULL__null; | |||
1770 | ||||
1771 | for (;;) { | |||
1772 | int start, end, stride; | |||
1773 | ||||
1774 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
1775 | next = scan; | |||
1776 | if (*next == '\0') { | |||
1777 | break; | |||
1778 | } | |||
1779 | ||||
1780 | if (*next == '{') { | |||
1781 | int num; | |||
1782 | next++; // skip '{' | |||
1783 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1784 | scan = next; | |||
1785 | ||||
1786 | // Read the first integer in the set. | |||
1787 | if ((*next < '0') || (*next > '9')) { | |||
1788 | KMP_WARNING(AffSyntaxError, var)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffSyntaxError , var), __kmp_msg_null); | |||
1789 | return FALSE0; | |||
1790 | } | |||
1791 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
1792 | num = __kmp_str_to_int(scan, *next); | |||
1793 | KMP_ASSERT(num >= 0)if (!(num >= 0)) { __kmp_debug_assert("num >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 1793); }; | |||
1794 | ||||
1795 | for (;;) { | |||
1796 | // Check for end of set. | |||
1797 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1798 | if (*next == '}') { | |||
1799 | next++; // skip '}' | |||
1800 | break; | |||
1801 | } | |||
1802 | ||||
1803 | // Skip optional comma. | |||
1804 | if (*next == ',') { | |||
1805 | next++; | |||
1806 | } | |||
1807 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1808 | ||||
1809 | // Read the next integer in the set. | |||
1810 | scan = next; | |||
1811 | if ((*next < '0') || (*next > '9')) { | |||
1812 | KMP_WARNING(AffSyntaxError, var)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffSyntaxError , var), __kmp_msg_null); | |||
1813 | return FALSE0; | |||
1814 | } | |||
1815 | ||||
1816 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
1817 | num = __kmp_str_to_int(scan, *next); | |||
1818 | KMP_ASSERT(num >= 0)if (!(num >= 0)) { __kmp_debug_assert("num >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 1818); }; | |||
1819 | } | |||
1820 | empty = FALSE0; | |||
1821 | ||||
1822 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1823 | if (*next == ',') { | |||
1824 | next++; | |||
1825 | } | |||
1826 | scan = next; | |||
1827 | continue; | |||
1828 | } | |||
1829 | ||||
1830 | // Next character is not an integer => end of list | |||
1831 | if ((*next < '0') || (*next > '9')) { | |||
1832 | if (empty) { | |||
1833 | KMP_WARNING(AffSyntaxError, var)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffSyntaxError , var), __kmp_msg_null); | |||
1834 | return FALSE0; | |||
1835 | } | |||
1836 | break; | |||
1837 | } | |||
1838 | ||||
1839 | // Read the first integer. | |||
1840 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
1841 | start = __kmp_str_to_int(scan, *next); | |||
1842 | KMP_ASSERT(start >= 0)if (!(start >= 0)) { __kmp_debug_assert("start >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 1842); }; | |||
1843 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1844 | ||||
1845 | // If this isn't a range, then go on. | |||
1846 | if (*next != '-') { | |||
1847 | empty = FALSE0; | |||
1848 | ||||
1849 | // Skip optional comma. | |||
1850 | if (*next == ',') { | |||
1851 | next++; | |||
1852 | } | |||
1853 | scan = next; | |||
1854 | continue; | |||
1855 | } | |||
1856 | ||||
1857 | // This is a range. Skip over the '-' and read in the 2nd int. | |||
1858 | next++; // skip '-' | |||
1859 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1860 | scan = next; | |||
1861 | if ((*next < '0') || (*next > '9')) { | |||
1862 | KMP_WARNING(AffSyntaxError, var)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffSyntaxError , var), __kmp_msg_null); | |||
1863 | return FALSE0; | |||
1864 | } | |||
1865 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
1866 | end = __kmp_str_to_int(scan, *next); | |||
1867 | KMP_ASSERT(end >= 0)if (!(end >= 0)) { __kmp_debug_assert("end >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 1867); }; | |||
1868 | ||||
1869 | // Check for a stride parameter | |||
1870 | stride = 1; | |||
1871 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1872 | if (*next == ':') { | |||
1873 | // A stride is specified. Skip over the ':" and read the 3rd int. | |||
1874 | int sign = +1; | |||
1875 | next++; // skip ':' | |||
1876 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1877 | scan = next; | |||
1878 | if (*next == '-') { | |||
1879 | sign = -1; | |||
1880 | next++; | |||
1881 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1882 | scan = next; | |||
1883 | } | |||
1884 | if ((*next < '0') || (*next > '9')) { | |||
1885 | KMP_WARNING(AffSyntaxError, var)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffSyntaxError , var), __kmp_msg_null); | |||
1886 | return FALSE0; | |||
1887 | } | |||
1888 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
1889 | stride = __kmp_str_to_int(scan, *next); | |||
1890 | KMP_ASSERT(stride >= 0)if (!(stride >= 0)) { __kmp_debug_assert("stride >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 1890); }; | |||
1891 | stride *= sign; | |||
1892 | } | |||
1893 | ||||
1894 | // Do some range checks. | |||
1895 | if (stride == 0) { | |||
1896 | KMP_WARNING(AffZeroStride, var)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffZeroStride , var), __kmp_msg_null); | |||
1897 | return FALSE0; | |||
1898 | } | |||
1899 | if (stride > 0) { | |||
1900 | if (start > end) { | |||
1901 | KMP_WARNING(AffStartGreaterEnd, var, start, end)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffStartGreaterEnd , var, start, end), __kmp_msg_null); | |||
1902 | return FALSE0; | |||
1903 | } | |||
1904 | } else { | |||
1905 | if (start < end) { | |||
1906 | KMP_WARNING(AffStrideLessZero, var, start, end)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffStrideLessZero , var, start, end), __kmp_msg_null); | |||
1907 | return FALSE0; | |||
1908 | } | |||
1909 | } | |||
1910 | if ((end - start) / stride > 65536) { | |||
1911 | KMP_WARNING(AffRangeTooBig, var, end, start, stride)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffRangeTooBig , var, end, start, stride), __kmp_msg_null); | |||
1912 | return FALSE0; | |||
1913 | } | |||
1914 | ||||
1915 | empty = FALSE0; | |||
1916 | ||||
1917 | // Skip optional comma. | |||
1918 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
1919 | if (*next == ',') { | |||
1920 | next++; | |||
1921 | } | |||
1922 | scan = next; | |||
1923 | } | |||
1924 | ||||
1925 | *nextEnv = next; | |||
1926 | ||||
1927 | { | |||
1928 | int len = next - env; | |||
1929 | char *retlist = (char *)__kmp_allocate((len + 1) * sizeof(char))___kmp_allocate(((len + 1) * sizeof(char)), "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 1929); | |||
1930 | KMP_MEMCPY_S(retlist, (len + 1) * sizeof(char), env, len * sizeof(char))memcpy(retlist, env, len * sizeof(char)); | |||
1931 | retlist[len] = '\0'; | |||
1932 | *proclist = retlist; | |||
1933 | } | |||
1934 | return TRUE(!0); | |||
1935 | } | |||
1936 | ||||
1937 | // If KMP_AFFINITY is specified without a type, then | |||
1938 | // __kmp_affinity_notype should point to its setting. | |||
1939 | static kmp_setting_t *__kmp_affinity_notype = NULL__null; | |||
1940 | ||||
1941 | static void __kmp_parse_affinity_env(char const *name, char const *value, | |||
1942 | enum affinity_type *out_type, | |||
1943 | char **out_proclist, int *out_verbose, | |||
1944 | int *out_warn, int *out_respect, | |||
1945 | enum affinity_gran *out_gran, | |||
1946 | int *out_gran_levels, int *out_dups, | |||
1947 | int *out_compact, int *out_offset) { | |||
1948 | char *buffer = NULL__null; // Copy of env var value. | |||
1949 | char *buf = NULL__null; // Buffer for strtok_r() function. | |||
1950 | char *next = NULL__null; // end of token / start of next. | |||
1951 | const char *start; // start of current token (for err msgs) | |||
1952 | int count = 0; // Counter of parsed integer numbers. | |||
1953 | int number[2]; // Parsed numbers. | |||
1954 | ||||
1955 | // Guards. | |||
1956 | int type = 0; | |||
1957 | int proclist = 0; | |||
1958 | int verbose = 0; | |||
1959 | int warnings = 0; | |||
1960 | int respect = 0; | |||
1961 | int gran = 0; | |||
1962 | int dups = 0; | |||
1963 | ||||
1964 | KMP_ASSERT(value != NULL)if (!(value != __null)) { __kmp_debug_assert("value != NULL", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 1964); }; | |||
1965 | ||||
1966 | if (TCR_4(__kmp_init_middle)(__kmp_init_middle)) { | |||
1967 | KMP_WARNING(EnvMiddleWarn, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvMiddleWarn , name), __kmp_msg_null); | |||
1968 | __kmp_env_toPrint(name, 0); | |||
1969 | return; | |||
1970 | } | |||
1971 | __kmp_env_toPrint(name, 1); | |||
1972 | ||||
1973 | buffer = | |||
1974 | __kmp_str_format("%s", value); // Copy env var to keep original intact. | |||
1975 | buf = buffer; | |||
1976 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
1977 | ||||
1978 | // Helper macros. | |||
1979 | ||||
1980 | // If we see a parse error, emit a warning and scan to the next ",". | |||
1981 | // | |||
1982 | // FIXME - there's got to be a better way to print an error | |||
1983 | // message, hopefully without overwritting peices of buf. | |||
1984 | #define EMIT_WARN(skip, errlist) \ | |||
1985 | { \ | |||
1986 | char ch; \ | |||
1987 | if (skip) { \ | |||
1988 | SKIP_TO(next, ','){ while (*(next) != '\0' && *(next) != (',')) (next)++ ; }; \ | |||
1989 | } \ | |||
1990 | ch = *next; \ | |||
1991 | *next = '\0'; \ | |||
1992 | KMP_WARNING errlist; \ | |||
1993 | *next = ch; \ | |||
1994 | if (skip) { \ | |||
1995 | if (ch == ',') \ | |||
1996 | next++; \ | |||
1997 | } \ | |||
1998 | buf = next; \ | |||
1999 | } | |||
2000 | ||||
2001 | #define _set_param(_guard, _var, _val) \ | |||
2002 | { \ | |||
2003 | if (_guard == 0) { \ | |||
2004 | _var = _val; \ | |||
2005 | } else { \ | |||
2006 | EMIT_WARN(FALSE0, (AffParamDefined, name, start)); \ | |||
2007 | } \ | |||
2008 | ++_guard; \ | |||
2009 | } | |||
2010 | ||||
2011 | #define set_type(val) _set_param(type, *out_type, val) | |||
2012 | #define set_verbose(val) _set_param(verbose, *out_verbose, val) | |||
2013 | #define set_warnings(val) _set_param(warnings, *out_warn, val) | |||
2014 | #define set_respect(val) _set_param(respect, *out_respect, val) | |||
2015 | #define set_dups(val)_set_param(dups, *out_dups, val) _set_param(dups, *out_dups, val) | |||
2016 | #define set_proclist(val)_set_param(proclist, *out_proclist, val) _set_param(proclist, *out_proclist, val) | |||
2017 | ||||
2018 | #define set_gran(val, levels){ if (gran == 0) { *out_gran = val; *out_gran_levels = levels ; } else { EMIT_WARN(0, (AffParamDefined, name, start)); } ++ gran; } \ | |||
2019 | { \ | |||
2020 | if (gran == 0) { \ | |||
2021 | *out_gran = val; \ | |||
2022 | *out_gran_levels = levels; \ | |||
2023 | } else { \ | |||
2024 | EMIT_WARN(FALSE0, (AffParamDefined, name, start)); \ | |||
2025 | } \ | |||
2026 | ++gran; \ | |||
2027 | } | |||
2028 | ||||
2029 | #if OMP_40_ENABLED(50 >= 40) | |||
2030 | KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&if (!((__kmp_nested_proc_bind.bind_types != __null) && (__kmp_nested_proc_bind.used > 0))) { __kmp_debug_assert( "(__kmp_nested_proc_bind.bind_types != __null) && (__kmp_nested_proc_bind.used > 0)" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2031); } | |||
2031 | (__kmp_nested_proc_bind.used > 0))if (!((__kmp_nested_proc_bind.bind_types != __null) && (__kmp_nested_proc_bind.used > 0))) { __kmp_debug_assert( "(__kmp_nested_proc_bind.bind_types != __null) && (__kmp_nested_proc_bind.used > 0)" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2031); }; | |||
2032 | #endif | |||
2033 | ||||
2034 | while (*buf != '\0') { | |||
2035 | start = next = buf; | |||
2036 | ||||
2037 | if (__kmp_match_str("none", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2038 | set_type(affinity_none); | |||
2039 | #if OMP_40_ENABLED(50 >= 40) | |||
2040 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; | |||
2041 | #endif | |||
2042 | buf = next; | |||
2043 | } else if (__kmp_match_str("scatter", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2044 | set_type(affinity_scatter); | |||
2045 | #if OMP_40_ENABLED(50 >= 40) | |||
2046 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; | |||
2047 | #endif | |||
2048 | buf = next; | |||
2049 | } else if (__kmp_match_str("compact", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2050 | set_type(affinity_compact); | |||
2051 | #if OMP_40_ENABLED(50 >= 40) | |||
2052 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; | |||
2053 | #endif | |||
2054 | buf = next; | |||
2055 | } else if (__kmp_match_str("logical", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2056 | set_type(affinity_logical); | |||
2057 | #if OMP_40_ENABLED(50 >= 40) | |||
2058 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; | |||
2059 | #endif | |||
2060 | buf = next; | |||
2061 | } else if (__kmp_match_str("physical", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2062 | set_type(affinity_physical); | |||
2063 | #if OMP_40_ENABLED(50 >= 40) | |||
2064 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; | |||
2065 | #endif | |||
2066 | buf = next; | |||
2067 | } else if (__kmp_match_str("explicit", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2068 | set_type(affinity_explicit); | |||
2069 | #if OMP_40_ENABLED(50 >= 40) | |||
2070 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; | |||
2071 | #endif | |||
2072 | buf = next; | |||
2073 | } else if (__kmp_match_str("balanced", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2074 | set_type(affinity_balanced); | |||
2075 | #if OMP_40_ENABLED(50 >= 40) | |||
2076 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; | |||
2077 | #endif | |||
2078 | buf = next; | |||
2079 | } else if (__kmp_match_str("disabled", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2080 | set_type(affinity_disabled); | |||
2081 | #if OMP_40_ENABLED(50 >= 40) | |||
2082 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; | |||
2083 | #endif | |||
2084 | buf = next; | |||
2085 | } else if (__kmp_match_str("verbose", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2086 | set_verbose(TRUE(!0)); | |||
2087 | buf = next; | |||
2088 | } else if (__kmp_match_str("noverbose", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2089 | set_verbose(FALSE0); | |||
2090 | buf = next; | |||
2091 | } else if (__kmp_match_str("warnings", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2092 | set_warnings(TRUE(!0)); | |||
2093 | buf = next; | |||
2094 | } else if (__kmp_match_str("nowarnings", buf, | |||
2095 | CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2096 | set_warnings(FALSE0); | |||
2097 | buf = next; | |||
2098 | } else if (__kmp_match_str("respect", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2099 | set_respect(TRUE(!0)); | |||
2100 | buf = next; | |||
2101 | } else if (__kmp_match_str("norespect", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2102 | set_respect(FALSE0); | |||
2103 | buf = next; | |||
2104 | } else if (__kmp_match_str("duplicates", buf, | |||
2105 | CCAST(const char **, &next)const_cast<const char **>(&next)) || | |||
2106 | __kmp_match_str("dups", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2107 | set_dups(TRUE)_set_param(dups, *out_dups, (!0)); | |||
2108 | buf = next; | |||
2109 | } else if (__kmp_match_str("noduplicates", buf, | |||
2110 | CCAST(const char **, &next)const_cast<const char **>(&next)) || | |||
2111 | __kmp_match_str("nodups", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2112 | set_dups(FALSE)_set_param(dups, *out_dups, 0); | |||
2113 | buf = next; | |||
2114 | } else if (__kmp_match_str("granularity", buf, | |||
2115 | CCAST(const char **, &next)const_cast<const char **>(&next)) || | |||
2116 | __kmp_match_str("gran", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2117 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
2118 | if (*next != '=') { | |||
2119 | EMIT_WARN(TRUE(!0), (AffInvalidParam, name, start)); | |||
2120 | continue; | |||
2121 | } | |||
2122 | next++; // skip '=' | |||
2123 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
2124 | ||||
2125 | buf = next; | |||
2126 | if (__kmp_match_str("fine", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2127 | set_gran(affinity_gran_fine, -1){ if (gran == 0) { *out_gran = affinity_gran_fine; *out_gran_levels = -1; } else { EMIT_WARN(0, (AffParamDefined, name, start)); } ++gran; }; | |||
2128 | buf = next; | |||
2129 | } else if (__kmp_match_str("thread", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2130 | set_gran(affinity_gran_thread, -1){ if (gran == 0) { *out_gran = affinity_gran_thread; *out_gran_levels = -1; } else { EMIT_WARN(0, (AffParamDefined, name, start)); } ++gran; }; | |||
2131 | buf = next; | |||
2132 | } else if (__kmp_match_str("core", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2133 | set_gran(affinity_gran_core, -1){ if (gran == 0) { *out_gran = affinity_gran_core; *out_gran_levels = -1; } else { EMIT_WARN(0, (AffParamDefined, name, start)); } ++gran; }; | |||
2134 | buf = next; | |||
2135 | #if KMP_USE_HWLOC0 | |||
2136 | } else if (__kmp_match_str("tile", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2137 | set_gran(affinity_gran_tile, -1){ if (gran == 0) { *out_gran = affinity_gran_tile; *out_gran_levels = -1; } else { EMIT_WARN(0, (AffParamDefined, name, start)); } ++gran; }; | |||
2138 | buf = next; | |||
2139 | #endif | |||
2140 | } else if (__kmp_match_str("package", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2141 | set_gran(affinity_gran_package, -1){ if (gran == 0) { *out_gran = affinity_gran_package; *out_gran_levels = -1; } else { EMIT_WARN(0, (AffParamDefined, name, start)); } ++gran; }; | |||
2142 | buf = next; | |||
2143 | } else if (__kmp_match_str("node", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2144 | set_gran(affinity_gran_node, -1){ if (gran == 0) { *out_gran = affinity_gran_node; *out_gran_levels = -1; } else { EMIT_WARN(0, (AffParamDefined, name, start)); } ++gran; }; | |||
2145 | buf = next; | |||
2146 | #if KMP_GROUP_AFFINITY0 | |||
2147 | } else if (__kmp_match_str("group", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2148 | set_gran(affinity_gran_group, -1){ if (gran == 0) { *out_gran = affinity_gran_group; *out_gran_levels = -1; } else { EMIT_WARN(0, (AffParamDefined, name, start)); } ++gran; }; | |||
2149 | buf = next; | |||
2150 | #endif /* KMP_GROUP AFFINITY */ | |||
2151 | } else if ((*buf >= '0') && (*buf <= '9')) { | |||
2152 | int n; | |||
2153 | next = buf; | |||
2154 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
2155 | n = __kmp_str_to_int(buf, *next); | |||
2156 | KMP_ASSERT(n >= 0)if (!(n >= 0)) { __kmp_debug_assert("n >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2156); }; | |||
2157 | buf = next; | |||
2158 | set_gran(affinity_gran_default, n){ if (gran == 0) { *out_gran = affinity_gran_default; *out_gran_levels = n; } else { EMIT_WARN(0, (AffParamDefined, name, start)); } ++gran; }; | |||
2159 | } else { | |||
2160 | EMIT_WARN(TRUE(!0), (AffInvalidParam, name, start)); | |||
2161 | continue; | |||
2162 | } | |||
2163 | } else if (__kmp_match_str("proclist", buf, CCAST(const char **, &next)const_cast<const char **>(&next))) { | |||
2164 | char *temp_proclist; | |||
2165 | ||||
2166 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
2167 | if (*next != '=') { | |||
2168 | EMIT_WARN(TRUE(!0), (AffInvalidParam, name, start)); | |||
2169 | continue; | |||
2170 | } | |||
2171 | next++; // skip '=' | |||
2172 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
2173 | if (*next != '[') { | |||
2174 | EMIT_WARN(TRUE(!0), (AffInvalidParam, name, start)); | |||
2175 | continue; | |||
2176 | } | |||
2177 | next++; // skip '[' | |||
2178 | buf = next; | |||
2179 | if (!__kmp_parse_affinity_proc_id_list( | |||
2180 | name, buf, CCAST(const char **, &next)const_cast<const char **>(&next), &temp_proclist)) { | |||
2181 | // warning already emitted. | |||
2182 | SKIP_TO(next, ']'){ while (*(next) != '\0' && *(next) != (']')) (next)++ ; }; | |||
2183 | if (*next == ']') | |||
2184 | next++; | |||
2185 | SKIP_TO(next, ','){ while (*(next) != '\0' && *(next) != (',')) (next)++ ; }; | |||
2186 | if (*next == ',') | |||
2187 | next++; | |||
2188 | buf = next; | |||
2189 | continue; | |||
2190 | } | |||
2191 | if (*next != ']') { | |||
2192 | EMIT_WARN(TRUE(!0), (AffInvalidParam, name, start)); | |||
2193 | continue; | |||
2194 | } | |||
2195 | next++; // skip ']' | |||
2196 | set_proclist(temp_proclist)_set_param(proclist, *out_proclist, temp_proclist); | |||
2197 | } else if ((*buf >= '0') && (*buf <= '9')) { | |||
2198 | // Parse integer numbers -- permute and offset. | |||
2199 | int n; | |||
2200 | next = buf; | |||
2201 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
2202 | n = __kmp_str_to_int(buf, *next); | |||
2203 | KMP_ASSERT(n >= 0)if (!(n >= 0)) { __kmp_debug_assert("n >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2203); }; | |||
2204 | buf = next; | |||
2205 | if (count < 2) { | |||
2206 | number[count] = n; | |||
2207 | } else { | |||
2208 | KMP_WARNING(AffManyParams, name, start)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffManyParams , name, start), __kmp_msg_null); | |||
2209 | } | |||
2210 | ++count; | |||
2211 | } else { | |||
2212 | EMIT_WARN(TRUE(!0), (AffInvalidParam, name, start)); | |||
2213 | continue; | |||
2214 | } | |||
2215 | ||||
2216 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
2217 | if (*next == ',') { | |||
2218 | next++; | |||
2219 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
2220 | } else if (*next != '\0') { | |||
2221 | const char *temp = next; | |||
2222 | EMIT_WARN(TRUE(!0), (ParseExtraCharsWarn, name, temp)); | |||
2223 | continue; | |||
2224 | } | |||
2225 | buf = next; | |||
2226 | } // while | |||
2227 | ||||
2228 | #undef EMIT_WARN | |||
2229 | #undef _set_param | |||
2230 | #undef set_type | |||
2231 | #undef set_verbose | |||
2232 | #undef set_warnings | |||
2233 | #undef set_respect | |||
2234 | #undef set_granularity | |||
2235 | ||||
2236 | __kmp_str_free(&buffer); | |||
2237 | ||||
2238 | if (proclist) { | |||
2239 | if (!type) { | |||
2240 | KMP_WARNING(AffProcListNoType, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffProcListNoType , name), __kmp_msg_null); | |||
2241 | *out_type = affinity_explicit; | |||
2242 | #if OMP_40_ENABLED(50 >= 40) | |||
2243 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; | |||
2244 | #endif | |||
2245 | } else if (*out_type != affinity_explicit) { | |||
2246 | KMP_WARNING(AffProcListNotExplicit, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffProcListNotExplicit , name), __kmp_msg_null); | |||
2247 | KMP_ASSERT(*out_proclist != NULL)if (!(*out_proclist != __null)) { __kmp_debug_assert("*out_proclist != NULL" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2247); }; | |||
2248 | KMP_INTERNAL_FREE(*out_proclist)free(*out_proclist); | |||
2249 | *out_proclist = NULL__null; | |||
2250 | } | |||
2251 | } | |||
2252 | switch (*out_type) { | |||
2253 | case affinity_logical: | |||
2254 | case affinity_physical: { | |||
2255 | if (count > 0) { | |||
2256 | *out_offset = number[0]; | |||
2257 | } | |||
2258 | if (count > 1) { | |||
2259 | KMP_WARNING(AffManyParamsForLogic, name, number[1])__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffManyParamsForLogic , name, number[1]), __kmp_msg_null); | |||
2260 | } | |||
2261 | } break; | |||
2262 | case affinity_balanced: { | |||
2263 | if (count > 0) { | |||
2264 | *out_compact = number[0]; | |||
2265 | } | |||
2266 | if (count > 1) { | |||
2267 | *out_offset = number[1]; | |||
2268 | } | |||
2269 | ||||
2270 | if (__kmp_affinity_gran == affinity_gran_default) { | |||
2271 | #if KMP_MIC_SUPPORTED((0 || 1) && (1 || 0)) | |||
2272 | if (__kmp_mic_type != non_mic) { | |||
2273 | if (__kmp_affinity_verbose || __kmp_affinity_warnings) { | |||
2274 | KMP_WARNING(AffGranUsing, "KMP_AFFINITY", "fine")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffGranUsing , "KMP_AFFINITY", "fine"), __kmp_msg_null); | |||
2275 | } | |||
2276 | __kmp_affinity_gran = affinity_gran_fine; | |||
2277 | } else | |||
2278 | #endif | |||
2279 | { | |||
2280 | if (__kmp_affinity_verbose || __kmp_affinity_warnings) { | |||
2281 | KMP_WARNING(AffGranUsing, "KMP_AFFINITY", "core")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffGranUsing , "KMP_AFFINITY", "core"), __kmp_msg_null); | |||
2282 | } | |||
2283 | __kmp_affinity_gran = affinity_gran_core; | |||
2284 | } | |||
2285 | } | |||
2286 | } break; | |||
2287 | case affinity_scatter: | |||
2288 | case affinity_compact: { | |||
2289 | if (count > 0) { | |||
2290 | *out_compact = number[0]; | |||
2291 | } | |||
2292 | if (count > 1) { | |||
2293 | *out_offset = number[1]; | |||
2294 | } | |||
2295 | } break; | |||
2296 | case affinity_explicit: { | |||
2297 | if (*out_proclist == NULL__null) { | |||
2298 | KMP_WARNING(AffNoProcList, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffNoProcList , name), __kmp_msg_null); | |||
2299 | __kmp_affinity_type = affinity_none; | |||
2300 | } | |||
2301 | if (count > 0) { | |||
2302 | KMP_WARNING(AffNoParam, name, "explicit")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffNoParam , name, "explicit"), __kmp_msg_null); | |||
2303 | } | |||
2304 | } break; | |||
2305 | case affinity_none: { | |||
2306 | if (count > 0) { | |||
2307 | KMP_WARNING(AffNoParam, name, "none")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffNoParam , name, "none"), __kmp_msg_null); | |||
2308 | } | |||
2309 | } break; | |||
2310 | case affinity_disabled: { | |||
2311 | if (count > 0) { | |||
2312 | KMP_WARNING(AffNoParam, name, "disabled")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffNoParam , name, "disabled"), __kmp_msg_null); | |||
2313 | } | |||
2314 | } break; | |||
2315 | case affinity_default: { | |||
2316 | if (count > 0) { | |||
2317 | KMP_WARNING(AffNoParam, name, "default")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffNoParam , name, "default"), __kmp_msg_null); | |||
2318 | } | |||
2319 | } break; | |||
2320 | default: { KMP_ASSERT(0)if (!(0)) { __kmp_debug_assert("0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2320); }; } | |||
2321 | } | |||
2322 | } // __kmp_parse_affinity_env | |||
2323 | ||||
2324 | static void __kmp_stg_parse_affinity(char const *name, char const *value, | |||
2325 | void *data) { | |||
2326 | kmp_setting_t **rivals = (kmp_setting_t **)data; | |||
2327 | int rc; | |||
2328 | ||||
2329 | rc = __kmp_stg_check_rivals(name, value, rivals); | |||
2330 | if (rc) { | |||
2331 | return; | |||
2332 | } | |||
2333 | ||||
2334 | __kmp_parse_affinity_env(name, value, &__kmp_affinity_type, | |||
2335 | &__kmp_affinity_proclist, &__kmp_affinity_verbose, | |||
2336 | &__kmp_affinity_warnings, | |||
2337 | &__kmp_affinity_respect_mask, &__kmp_affinity_gran, | |||
2338 | &__kmp_affinity_gran_levels, &__kmp_affinity_dups, | |||
2339 | &__kmp_affinity_compact, &__kmp_affinity_offset); | |||
2340 | ||||
2341 | } // __kmp_stg_parse_affinity | |||
2342 | ||||
2343 | static void __kmp_stg_print_affinity(kmp_str_buf_t *buffer, char const *name, | |||
2344 | void *data) { | |||
2345 | if (__kmp_env_format) { | |||
2346 | KMP_STR_BUF_PRINT_NAME_EX(name)__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
2347 | } else { | |||
2348 | __kmp_str_buf_print(buffer, " %s='", name); | |||
2349 | } | |||
2350 | if (__kmp_affinity_verbose) { | |||
2351 | __kmp_str_buf_print(buffer, "%s,", "verbose"); | |||
2352 | } else { | |||
2353 | __kmp_str_buf_print(buffer, "%s,", "noverbose"); | |||
2354 | } | |||
2355 | if (__kmp_affinity_warnings) { | |||
2356 | __kmp_str_buf_print(buffer, "%s,", "warnings"); | |||
2357 | } else { | |||
2358 | __kmp_str_buf_print(buffer, "%s,", "nowarnings"); | |||
2359 | } | |||
2360 | if (KMP_AFFINITY_CAPABLE()(__kmp_affin_mask_size > 0)) { | |||
2361 | if (__kmp_affinity_respect_mask) { | |||
2362 | __kmp_str_buf_print(buffer, "%s,", "respect"); | |||
2363 | } else { | |||
2364 | __kmp_str_buf_print(buffer, "%s,", "norespect"); | |||
2365 | } | |||
2366 | switch (__kmp_affinity_gran) { | |||
2367 | case affinity_gran_default: | |||
2368 | __kmp_str_buf_print(buffer, "%s", "granularity=default,"); | |||
2369 | break; | |||
2370 | case affinity_gran_fine: | |||
2371 | __kmp_str_buf_print(buffer, "%s", "granularity=fine,"); | |||
2372 | break; | |||
2373 | case affinity_gran_thread: | |||
2374 | __kmp_str_buf_print(buffer, "%s", "granularity=thread,"); | |||
2375 | break; | |||
2376 | case affinity_gran_core: | |||
2377 | __kmp_str_buf_print(buffer, "%s", "granularity=core,"); | |||
2378 | break; | |||
2379 | case affinity_gran_package: | |||
2380 | __kmp_str_buf_print(buffer, "%s", "granularity=package,"); | |||
2381 | break; | |||
2382 | case affinity_gran_node: | |||
2383 | __kmp_str_buf_print(buffer, "%s", "granularity=node,"); | |||
2384 | break; | |||
2385 | #if KMP_GROUP_AFFINITY0 | |||
2386 | case affinity_gran_group: | |||
2387 | __kmp_str_buf_print(buffer, "%s", "granularity=group,"); | |||
2388 | break; | |||
2389 | #endif /* KMP_GROUP_AFFINITY */ | |||
2390 | } | |||
2391 | } | |||
2392 | if (!KMP_AFFINITY_CAPABLE()(__kmp_affin_mask_size > 0)) { | |||
2393 | __kmp_str_buf_print(buffer, "%s", "disabled"); | |||
2394 | } else | |||
2395 | switch (__kmp_affinity_type) { | |||
2396 | case affinity_none: | |||
2397 | __kmp_str_buf_print(buffer, "%s", "none"); | |||
2398 | break; | |||
2399 | case affinity_physical: | |||
2400 | __kmp_str_buf_print(buffer, "%s,%d", "physical", __kmp_affinity_offset); | |||
2401 | break; | |||
2402 | case affinity_logical: | |||
2403 | __kmp_str_buf_print(buffer, "%s,%d", "logical", __kmp_affinity_offset); | |||
2404 | break; | |||
2405 | case affinity_compact: | |||
2406 | __kmp_str_buf_print(buffer, "%s,%d,%d", "compact", __kmp_affinity_compact, | |||
2407 | __kmp_affinity_offset); | |||
2408 | break; | |||
2409 | case affinity_scatter: | |||
2410 | __kmp_str_buf_print(buffer, "%s,%d,%d", "scatter", __kmp_affinity_compact, | |||
2411 | __kmp_affinity_offset); | |||
2412 | break; | |||
2413 | case affinity_explicit: | |||
2414 | __kmp_str_buf_print(buffer, "%s=[%s],%s", "proclist", | |||
2415 | __kmp_affinity_proclist, "explicit"); | |||
2416 | break; | |||
2417 | case affinity_balanced: | |||
2418 | __kmp_str_buf_print(buffer, "%s,%d,%d", "balanced", | |||
2419 | __kmp_affinity_compact, __kmp_affinity_offset); | |||
2420 | break; | |||
2421 | case affinity_disabled: | |||
2422 | __kmp_str_buf_print(buffer, "%s", "disabled"); | |||
2423 | break; | |||
2424 | case affinity_default: | |||
2425 | __kmp_str_buf_print(buffer, "%s", "default"); | |||
2426 | break; | |||
2427 | default: | |||
2428 | __kmp_str_buf_print(buffer, "%s", "<unknown>"); | |||
2429 | break; | |||
2430 | } | |||
2431 | __kmp_str_buf_print(buffer, "'\n"); | |||
2432 | } //__kmp_stg_print_affinity | |||
2433 | ||||
2434 | #ifdef KMP_GOMP_COMPAT | |||
2435 | ||||
2436 | static void __kmp_stg_parse_gomp_cpu_affinity(char const *name, | |||
2437 | char const *value, void *data) { | |||
2438 | const char *next = NULL__null; | |||
2439 | char *temp_proclist; | |||
2440 | kmp_setting_t **rivals = (kmp_setting_t **)data; | |||
2441 | int rc; | |||
2442 | ||||
2443 | rc = __kmp_stg_check_rivals(name, value, rivals); | |||
2444 | if (rc) { | |||
2445 | return; | |||
2446 | } | |||
2447 | ||||
2448 | if (TCR_4(__kmp_init_middle)(__kmp_init_middle)) { | |||
2449 | KMP_WARNING(EnvMiddleWarn, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvMiddleWarn , name), __kmp_msg_null); | |||
2450 | __kmp_env_toPrint(name, 0); | |||
2451 | return; | |||
2452 | } | |||
2453 | ||||
2454 | __kmp_env_toPrint(name, 1); | |||
2455 | ||||
2456 | if (__kmp_parse_affinity_proc_id_list(name, value, &next, &temp_proclist)) { | |||
2457 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
2458 | if (*next == '\0') { | |||
2459 | // GOMP_CPU_AFFINITY => granularity=fine,explicit,proclist=... | |||
2460 | __kmp_affinity_proclist = temp_proclist; | |||
2461 | __kmp_affinity_type = affinity_explicit; | |||
2462 | __kmp_affinity_gran = affinity_gran_fine; | |||
2463 | #if OMP_40_ENABLED(50 >= 40) | |||
2464 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; | |||
2465 | #endif | |||
2466 | } else { | |||
2467 | KMP_WARNING(AffSyntaxError, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffSyntaxError , name), __kmp_msg_null); | |||
2468 | if (temp_proclist != NULL__null) { | |||
2469 | KMP_INTERNAL_FREE((void *)temp_proclist)free((void *)temp_proclist); | |||
2470 | } | |||
2471 | } | |||
2472 | } else { | |||
2473 | // Warning already emitted | |||
2474 | __kmp_affinity_type = affinity_none; | |||
2475 | #if OMP_40_ENABLED(50 >= 40) | |||
2476 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; | |||
2477 | #endif | |||
2478 | } | |||
2479 | } // __kmp_stg_parse_gomp_cpu_affinity | |||
2480 | ||||
2481 | #endif /* KMP_GOMP_COMPAT */ | |||
2482 | ||||
2483 | #if OMP_40_ENABLED(50 >= 40) | |||
2484 | ||||
2485 | /*----------------------------------------------------------------------------- | |||
2486 | The OMP_PLACES proc id list parser. Here is the grammar: | |||
2487 | ||||
2488 | place_list := place | |||
2489 | place_list := place , place_list | |||
2490 | place := num | |||
2491 | place := place : num | |||
2492 | place := place : num : signed | |||
2493 | place := { subplacelist } | |||
2494 | place := ! place // (lowest priority) | |||
2495 | subplace_list := subplace | |||
2496 | subplace_list := subplace , subplace_list | |||
2497 | subplace := num | |||
2498 | subplace := num : num | |||
2499 | subplace := num : num : signed | |||
2500 | signed := num | |||
2501 | signed := + signed | |||
2502 | signed := - signed | |||
2503 | -----------------------------------------------------------------------------*/ | |||
2504 | ||||
2505 | static int __kmp_parse_subplace_list(const char *var, const char **scan) { | |||
2506 | const char *next; | |||
2507 | ||||
2508 | for (;;) { | |||
2509 | int start, count, stride; | |||
2510 | ||||
2511 | // | |||
2512 | // Read in the starting proc id | |||
2513 | // | |||
2514 | SKIP_WS(*scan){ while (*(*scan) == ' ' || *(*scan) == '\t') (*scan)++; }; | |||
2515 | if ((**scan < '0') || (**scan > '9')) { | |||
2516 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2517 | return FALSE0; | |||
2518 | } | |||
2519 | next = *scan; | |||
2520 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
2521 | start = __kmp_str_to_int(*scan, *next); | |||
2522 | KMP_ASSERT(start >= 0)if (!(start >= 0)) { __kmp_debug_assert("start >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2522); }; | |||
2523 | *scan = next; | |||
2524 | ||||
2525 | // valid follow sets are ',' ':' and '}' | |||
2526 | SKIP_WS(*scan){ while (*(*scan) == ' ' || *(*scan) == '\t') (*scan)++; }; | |||
2527 | if (**scan == '}') { | |||
2528 | break; | |||
2529 | } | |||
2530 | if (**scan == ',') { | |||
2531 | (*scan)++; // skip ',' | |||
2532 | continue; | |||
2533 | } | |||
2534 | if (**scan != ':') { | |||
2535 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2536 | return FALSE0; | |||
2537 | } | |||
2538 | (*scan)++; // skip ':' | |||
2539 | ||||
2540 | // Read count parameter | |||
2541 | SKIP_WS(*scan){ while (*(*scan) == ' ' || *(*scan) == '\t') (*scan)++; }; | |||
2542 | if ((**scan < '0') || (**scan > '9')) { | |||
2543 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2544 | return FALSE0; | |||
2545 | } | |||
2546 | next = *scan; | |||
2547 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
2548 | count = __kmp_str_to_int(*scan, *next); | |||
2549 | KMP_ASSERT(count >= 0)if (!(count >= 0)) { __kmp_debug_assert("count >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2549); }; | |||
2550 | *scan = next; | |||
2551 | ||||
2552 | // valid follow sets are ',' ':' and '}' | |||
2553 | SKIP_WS(*scan){ while (*(*scan) == ' ' || *(*scan) == '\t') (*scan)++; }; | |||
2554 | if (**scan == '}') { | |||
2555 | break; | |||
2556 | } | |||
2557 | if (**scan == ',') { | |||
2558 | (*scan)++; // skip ',' | |||
2559 | continue; | |||
2560 | } | |||
2561 | if (**scan != ':') { | |||
2562 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2563 | return FALSE0; | |||
2564 | } | |||
2565 | (*scan)++; // skip ':' | |||
2566 | ||||
2567 | // Read stride parameter | |||
2568 | int sign = +1; | |||
2569 | for (;;) { | |||
2570 | SKIP_WS(*scan){ while (*(*scan) == ' ' || *(*scan) == '\t') (*scan)++; }; | |||
2571 | if (**scan == '+') { | |||
2572 | (*scan)++; // skip '+' | |||
2573 | continue; | |||
2574 | } | |||
2575 | if (**scan == '-') { | |||
2576 | sign *= -1; | |||
2577 | (*scan)++; // skip '-' | |||
2578 | continue; | |||
2579 | } | |||
2580 | break; | |||
2581 | } | |||
2582 | SKIP_WS(*scan){ while (*(*scan) == ' ' || *(*scan) == '\t') (*scan)++; }; | |||
2583 | if ((**scan < '0') || (**scan > '9')) { | |||
2584 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2585 | return FALSE0; | |||
2586 | } | |||
2587 | next = *scan; | |||
2588 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
2589 | stride = __kmp_str_to_int(*scan, *next); | |||
2590 | KMP_ASSERT(stride >= 0)if (!(stride >= 0)) { __kmp_debug_assert("stride >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2590); }; | |||
2591 | *scan = next; | |||
2592 | stride *= sign; | |||
2593 | ||||
2594 | // valid follow sets are ',' and '}' | |||
2595 | SKIP_WS(*scan){ while (*(*scan) == ' ' || *(*scan) == '\t') (*scan)++; }; | |||
2596 | if (**scan == '}') { | |||
2597 | break; | |||
2598 | } | |||
2599 | if (**scan == ',') { | |||
2600 | (*scan)++; // skip ',' | |||
2601 | continue; | |||
2602 | } | |||
2603 | ||||
2604 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2605 | return FALSE0; | |||
2606 | } | |||
2607 | return TRUE(!0); | |||
2608 | } | |||
2609 | ||||
2610 | static int __kmp_parse_place(const char *var, const char **scan) { | |||
2611 | const char *next; | |||
2612 | ||||
2613 | // valid follow sets are '{' '!' and num | |||
2614 | SKIP_WS(*scan){ while (*(*scan) == ' ' || *(*scan) == '\t') (*scan)++; }; | |||
2615 | if (**scan == '{') { | |||
2616 | (*scan)++; // skip '{' | |||
2617 | if (!__kmp_parse_subplace_list(var, scan)) { | |||
2618 | return FALSE0; | |||
2619 | } | |||
2620 | if (**scan != '}') { | |||
2621 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2622 | return FALSE0; | |||
2623 | } | |||
2624 | (*scan)++; // skip '}' | |||
2625 | } else if (**scan == '!') { | |||
2626 | (*scan)++; // skip '!' | |||
2627 | return __kmp_parse_place(var, scan); //'!' has lower precedence than ':' | |||
2628 | } else if ((**scan >= '0') && (**scan <= '9')) { | |||
2629 | next = *scan; | |||
2630 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
2631 | int proc = __kmp_str_to_int(*scan, *next); | |||
2632 | KMP_ASSERT(proc >= 0)if (!(proc >= 0)) { __kmp_debug_assert("proc >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2632); }; | |||
2633 | *scan = next; | |||
2634 | } else { | |||
2635 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2636 | return FALSE0; | |||
2637 | } | |||
2638 | return TRUE(!0); | |||
2639 | } | |||
2640 | ||||
2641 | static int __kmp_parse_place_list(const char *var, const char *env, | |||
2642 | char **place_list) { | |||
2643 | const char *scan = env; | |||
2644 | const char *next = scan; | |||
2645 | ||||
2646 | for (;;) { | |||
2647 | int count, stride; | |||
2648 | ||||
2649 | if (!__kmp_parse_place(var, &scan)) { | |||
2650 | return FALSE0; | |||
2651 | } | |||
2652 | ||||
2653 | // valid follow sets are ',' ':' and EOL | |||
2654 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
2655 | if (*scan == '\0') { | |||
2656 | break; | |||
2657 | } | |||
2658 | if (*scan == ',') { | |||
2659 | scan++; // skip ',' | |||
2660 | continue; | |||
2661 | } | |||
2662 | if (*scan != ':') { | |||
2663 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2664 | return FALSE0; | |||
2665 | } | |||
2666 | scan++; // skip ':' | |||
2667 | ||||
2668 | // Read count parameter | |||
2669 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
2670 | if ((*scan < '0') || (*scan > '9')) { | |||
2671 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2672 | return FALSE0; | |||
2673 | } | |||
2674 | next = scan; | |||
2675 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
2676 | count = __kmp_str_to_int(scan, *next); | |||
2677 | KMP_ASSERT(count >= 0)if (!(count >= 0)) { __kmp_debug_assert("count >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2677); }; | |||
2678 | scan = next; | |||
2679 | ||||
2680 | // valid follow sets are ',' ':' and EOL | |||
2681 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
2682 | if (*scan == '\0') { | |||
2683 | break; | |||
2684 | } | |||
2685 | if (*scan == ',') { | |||
2686 | scan++; // skip ',' | |||
2687 | continue; | |||
2688 | } | |||
2689 | if (*scan != ':') { | |||
2690 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2691 | return FALSE0; | |||
2692 | } | |||
2693 | scan++; // skip ':' | |||
2694 | ||||
2695 | // Read stride parameter | |||
2696 | int sign = +1; | |||
2697 | for (;;) { | |||
2698 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
2699 | if (*scan == '+') { | |||
2700 | scan++; // skip '+' | |||
2701 | continue; | |||
2702 | } | |||
2703 | if (*scan == '-') { | |||
2704 | sign *= -1; | |||
2705 | scan++; // skip '-' | |||
2706 | continue; | |||
2707 | } | |||
2708 | break; | |||
2709 | } | |||
2710 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
2711 | if ((*scan < '0') || (*scan > '9')) { | |||
2712 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2713 | return FALSE0; | |||
2714 | } | |||
2715 | next = scan; | |||
2716 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
2717 | stride = __kmp_str_to_int(scan, *next); | |||
2718 | KMP_ASSERT(stride >= 0)if (!(stride >= 0)) { __kmp_debug_assert("stride >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2718); }; | |||
2719 | scan = next; | |||
2720 | stride *= sign; | |||
2721 | ||||
2722 | // valid follow sets are ',' and EOL | |||
2723 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
2724 | if (*scan == '\0') { | |||
2725 | break; | |||
2726 | } | |||
2727 | if (*scan == ',') { | |||
2728 | scan++; // skip ',' | |||
2729 | continue; | |||
2730 | } | |||
2731 | ||||
2732 | KMP_WARNING(SyntaxErrorUsing, var, "\"threads\"")__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , var, "\"threads\""), __kmp_msg_null); | |||
2733 | return FALSE0; | |||
2734 | } | |||
2735 | ||||
2736 | { | |||
2737 | int len = scan - env; | |||
2738 | char *retlist = (char *)__kmp_allocate((len + 1) * sizeof(char))___kmp_allocate(((len + 1) * sizeof(char)), "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2738); | |||
2739 | KMP_MEMCPY_S(retlist, (len + 1) * sizeof(char), env, len * sizeof(char))memcpy(retlist, env, len * sizeof(char)); | |||
2740 | retlist[len] = '\0'; | |||
2741 | *place_list = retlist; | |||
2742 | } | |||
2743 | return TRUE(!0); | |||
2744 | } | |||
2745 | ||||
2746 | static void __kmp_stg_parse_places(char const *name, char const *value, | |||
2747 | void *data) { | |||
2748 | int count; | |||
2749 | const char *scan = value; | |||
2750 | const char *next = scan; | |||
2751 | const char *kind = "\"threads\""; | |||
2752 | kmp_setting_t **rivals = (kmp_setting_t **)data; | |||
2753 | int rc; | |||
2754 | ||||
2755 | rc = __kmp_stg_check_rivals(name, value, rivals); | |||
2756 | if (rc) { | |||
2757 | return; | |||
2758 | } | |||
2759 | ||||
2760 | // If OMP_PROC_BIND is not specified but OMP_PLACES is, | |||
2761 | // then let OMP_PROC_BIND default to true. | |||
2762 | if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) { | |||
2763 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_true; | |||
2764 | } | |||
2765 | ||||
2766 | //__kmp_affinity_num_places = 0; | |||
2767 | ||||
2768 | if (__kmp_match_str("threads", scan, &next)) { | |||
2769 | scan = next; | |||
2770 | __kmp_affinity_type = affinity_compact; | |||
2771 | __kmp_affinity_gran = affinity_gran_thread; | |||
2772 | __kmp_affinity_dups = FALSE0; | |||
2773 | kind = "\"threads\""; | |||
2774 | } else if (__kmp_match_str("cores", scan, &next)) { | |||
2775 | scan = next; | |||
2776 | __kmp_affinity_type = affinity_compact; | |||
2777 | __kmp_affinity_gran = affinity_gran_core; | |||
2778 | __kmp_affinity_dups = FALSE0; | |||
2779 | kind = "\"cores\""; | |||
2780 | #if KMP_USE_HWLOC0 | |||
2781 | } else if (__kmp_match_str("tiles", scan, &next)) { | |||
2782 | scan = next; | |||
2783 | __kmp_affinity_type = affinity_compact; | |||
2784 | __kmp_affinity_gran = affinity_gran_tile; | |||
2785 | __kmp_affinity_dups = FALSE0; | |||
2786 | kind = "\"tiles\""; | |||
2787 | #endif | |||
2788 | } else if (__kmp_match_str("sockets", scan, &next)) { | |||
2789 | scan = next; | |||
2790 | __kmp_affinity_type = affinity_compact; | |||
2791 | __kmp_affinity_gran = affinity_gran_package; | |||
2792 | __kmp_affinity_dups = FALSE0; | |||
2793 | kind = "\"sockets\""; | |||
2794 | } else { | |||
2795 | if (__kmp_affinity_proclist != NULL__null) { | |||
2796 | KMP_INTERNAL_FREE((void *)__kmp_affinity_proclist)free((void *)__kmp_affinity_proclist); | |||
2797 | __kmp_affinity_proclist = NULL__null; | |||
2798 | } | |||
2799 | if (__kmp_parse_place_list(name, value, &__kmp_affinity_proclist)) { | |||
2800 | __kmp_affinity_type = affinity_explicit; | |||
2801 | __kmp_affinity_gran = affinity_gran_fine; | |||
2802 | __kmp_affinity_dups = FALSE0; | |||
2803 | if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) { | |||
2804 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_true; | |||
2805 | } | |||
2806 | } | |||
2807 | return; | |||
2808 | } | |||
2809 | ||||
2810 | if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default) { | |||
2811 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_true; | |||
2812 | } | |||
2813 | ||||
2814 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
2815 | if (*scan == '\0') { | |||
2816 | return; | |||
2817 | } | |||
2818 | ||||
2819 | // Parse option count parameter in parentheses | |||
2820 | if (*scan != '(') { | |||
2821 | KMP_WARNING(SyntaxErrorUsing, name, kind)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , name, kind), __kmp_msg_null); | |||
2822 | return; | |||
2823 | } | |||
2824 | scan++; // skip '(' | |||
2825 | ||||
2826 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
2827 | next = scan; | |||
2828 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
2829 | count = __kmp_str_to_int(scan, *next); | |||
2830 | KMP_ASSERT(count >= 0)if (!(count >= 0)) { __kmp_debug_assert("count >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 2830); }; | |||
2831 | scan = next; | |||
2832 | ||||
2833 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
2834 | if (*scan != ')') { | |||
2835 | KMP_WARNING(SyntaxErrorUsing, name, kind)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_SyntaxErrorUsing , name, kind), __kmp_msg_null); | |||
2836 | return; | |||
2837 | } | |||
2838 | scan++; // skip ')' | |||
2839 | ||||
2840 | SKIP_WS(scan){ while (*(scan) == ' ' || *(scan) == '\t') (scan)++; }; | |||
2841 | if (*scan != '\0') { | |||
2842 | KMP_WARNING(ParseExtraCharsWarn, name, scan)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_ParseExtraCharsWarn , name, scan), __kmp_msg_null); | |||
2843 | } | |||
2844 | __kmp_affinity_num_places = count; | |||
2845 | } | |||
2846 | ||||
2847 | static void __kmp_stg_print_places(kmp_str_buf_t *buffer, char const *name, | |||
2848 | void *data) { | |||
2849 | if (__kmp_env_format) { | |||
2850 | KMP_STR_BUF_PRINT_NAME__kmp_str_buf_print(buffer, " %s %s", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
2851 | } else { | |||
2852 | __kmp_str_buf_print(buffer, " %s", name); | |||
2853 | } | |||
2854 | if ((__kmp_nested_proc_bind.used == 0) || | |||
2855 | (__kmp_nested_proc_bind.bind_types == NULL__null) || | |||
2856 | (__kmp_nested_proc_bind.bind_types[0] == proc_bind_false)) { | |||
2857 | __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
2858 | } else if (__kmp_affinity_type == affinity_explicit) { | |||
2859 | if (__kmp_affinity_proclist != NULL__null) { | |||
2860 | __kmp_str_buf_print(buffer, "='%s'\n", __kmp_affinity_proclist); | |||
2861 | } else { | |||
2862 | __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
2863 | } | |||
2864 | } else if (__kmp_affinity_type == affinity_compact) { | |||
2865 | int num; | |||
2866 | if (__kmp_affinity_num_masks > 0) { | |||
2867 | num = __kmp_affinity_num_masks; | |||
2868 | } else if (__kmp_affinity_num_places > 0) { | |||
2869 | num = __kmp_affinity_num_places; | |||
2870 | } else { | |||
2871 | num = 0; | |||
2872 | } | |||
2873 | if (__kmp_affinity_gran == affinity_gran_thread) { | |||
2874 | if (num > 0) { | |||
2875 | __kmp_str_buf_print(buffer, "='threads(%d)'\n", num); | |||
2876 | } else { | |||
2877 | __kmp_str_buf_print(buffer, "='threads'\n"); | |||
2878 | } | |||
2879 | } else if (__kmp_affinity_gran == affinity_gran_core) { | |||
2880 | if (num > 0) { | |||
2881 | __kmp_str_buf_print(buffer, "='cores(%d)' \n", num); | |||
2882 | } else { | |||
2883 | __kmp_str_buf_print(buffer, "='cores'\n"); | |||
2884 | } | |||
2885 | #if KMP_USE_HWLOC0 | |||
2886 | } else if (__kmp_affinity_gran == affinity_gran_tile) { | |||
2887 | if (num > 0) { | |||
2888 | __kmp_str_buf_print(buffer, "='tiles(%d)' \n", num); | |||
2889 | } else { | |||
2890 | __kmp_str_buf_print(buffer, "='tiles'\n"); | |||
2891 | } | |||
2892 | #endif | |||
2893 | } else if (__kmp_affinity_gran == affinity_gran_package) { | |||
2894 | if (num > 0) { | |||
2895 | __kmp_str_buf_print(buffer, "='sockets(%d)'\n", num); | |||
2896 | } else { | |||
2897 | __kmp_str_buf_print(buffer, "='sockets'\n"); | |||
2898 | } | |||
2899 | } else { | |||
2900 | __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
2901 | } | |||
2902 | } else { | |||
2903 | __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
2904 | } | |||
2905 | } | |||
2906 | ||||
2907 | #endif /* OMP_40_ENABLED */ | |||
2908 | ||||
2909 | #if (!OMP_40_ENABLED(50 >= 40)) | |||
2910 | ||||
2911 | static void __kmp_stg_parse_proc_bind(char const *name, char const *value, | |||
2912 | void *data) { | |||
2913 | int enabled; | |||
2914 | kmp_setting_t **rivals = (kmp_setting_t **)data; | |||
2915 | int rc; | |||
2916 | ||||
2917 | rc = __kmp_stg_check_rivals(name, value, rivals); | |||
2918 | if (rc) { | |||
2919 | return; | |||
2920 | } | |||
2921 | ||||
2922 | // In OMP 3.1, OMP_PROC_BIND is strictly a boolean | |||
2923 | __kmp_stg_parse_bool(name, value, &enabled); | |||
2924 | if (enabled) { | |||
2925 | // OMP_PROC_BIND => granularity=fine,scatter on MIC | |||
2926 | // OMP_PROC_BIND => granularity=core,scatter elsewhere | |||
2927 | __kmp_affinity_type = affinity_scatter; | |||
2928 | #if KMP_MIC_SUPPORTED((0 || 1) && (1 || 0)) | |||
2929 | if (__kmp_mic_type != non_mic) | |||
2930 | __kmp_affinity_gran = affinity_gran_fine; | |||
2931 | else | |||
2932 | #endif | |||
2933 | __kmp_affinity_gran = affinity_gran_core; | |||
2934 | } else { | |||
2935 | __kmp_affinity_type = affinity_none; | |||
2936 | } | |||
2937 | } // __kmp_parse_proc_bind | |||
2938 | ||||
2939 | #endif /* if (! OMP_40_ENABLED) */ | |||
2940 | ||||
2941 | static void __kmp_stg_parse_topology_method(char const *name, char const *value, | |||
2942 | void *data) { | |||
2943 | if (__kmp_str_match("all", 1, value)) { | |||
2944 | __kmp_affinity_top_method = affinity_top_method_all; | |||
2945 | } | |||
2946 | #if KMP_USE_HWLOC0 | |||
2947 | else if (__kmp_str_match("hwloc", 1, value)) { | |||
2948 | __kmp_affinity_top_method = affinity_top_method_hwloc; | |||
2949 | } | |||
2950 | #endif | |||
2951 | #if KMP_ARCH_X860 || KMP_ARCH_X86_641 | |||
2952 | else if (__kmp_str_match("x2apic id", 9, value) || | |||
2953 | __kmp_str_match("x2apic_id", 9, value) || | |||
2954 | __kmp_str_match("x2apic-id", 9, value) || | |||
2955 | __kmp_str_match("x2apicid", 8, value) || | |||
2956 | __kmp_str_match("cpuid leaf 11", 13, value) || | |||
2957 | __kmp_str_match("cpuid_leaf_11", 13, value) || | |||
2958 | __kmp_str_match("cpuid-leaf-11", 13, value) || | |||
2959 | __kmp_str_match("cpuid leaf11", 12, value) || | |||
2960 | __kmp_str_match("cpuid_leaf11", 12, value) || | |||
2961 | __kmp_str_match("cpuid-leaf11", 12, value) || | |||
2962 | __kmp_str_match("cpuidleaf 11", 12, value) || | |||
2963 | __kmp_str_match("cpuidleaf_11", 12, value) || | |||
2964 | __kmp_str_match("cpuidleaf-11", 12, value) || | |||
2965 | __kmp_str_match("cpuidleaf11", 11, value) || | |||
2966 | __kmp_str_match("cpuid 11", 8, value) || | |||
2967 | __kmp_str_match("cpuid_11", 8, value) || | |||
2968 | __kmp_str_match("cpuid-11", 8, value) || | |||
2969 | __kmp_str_match("cpuid11", 7, value) || | |||
2970 | __kmp_str_match("leaf 11", 7, value) || | |||
2971 | __kmp_str_match("leaf_11", 7, value) || | |||
2972 | __kmp_str_match("leaf-11", 7, value) || | |||
2973 | __kmp_str_match("leaf11", 6, value)) { | |||
2974 | __kmp_affinity_top_method = affinity_top_method_x2apicid; | |||
2975 | } else if (__kmp_str_match("apic id", 7, value) || | |||
2976 | __kmp_str_match("apic_id", 7, value) || | |||
2977 | __kmp_str_match("apic-id", 7, value) || | |||
2978 | __kmp_str_match("apicid", 6, value) || | |||
2979 | __kmp_str_match("cpuid leaf 4", 12, value) || | |||
2980 | __kmp_str_match("cpuid_leaf_4", 12, value) || | |||
2981 | __kmp_str_match("cpuid-leaf-4", 12, value) || | |||
2982 | __kmp_str_match("cpuid leaf4", 11, value) || | |||
2983 | __kmp_str_match("cpuid_leaf4", 11, value) || | |||
2984 | __kmp_str_match("cpuid-leaf4", 11, value) || | |||
2985 | __kmp_str_match("cpuidleaf 4", 11, value) || | |||
2986 | __kmp_str_match("cpuidleaf_4", 11, value) || | |||
2987 | __kmp_str_match("cpuidleaf-4", 11, value) || | |||
2988 | __kmp_str_match("cpuidleaf4", 10, value) || | |||
2989 | __kmp_str_match("cpuid 4", 7, value) || | |||
2990 | __kmp_str_match("cpuid_4", 7, value) || | |||
2991 | __kmp_str_match("cpuid-4", 7, value) || | |||
2992 | __kmp_str_match("cpuid4", 6, value) || | |||
2993 | __kmp_str_match("leaf 4", 6, value) || | |||
2994 | __kmp_str_match("leaf_4", 6, value) || | |||
2995 | __kmp_str_match("leaf-4", 6, value) || | |||
2996 | __kmp_str_match("leaf4", 5, value)) { | |||
2997 | __kmp_affinity_top_method = affinity_top_method_apicid; | |||
2998 | } | |||
2999 | #endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */ | |||
3000 | else if (__kmp_str_match("/proc/cpuinfo", 2, value) || | |||
3001 | __kmp_str_match("cpuinfo", 5, value)) { | |||
3002 | __kmp_affinity_top_method = affinity_top_method_cpuinfo; | |||
3003 | } | |||
3004 | #if KMP_GROUP_AFFINITY0 | |||
3005 | else if (__kmp_str_match("group", 1, value)) { | |||
3006 | __kmp_affinity_top_method = affinity_top_method_group; | |||
3007 | } | |||
3008 | #endif /* KMP_GROUP_AFFINITY */ | |||
3009 | else if (__kmp_str_match("flat", 1, value)) { | |||
3010 | __kmp_affinity_top_method = affinity_top_method_flat; | |||
3011 | } else { | |||
3012 | KMP_WARNING(StgInvalidValue, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgInvalidValue , name, value), __kmp_msg_null); | |||
3013 | } | |||
3014 | } // __kmp_stg_parse_topology_method | |||
3015 | ||||
3016 | static void __kmp_stg_print_topology_method(kmp_str_buf_t *buffer, | |||
3017 | char const *name, void *data) { | |||
3018 | char const *value = NULL__null; | |||
3019 | ||||
3020 | switch (__kmp_affinity_top_method) { | |||
3021 | case affinity_top_method_default: | |||
3022 | value = "default"; | |||
3023 | break; | |||
3024 | ||||
3025 | case affinity_top_method_all: | |||
3026 | value = "all"; | |||
3027 | break; | |||
3028 | ||||
3029 | #if KMP_ARCH_X860 || KMP_ARCH_X86_641 | |||
3030 | case affinity_top_method_x2apicid: | |||
3031 | value = "x2APIC id"; | |||
3032 | break; | |||
3033 | ||||
3034 | case affinity_top_method_apicid: | |||
3035 | value = "APIC id"; | |||
3036 | break; | |||
3037 | #endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */ | |||
3038 | ||||
3039 | #if KMP_USE_HWLOC0 | |||
3040 | case affinity_top_method_hwloc: | |||
3041 | value = "hwloc"; | |||
3042 | break; | |||
3043 | #endif | |||
3044 | ||||
3045 | case affinity_top_method_cpuinfo: | |||
3046 | value = "cpuinfo"; | |||
3047 | break; | |||
3048 | ||||
3049 | #if KMP_GROUP_AFFINITY0 | |||
3050 | case affinity_top_method_group: | |||
3051 | value = "group"; | |||
3052 | break; | |||
3053 | #endif /* KMP_GROUP_AFFINITY */ | |||
3054 | ||||
3055 | case affinity_top_method_flat: | |||
3056 | value = "flat"; | |||
3057 | break; | |||
3058 | } | |||
3059 | ||||
3060 | if (value != NULL__null) { | |||
3061 | __kmp_stg_print_str(buffer, name, value); | |||
3062 | } | |||
3063 | } // __kmp_stg_print_topology_method | |||
3064 | ||||
3065 | #endif /* KMP_AFFINITY_SUPPORTED */ | |||
3066 | ||||
3067 | #if OMP_40_ENABLED(50 >= 40) | |||
3068 | ||||
3069 | // OMP_PROC_BIND / bind-var is functional on all 4.0 builds, including OS X* | |||
3070 | // OMP_PLACES / place-partition-var is not. | |||
3071 | static void __kmp_stg_parse_proc_bind(char const *name, char const *value, | |||
3072 | void *data) { | |||
3073 | kmp_setting_t **rivals = (kmp_setting_t **)data; | |||
3074 | int rc; | |||
3075 | ||||
3076 | rc = __kmp_stg_check_rivals(name, value, rivals); | |||
3077 | if (rc) { | |||
3078 | return; | |||
3079 | } | |||
3080 | ||||
3081 | // In OMP 4.0 OMP_PROC_BIND is a vector of proc_bind types. | |||
3082 | KMP_DEBUG_ASSERT((__kmp_nested_proc_bind.bind_types != NULL) &&if (!((__kmp_nested_proc_bind.bind_types != __null) && (__kmp_nested_proc_bind.used > 0))) { __kmp_debug_assert( "(__kmp_nested_proc_bind.bind_types != __null) && (__kmp_nested_proc_bind.used > 0)" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3083); } | |||
3083 | (__kmp_nested_proc_bind.used > 0))if (!((__kmp_nested_proc_bind.bind_types != __null) && (__kmp_nested_proc_bind.used > 0))) { __kmp_debug_assert( "(__kmp_nested_proc_bind.bind_types != __null) && (__kmp_nested_proc_bind.used > 0)" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3083); }; | |||
3084 | ||||
3085 | const char *buf = value; | |||
3086 | const char *next; | |||
3087 | int num; | |||
3088 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3089 | if ((*buf >= '0') && (*buf <= '9')) { | |||
3090 | next = buf; | |||
3091 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
3092 | num = __kmp_str_to_int(buf, *next); | |||
3093 | KMP_ASSERT(num >= 0)if (!(num >= 0)) { __kmp_debug_assert("num >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3093); }; | |||
3094 | buf = next; | |||
3095 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3096 | } else { | |||
3097 | num = -1; | |||
3098 | } | |||
3099 | ||||
3100 | next = buf; | |||
3101 | if (__kmp_match_str("disabled", buf, &next)) { | |||
3102 | buf = next; | |||
3103 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3104 | #if KMP_AFFINITY_SUPPORTED1 | |||
3105 | __kmp_affinity_type = affinity_disabled; | |||
3106 | #endif /* KMP_AFFINITY_SUPPORTED */ | |||
3107 | __kmp_nested_proc_bind.used = 1; | |||
3108 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; | |||
3109 | } else if ((num == (int)proc_bind_false) || | |||
3110 | __kmp_match_str("false", buf, &next)) { | |||
3111 | buf = next; | |||
3112 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3113 | #if KMP_AFFINITY_SUPPORTED1 | |||
3114 | __kmp_affinity_type = affinity_none; | |||
3115 | #endif /* KMP_AFFINITY_SUPPORTED */ | |||
3116 | __kmp_nested_proc_bind.used = 1; | |||
3117 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; | |||
3118 | } else if ((num == (int)proc_bind_true) || | |||
3119 | __kmp_match_str("true", buf, &next)) { | |||
3120 | buf = next; | |||
3121 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3122 | __kmp_nested_proc_bind.used = 1; | |||
3123 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_true; | |||
3124 | } else { | |||
3125 | // Count the number of values in the env var string | |||
3126 | const char *scan; | |||
3127 | int nelem = 1; | |||
3128 | for (scan = buf; *scan != '\0'; scan++) { | |||
3129 | if (*scan == ',') { | |||
3130 | nelem++; | |||
3131 | } | |||
3132 | } | |||
3133 | ||||
3134 | // Create / expand the nested proc_bind array as needed | |||
3135 | if (__kmp_nested_proc_bind.size < nelem) { | |||
3136 | __kmp_nested_proc_bind.bind_types = | |||
3137 | (kmp_proc_bind_t *)KMP_INTERNAL_REALLOC(realloc((__kmp_nested_proc_bind.bind_types), (sizeof(kmp_proc_bind_t ) * nelem)) | |||
3138 | __kmp_nested_proc_bind.bind_types,realloc((__kmp_nested_proc_bind.bind_types), (sizeof(kmp_proc_bind_t ) * nelem)) | |||
3139 | sizeof(kmp_proc_bind_t) * nelem)realloc((__kmp_nested_proc_bind.bind_types), (sizeof(kmp_proc_bind_t ) * nelem)); | |||
3140 | if (__kmp_nested_proc_bind.bind_types == NULL__null) { | |||
3141 | KMP_FATAL(MemoryAllocFailed)__kmp_fatal(__kmp_msg_format(kmp_i18n_msg_MemoryAllocFailed), __kmp_msg_null); | |||
3142 | } | |||
3143 | __kmp_nested_proc_bind.size = nelem; | |||
3144 | } | |||
3145 | __kmp_nested_proc_bind.used = nelem; | |||
3146 | ||||
3147 | // Save values in the nested proc_bind array | |||
3148 | int i = 0; | |||
3149 | for (;;) { | |||
3150 | enum kmp_proc_bind_t bind; | |||
3151 | ||||
3152 | if ((num == (int)proc_bind_master) || | |||
3153 | __kmp_match_str("master", buf, &next)) { | |||
3154 | buf = next; | |||
3155 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3156 | bind = proc_bind_master; | |||
3157 | } else if ((num == (int)proc_bind_close) || | |||
3158 | __kmp_match_str("close", buf, &next)) { | |||
3159 | buf = next; | |||
3160 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3161 | bind = proc_bind_close; | |||
3162 | } else if ((num == (int)proc_bind_spread) || | |||
3163 | __kmp_match_str("spread", buf, &next)) { | |||
3164 | buf = next; | |||
3165 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3166 | bind = proc_bind_spread; | |||
3167 | } else { | |||
3168 | KMP_WARNING(StgInvalidValue, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgInvalidValue , name, value), __kmp_msg_null); | |||
3169 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; | |||
3170 | __kmp_nested_proc_bind.used = 1; | |||
3171 | return; | |||
3172 | } | |||
3173 | ||||
3174 | __kmp_nested_proc_bind.bind_types[i++] = bind; | |||
3175 | if (i >= nelem) { | |||
3176 | break; | |||
3177 | } | |||
3178 | KMP_DEBUG_ASSERT(*buf == ',')if (!(*buf == ',')) { __kmp_debug_assert("*buf == ','", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3178); }; | |||
3179 | buf++; | |||
3180 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3181 | ||||
3182 | // Read next value if it was specified as an integer | |||
3183 | if ((*buf >= '0') && (*buf <= '9')) { | |||
3184 | next = buf; | |||
3185 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
3186 | num = __kmp_str_to_int(buf, *next); | |||
3187 | KMP_ASSERT(num >= 0)if (!(num >= 0)) { __kmp_debug_assert("num >= 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3187); }; | |||
3188 | buf = next; | |||
3189 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3190 | } else { | |||
3191 | num = -1; | |||
3192 | } | |||
3193 | } | |||
3194 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3195 | } | |||
3196 | if (*buf != '\0') { | |||
3197 | KMP_WARNING(ParseExtraCharsWarn, name, buf)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_ParseExtraCharsWarn , name, buf), __kmp_msg_null); | |||
3198 | } | |||
3199 | } | |||
3200 | ||||
3201 | static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer, char const *name, | |||
3202 | void *data) { | |||
3203 | int nelem = __kmp_nested_proc_bind.used; | |||
3204 | if (__kmp_env_format) { | |||
3205 | KMP_STR_BUF_PRINT_NAME__kmp_str_buf_print(buffer, " %s %s", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
3206 | } else { | |||
3207 | __kmp_str_buf_print(buffer, " %s", name); | |||
3208 | } | |||
3209 | if (nelem == 0) { | |||
3210 | __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
3211 | } else { | |||
3212 | int i; | |||
3213 | __kmp_str_buf_print(buffer, "='", name); | |||
3214 | for (i = 0; i < nelem; i++) { | |||
3215 | switch (__kmp_nested_proc_bind.bind_types[i]) { | |||
3216 | case proc_bind_false: | |||
3217 | __kmp_str_buf_print(buffer, "false"); | |||
3218 | break; | |||
3219 | ||||
3220 | case proc_bind_true: | |||
3221 | __kmp_str_buf_print(buffer, "true"); | |||
3222 | break; | |||
3223 | ||||
3224 | case proc_bind_master: | |||
3225 | __kmp_str_buf_print(buffer, "master"); | |||
3226 | break; | |||
3227 | ||||
3228 | case proc_bind_close: | |||
3229 | __kmp_str_buf_print(buffer, "close"); | |||
3230 | break; | |||
3231 | ||||
3232 | case proc_bind_spread: | |||
3233 | __kmp_str_buf_print(buffer, "spread"); | |||
3234 | break; | |||
3235 | ||||
3236 | case proc_bind_intel: | |||
3237 | __kmp_str_buf_print(buffer, "intel"); | |||
3238 | break; | |||
3239 | ||||
3240 | case proc_bind_default: | |||
3241 | __kmp_str_buf_print(buffer, "default"); | |||
3242 | break; | |||
3243 | } | |||
3244 | if (i < nelem - 1) { | |||
3245 | __kmp_str_buf_print(buffer, ","); | |||
3246 | } | |||
3247 | } | |||
3248 | __kmp_str_buf_print(buffer, "'\n"); | |||
3249 | } | |||
3250 | } | |||
3251 | ||||
3252 | #endif /* OMP_40_ENABLED */ | |||
3253 | ||||
3254 | #if OMP_50_ENABLED(50 >= 50) | |||
3255 | ||||
3256 | // OMP_ALLOCATOR sets default allocator | |||
3257 | static void __kmp_stg_parse_allocator(char const *name, char const *value, | |||
3258 | void *data) { | |||
3259 | /* | |||
3260 | The value can be any predefined allocator: | |||
3261 | omp_default_mem_alloc = 1; | |||
3262 | omp_large_cap_mem_alloc = 2; | |||
3263 | omp_const_mem_alloc = 3; | |||
3264 | omp_high_bw_mem_alloc = 4; | |||
3265 | omp_low_lat_mem_alloc = 5; | |||
3266 | omp_cgroup_mem_alloc = 6; | |||
3267 | omp_pteam_mem_alloc = 7; | |||
3268 | omp_thread_mem_alloc = 8; | |||
3269 | Acceptable value is either a digit or a string. | |||
3270 | */ | |||
3271 | const char *buf = value; | |||
3272 | const char *next; | |||
3273 | int num; | |||
3274 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3275 | if ((*buf > '0') && (*buf < '9')) { | |||
3276 | next = buf; | |||
3277 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
3278 | num = __kmp_str_to_int(buf, *next); | |||
3279 | KMP_ASSERT(num > 0)if (!(num > 0)) { __kmp_debug_assert("num > 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3279); }; | |||
3280 | switch (num) { | |||
3281 | case 4: | |||
3282 | if (__kmp_hbw_mem_available) { | |||
3283 | __kmp_def_allocator = omp_high_bw_mem_alloc; | |||
3284 | } else { | |||
3285 | __kmp_msg(kmp_ms_warning, | |||
3286 | KMP_MSG(OmpNoAllocator, "omp_high_bw_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_high_bw_mem_alloc" ), | |||
3287 | __kmp_msg_null); | |||
3288 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3289 | } | |||
3290 | break; | |||
3291 | case 1: | |||
3292 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3293 | break; | |||
3294 | case 2: | |||
3295 | __kmp_msg(kmp_ms_warning, | |||
3296 | KMP_MSG(OmpNoAllocator, "omp_large_cap_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_large_cap_mem_alloc" ), | |||
3297 | __kmp_msg_null); | |||
3298 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3299 | break; | |||
3300 | case 3: | |||
3301 | __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_const_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_const_mem_alloc" ), | |||
3302 | __kmp_msg_null); | |||
3303 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3304 | break; | |||
3305 | case 5: | |||
3306 | __kmp_msg(kmp_ms_warning, | |||
3307 | KMP_MSG(OmpNoAllocator, "omp_low_lat_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_low_lat_mem_alloc" ), | |||
3308 | __kmp_msg_null); | |||
3309 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3310 | break; | |||
3311 | case 6: | |||
3312 | __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_cgroup_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_cgroup_mem_alloc" ), | |||
3313 | __kmp_msg_null); | |||
3314 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3315 | break; | |||
3316 | case 7: | |||
3317 | __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_pteam_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_pteam_mem_alloc" ), | |||
3318 | __kmp_msg_null); | |||
3319 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3320 | break; | |||
3321 | case 8: | |||
3322 | __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_thread_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_thread_mem_alloc" ), | |||
3323 | __kmp_msg_null); | |||
3324 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3325 | break; | |||
3326 | } | |||
3327 | return; | |||
3328 | } | |||
3329 | next = buf; | |||
3330 | if (__kmp_match_str("omp_high_bw_mem_alloc", buf, &next)) { | |||
3331 | if (__kmp_hbw_mem_available) { | |||
3332 | __kmp_def_allocator = omp_high_bw_mem_alloc; | |||
3333 | } else { | |||
3334 | __kmp_msg(kmp_ms_warning, | |||
3335 | KMP_MSG(OmpNoAllocator, "omp_high_bw_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_high_bw_mem_alloc" ), | |||
3336 | __kmp_msg_null); | |||
3337 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3338 | } | |||
3339 | } else if (__kmp_match_str("omp_default_mem_alloc", buf, &next)) { | |||
3340 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3341 | } else if (__kmp_match_str("omp_large_cap_mem_alloc", buf, &next)) { | |||
3342 | __kmp_msg(kmp_ms_warning, | |||
3343 | KMP_MSG(OmpNoAllocator, "omp_large_cap_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_large_cap_mem_alloc" ), | |||
3344 | __kmp_msg_null); | |||
3345 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3346 | } else if (__kmp_match_str("omp_const_mem_alloc", buf, &next)) { | |||
3347 | __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_const_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_const_mem_alloc" ), | |||
3348 | __kmp_msg_null); | |||
3349 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3350 | } else if (__kmp_match_str("omp_low_lat_mem_alloc", buf, &next)) { | |||
3351 | __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_low_lat_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_low_lat_mem_alloc" ), | |||
3352 | __kmp_msg_null); | |||
3353 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3354 | } else if (__kmp_match_str("omp_cgroup_mem_alloc", buf, &next)) { | |||
3355 | __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_cgroup_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_cgroup_mem_alloc" ), | |||
3356 | __kmp_msg_null); | |||
3357 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3358 | } else if (__kmp_match_str("omp_pteam_mem_alloc", buf, &next)) { | |||
3359 | __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_pteam_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_pteam_mem_alloc" ), | |||
3360 | __kmp_msg_null); | |||
3361 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3362 | } else if (__kmp_match_str("omp_thread_mem_alloc", buf, &next)) { | |||
3363 | __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_thread_mem_alloc")__kmp_msg_format(kmp_i18n_msg_OmpNoAllocator, "omp_thread_mem_alloc" ), | |||
3364 | __kmp_msg_null); | |||
3365 | __kmp_def_allocator = omp_default_mem_alloc; | |||
3366 | } | |||
3367 | buf = next; | |||
3368 | SKIP_WS(buf){ while (*(buf) == ' ' || *(buf) == '\t') (buf)++; }; | |||
3369 | if (*buf != '\0') { | |||
3370 | KMP_WARNING(ParseExtraCharsWarn, name, buf)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_ParseExtraCharsWarn , name, buf), __kmp_msg_null); | |||
3371 | } | |||
3372 | } | |||
3373 | ||||
3374 | static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer, char const *name, | |||
3375 | void *data) { | |||
3376 | if (__kmp_def_allocator == omp_default_mem_alloc) { | |||
3377 | __kmp_stg_print_str(buffer, name, "omp_default_mem_alloc"); | |||
3378 | } else if (__kmp_def_allocator == omp_high_bw_mem_alloc) { | |||
3379 | __kmp_stg_print_str(buffer, name, "omp_high_bw_mem_alloc"); | |||
3380 | } else if (__kmp_def_allocator == omp_large_cap_mem_alloc) { | |||
3381 | __kmp_stg_print_str(buffer, name, "omp_large_cap_mem_alloc"); | |||
3382 | } else if (__kmp_def_allocator == omp_const_mem_alloc) { | |||
3383 | __kmp_stg_print_str(buffer, name, "omp_const_mem_alloc"); | |||
3384 | } else if (__kmp_def_allocator == omp_low_lat_mem_alloc) { | |||
3385 | __kmp_stg_print_str(buffer, name, "omp_low_lat_mem_alloc"); | |||
3386 | } else if (__kmp_def_allocator == omp_cgroup_mem_alloc) { | |||
3387 | __kmp_stg_print_str(buffer, name, "omp_cgroup_mem_alloc"); | |||
3388 | } else if (__kmp_def_allocator == omp_pteam_mem_alloc) { | |||
3389 | __kmp_stg_print_str(buffer, name, "omp_pteam_mem_alloc"); | |||
3390 | } else if (__kmp_def_allocator == omp_thread_mem_alloc) { | |||
3391 | __kmp_stg_print_str(buffer, name, "omp_thread_mem_alloc"); | |||
3392 | } | |||
3393 | } | |||
3394 | ||||
3395 | #endif /* OMP_50_ENABLED */ | |||
3396 | ||||
3397 | // ----------------------------------------------------------------------------- | |||
3398 | // OMP_DYNAMIC | |||
3399 | ||||
3400 | static void __kmp_stg_parse_omp_dynamic(char const *name, char const *value, | |||
3401 | void *data) { | |||
3402 | __kmp_stg_parse_bool(name, value, &(__kmp_global.g.g_dynamic)); | |||
3403 | } // __kmp_stg_parse_omp_dynamic | |||
3404 | ||||
3405 | static void __kmp_stg_print_omp_dynamic(kmp_str_buf_t *buffer, char const *name, | |||
3406 | void *data) { | |||
3407 | __kmp_stg_print_bool(buffer, name, __kmp_global.g.g_dynamic); | |||
3408 | } // __kmp_stg_print_omp_dynamic | |||
3409 | ||||
3410 | static void __kmp_stg_parse_kmp_dynamic_mode(char const *name, | |||
3411 | char const *value, void *data) { | |||
3412 | if (TCR_4(__kmp_init_parallel)(__kmp_init_parallel)) { | |||
3413 | KMP_WARNING(EnvParallelWarn, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvParallelWarn , name), __kmp_msg_null); | |||
3414 | __kmp_env_toPrint(name, 0); | |||
3415 | return; | |||
3416 | } | |||
3417 | #ifdef USE_LOAD_BALANCE1 | |||
3418 | else if (__kmp_str_match("load balance", 2, value) || | |||
3419 | __kmp_str_match("load_balance", 2, value) || | |||
3420 | __kmp_str_match("load-balance", 2, value) || | |||
3421 | __kmp_str_match("loadbalance", 2, value) || | |||
3422 | __kmp_str_match("balance", 1, value)) { | |||
3423 | __kmp_global.g.g_dynamic_mode = dynamic_load_balance; | |||
3424 | } | |||
3425 | #endif /* USE_LOAD_BALANCE */ | |||
3426 | else if (__kmp_str_match("thread limit", 1, value) || | |||
3427 | __kmp_str_match("thread_limit", 1, value) || | |||
3428 | __kmp_str_match("thread-limit", 1, value) || | |||
3429 | __kmp_str_match("threadlimit", 1, value) || | |||
3430 | __kmp_str_match("limit", 2, value)) { | |||
3431 | __kmp_global.g.g_dynamic_mode = dynamic_thread_limit; | |||
3432 | } else if (__kmp_str_match("random", 1, value)) { | |||
3433 | __kmp_global.g.g_dynamic_mode = dynamic_random; | |||
3434 | } else { | |||
3435 | KMP_WARNING(StgInvalidValue, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgInvalidValue , name, value), __kmp_msg_null); | |||
3436 | } | |||
3437 | } //__kmp_stg_parse_kmp_dynamic_mode | |||
3438 | ||||
3439 | static void __kmp_stg_print_kmp_dynamic_mode(kmp_str_buf_t *buffer, | |||
3440 | char const *name, void *data) { | |||
3441 | #if KMP_DEBUG1 | |||
3442 | if (__kmp_global.g.g_dynamic_mode == dynamic_default) { | |||
3443 | __kmp_str_buf_print(buffer, " %s: %s \n", name, KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
3444 | } | |||
3445 | #ifdef USE_LOAD_BALANCE1 | |||
3446 | else if (__kmp_global.g.g_dynamic_mode == dynamic_load_balance) { | |||
3447 | __kmp_stg_print_str(buffer, name, "load balance"); | |||
3448 | } | |||
3449 | #endif /* USE_LOAD_BALANCE */ | |||
3450 | else if (__kmp_global.g.g_dynamic_mode == dynamic_thread_limit) { | |||
3451 | __kmp_stg_print_str(buffer, name, "thread limit"); | |||
3452 | } else if (__kmp_global.g.g_dynamic_mode == dynamic_random) { | |||
3453 | __kmp_stg_print_str(buffer, name, "random"); | |||
3454 | } else { | |||
3455 | KMP_ASSERT(0)if (!(0)) { __kmp_debug_assert("0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3455); }; | |||
3456 | } | |||
3457 | #endif /* KMP_DEBUG */ | |||
3458 | } // __kmp_stg_print_kmp_dynamic_mode | |||
3459 | ||||
3460 | #ifdef USE_LOAD_BALANCE1 | |||
3461 | ||||
3462 | // ----------------------------------------------------------------------------- | |||
3463 | // KMP_LOAD_BALANCE_INTERVAL | |||
3464 | ||||
3465 | static void __kmp_stg_parse_ld_balance_interval(char const *name, | |||
3466 | char const *value, void *data) { | |||
3467 | double interval = __kmp_convert_to_double(value); | |||
3468 | if (interval >= 0) { | |||
3469 | __kmp_load_balance_interval = interval; | |||
3470 | } else { | |||
3471 | KMP_WARNING(StgInvalidValue, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgInvalidValue , name, value), __kmp_msg_null); | |||
3472 | } | |||
3473 | } // __kmp_stg_parse_load_balance_interval | |||
3474 | ||||
3475 | static void __kmp_stg_print_ld_balance_interval(kmp_str_buf_t *buffer, | |||
3476 | char const *name, void *data) { | |||
3477 | #if KMP_DEBUG1 | |||
3478 | __kmp_str_buf_print(buffer, " %s=%8.6f\n", name, | |||
3479 | __kmp_load_balance_interval); | |||
3480 | #endif /* KMP_DEBUG */ | |||
3481 | } // __kmp_stg_print_load_balance_interval | |||
3482 | ||||
3483 | #endif /* USE_LOAD_BALANCE */ | |||
3484 | ||||
3485 | // ----------------------------------------------------------------------------- | |||
3486 | // KMP_INIT_AT_FORK | |||
3487 | ||||
3488 | static void __kmp_stg_parse_init_at_fork(char const *name, char const *value, | |||
3489 | void *data) { | |||
3490 | __kmp_stg_parse_bool(name, value, &__kmp_need_register_atfork); | |||
3491 | if (__kmp_need_register_atfork) { | |||
3492 | __kmp_need_register_atfork_specified = TRUE(!0); | |||
3493 | } | |||
3494 | } // __kmp_stg_parse_init_at_fork | |||
3495 | ||||
3496 | static void __kmp_stg_print_init_at_fork(kmp_str_buf_t *buffer, | |||
3497 | char const *name, void *data) { | |||
3498 | __kmp_stg_print_bool(buffer, name, __kmp_need_register_atfork_specified); | |||
3499 | } // __kmp_stg_print_init_at_fork | |||
3500 | ||||
3501 | // ----------------------------------------------------------------------------- | |||
3502 | // KMP_SCHEDULE | |||
3503 | ||||
3504 | static void __kmp_stg_parse_schedule(char const *name, char const *value, | |||
3505 | void *data) { | |||
3506 | ||||
3507 | if (value != NULL__null) { | |||
3508 | size_t length = KMP_STRLENstrlen(value); | |||
3509 | if (length > INT_MAX2147483647) { | |||
3510 | KMP_WARNING(LongValue, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_LongValue , name), __kmp_msg_null); | |||
3511 | } else { | |||
3512 | const char *semicolon; | |||
3513 | if (value[length - 1] == '"' || value[length - 1] == '\'') | |||
3514 | KMP_WARNING(UnbalancedQuotes, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_UnbalancedQuotes , name), __kmp_msg_null); | |||
3515 | do { | |||
3516 | char sentinel; | |||
3517 | ||||
3518 | semicolon = strchr(value, ';'); | |||
3519 | if (*value && semicolon != value) { | |||
3520 | const char *comma = strchr(value, ','); | |||
3521 | ||||
3522 | if (comma) { | |||
3523 | ++comma; | |||
3524 | sentinel = ','; | |||
3525 | } else | |||
3526 | sentinel = ';'; | |||
3527 | if (!__kmp_strcasecmp_with_sentinel("static", value, sentinel)) { | |||
3528 | if (!__kmp_strcasecmp_with_sentinel("greedy", comma, ';')) { | |||
3529 | __kmp_static = kmp_sch_static_greedy; | |||
3530 | continue; | |||
3531 | } else if (!__kmp_strcasecmp_with_sentinel("balanced", comma, | |||
3532 | ';')) { | |||
3533 | __kmp_static = kmp_sch_static_balanced; | |||
3534 | continue; | |||
3535 | } | |||
3536 | } else if (!__kmp_strcasecmp_with_sentinel("guided", value, | |||
3537 | sentinel)) { | |||
3538 | if (!__kmp_strcasecmp_with_sentinel("iterative", comma, ';')) { | |||
3539 | __kmp_guided = kmp_sch_guided_iterative_chunked; | |||
3540 | continue; | |||
3541 | } else if (!__kmp_strcasecmp_with_sentinel("analytical", comma, | |||
3542 | ';')) { | |||
3543 | /* analytical not allowed for too many threads */ | |||
3544 | __kmp_guided = kmp_sch_guided_analytical_chunked; | |||
3545 | continue; | |||
3546 | } | |||
3547 | } | |||
3548 | KMP_WARNING(InvalidClause, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_InvalidClause , name, value), __kmp_msg_null); | |||
3549 | } else | |||
3550 | KMP_WARNING(EmptyClause, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EmptyClause , name), __kmp_msg_null); | |||
3551 | } while ((value = semicolon ? semicolon + 1 : NULL__null)); | |||
3552 | } | |||
3553 | } | |||
3554 | ||||
3555 | } // __kmp_stg_parse__schedule | |||
3556 | ||||
3557 | static void __kmp_stg_print_schedule(kmp_str_buf_t *buffer, char const *name, | |||
3558 | void *data) { | |||
3559 | if (__kmp_env_format) { | |||
3560 | KMP_STR_BUF_PRINT_NAME_EX(name)__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
3561 | } else { | |||
3562 | __kmp_str_buf_print(buffer, " %s='", name); | |||
3563 | } | |||
3564 | if (__kmp_static == kmp_sch_static_greedy) { | |||
3565 | __kmp_str_buf_print(buffer, "%s", "static,greedy"); | |||
3566 | } else if (__kmp_static == kmp_sch_static_balanced) { | |||
3567 | __kmp_str_buf_print(buffer, "%s", "static,balanced"); | |||
3568 | } | |||
3569 | if (__kmp_guided == kmp_sch_guided_iterative_chunked) { | |||
3570 | __kmp_str_buf_print(buffer, ";%s'\n", "guided,iterative"); | |||
3571 | } else if (__kmp_guided == kmp_sch_guided_analytical_chunked) { | |||
3572 | __kmp_str_buf_print(buffer, ";%s'\n", "guided,analytical"); | |||
3573 | } | |||
3574 | } // __kmp_stg_print_schedule | |||
3575 | ||||
3576 | // ----------------------------------------------------------------------------- | |||
3577 | // OMP_SCHEDULE | |||
3578 | ||||
3579 | static inline void __kmp_omp_schedule_restore() { | |||
3580 | #if KMP_USE_HIER_SCHED0 | |||
3581 | __kmp_hier_scheds.deallocate(); | |||
3582 | #endif | |||
3583 | __kmp_chunk = 0; | |||
3584 | __kmp_sched = kmp_sch_default; | |||
3585 | } | |||
3586 | ||||
3587 | static const char *__kmp_parse_single_omp_schedule(const char *name, | |||
3588 | const char *value, | |||
3589 | bool parse_hier = false) { | |||
3590 | /* get the specified scheduling style */ | |||
3591 | const char *ptr = value; | |||
3592 | const char *comma = strchr(ptr, ','); | |||
3593 | const char *delim; | |||
3594 | int chunk = 0; | |||
3595 | enum sched_type sched = kmp_sch_default; | |||
3596 | if (*ptr == '\0') | |||
3597 | return NULL__null; | |||
3598 | #if KMP_USE_HIER_SCHED0 | |||
3599 | kmp_hier_layer_e layer = kmp_hier_layer_e::LAYER_THREAD; | |||
3600 | if (parse_hier) { | |||
3601 | if (!__kmp_strcasecmp_with_sentinel("L1", ptr, ',')) { | |||
3602 | layer = kmp_hier_layer_e::LAYER_L1; | |||
3603 | } else if (!__kmp_strcasecmp_with_sentinel("L2", ptr, ',')) { | |||
3604 | layer = kmp_hier_layer_e::LAYER_L2; | |||
3605 | } else if (!__kmp_strcasecmp_with_sentinel("L3", ptr, ',')) { | |||
3606 | layer = kmp_hier_layer_e::LAYER_L3; | |||
3607 | } else if (!__kmp_strcasecmp_with_sentinel("NUMA", ptr, ',')) { | |||
3608 | layer = kmp_hier_layer_e::LAYER_NUMA; | |||
3609 | } | |||
3610 | if (layer != kmp_hier_layer_e::LAYER_THREAD && !comma) { | |||
3611 | // If there is no comma after the layer, then this schedule is invalid | |||
3612 | KMP_WARNING(StgInvalidValue, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgInvalidValue , name, value), __kmp_msg_null); | |||
3613 | __kmp_omp_schedule_restore(); | |||
3614 | return NULL__null; | |||
3615 | } else if (layer != kmp_hier_layer_e::LAYER_THREAD) { | |||
3616 | ptr = ++comma; | |||
3617 | comma = strchr(ptr, ','); | |||
3618 | } | |||
3619 | } | |||
3620 | delim = ptr; | |||
3621 | while (*delim != ',' && *delim != ':' && *delim != '\0') | |||
3622 | delim++; | |||
3623 | #else // KMP_USE_HIER_SCHED | |||
3624 | delim = ptr; | |||
3625 | while (*delim != ',' && *delim != '\0') | |||
3626 | delim++; | |||
3627 | #endif // KMP_USE_HIER_SCHED | |||
3628 | if (!__kmp_strcasecmp_with_sentinel("dynamic", ptr, *delim)) /* DYNAMIC */ | |||
3629 | sched = kmp_sch_dynamic_chunked; | |||
3630 | else if (!__kmp_strcasecmp_with_sentinel("guided", ptr, *delim)) /* GUIDED */ | |||
3631 | sched = kmp_sch_guided_chunked; | |||
3632 | // AC: TODO: add AUTO schedule, and probably remove TRAPEZOIDAL (OMP 3.0 does | |||
3633 | // not allow it) | |||
3634 | else if (!__kmp_strcasecmp_with_sentinel("auto", ptr, *delim)) { /* AUTO */ | |||
3635 | sched = kmp_sch_auto; | |||
3636 | if (comma) { | |||
3637 | __kmp_msg(kmp_ms_warning, KMP_MSG(IgnoreChunk, name, comma)__kmp_msg_format(kmp_i18n_msg_IgnoreChunk, name, comma), | |||
3638 | __kmp_msg_null); | |||
3639 | comma = NULL__null; | |||
3640 | } | |||
3641 | } else if (!__kmp_strcasecmp_with_sentinel("trapezoidal", ptr, | |||
3642 | *delim)) /* TRAPEZOIDAL */ | |||
3643 | sched = kmp_sch_trapezoidal; | |||
3644 | else if (!__kmp_strcasecmp_with_sentinel("static", ptr, *delim)) /* STATIC */ | |||
3645 | sched = kmp_sch_static; | |||
3646 | #if KMP_STATIC_STEAL_ENABLED1 | |||
3647 | else if (!__kmp_strcasecmp_with_sentinel("static_steal", ptr, *delim)) | |||
3648 | sched = kmp_sch_static_steal; | |||
3649 | #endif | |||
3650 | else { | |||
3651 | KMP_WARNING(StgInvalidValue, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgInvalidValue , name, value), __kmp_msg_null); | |||
3652 | __kmp_omp_schedule_restore(); | |||
3653 | return NULL__null; | |||
3654 | } | |||
3655 | if (ptr && comma && *comma == *delim) { | |||
3656 | ptr = comma + 1; | |||
3657 | SKIP_DIGITS(ptr){ while (*(ptr) >= '0' && *(ptr) <= '9') (ptr)++ ; }; | |||
3658 | ||||
3659 | if (sched == kmp_sch_static) | |||
3660 | sched = kmp_sch_static_chunked; | |||
3661 | ++comma; | |||
3662 | chunk = __kmp_str_to_int(comma, *ptr); | |||
3663 | if (chunk < 1) { | |||
3664 | chunk = KMP_DEFAULT_CHUNK1; | |||
3665 | __kmp_msg(kmp_ms_warning, KMP_MSG(InvalidChunk, name, comma)__kmp_msg_format(kmp_i18n_msg_InvalidChunk, name, comma), | |||
3666 | __kmp_msg_null); | |||
3667 | KMP_INFORM(Using_int_Value, name, __kmp_chunk)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_int_Value , name, __kmp_chunk), __kmp_msg_null); | |||
3668 | // AC: next block commented out until KMP_DEFAULT_CHUNK != KMP_MIN_CHUNK | |||
3669 | // (to improve code coverage :) | |||
3670 | // The default chunk size is 1 according to standard, thus making | |||
3671 | // KMP_MIN_CHUNK not 1 we would introduce mess: | |||
3672 | // wrong chunk becomes 1, but it will be impossible to explicitely set | |||
3673 | // 1, because it becomes KMP_MIN_CHUNK... | |||
3674 | // } else if ( chunk < KMP_MIN_CHUNK ) { | |||
3675 | // chunk = KMP_MIN_CHUNK; | |||
3676 | } else if (chunk > KMP_MAX_CHUNK(2147483647 - 1)) { | |||
3677 | chunk = KMP_MAX_CHUNK(2147483647 - 1); | |||
3678 | __kmp_msg(kmp_ms_warning, KMP_MSG(LargeChunk, name, comma)__kmp_msg_format(kmp_i18n_msg_LargeChunk, name, comma), | |||
3679 | __kmp_msg_null); | |||
3680 | KMP_INFORM(Using_int_Value, name, chunk)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_int_Value , name, chunk), __kmp_msg_null); | |||
3681 | } | |||
3682 | } else if (ptr) { | |||
3683 | SKIP_TOKEN(ptr){ while ((*(ptr) >= '0' && *(ptr) <= '9') || (* (ptr) >= 'a' && *(ptr) <= 'z') || (*(ptr) >= 'A' && *(ptr) <= 'Z') || *(ptr) == '_') (ptr)++; }; | |||
3684 | } | |||
3685 | #if KMP_USE_HIER_SCHED0 | |||
3686 | if (layer != kmp_hier_layer_e::LAYER_THREAD) { | |||
3687 | __kmp_hier_scheds.append(sched, chunk, layer); | |||
3688 | } else | |||
3689 | #endif | |||
3690 | { | |||
3691 | __kmp_chunk = chunk; | |||
3692 | __kmp_sched = sched; | |||
3693 | } | |||
3694 | return ptr; | |||
3695 | } | |||
3696 | ||||
3697 | static void __kmp_stg_parse_omp_schedule(char const *name, char const *value, | |||
3698 | void *data) { | |||
3699 | size_t length; | |||
3700 | const char *ptr = value; | |||
3701 | SKIP_WS(ptr){ while (*(ptr) == ' ' || *(ptr) == '\t') (ptr)++; }; | |||
3702 | if (value) { | |||
3703 | length = KMP_STRLENstrlen(value); | |||
3704 | if (length) { | |||
3705 | if (value[length - 1] == '"' || value[length - 1] == '\'') | |||
3706 | KMP_WARNING(UnbalancedQuotes, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_UnbalancedQuotes , name), __kmp_msg_null); | |||
3707 | /* get the specified scheduling style */ | |||
3708 | #if KMP_USE_HIER_SCHED0 | |||
3709 | if (!__kmp_strcasecmp_with_sentinel("EXPERIMENTAL", ptr, ' ')) { | |||
3710 | SKIP_TOKEN(ptr){ while ((*(ptr) >= '0' && *(ptr) <= '9') || (* (ptr) >= 'a' && *(ptr) <= 'z') || (*(ptr) >= 'A' && *(ptr) <= 'Z') || *(ptr) == '_') (ptr)++; }; | |||
3711 | SKIP_WS(ptr){ while (*(ptr) == ' ' || *(ptr) == '\t') (ptr)++; }; | |||
3712 | while ((ptr = __kmp_parse_single_omp_schedule(name, ptr, true))) { | |||
3713 | while (*ptr == ' ' || *ptr == '\t' || *ptr == ':') | |||
3714 | ptr++; | |||
3715 | } | |||
3716 | } else | |||
3717 | #endif | |||
3718 | __kmp_parse_single_omp_schedule(name, ptr); | |||
3719 | } else | |||
3720 | KMP_WARNING(EmptyString, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EmptyString , name), __kmp_msg_null); | |||
3721 | } | |||
3722 | #if KMP_USE_HIER_SCHED0 | |||
3723 | __kmp_hier_scheds.sort(); | |||
3724 | #endif | |||
3725 | K_DIAG(1, ("__kmp_static == %d\n", __kmp_static)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_static == %d\n" , __kmp_static); } } | |||
3726 | K_DIAG(1, ("__kmp_guided == %d\n", __kmp_guided)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_guided == %d\n" , __kmp_guided); } } | |||
3727 | K_DIAG(1, ("__kmp_sched == %d\n", __kmp_sched)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_sched == %d\n" , __kmp_sched); } } | |||
3728 | K_DIAG(1, ("__kmp_chunk == %d\n", __kmp_chunk)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_chunk == %d\n" , __kmp_chunk); } } | |||
3729 | } // __kmp_stg_parse_omp_schedule | |||
3730 | ||||
3731 | static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer, | |||
3732 | char const *name, void *data) { | |||
3733 | if (__kmp_env_format) { | |||
3734 | KMP_STR_BUF_PRINT_NAME_EX(name)__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
3735 | } else { | |||
3736 | __kmp_str_buf_print(buffer, " %s='", name); | |||
3737 | } | |||
3738 | if (__kmp_chunk) { | |||
3739 | switch (__kmp_sched) { | |||
3740 | case kmp_sch_dynamic_chunked: | |||
3741 | __kmp_str_buf_print(buffer, "%s,%d'\n", "dynamic", __kmp_chunk); | |||
3742 | break; | |||
3743 | case kmp_sch_guided_iterative_chunked: | |||
3744 | case kmp_sch_guided_analytical_chunked: | |||
3745 | __kmp_str_buf_print(buffer, "%s,%d'\n", "guided", __kmp_chunk); | |||
3746 | break; | |||
3747 | case kmp_sch_trapezoidal: | |||
3748 | __kmp_str_buf_print(buffer, "%s,%d'\n", "trapezoidal", __kmp_chunk); | |||
3749 | break; | |||
3750 | case kmp_sch_static: | |||
3751 | case kmp_sch_static_chunked: | |||
3752 | case kmp_sch_static_balanced: | |||
3753 | case kmp_sch_static_greedy: | |||
3754 | __kmp_str_buf_print(buffer, "%s,%d'\n", "static", __kmp_chunk); | |||
3755 | break; | |||
3756 | case kmp_sch_static_steal: | |||
3757 | __kmp_str_buf_print(buffer, "%s,%d'\n", "static_steal", __kmp_chunk); | |||
3758 | break; | |||
3759 | case kmp_sch_auto: | |||
3760 | __kmp_str_buf_print(buffer, "%s,%d'\n", "auto", __kmp_chunk); | |||
3761 | break; | |||
3762 | } | |||
3763 | } else { | |||
3764 | switch (__kmp_sched) { | |||
3765 | case kmp_sch_dynamic_chunked: | |||
3766 | __kmp_str_buf_print(buffer, "%s'\n", "dynamic"); | |||
3767 | break; | |||
3768 | case kmp_sch_guided_iterative_chunked: | |||
3769 | case kmp_sch_guided_analytical_chunked: | |||
3770 | __kmp_str_buf_print(buffer, "%s'\n", "guided"); | |||
3771 | break; | |||
3772 | case kmp_sch_trapezoidal: | |||
3773 | __kmp_str_buf_print(buffer, "%s'\n", "trapezoidal"); | |||
3774 | break; | |||
3775 | case kmp_sch_static: | |||
3776 | case kmp_sch_static_chunked: | |||
3777 | case kmp_sch_static_balanced: | |||
3778 | case kmp_sch_static_greedy: | |||
3779 | __kmp_str_buf_print(buffer, "%s'\n", "static"); | |||
3780 | break; | |||
3781 | case kmp_sch_static_steal: | |||
3782 | __kmp_str_buf_print(buffer, "%s'\n", "static_steal"); | |||
3783 | break; | |||
3784 | case kmp_sch_auto: | |||
3785 | __kmp_str_buf_print(buffer, "%s'\n", "auto"); | |||
3786 | break; | |||
3787 | } | |||
3788 | } | |||
3789 | } // __kmp_stg_print_omp_schedule | |||
3790 | ||||
3791 | #if KMP_USE_HIER_SCHED0 | |||
3792 | // ----------------------------------------------------------------------------- | |||
3793 | // KMP_DISP_HAND_THREAD | |||
3794 | static void __kmp_stg_parse_kmp_hand_thread(char const *name, char const *value, | |||
3795 | void *data) { | |||
3796 | __kmp_stg_parse_bool(name, value, &(__kmp_dispatch_hand_threading)); | |||
3797 | } // __kmp_stg_parse_kmp_hand_thread | |||
3798 | ||||
3799 | static void __kmp_stg_print_kmp_hand_thread(kmp_str_buf_t *buffer, | |||
3800 | char const *name, void *data) { | |||
3801 | __kmp_stg_print_bool(buffer, name, __kmp_dispatch_hand_threading); | |||
3802 | } // __kmp_stg_print_kmp_hand_thread | |||
3803 | #endif | |||
3804 | ||||
3805 | // ----------------------------------------------------------------------------- | |||
3806 | // KMP_ATOMIC_MODE | |||
3807 | ||||
3808 | static void __kmp_stg_parse_atomic_mode(char const *name, char const *value, | |||
3809 | void *data) { | |||
3810 | // Modes: 0 -- do not change default; 1 -- Intel perf mode, 2 -- GOMP | |||
3811 | // compatibility mode. | |||
3812 | int mode = 0; | |||
3813 | int max = 1; | |||
3814 | #ifdef KMP_GOMP_COMPAT | |||
3815 | max = 2; | |||
3816 | #endif /* KMP_GOMP_COMPAT */ | |||
3817 | __kmp_stg_parse_int(name, value, 0, max, &mode); | |||
3818 | // TODO; parse_int is not very suitable for this case. In case of overflow it | |||
3819 | // is better to use | |||
3820 | // 0 rather that max value. | |||
3821 | if (mode > 0) { | |||
3822 | __kmp_atomic_mode = mode; | |||
3823 | } | |||
3824 | } // __kmp_stg_parse_atomic_mode | |||
3825 | ||||
3826 | static void __kmp_stg_print_atomic_mode(kmp_str_buf_t *buffer, char const *name, | |||
3827 | void *data) { | |||
3828 | __kmp_stg_print_int(buffer, name, __kmp_atomic_mode); | |||
3829 | } // __kmp_stg_print_atomic_mode | |||
3830 | ||||
3831 | // ----------------------------------------------------------------------------- | |||
3832 | // KMP_CONSISTENCY_CHECK | |||
3833 | ||||
3834 | static void __kmp_stg_parse_consistency_check(char const *name, | |||
3835 | char const *value, void *data) { | |||
3836 | if (!__kmp_strcasecmp_with_sentinel("all", value, 0)) { | |||
3837 | // Note, this will not work from kmp_set_defaults because th_cons stack was | |||
3838 | // not allocated | |||
3839 | // for existed thread(s) thus the first __kmp_push_<construct> will break | |||
3840 | // with assertion. | |||
3841 | // TODO: allocate th_cons if called from kmp_set_defaults. | |||
3842 | __kmp_env_consistency_check = TRUE(!0); | |||
3843 | } else if (!__kmp_strcasecmp_with_sentinel("none", value, 0)) { | |||
3844 | __kmp_env_consistency_check = FALSE0; | |||
3845 | } else { | |||
3846 | KMP_WARNING(StgInvalidValue, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgInvalidValue , name, value), __kmp_msg_null); | |||
3847 | } | |||
3848 | } // __kmp_stg_parse_consistency_check | |||
3849 | ||||
3850 | static void __kmp_stg_print_consistency_check(kmp_str_buf_t *buffer, | |||
3851 | char const *name, void *data) { | |||
3852 | #if KMP_DEBUG1 | |||
3853 | const char *value = NULL__null; | |||
3854 | ||||
3855 | if (__kmp_env_consistency_check) { | |||
3856 | value = "all"; | |||
3857 | } else { | |||
3858 | value = "none"; | |||
3859 | } | |||
3860 | ||||
3861 | if (value != NULL__null) { | |||
3862 | __kmp_stg_print_str(buffer, name, value); | |||
3863 | } | |||
3864 | #endif /* KMP_DEBUG */ | |||
3865 | } // __kmp_stg_print_consistency_check | |||
3866 | ||||
3867 | #if USE_ITT_BUILD1 | |||
3868 | // ----------------------------------------------------------------------------- | |||
3869 | // KMP_ITT_PREPARE_DELAY | |||
3870 | ||||
3871 | #if USE_ITT_NOTIFY1 | |||
3872 | ||||
3873 | static void __kmp_stg_parse_itt_prepare_delay(char const *name, | |||
3874 | char const *value, void *data) { | |||
3875 | // Experimental code: KMP_ITT_PREPARE_DELAY specifies numbert of loop | |||
3876 | // iterations. | |||
3877 | int delay = 0; | |||
3878 | __kmp_stg_parse_int(name, value, 0, INT_MAX2147483647, &delay); | |||
3879 | __kmp_itt_prepare_delay = delay; | |||
3880 | } // __kmp_str_parse_itt_prepare_delay | |||
3881 | ||||
3882 | static void __kmp_stg_print_itt_prepare_delay(kmp_str_buf_t *buffer, | |||
3883 | char const *name, void *data) { | |||
3884 | __kmp_stg_print_uint64(buffer, name, __kmp_itt_prepare_delay); | |||
3885 | ||||
3886 | } // __kmp_str_print_itt_prepare_delay | |||
3887 | ||||
3888 | #endif // USE_ITT_NOTIFY | |||
3889 | #endif /* USE_ITT_BUILD */ | |||
3890 | ||||
3891 | // ----------------------------------------------------------------------------- | |||
3892 | // KMP_MALLOC_POOL_INCR | |||
3893 | ||||
3894 | static void __kmp_stg_parse_malloc_pool_incr(char const *name, | |||
3895 | char const *value, void *data) { | |||
3896 | __kmp_stg_parse_size(name, value, KMP_MIN_MALLOC_POOL_INCR((size_t)(4 * 1024)), | |||
3897 | KMP_MAX_MALLOC_POOL_INCR(~((size_t)1 << ((sizeof(size_t) * (1 << 3)) - 1) )), NULL__null, &__kmp_malloc_pool_incr, | |||
3898 | 1); | |||
3899 | } // __kmp_stg_parse_malloc_pool_incr | |||
3900 | ||||
3901 | static void __kmp_stg_print_malloc_pool_incr(kmp_str_buf_t *buffer, | |||
3902 | char const *name, void *data) { | |||
3903 | __kmp_stg_print_size(buffer, name, __kmp_malloc_pool_incr); | |||
3904 | ||||
3905 | } // _kmp_stg_print_malloc_pool_incr | |||
3906 | ||||
3907 | #ifdef KMP_DEBUG1 | |||
3908 | ||||
3909 | // ----------------------------------------------------------------------------- | |||
3910 | // KMP_PAR_RANGE | |||
3911 | ||||
3912 | static void __kmp_stg_parse_par_range_env(char const *name, char const *value, | |||
3913 | void *data) { | |||
3914 | __kmp_stg_parse_par_range(name, value, &__kmp_par_range, | |||
3915 | __kmp_par_range_routine, __kmp_par_range_filename, | |||
3916 | &__kmp_par_range_lb, &__kmp_par_range_ub); | |||
3917 | } // __kmp_stg_parse_par_range_env | |||
3918 | ||||
3919 | static void __kmp_stg_print_par_range_env(kmp_str_buf_t *buffer, | |||
3920 | char const *name, void *data) { | |||
3921 | if (__kmp_par_range != 0) { | |||
3922 | __kmp_stg_print_str(buffer, name, par_range_to_print); | |||
3923 | } | |||
3924 | } // __kmp_stg_print_par_range_env | |||
3925 | ||||
3926 | // ----------------------------------------------------------------------------- | |||
3927 | // KMP_YIELD_CYCLE, KMP_YIELD_ON, KMP_YIELD_OFF | |||
3928 | ||||
3929 | static void __kmp_stg_parse_yield_cycle(char const *name, char const *value, | |||
3930 | void *data) { | |||
3931 | int flag = __kmp_yield_cycle; | |||
3932 | __kmp_stg_parse_bool(name, value, &flag); | |||
3933 | __kmp_yield_cycle = flag; | |||
3934 | } // __kmp_stg_parse_yield_cycle | |||
3935 | ||||
3936 | static void __kmp_stg_print_yield_cycle(kmp_str_buf_t *buffer, char const *name, | |||
3937 | void *data) { | |||
3938 | __kmp_stg_print_bool(buffer, name, __kmp_yield_cycle); | |||
3939 | } // __kmp_stg_print_yield_cycle | |||
3940 | ||||
3941 | static void __kmp_stg_parse_yield_on(char const *name, char const *value, | |||
3942 | void *data) { | |||
3943 | __kmp_stg_parse_int(name, value, 2, INT_MAX2147483647, &__kmp_yield_on_count); | |||
3944 | } // __kmp_stg_parse_yield_on | |||
3945 | ||||
3946 | static void __kmp_stg_print_yield_on(kmp_str_buf_t *buffer, char const *name, | |||
3947 | void *data) { | |||
3948 | __kmp_stg_print_int(buffer, name, __kmp_yield_on_count); | |||
3949 | } // __kmp_stg_print_yield_on | |||
3950 | ||||
3951 | static void __kmp_stg_parse_yield_off(char const *name, char const *value, | |||
3952 | void *data) { | |||
3953 | __kmp_stg_parse_int(name, value, 2, INT_MAX2147483647, &__kmp_yield_off_count); | |||
3954 | } // __kmp_stg_parse_yield_off | |||
3955 | ||||
3956 | static void __kmp_stg_print_yield_off(kmp_str_buf_t *buffer, char const *name, | |||
3957 | void *data) { | |||
3958 | __kmp_stg_print_int(buffer, name, __kmp_yield_off_count); | |||
3959 | } // __kmp_stg_print_yield_off | |||
3960 | ||||
3961 | #endif | |||
3962 | ||||
3963 | // ----------------------------------------------------------------------------- | |||
3964 | // KMP_INIT_WAIT, KMP_NEXT_WAIT | |||
3965 | ||||
3966 | static void __kmp_stg_parse_init_wait(char const *name, char const *value, | |||
3967 | void *data) { | |||
3968 | int wait; | |||
3969 | KMP_ASSERT((__kmp_init_wait & 1) == 0)if (!((__kmp_init_wait & 1) == 0)) { __kmp_debug_assert("(__kmp_init_wait & 1) == 0" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3969); }; | |||
3970 | wait = __kmp_init_wait / 2; | |||
3971 | __kmp_stg_parse_int(name, value, KMP_MIN_INIT_WAIT1, KMP_MAX_INIT_WAIT(2147483647 / 2), &wait); | |||
3972 | __kmp_init_wait = wait * 2; | |||
3973 | KMP_ASSERT((__kmp_init_wait & 1) == 0)if (!((__kmp_init_wait & 1) == 0)) { __kmp_debug_assert("(__kmp_init_wait & 1) == 0" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3973); }; | |||
3974 | __kmp_yield_init = __kmp_init_wait; | |||
3975 | } // __kmp_stg_parse_init_wait | |||
3976 | ||||
3977 | static void __kmp_stg_print_init_wait(kmp_str_buf_t *buffer, char const *name, | |||
3978 | void *data) { | |||
3979 | __kmp_stg_print_int(buffer, name, __kmp_init_wait); | |||
3980 | } // __kmp_stg_print_init_wait | |||
3981 | ||||
3982 | static void __kmp_stg_parse_next_wait(char const *name, char const *value, | |||
3983 | void *data) { | |||
3984 | int wait; | |||
3985 | KMP_ASSERT((__kmp_next_wait & 1) == 0)if (!((__kmp_next_wait & 1) == 0)) { __kmp_debug_assert("(__kmp_next_wait & 1) == 0" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3985); }; | |||
3986 | wait = __kmp_next_wait / 2; | |||
3987 | __kmp_stg_parse_int(name, value, KMP_MIN_NEXT_WAIT1, KMP_MAX_NEXT_WAIT(2147483647 / 2), &wait); | |||
3988 | __kmp_next_wait = wait * 2; | |||
3989 | KMP_ASSERT((__kmp_next_wait & 1) == 0)if (!((__kmp_next_wait & 1) == 0)) { __kmp_debug_assert("(__kmp_next_wait & 1) == 0" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 3989); }; | |||
3990 | __kmp_yield_next = __kmp_next_wait; | |||
3991 | } // __kmp_stg_parse_next_wait | |||
3992 | ||||
3993 | static void __kmp_stg_print_next_wait(kmp_str_buf_t *buffer, char const *name, | |||
3994 | void *data) { | |||
3995 | __kmp_stg_print_int(buffer, name, __kmp_next_wait); | |||
3996 | } //__kmp_stg_print_next_wait | |||
3997 | ||||
3998 | // ----------------------------------------------------------------------------- | |||
3999 | // KMP_GTID_MODE | |||
4000 | ||||
4001 | static void __kmp_stg_parse_gtid_mode(char const *name, char const *value, | |||
4002 | void *data) { | |||
4003 | // Modes: | |||
4004 | // 0 -- do not change default | |||
4005 | // 1 -- sp search | |||
4006 | // 2 -- use "keyed" TLS var, i.e. | |||
4007 | // pthread_getspecific(Linux* OS/OS X*) or TlsGetValue(Windows* OS) | |||
4008 | // 3 -- __declspec(thread) TLS var in tdata section | |||
4009 | int mode = 0; | |||
4010 | int max = 2; | |||
4011 | #ifdef KMP_TDATA_GTID1 | |||
4012 | max = 3; | |||
4013 | #endif /* KMP_TDATA_GTID */ | |||
4014 | __kmp_stg_parse_int(name, value, 0, max, &mode); | |||
4015 | // TODO; parse_int is not very suitable for this case. In case of overflow it | |||
4016 | // is better to use 0 rather that max value. | |||
4017 | if (mode == 0) { | |||
4018 | __kmp_adjust_gtid_mode = TRUE(!0); | |||
4019 | } else { | |||
4020 | __kmp_gtid_mode = mode; | |||
4021 | __kmp_adjust_gtid_mode = FALSE0; | |||
4022 | } | |||
4023 | } // __kmp_str_parse_gtid_mode | |||
4024 | ||||
4025 | static void __kmp_stg_print_gtid_mode(kmp_str_buf_t *buffer, char const *name, | |||
4026 | void *data) { | |||
4027 | if (__kmp_adjust_gtid_mode) { | |||
4028 | __kmp_stg_print_int(buffer, name, 0); | |||
4029 | } else { | |||
4030 | __kmp_stg_print_int(buffer, name, __kmp_gtid_mode); | |||
4031 | } | |||
4032 | } // __kmp_stg_print_gtid_mode | |||
4033 | ||||
4034 | // ----------------------------------------------------------------------------- | |||
4035 | // KMP_NUM_LOCKS_IN_BLOCK | |||
4036 | ||||
4037 | static void __kmp_stg_parse_lock_block(char const *name, char const *value, | |||
4038 | void *data) { | |||
4039 | __kmp_stg_parse_int(name, value, 0, KMP_INT_MAX((kmp_int32)0x7FFFFFFF), &__kmp_num_locks_in_block); | |||
4040 | } // __kmp_str_parse_lock_block | |||
4041 | ||||
4042 | static void __kmp_stg_print_lock_block(kmp_str_buf_t *buffer, char const *name, | |||
4043 | void *data) { | |||
4044 | __kmp_stg_print_int(buffer, name, __kmp_num_locks_in_block); | |||
4045 | } // __kmp_stg_print_lock_block | |||
4046 | ||||
4047 | // ----------------------------------------------------------------------------- | |||
4048 | // KMP_LOCK_KIND | |||
4049 | ||||
4050 | #if KMP_USE_DYNAMIC_LOCK1 | |||
4051 | #define KMP_STORE_LOCK_SEQ(a)(__kmp_user_lock_seq = lockseq_a) (__kmp_user_lock_seq = lockseq_##a) | |||
4052 | #else | |||
4053 | #define KMP_STORE_LOCK_SEQ(a)(__kmp_user_lock_seq = lockseq_a) | |||
4054 | #endif | |||
4055 | ||||
4056 | static void __kmp_stg_parse_lock_kind(char const *name, char const *value, | |||
4057 | void *data) { | |||
4058 | if (__kmp_init_user_locks) { | |||
4059 | KMP_WARNING(EnvLockWarn, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvLockWarn , name), __kmp_msg_null); | |||
4060 | return; | |||
4061 | } | |||
4062 | ||||
4063 | if (__kmp_str_match("tas", 2, value) || | |||
4064 | __kmp_str_match("test and set", 2, value) || | |||
4065 | __kmp_str_match("test_and_set", 2, value) || | |||
4066 | __kmp_str_match("test-and-set", 2, value) || | |||
4067 | __kmp_str_match("test andset", 2, value) || | |||
4068 | __kmp_str_match("test_andset", 2, value) || | |||
4069 | __kmp_str_match("test-andset", 2, value) || | |||
4070 | __kmp_str_match("testand set", 2, value) || | |||
4071 | __kmp_str_match("testand_set", 2, value) || | |||
4072 | __kmp_str_match("testand-set", 2, value) || | |||
4073 | __kmp_str_match("testandset", 2, value)) { | |||
4074 | __kmp_user_lock_kind = lk_tas; | |||
4075 | KMP_STORE_LOCK_SEQ(tas)(__kmp_user_lock_seq = lockseq_tas); | |||
4076 | } | |||
4077 | #if KMP_USE_FUTEX(1 && !0 && (0 || 1 || KMP_ARCH_ARM || 0)) | |||
4078 | else if (__kmp_str_match("futex", 1, value)) { | |||
4079 | if (__kmp_futex_determine_capable()) { | |||
4080 | __kmp_user_lock_kind = lk_futex; | |||
4081 | KMP_STORE_LOCK_SEQ(futex)(__kmp_user_lock_seq = lockseq_futex); | |||
4082 | } else { | |||
4083 | KMP_WARNING(FutexNotSupported, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_FutexNotSupported , name, value), __kmp_msg_null); | |||
4084 | } | |||
4085 | } | |||
4086 | #endif | |||
4087 | else if (__kmp_str_match("ticket", 2, value)) { | |||
4088 | __kmp_user_lock_kind = lk_ticket; | |||
4089 | KMP_STORE_LOCK_SEQ(ticket)(__kmp_user_lock_seq = lockseq_ticket); | |||
4090 | } else if (__kmp_str_match("queuing", 1, value) || | |||
4091 | __kmp_str_match("queue", 1, value)) { | |||
4092 | __kmp_user_lock_kind = lk_queuing; | |||
4093 | KMP_STORE_LOCK_SEQ(queuing)(__kmp_user_lock_seq = lockseq_queuing); | |||
4094 | } else if (__kmp_str_match("drdpa ticket", 1, value) || | |||
4095 | __kmp_str_match("drdpa_ticket", 1, value) || | |||
4096 | __kmp_str_match("drdpa-ticket", 1, value) || | |||
4097 | __kmp_str_match("drdpaticket", 1, value) || | |||
4098 | __kmp_str_match("drdpa", 1, value)) { | |||
4099 | __kmp_user_lock_kind = lk_drdpa; | |||
4100 | KMP_STORE_LOCK_SEQ(drdpa)(__kmp_user_lock_seq = lockseq_drdpa); | |||
4101 | } | |||
4102 | #if KMP_USE_ADAPTIVE_LOCKS(0 || 1) && !0 | |||
4103 | else if (__kmp_str_match("adaptive", 1, value)) { | |||
4104 | if (__kmp_cpuinfo.rtm) { // ??? Is cpuinfo available here? | |||
4105 | __kmp_user_lock_kind = lk_adaptive; | |||
4106 | KMP_STORE_LOCK_SEQ(adaptive)(__kmp_user_lock_seq = lockseq_adaptive); | |||
4107 | } else { | |||
4108 | KMP_WARNING(AdaptiveNotSupported, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AdaptiveNotSupported , name, value), __kmp_msg_null); | |||
4109 | __kmp_user_lock_kind = lk_queuing; | |||
4110 | KMP_STORE_LOCK_SEQ(queuing)(__kmp_user_lock_seq = lockseq_queuing); | |||
4111 | } | |||
4112 | } | |||
4113 | #endif // KMP_USE_ADAPTIVE_LOCKS | |||
4114 | #if KMP_USE_DYNAMIC_LOCK1 && KMP_USE_TSX(0 || 1) && !0 | |||
4115 | else if (__kmp_str_match("rtm", 1, value)) { | |||
4116 | if (__kmp_cpuinfo.rtm) { | |||
4117 | __kmp_user_lock_kind = lk_rtm; | |||
4118 | KMP_STORE_LOCK_SEQ(rtm)(__kmp_user_lock_seq = lockseq_rtm); | |||
4119 | } else { | |||
4120 | KMP_WARNING(AdaptiveNotSupported, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AdaptiveNotSupported , name, value), __kmp_msg_null); | |||
4121 | __kmp_user_lock_kind = lk_queuing; | |||
4122 | KMP_STORE_LOCK_SEQ(queuing)(__kmp_user_lock_seq = lockseq_queuing); | |||
4123 | } | |||
4124 | } else if (__kmp_str_match("hle", 1, value)) { | |||
4125 | __kmp_user_lock_kind = lk_hle; | |||
4126 | KMP_STORE_LOCK_SEQ(hle)(__kmp_user_lock_seq = lockseq_hle); | |||
4127 | } | |||
4128 | #endif | |||
4129 | else { | |||
4130 | KMP_WARNING(StgInvalidValue, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgInvalidValue , name, value), __kmp_msg_null); | |||
4131 | } | |||
4132 | } | |||
4133 | ||||
4134 | static void __kmp_stg_print_lock_kind(kmp_str_buf_t *buffer, char const *name, | |||
4135 | void *data) { | |||
4136 | const char *value = NULL__null; | |||
4137 | ||||
4138 | switch (__kmp_user_lock_kind) { | |||
4139 | case lk_default: | |||
4140 | value = "default"; | |||
4141 | break; | |||
4142 | ||||
4143 | case lk_tas: | |||
4144 | value = "tas"; | |||
4145 | break; | |||
4146 | ||||
4147 | #if KMP_USE_FUTEX(1 && !0 && (0 || 1 || KMP_ARCH_ARM || 0)) | |||
4148 | case lk_futex: | |||
4149 | value = "futex"; | |||
4150 | break; | |||
4151 | #endif | |||
4152 | ||||
4153 | #if KMP_USE_DYNAMIC_LOCK1 && KMP_USE_TSX(0 || 1) && !0 | |||
4154 | case lk_rtm: | |||
4155 | value = "rtm"; | |||
4156 | break; | |||
4157 | ||||
4158 | case lk_hle: | |||
4159 | value = "hle"; | |||
4160 | break; | |||
4161 | #endif | |||
4162 | ||||
4163 | case lk_ticket: | |||
4164 | value = "ticket"; | |||
4165 | break; | |||
4166 | ||||
4167 | case lk_queuing: | |||
4168 | value = "queuing"; | |||
4169 | break; | |||
4170 | ||||
4171 | case lk_drdpa: | |||
4172 | value = "drdpa"; | |||
4173 | break; | |||
4174 | #if KMP_USE_ADAPTIVE_LOCKS(0 || 1) && !0 | |||
4175 | case lk_adaptive: | |||
4176 | value = "adaptive"; | |||
4177 | break; | |||
4178 | #endif | |||
4179 | } | |||
4180 | ||||
4181 | if (value != NULL__null) { | |||
4182 | __kmp_stg_print_str(buffer, name, value); | |||
4183 | } | |||
4184 | } | |||
4185 | ||||
4186 | // ----------------------------------------------------------------------------- | |||
4187 | // KMP_SPIN_BACKOFF_PARAMS | |||
4188 | ||||
4189 | // KMP_SPIN_BACKOFF_PARAMS=max_backoff[,min_tick] (max backoff size, min tick | |||
4190 | // for machine pause) | |||
4191 | static void __kmp_stg_parse_spin_backoff_params(const char *name, | |||
4192 | const char *value, void *data) { | |||
4193 | const char *next = value; | |||
4194 | ||||
4195 | int total = 0; // Count elements that were set. It'll be used as an array size | |||
4196 | int prev_comma = FALSE0; // For correct processing sequential commas | |||
4197 | int i; | |||
4198 | ||||
4199 | kmp_uint32 max_backoff = __kmp_spin_backoff_params.max_backoff; | |||
4200 | kmp_uint32 min_tick = __kmp_spin_backoff_params.min_tick; | |||
4201 | ||||
4202 | // Run only 3 iterations because it is enough to read two values or find a | |||
4203 | // syntax error | |||
4204 | for (i = 0; i < 3; i++) { | |||
4205 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
4206 | ||||
4207 | if (*next == '\0') { | |||
4208 | break; | |||
4209 | } | |||
4210 | // Next character is not an integer or not a comma OR number of values > 2 | |||
4211 | // => end of list | |||
4212 | if (((*next < '0' || *next > '9') && *next != ',') || total > 2) { | |||
4213 | KMP_WARNING(EnvSyntaxError, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvSyntaxError , name, value), __kmp_msg_null); | |||
4214 | return; | |||
4215 | } | |||
4216 | // The next character is ',' | |||
4217 | if (*next == ',') { | |||
4218 | // ',' is the fisrt character | |||
4219 | if (total == 0 || prev_comma) { | |||
4220 | total++; | |||
4221 | } | |||
4222 | prev_comma = TRUE(!0); | |||
4223 | next++; // skip ',' | |||
4224 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
4225 | } | |||
4226 | // Next character is a digit | |||
4227 | if (*next >= '0' && *next <= '9') { | |||
4228 | int num; | |||
4229 | const char *buf = next; | |||
4230 | char const *msg = NULL__null; | |||
4231 | prev_comma = FALSE0; | |||
4232 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
4233 | total++; | |||
4234 | ||||
4235 | const char *tmp = next; | |||
4236 | SKIP_WS(tmp){ while (*(tmp) == ' ' || *(tmp) == '\t') (tmp)++; }; | |||
4237 | if ((*next == ' ' || *next == '\t') && (*tmp >= '0' && *tmp <= '9')) { | |||
4238 | KMP_WARNING(EnvSpacesNotAllowed, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvSpacesNotAllowed , name, value), __kmp_msg_null); | |||
4239 | return; | |||
4240 | } | |||
4241 | ||||
4242 | num = __kmp_str_to_int(buf, *next); | |||
4243 | if (num <= 0) { // The number of retries should be > 0 | |||
4244 | msg = KMP_I18N_STR(ValueTooSmall)__kmp_i18n_catgets(kmp_i18n_str_ValueTooSmall); | |||
4245 | num = 1; | |||
4246 | } else if (num > KMP_INT_MAX((kmp_int32)0x7FFFFFFF)) { | |||
4247 | msg = KMP_I18N_STR(ValueTooLarge)__kmp_i18n_catgets(kmp_i18n_str_ValueTooLarge); | |||
4248 | num = KMP_INT_MAX((kmp_int32)0x7FFFFFFF); | |||
4249 | } | |||
4250 | if (msg != NULL__null) { | |||
4251 | // Message is not empty. Print warning. | |||
4252 | KMP_WARNING(ParseSizeIntWarn, name, value, msg)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_ParseSizeIntWarn , name, value, msg), __kmp_msg_null); | |||
4253 | KMP_INFORM(Using_int_Value, name, num)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_int_Value , name, num), __kmp_msg_null); | |||
4254 | } | |||
4255 | if (total == 1) { | |||
4256 | max_backoff = num; | |||
4257 | } else if (total == 2) { | |||
4258 | min_tick = num; | |||
4259 | } | |||
4260 | } | |||
4261 | } | |||
4262 | KMP_DEBUG_ASSERT(total > 0)if (!(total > 0)) { __kmp_debug_assert("total > 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 4262); }; | |||
4263 | if (total <= 0) { | |||
4264 | KMP_WARNING(EnvSyntaxError, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvSyntaxError , name, value), __kmp_msg_null); | |||
4265 | return; | |||
4266 | } | |||
4267 | __kmp_spin_backoff_params.max_backoff = max_backoff; | |||
4268 | __kmp_spin_backoff_params.min_tick = min_tick; | |||
4269 | } | |||
4270 | ||||
4271 | static void __kmp_stg_print_spin_backoff_params(kmp_str_buf_t *buffer, | |||
4272 | char const *name, void *data) { | |||
4273 | if (__kmp_env_format) { | |||
4274 | KMP_STR_BUF_PRINT_NAME_EX(name)__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
4275 | } else { | |||
4276 | __kmp_str_buf_print(buffer, " %s='", name); | |||
4277 | } | |||
4278 | __kmp_str_buf_print(buffer, "%d,%d'\n", __kmp_spin_backoff_params.max_backoff, | |||
4279 | __kmp_spin_backoff_params.min_tick); | |||
4280 | } | |||
4281 | ||||
4282 | #if KMP_USE_ADAPTIVE_LOCKS(0 || 1) && !0 | |||
4283 | ||||
4284 | // ----------------------------------------------------------------------------- | |||
4285 | // KMP_ADAPTIVE_LOCK_PROPS, KMP_SPECULATIVE_STATSFILE | |||
4286 | ||||
4287 | // Parse out values for the tunable parameters from a string of the form | |||
4288 | // KMP_ADAPTIVE_LOCK_PROPS=max_soft_retries[,max_badness] | |||
4289 | static void __kmp_stg_parse_adaptive_lock_props(const char *name, | |||
4290 | const char *value, void *data) { | |||
4291 | int max_retries = 0; | |||
4292 | int max_badness = 0; | |||
4293 | ||||
4294 | const char *next = value; | |||
4295 | ||||
4296 | int total = 0; // Count elements that were set. It'll be used as an array size | |||
4297 | int prev_comma = FALSE0; // For correct processing sequential commas | |||
4298 | int i; | |||
4299 | ||||
4300 | // Save values in the structure __kmp_speculative_backoff_params | |||
4301 | // Run only 3 iterations because it is enough to read two values or find a | |||
4302 | // syntax error | |||
4303 | for (i = 0; i < 3; i++) { | |||
4304 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
4305 | ||||
4306 | if (*next == '\0') { | |||
4307 | break; | |||
4308 | } | |||
4309 | // Next character is not an integer or not a comma OR number of values > 2 | |||
4310 | // => end of list | |||
4311 | if (((*next < '0' || *next > '9') && *next != ',') || total > 2) { | |||
4312 | KMP_WARNING(EnvSyntaxError, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvSyntaxError , name, value), __kmp_msg_null); | |||
4313 | return; | |||
4314 | } | |||
4315 | // The next character is ',' | |||
4316 | if (*next == ',') { | |||
4317 | // ',' is the fisrt character | |||
4318 | if (total == 0 || prev_comma) { | |||
4319 | total++; | |||
4320 | } | |||
4321 | prev_comma = TRUE(!0); | |||
4322 | next++; // skip ',' | |||
4323 | SKIP_WS(next){ while (*(next) == ' ' || *(next) == '\t') (next)++; }; | |||
4324 | } | |||
4325 | // Next character is a digit | |||
4326 | if (*next >= '0' && *next <= '9') { | |||
4327 | int num; | |||
4328 | const char *buf = next; | |||
4329 | char const *msg = NULL__null; | |||
4330 | prev_comma = FALSE0; | |||
4331 | SKIP_DIGITS(next){ while (*(next) >= '0' && *(next) <= '9') (next )++; }; | |||
4332 | total++; | |||
4333 | ||||
4334 | const char *tmp = next; | |||
4335 | SKIP_WS(tmp){ while (*(tmp) == ' ' || *(tmp) == '\t') (tmp)++; }; | |||
4336 | if ((*next == ' ' || *next == '\t') && (*tmp >= '0' && *tmp <= '9')) { | |||
4337 | KMP_WARNING(EnvSpacesNotAllowed, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvSpacesNotAllowed , name, value), __kmp_msg_null); | |||
4338 | return; | |||
4339 | } | |||
4340 | ||||
4341 | num = __kmp_str_to_int(buf, *next); | |||
4342 | if (num < 0) { // The number of retries should be >= 0 | |||
4343 | msg = KMP_I18N_STR(ValueTooSmall)__kmp_i18n_catgets(kmp_i18n_str_ValueTooSmall); | |||
4344 | num = 1; | |||
4345 | } else if (num > KMP_INT_MAX((kmp_int32)0x7FFFFFFF)) { | |||
4346 | msg = KMP_I18N_STR(ValueTooLarge)__kmp_i18n_catgets(kmp_i18n_str_ValueTooLarge); | |||
4347 | num = KMP_INT_MAX((kmp_int32)0x7FFFFFFF); | |||
4348 | } | |||
4349 | if (msg != NULL__null) { | |||
4350 | // Message is not empty. Print warning. | |||
4351 | KMP_WARNING(ParseSizeIntWarn, name, value, msg)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_ParseSizeIntWarn , name, value, msg), __kmp_msg_null); | |||
4352 | KMP_INFORM(Using_int_Value, name, num)__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_Using_int_Value , name, num), __kmp_msg_null); | |||
4353 | } | |||
4354 | if (total == 1) { | |||
4355 | max_retries = num; | |||
4356 | } else if (total == 2) { | |||
4357 | max_badness = num; | |||
4358 | } | |||
4359 | } | |||
4360 | } | |||
4361 | KMP_DEBUG_ASSERT(total > 0)if (!(total > 0)) { __kmp_debug_assert("total > 0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 4361); }; | |||
4362 | if (total <= 0) { | |||
4363 | KMP_WARNING(EnvSyntaxError, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvSyntaxError , name, value), __kmp_msg_null); | |||
4364 | return; | |||
4365 | } | |||
4366 | __kmp_adaptive_backoff_params.max_soft_retries = max_retries; | |||
4367 | __kmp_adaptive_backoff_params.max_badness = max_badness; | |||
4368 | } | |||
4369 | ||||
4370 | static void __kmp_stg_print_adaptive_lock_props(kmp_str_buf_t *buffer, | |||
4371 | char const *name, void *data) { | |||
4372 | if (__kmp_env_format) { | |||
4373 | KMP_STR_BUF_PRINT_NAME_EX(name)__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
4374 | } else { | |||
4375 | __kmp_str_buf_print(buffer, " %s='", name); | |||
4376 | } | |||
4377 | __kmp_str_buf_print(buffer, "%d,%d'\n", | |||
4378 | __kmp_adaptive_backoff_params.max_soft_retries, | |||
4379 | __kmp_adaptive_backoff_params.max_badness); | |||
4380 | } // __kmp_stg_print_adaptive_lock_props | |||
4381 | ||||
4382 | #if KMP_DEBUG_ADAPTIVE_LOCKS0 | |||
4383 | ||||
4384 | static void __kmp_stg_parse_speculative_statsfile(char const *name, | |||
4385 | char const *value, | |||
4386 | void *data) { | |||
4387 | __kmp_stg_parse_file(name, value, "", CCAST(char**, &__kmp_speculative_statsfile)const_cast<char**>(&__kmp_speculative_statsfile)); | |||
4388 | } // __kmp_stg_parse_speculative_statsfile | |||
4389 | ||||
4390 | static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer, | |||
4391 | char const *name, | |||
4392 | void *data) { | |||
4393 | if (__kmp_str_match("-", 0, __kmp_speculative_statsfile)) { | |||
4394 | __kmp_stg_print_str(buffer, name, "stdout"); | |||
4395 | } else { | |||
4396 | __kmp_stg_print_str(buffer, name, __kmp_speculative_statsfile); | |||
4397 | } | |||
4398 | ||||
4399 | } // __kmp_stg_print_speculative_statsfile | |||
4400 | ||||
4401 | #endif // KMP_DEBUG_ADAPTIVE_LOCKS | |||
4402 | ||||
4403 | #endif // KMP_USE_ADAPTIVE_LOCKS | |||
4404 | ||||
4405 | // ----------------------------------------------------------------------------- | |||
4406 | // KMP_HW_SUBSET (was KMP_PLACE_THREADS) | |||
4407 | ||||
4408 | // The longest observable sequense of items is | |||
4409 | // Socket-Node-Tile-Core-Thread | |||
4410 | // So, let's limit to 5 levels for now | |||
4411 | // The input string is usually short enough, let's use 512 limit for now | |||
4412 | #define MAX_T_LEVEL5 5 | |||
4413 | #define MAX_STR_LEN512 512 | |||
4414 | static void __kmp_stg_parse_hw_subset(char const *name, char const *value, | |||
4415 | void *data) { | |||
4416 | // Value example: 1s,5c@3,2T | |||
4417 | // Which means "use 1 socket, 5 cores with offset 3, 2 threads per core" | |||
4418 | kmp_setting_t **rivals = (kmp_setting_t **)data; | |||
4419 | if (strcmp(name, "KMP_PLACE_THREADS") == 0) { | |||
4420 | KMP_INFORM(EnvVarDeprecated, name, "KMP_HW_SUBSET")__kmp_msg(kmp_ms_inform, __kmp_msg_format(kmp_i18n_msg_EnvVarDeprecated , name, "KMP_HW_SUBSET"), __kmp_msg_null); | |||
4421 | } | |||
4422 | if (__kmp_stg_check_rivals(name, value, rivals)) { | |||
4423 | return; | |||
4424 | } | |||
4425 | ||||
4426 | char *components[MAX_T_LEVEL5]; | |||
4427 | char const *digits = "0123456789"; | |||
4428 | char input[MAX_STR_LEN512]; | |||
4429 | size_t len = 0, mlen = MAX_STR_LEN512; | |||
4430 | int level = 0; | |||
4431 | // Canonize the string (remove spaces, unify delimiters, etc.) | |||
4432 | char *pos = CCAST(char *, value)const_cast<char *>(value); | |||
4433 | while (*pos && mlen) { | |||
4434 | if (*pos != ' ') { // skip spaces | |||
4435 | if (len == 0 && *pos == ':') { | |||
4436 | __kmp_hws_abs_flag = 1; // if the first symbol is ":", skip it | |||
4437 | } else { | |||
4438 | input[len] = toupper(*pos); | |||
4439 | if (input[len] == 'X') | |||
4440 | input[len] = ','; // unify delimiters of levels | |||
4441 | if (input[len] == 'O' && strchr(digits, *(pos + 1))) | |||
4442 | input[len] = '@'; // unify delimiters of offset | |||
4443 | len++; | |||
4444 | } | |||
4445 | } | |||
4446 | mlen--; | |||
4447 | pos++; | |||
4448 | } | |||
4449 | if (len == 0 || mlen == 0) | |||
4450 | goto err; // contents is either empty or too long | |||
4451 | input[len] = '\0'; | |||
4452 | __kmp_hws_requested = 1; // mark that subset requested | |||
4453 | // Split by delimiter | |||
4454 | pos = input; | |||
4455 | components[level++] = pos; | |||
4456 | while ((pos = strchr(pos, ','))) { | |||
4457 | *pos = '\0'; // modify input and avoid more copying | |||
4458 | components[level++] = ++pos; // expect something after "," | |||
4459 | if (level > MAX_T_LEVEL5) | |||
4460 | goto err; // too many components provided | |||
4461 | } | |||
4462 | // Check each component | |||
4463 | for (int i = 0; i < level; ++i) { | |||
4464 | int offset = 0; | |||
4465 | int num = atoi(components[i]); // each component should start with a number | |||
4466 | if ((pos = strchr(components[i], '@'))) { | |||
4467 | offset = atoi(pos + 1); // save offset | |||
4468 | *pos = '\0'; // cut the offset from the component | |||
4469 | } | |||
4470 | pos = components[i] + strspn(components[i], digits); | |||
4471 | if (pos == components[i]) | |||
4472 | goto err; | |||
4473 | // detect the component type | |||
4474 | switch (*pos) { | |||
4475 | case 'S': // Socket | |||
4476 | if (__kmp_hws_socket.num > 0) | |||
4477 | goto err; // duplicate is not allowed | |||
4478 | __kmp_hws_socket.num = num; | |||
4479 | __kmp_hws_socket.offset = offset; | |||
4480 | break; | |||
4481 | case 'N': // NUMA Node | |||
4482 | if (__kmp_hws_node.num > 0) | |||
4483 | goto err; // duplicate is not allowed | |||
4484 | __kmp_hws_node.num = num; | |||
4485 | __kmp_hws_node.offset = offset; | |||
4486 | break; | |||
4487 | case 'L': // Cache | |||
4488 | if (*(pos + 1) == '2') { // L2 - Tile | |||
4489 | if (__kmp_hws_tile.num > 0) | |||
4490 | goto err; // duplicate is not allowed | |||
4491 | __kmp_hws_tile.num = num; | |||
4492 | __kmp_hws_tile.offset = offset; | |||
4493 | } else if (*(pos + 1) == '3') { // L3 - Socket | |||
4494 | if (__kmp_hws_socket.num > 0) | |||
4495 | goto err; // duplicate is not allowed | |||
4496 | __kmp_hws_socket.num = num; | |||
4497 | __kmp_hws_socket.offset = offset; | |||
4498 | } else if (*(pos + 1) == '1') { // L1 - Core | |||
4499 | if (__kmp_hws_core.num > 0) | |||
4500 | goto err; // duplicate is not allowed | |||
4501 | __kmp_hws_core.num = num; | |||
4502 | __kmp_hws_core.offset = offset; | |||
4503 | } | |||
4504 | break; | |||
4505 | case 'C': // Core (or Cache?) | |||
4506 | if (*(pos + 1) != 'A') { | |||
4507 | if (__kmp_hws_core.num > 0) | |||
4508 | goto err; // duplicate is not allowed | |||
4509 | __kmp_hws_core.num = num; | |||
4510 | __kmp_hws_core.offset = offset; | |||
4511 | } else { // Cache | |||
4512 | char *d = pos + strcspn(pos, digits); // find digit | |||
4513 | if (*d == '2') { // L2 - Tile | |||
4514 | if (__kmp_hws_tile.num > 0) | |||
4515 | goto err; // duplicate is not allowed | |||
4516 | __kmp_hws_tile.num = num; | |||
4517 | __kmp_hws_tile.offset = offset; | |||
4518 | } else if (*d == '3') { // L3 - Socket | |||
4519 | if (__kmp_hws_socket.num > 0) | |||
4520 | goto err; // duplicate is not allowed | |||
4521 | __kmp_hws_socket.num = num; | |||
4522 | __kmp_hws_socket.offset = offset; | |||
4523 | } else if (*d == '1') { // L1 - Core | |||
4524 | if (__kmp_hws_core.num > 0) | |||
4525 | goto err; // duplicate is not allowed | |||
4526 | __kmp_hws_core.num = num; | |||
4527 | __kmp_hws_core.offset = offset; | |||
4528 | } else { | |||
4529 | goto err; | |||
4530 | } | |||
4531 | } | |||
4532 | break; | |||
4533 | case 'T': // Thread | |||
4534 | if (__kmp_hws_proc.num > 0) | |||
4535 | goto err; // duplicate is not allowed | |||
4536 | __kmp_hws_proc.num = num; | |||
4537 | __kmp_hws_proc.offset = offset; | |||
4538 | break; | |||
4539 | default: | |||
4540 | goto err; | |||
4541 | } | |||
4542 | } | |||
4543 | return; | |||
4544 | err: | |||
4545 | KMP_WARNING(AffHWSubsetInvalid, name, value)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffHWSubsetInvalid , name, value), __kmp_msg_null); | |||
4546 | __kmp_hws_requested = 0; // mark that subset not requested | |||
4547 | return; | |||
4548 | } | |||
4549 | ||||
4550 | static void __kmp_stg_print_hw_subset(kmp_str_buf_t *buffer, char const *name, | |||
4551 | void *data) { | |||
4552 | if (__kmp_hws_requested) { | |||
4553 | int comma = 0; | |||
4554 | kmp_str_buf_t buf; | |||
4555 | __kmp_str_buf_init(&buf){ (&buf)->str = (&buf)->bulk; (&buf)->size = sizeof((&buf)->bulk); (&buf)->used = 0; (& buf)->bulk[0] = 0; }; | |||
4556 | if (__kmp_env_format) | |||
4557 | KMP_STR_BUF_PRINT_NAME_EX(name)__kmp_str_buf_print(buffer, " %s %s='", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
4558 | else | |||
4559 | __kmp_str_buf_print(buffer, " %s='", name); | |||
4560 | if (__kmp_hws_socket.num) { | |||
4561 | __kmp_str_buf_print(&buf, "%ds", __kmp_hws_socket.num); | |||
4562 | if (__kmp_hws_socket.offset) | |||
4563 | __kmp_str_buf_print(&buf, "@%d", __kmp_hws_socket.offset); | |||
4564 | comma = 1; | |||
4565 | } | |||
4566 | if (__kmp_hws_node.num) { | |||
4567 | __kmp_str_buf_print(&buf, "%s%dn", comma ? "," : "", __kmp_hws_node.num); | |||
4568 | if (__kmp_hws_node.offset) | |||
4569 | __kmp_str_buf_print(&buf, "@%d", __kmp_hws_node.offset); | |||
4570 | comma = 1; | |||
4571 | } | |||
4572 | if (__kmp_hws_tile.num) { | |||
4573 | __kmp_str_buf_print(&buf, "%s%dL2", comma ? "," : "", __kmp_hws_tile.num); | |||
4574 | if (__kmp_hws_tile.offset) | |||
4575 | __kmp_str_buf_print(&buf, "@%d", __kmp_hws_tile.offset); | |||
4576 | comma = 1; | |||
4577 | } | |||
4578 | if (__kmp_hws_core.num) { | |||
4579 | __kmp_str_buf_print(&buf, "%s%dc", comma ? "," : "", __kmp_hws_core.num); | |||
4580 | if (__kmp_hws_core.offset) | |||
4581 | __kmp_str_buf_print(&buf, "@%d", __kmp_hws_core.offset); | |||
4582 | comma = 1; | |||
4583 | } | |||
4584 | if (__kmp_hws_proc.num) | |||
4585 | __kmp_str_buf_print(&buf, "%s%dt", comma ? "," : "", __kmp_hws_proc.num); | |||
4586 | __kmp_str_buf_print(buffer, "%s'\n", buf.str); | |||
4587 | __kmp_str_buf_free(&buf); | |||
4588 | } | |||
4589 | } | |||
4590 | ||||
4591 | #if USE_ITT_BUILD1 | |||
4592 | // ----------------------------------------------------------------------------- | |||
4593 | // KMP_FORKJOIN_FRAMES | |||
4594 | ||||
4595 | static void __kmp_stg_parse_forkjoin_frames(char const *name, char const *value, | |||
4596 | void *data) { | |||
4597 | __kmp_stg_parse_bool(name, value, &__kmp_forkjoin_frames); | |||
4598 | } // __kmp_stg_parse_forkjoin_frames | |||
4599 | ||||
4600 | static void __kmp_stg_print_forkjoin_frames(kmp_str_buf_t *buffer, | |||
4601 | char const *name, void *data) { | |||
4602 | __kmp_stg_print_bool(buffer, name, __kmp_forkjoin_frames); | |||
4603 | } // __kmp_stg_print_forkjoin_frames | |||
4604 | ||||
4605 | // ----------------------------------------------------------------------------- | |||
4606 | // KMP_FORKJOIN_FRAMES_MODE | |||
4607 | ||||
4608 | static void __kmp_stg_parse_forkjoin_frames_mode(char const *name, | |||
4609 | char const *value, | |||
4610 | void *data) { | |||
4611 | __kmp_stg_parse_int(name, value, 0, 3, &__kmp_forkjoin_frames_mode); | |||
4612 | } // __kmp_stg_parse_forkjoin_frames | |||
4613 | ||||
4614 | static void __kmp_stg_print_forkjoin_frames_mode(kmp_str_buf_t *buffer, | |||
4615 | char const *name, void *data) { | |||
4616 | __kmp_stg_print_int(buffer, name, __kmp_forkjoin_frames_mode); | |||
4617 | } // __kmp_stg_print_forkjoin_frames | |||
4618 | #endif /* USE_ITT_BUILD */ | |||
4619 | ||||
4620 | // ----------------------------------------------------------------------------- | |||
4621 | // OMP_DISPLAY_ENV | |||
4622 | ||||
4623 | #if OMP_40_ENABLED(50 >= 40) | |||
4624 | ||||
4625 | static void __kmp_stg_parse_omp_display_env(char const *name, char const *value, | |||
4626 | void *data) { | |||
4627 | if (__kmp_str_match("VERBOSE", 1, value)) { | |||
4628 | __kmp_display_env_verbose = TRUE(!0); | |||
4629 | } else { | |||
4630 | __kmp_stg_parse_bool(name, value, &__kmp_display_env); | |||
4631 | } | |||
4632 | ||||
4633 | } // __kmp_stg_parse_omp_display_env | |||
4634 | ||||
4635 | static void __kmp_stg_print_omp_display_env(kmp_str_buf_t *buffer, | |||
4636 | char const *name, void *data) { | |||
4637 | if (__kmp_display_env_verbose) { | |||
4638 | __kmp_stg_print_str(buffer, name, "VERBOSE"); | |||
4639 | } else { | |||
4640 | __kmp_stg_print_bool(buffer, name, __kmp_display_env); | |||
4641 | } | |||
4642 | } // __kmp_stg_print_omp_display_env | |||
4643 | ||||
4644 | static void __kmp_stg_parse_omp_cancellation(char const *name, | |||
4645 | char const *value, void *data) { | |||
4646 | if (TCR_4(__kmp_init_parallel)(__kmp_init_parallel)) { | |||
4647 | KMP_WARNING(EnvParallelWarn, name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_EnvParallelWarn , name), __kmp_msg_null); | |||
4648 | return; | |||
4649 | } // read value before first parallel only | |||
4650 | __kmp_stg_parse_bool(name, value, &__kmp_omp_cancellation); | |||
4651 | } // __kmp_stg_parse_omp_cancellation | |||
4652 | ||||
4653 | static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer, | |||
4654 | char const *name, void *data) { | |||
4655 | __kmp_stg_print_bool(buffer, name, __kmp_omp_cancellation); | |||
4656 | } // __kmp_stg_print_omp_cancellation | |||
4657 | ||||
4658 | #endif | |||
4659 | ||||
4660 | #if OMP_50_ENABLED(50 >= 50) && OMPT_SUPPORT1 | |||
4661 | static int __kmp_tool = 1; | |||
4662 | ||||
4663 | static void __kmp_stg_parse_omp_tool(char const *name, char const *value, | |||
4664 | void *data) { | |||
4665 | __kmp_stg_parse_bool(name, value, &__kmp_tool); | |||
4666 | } // __kmp_stg_parse_omp_tool | |||
4667 | ||||
4668 | static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer, char const *name, | |||
4669 | void *data) { | |||
4670 | if (__kmp_env_format) { | |||
4671 | KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool, "enabled", "disabled")__kmp_str_buf_print(buffer, " %s %s='%s'\n", __kmp_i18n_catgets (kmp_i18n_str_Host), name, (__kmp_tool) ? "enabled" : "disabled" ); | |||
4672 | } else { | |||
4673 | __kmp_str_buf_print(buffer, " %s=%s\n", name, | |||
4674 | __kmp_tool ? "enabled" : "disabled"); | |||
4675 | } | |||
4676 | } // __kmp_stg_print_omp_tool | |||
4677 | ||||
4678 | static char *__kmp_tool_libraries = NULL__null; | |||
4679 | ||||
4680 | static void __kmp_stg_parse_omp_tool_libraries(char const *name, | |||
4681 | char const *value, void *data) { | |||
4682 | __kmp_stg_parse_str(name, value, &__kmp_tool_libraries); | |||
4683 | } // __kmp_stg_parse_omp_tool_libraries | |||
4684 | ||||
4685 | static void __kmp_stg_print_omp_tool_libraries(kmp_str_buf_t *buffer, | |||
4686 | char const *name, void *data) { | |||
4687 | if (__kmp_tool_libraries) | |||
4688 | __kmp_stg_print_str(buffer, name, __kmp_tool_libraries); | |||
4689 | else { | |||
4690 | if (__kmp_env_format) { | |||
4691 | KMP_STR_BUF_PRINT_NAME__kmp_str_buf_print(buffer, " %s %s", __kmp_i18n_catgets(kmp_i18n_str_Host ), name); | |||
4692 | } else { | |||
4693 | __kmp_str_buf_print(buffer, " %s", name); | |||
4694 | } | |||
4695 | __kmp_str_buf_print(buffer, ": %s\n", KMP_I18N_STR(NotDefined)__kmp_i18n_catgets(kmp_i18n_str_NotDefined)); | |||
4696 | } | |||
4697 | } // __kmp_stg_print_omp_tool_libraries | |||
4698 | ||||
4699 | #endif | |||
4700 | ||||
4701 | // Table. | |||
4702 | ||||
4703 | static kmp_setting_t __kmp_stg_table[] = { | |||
4704 | ||||
4705 | {"KMP_ALL_THREADS", __kmp_stg_parse_device_thread_limit, NULL__null, NULL__null, 0, 0}, | |||
4706 | {"KMP_BLOCKTIME", __kmp_stg_parse_blocktime, __kmp_stg_print_blocktime, | |||
4707 | NULL__null, 0, 0}, | |||
4708 | {"KMP_DUPLICATE_LIB_OK", __kmp_stg_parse_duplicate_lib_ok, | |||
4709 | __kmp_stg_print_duplicate_lib_ok, NULL__null, 0, 0}, | |||
4710 | {"KMP_LIBRARY", __kmp_stg_parse_wait_policy, __kmp_stg_print_wait_policy, | |||
4711 | NULL__null, 0, 0}, | |||
4712 | {"KMP_DEVICE_THREAD_LIMIT", __kmp_stg_parse_device_thread_limit, | |||
4713 | __kmp_stg_print_device_thread_limit, NULL__null, 0, 0}, | |||
4714 | #if KMP_USE_MONITOR | |||
4715 | {"KMP_MONITOR_STACKSIZE", __kmp_stg_parse_monitor_stacksize, | |||
4716 | __kmp_stg_print_monitor_stacksize, NULL__null, 0, 0}, | |||
4717 | #endif | |||
4718 | {"KMP_SETTINGS", __kmp_stg_parse_settings, __kmp_stg_print_settings, NULL__null, | |||
4719 | 0, 0}, | |||
4720 | {"KMP_STACKOFFSET", __kmp_stg_parse_stackoffset, | |||
4721 | __kmp_stg_print_stackoffset, NULL__null, 0, 0}, | |||
4722 | {"KMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize, | |||
4723 | NULL__null, 0, 0}, | |||
4724 | {"KMP_STACKPAD", __kmp_stg_parse_stackpad, __kmp_stg_print_stackpad, NULL__null, | |||
4725 | 0, 0}, | |||
4726 | {"KMP_VERSION", __kmp_stg_parse_version, __kmp_stg_print_version, NULL__null, 0, | |||
4727 | 0}, | |||
4728 | {"KMP_WARNINGS", __kmp_stg_parse_warnings, __kmp_stg_print_warnings, NULL__null, | |||
4729 | 0, 0}, | |||
4730 | ||||
4731 | {"OMP_NESTED", __kmp_stg_parse_nested, __kmp_stg_print_nested, NULL__null, 0, 0}, | |||
4732 | {"OMP_NUM_THREADS", __kmp_stg_parse_num_threads, | |||
4733 | __kmp_stg_print_num_threads, NULL__null, 0, 0}, | |||
4734 | {"OMP_STACKSIZE", __kmp_stg_parse_stacksize, __kmp_stg_print_stacksize, | |||
4735 | NULL__null, 0, 0}, | |||
4736 | ||||
4737 | {"KMP_TASKING", __kmp_stg_parse_tasking, __kmp_stg_print_tasking, NULL__null, 0, | |||
4738 | 0}, | |||
4739 | {"KMP_TASK_STEALING_CONSTRAINT", __kmp_stg_parse_task_stealing, | |||
4740 | __kmp_stg_print_task_stealing, NULL__null, 0, 0}, | |||
4741 | {"OMP_MAX_ACTIVE_LEVELS", __kmp_stg_parse_max_active_levels, | |||
4742 | __kmp_stg_print_max_active_levels, NULL__null, 0, 0}, | |||
4743 | #if OMP_40_ENABLED(50 >= 40) | |||
4744 | {"OMP_DEFAULT_DEVICE", __kmp_stg_parse_default_device, | |||
4745 | __kmp_stg_print_default_device, NULL__null, 0, 0}, | |||
4746 | #endif | |||
4747 | #if OMP_50_ENABLED(50 >= 50) | |||
4748 | {"OMP_TARGET_OFFLOAD", __kmp_stg_parse_target_offload, | |||
4749 | __kmp_stg_print_target_offload, NULL__null, 0, 0}, | |||
4750 | #endif | |||
4751 | #if OMP_45_ENABLED(50 >= 45) | |||
4752 | {"OMP_MAX_TASK_PRIORITY", __kmp_stg_parse_max_task_priority, | |||
4753 | __kmp_stg_print_max_task_priority, NULL__null, 0, 0}, | |||
4754 | {"KMP_TASKLOOP_MIN_TASKS", __kmp_stg_parse_taskloop_min_tasks, | |||
4755 | __kmp_stg_print_taskloop_min_tasks, NULL__null, 0, 0}, | |||
4756 | #endif | |||
4757 | {"OMP_THREAD_LIMIT", __kmp_stg_parse_thread_limit, | |||
4758 | __kmp_stg_print_thread_limit, NULL__null, 0, 0}, | |||
4759 | {"KMP_TEAMS_THREAD_LIMIT", __kmp_stg_parse_teams_thread_limit, | |||
4760 | __kmp_stg_print_teams_thread_limit, NULL__null, 0, 0}, | |||
4761 | {"OMP_WAIT_POLICY", __kmp_stg_parse_wait_policy, | |||
4762 | __kmp_stg_print_wait_policy, NULL__null, 0, 0}, | |||
4763 | {"KMP_DISP_NUM_BUFFERS", __kmp_stg_parse_disp_buffers, | |||
4764 | __kmp_stg_print_disp_buffers, NULL__null, 0, 0}, | |||
4765 | #if KMP_NESTED_HOT_TEAMS1 | |||
4766 | {"KMP_HOT_TEAMS_MAX_LEVEL", __kmp_stg_parse_hot_teams_level, | |||
4767 | __kmp_stg_print_hot_teams_level, NULL__null, 0, 0}, | |||
4768 | {"KMP_HOT_TEAMS_MODE", __kmp_stg_parse_hot_teams_mode, | |||
4769 | __kmp_stg_print_hot_teams_mode, NULL__null, 0, 0}, | |||
4770 | #endif // KMP_NESTED_HOT_TEAMS | |||
4771 | ||||
4772 | #if KMP_HANDLE_SIGNALS(1 || 0) | |||
4773 | {"KMP_HANDLE_SIGNALS", __kmp_stg_parse_handle_signals, | |||
4774 | __kmp_stg_print_handle_signals, NULL__null, 0, 0}, | |||
4775 | #endif | |||
4776 | ||||
4777 | #if KMP_ARCH_X860 || KMP_ARCH_X86_641 | |||
4778 | {"KMP_INHERIT_FP_CONTROL", __kmp_stg_parse_inherit_fp_control, | |||
4779 | __kmp_stg_print_inherit_fp_control, NULL__null, 0, 0}, | |||
4780 | #endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */ | |||
4781 | ||||
4782 | #ifdef KMP_GOMP_COMPAT | |||
4783 | {"GOMP_STACKSIZE", __kmp_stg_parse_stacksize, NULL__null, NULL__null, 0, 0}, | |||
4784 | #endif | |||
4785 | ||||
4786 | #ifdef KMP_DEBUG1 | |||
4787 | {"KMP_A_DEBUG", __kmp_stg_parse_a_debug, __kmp_stg_print_a_debug, NULL__null, 0, | |||
4788 | 0}, | |||
4789 | {"KMP_B_DEBUG", __kmp_stg_parse_b_debug, __kmp_stg_print_b_debug, NULL__null, 0, | |||
4790 | 0}, | |||
4791 | {"KMP_C_DEBUG", __kmp_stg_parse_c_debug, __kmp_stg_print_c_debug, NULL__null, 0, | |||
4792 | 0}, | |||
4793 | {"KMP_D_DEBUG", __kmp_stg_parse_d_debug, __kmp_stg_print_d_debug, NULL__null, 0, | |||
4794 | 0}, | |||
4795 | {"KMP_E_DEBUG", __kmp_stg_parse_e_debug, __kmp_stg_print_e_debug, NULL__null, 0, | |||
4796 | 0}, | |||
4797 | {"KMP_F_DEBUG", __kmp_stg_parse_f_debug, __kmp_stg_print_f_debug, NULL__null, 0, | |||
4798 | 0}, | |||
4799 | {"KMP_DEBUG", __kmp_stg_parse_debug, NULL__null, /* no print */ NULL__null, 0, 0}, | |||
4800 | {"KMP_DEBUG_BUF", __kmp_stg_parse_debug_buf, __kmp_stg_print_debug_buf, | |||
4801 | NULL__null, 0, 0}, | |||
4802 | {"KMP_DEBUG_BUF_ATOMIC", __kmp_stg_parse_debug_buf_atomic, | |||
4803 | __kmp_stg_print_debug_buf_atomic, NULL__null, 0, 0}, | |||
4804 | {"KMP_DEBUG_BUF_CHARS", __kmp_stg_parse_debug_buf_chars, | |||
4805 | __kmp_stg_print_debug_buf_chars, NULL__null, 0, 0}, | |||
4806 | {"KMP_DEBUG_BUF_LINES", __kmp_stg_parse_debug_buf_lines, | |||
4807 | __kmp_stg_print_debug_buf_lines, NULL__null, 0, 0}, | |||
4808 | {"KMP_DIAG", __kmp_stg_parse_diag, __kmp_stg_print_diag, NULL__null, 0, 0}, | |||
4809 | ||||
4810 | {"KMP_PAR_RANGE", __kmp_stg_parse_par_range_env, | |||
4811 | __kmp_stg_print_par_range_env, NULL__null, 0, 0}, | |||
4812 | {"KMP_YIELD_CYCLE", __kmp_stg_parse_yield_cycle, | |||
4813 | __kmp_stg_print_yield_cycle, NULL__null, 0, 0}, | |||
4814 | {"KMP_YIELD_ON", __kmp_stg_parse_yield_on, __kmp_stg_print_yield_on, NULL__null, | |||
4815 | 0, 0}, | |||
4816 | {"KMP_YIELD_OFF", __kmp_stg_parse_yield_off, __kmp_stg_print_yield_off, | |||
4817 | NULL__null, 0, 0}, | |||
4818 | #endif // KMP_DEBUG | |||
4819 | ||||
4820 | {"KMP_ALIGN_ALLOC", __kmp_stg_parse_align_alloc, | |||
4821 | __kmp_stg_print_align_alloc, NULL__null, 0, 0}, | |||
4822 | ||||
4823 | {"KMP_PLAIN_BARRIER", __kmp_stg_parse_barrier_branch_bit, | |||
4824 | __kmp_stg_print_barrier_branch_bit, NULL__null, 0, 0}, | |||
4825 | {"KMP_PLAIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, | |||
4826 | __kmp_stg_print_barrier_pattern, NULL__null, 0, 0}, | |||
4827 | {"KMP_FORKJOIN_BARRIER", __kmp_stg_parse_barrier_branch_bit, | |||
4828 | __kmp_stg_print_barrier_branch_bit, NULL__null, 0, 0}, | |||
4829 | {"KMP_FORKJOIN_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, | |||
4830 | __kmp_stg_print_barrier_pattern, NULL__null, 0, 0}, | |||
4831 | #if KMP_FAST_REDUCTION_BARRIER1 | |||
4832 | {"KMP_REDUCTION_BARRIER", __kmp_stg_parse_barrier_branch_bit, | |||
4833 | __kmp_stg_print_barrier_branch_bit, NULL__null, 0, 0}, | |||
4834 | {"KMP_REDUCTION_BARRIER_PATTERN", __kmp_stg_parse_barrier_pattern, | |||
4835 | __kmp_stg_print_barrier_pattern, NULL__null, 0, 0}, | |||
4836 | #endif | |||
4837 | ||||
4838 | {"KMP_ABORT_DELAY", __kmp_stg_parse_abort_delay, | |||
4839 | __kmp_stg_print_abort_delay, NULL__null, 0, 0}, | |||
4840 | {"KMP_CPUINFO_FILE", __kmp_stg_parse_cpuinfo_file, | |||
4841 | __kmp_stg_print_cpuinfo_file, NULL__null, 0, 0}, | |||
4842 | {"KMP_FORCE_REDUCTION", __kmp_stg_parse_force_reduction, | |||
4843 | __kmp_stg_print_force_reduction, NULL__null, 0, 0}, | |||
4844 | {"KMP_DETERMINISTIC_REDUCTION", __kmp_stg_parse_force_reduction, | |||
4845 | __kmp_stg_print_force_reduction, NULL__null, 0, 0}, | |||
4846 | {"KMP_STORAGE_MAP", __kmp_stg_parse_storage_map, | |||
4847 | __kmp_stg_print_storage_map, NULL__null, 0, 0}, | |||
4848 | {"KMP_ALL_THREADPRIVATE", __kmp_stg_parse_all_threadprivate, | |||
4849 | __kmp_stg_print_all_threadprivate, NULL__null, 0, 0}, | |||
4850 | {"KMP_FOREIGN_THREADS_THREADPRIVATE", | |||
4851 | __kmp_stg_parse_foreign_threads_threadprivate, | |||
4852 | __kmp_stg_print_foreign_threads_threadprivate, NULL__null, 0, 0}, | |||
4853 | ||||
4854 | #if KMP_AFFINITY_SUPPORTED1 | |||
4855 | {"KMP_AFFINITY", __kmp_stg_parse_affinity, __kmp_stg_print_affinity, NULL__null, | |||
4856 | 0, 0}, | |||
4857 | #ifdef KMP_GOMP_COMPAT | |||
4858 | {"GOMP_CPU_AFFINITY", __kmp_stg_parse_gomp_cpu_affinity, NULL__null, | |||
4859 | /* no print */ NULL__null, 0, 0}, | |||
4860 | #endif /* KMP_GOMP_COMPAT */ | |||
4861 | #if OMP_40_ENABLED(50 >= 40) | |||
4862 | {"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, | |||
4863 | NULL__null, 0, 0}, | |||
4864 | {"OMP_PLACES", __kmp_stg_parse_places, __kmp_stg_print_places, NULL__null, 0, 0}, | |||
4865 | #else | |||
4866 | {"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL__null, /* no print */ NULL__null, 0, | |||
4867 | 0}, | |||
4868 | #endif /* OMP_40_ENABLED */ | |||
4869 | {"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method, | |||
4870 | __kmp_stg_print_topology_method, NULL__null, 0, 0}, | |||
4871 | ||||
4872 | #else | |||
4873 | ||||
4874 | // KMP_AFFINITY is not supported on OS X*, nor is OMP_PLACES. | |||
4875 | // OMP_PROC_BIND and proc-bind-var are supported, however. | |||
4876 | #if OMP_40_ENABLED(50 >= 40) | |||
4877 | {"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, __kmp_stg_print_proc_bind, | |||
4878 | NULL__null, 0, 0}, | |||
4879 | #endif | |||
4880 | ||||
4881 | #endif // KMP_AFFINITY_SUPPORTED | |||
4882 | ||||
4883 | {"KMP_INIT_AT_FORK", __kmp_stg_parse_init_at_fork, | |||
4884 | __kmp_stg_print_init_at_fork, NULL__null, 0, 0}, | |||
4885 | {"KMP_SCHEDULE", __kmp_stg_parse_schedule, __kmp_stg_print_schedule, NULL__null, | |||
4886 | 0, 0}, | |||
4887 | {"OMP_SCHEDULE", __kmp_stg_parse_omp_schedule, __kmp_stg_print_omp_schedule, | |||
4888 | NULL__null, 0, 0}, | |||
4889 | #if KMP_USE_HIER_SCHED0 | |||
4890 | {"KMP_DISP_HAND_THREAD", __kmp_stg_parse_kmp_hand_thread, | |||
4891 | __kmp_stg_print_kmp_hand_thread, NULL__null, 0, 0}, | |||
4892 | #endif | |||
4893 | {"KMP_ATOMIC_MODE", __kmp_stg_parse_atomic_mode, | |||
4894 | __kmp_stg_print_atomic_mode, NULL__null, 0, 0}, | |||
4895 | {"KMP_CONSISTENCY_CHECK", __kmp_stg_parse_consistency_check, | |||
4896 | __kmp_stg_print_consistency_check, NULL__null, 0, 0}, | |||
4897 | ||||
4898 | #if USE_ITT_BUILD1 && USE_ITT_NOTIFY1 | |||
4899 | {"KMP_ITT_PREPARE_DELAY", __kmp_stg_parse_itt_prepare_delay, | |||
4900 | __kmp_stg_print_itt_prepare_delay, NULL__null, 0, 0}, | |||
4901 | #endif /* USE_ITT_BUILD && USE_ITT_NOTIFY */ | |||
4902 | {"KMP_MALLOC_POOL_INCR", __kmp_stg_parse_malloc_pool_incr, | |||
4903 | __kmp_stg_print_malloc_pool_incr, NULL__null, 0, 0}, | |||
4904 | {"KMP_INIT_WAIT", __kmp_stg_parse_init_wait, __kmp_stg_print_init_wait, | |||
4905 | NULL__null, 0, 0}, | |||
4906 | {"KMP_NEXT_WAIT", __kmp_stg_parse_next_wait, __kmp_stg_print_next_wait, | |||
4907 | NULL__null, 0, 0}, | |||
4908 | {"KMP_GTID_MODE", __kmp_stg_parse_gtid_mode, __kmp_stg_print_gtid_mode, | |||
4909 | NULL__null, 0, 0}, | |||
4910 | {"OMP_DYNAMIC", __kmp_stg_parse_omp_dynamic, __kmp_stg_print_omp_dynamic, | |||
4911 | NULL__null, 0, 0}, | |||
4912 | {"KMP_DYNAMIC_MODE", __kmp_stg_parse_kmp_dynamic_mode, | |||
4913 | __kmp_stg_print_kmp_dynamic_mode, NULL__null, 0, 0}, | |||
4914 | ||||
4915 | #ifdef USE_LOAD_BALANCE1 | |||
4916 | {"KMP_LOAD_BALANCE_INTERVAL", __kmp_stg_parse_ld_balance_interval, | |||
4917 | __kmp_stg_print_ld_balance_interval, NULL__null, 0, 0}, | |||
4918 | #endif | |||
4919 | ||||
4920 | {"KMP_NUM_LOCKS_IN_BLOCK", __kmp_stg_parse_lock_block, | |||
4921 | __kmp_stg_print_lock_block, NULL__null, 0, 0}, | |||
4922 | {"KMP_LOCK_KIND", __kmp_stg_parse_lock_kind, __kmp_stg_print_lock_kind, | |||
4923 | NULL__null, 0, 0}, | |||
4924 | {"KMP_SPIN_BACKOFF_PARAMS", __kmp_stg_parse_spin_backoff_params, | |||
4925 | __kmp_stg_print_spin_backoff_params, NULL__null, 0, 0}, | |||
4926 | #if KMP_USE_ADAPTIVE_LOCKS(0 || 1) && !0 | |||
4927 | {"KMP_ADAPTIVE_LOCK_PROPS", __kmp_stg_parse_adaptive_lock_props, | |||
4928 | __kmp_stg_print_adaptive_lock_props, NULL__null, 0, 0}, | |||
4929 | #if KMP_DEBUG_ADAPTIVE_LOCKS0 | |||
4930 | {"KMP_SPECULATIVE_STATSFILE", __kmp_stg_parse_speculative_statsfile, | |||
4931 | __kmp_stg_print_speculative_statsfile, NULL__null, 0, 0}, | |||
4932 | #endif | |||
4933 | #endif // KMP_USE_ADAPTIVE_LOCKS | |||
4934 | {"KMP_PLACE_THREADS", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset, | |||
4935 | NULL__null, 0, 0}, | |||
4936 | {"KMP_HW_SUBSET", __kmp_stg_parse_hw_subset, __kmp_stg_print_hw_subset, | |||
4937 | NULL__null, 0, 0}, | |||
4938 | #if USE_ITT_BUILD1 | |||
4939 | {"KMP_FORKJOIN_FRAMES", __kmp_stg_parse_forkjoin_frames, | |||
4940 | __kmp_stg_print_forkjoin_frames, NULL__null, 0, 0}, | |||
4941 | {"KMP_FORKJOIN_FRAMES_MODE", __kmp_stg_parse_forkjoin_frames_mode, | |||
4942 | __kmp_stg_print_forkjoin_frames_mode, NULL__null, 0, 0}, | |||
4943 | #endif | |||
4944 | ||||
4945 | #if OMP_40_ENABLED(50 >= 40) | |||
4946 | {"OMP_DISPLAY_ENV", __kmp_stg_parse_omp_display_env, | |||
4947 | __kmp_stg_print_omp_display_env, NULL__null, 0, 0}, | |||
4948 | {"OMP_CANCELLATION", __kmp_stg_parse_omp_cancellation, | |||
4949 | __kmp_stg_print_omp_cancellation, NULL__null, 0, 0}, | |||
4950 | #endif | |||
4951 | ||||
4952 | #if OMP_50_ENABLED(50 >= 50) | |||
4953 | {"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator, | |||
4954 | NULL__null, 0, 0}, | |||
4955 | #endif | |||
4956 | ||||
4957 | #if OMP_50_ENABLED(50 >= 50) && OMPT_SUPPORT1 | |||
4958 | {"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL__null, 0, | |||
4959 | 0}, | |||
4960 | {"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries, | |||
4961 | __kmp_stg_print_omp_tool_libraries, NULL__null, 0, 0}, | |||
4962 | #endif | |||
4963 | ||||
4964 | {"", NULL__null, NULL__null, NULL__null, 0, 0}}; // settings | |||
4965 | ||||
4966 | static int const __kmp_stg_count = | |||
4967 | sizeof(__kmp_stg_table) / sizeof(kmp_setting_t); | |||
4968 | ||||
4969 | static inline kmp_setting_t *__kmp_stg_find(char const *name) { | |||
4970 | ||||
4971 | int i; | |||
4972 | if (name != NULL__null) { | |||
4973 | for (i = 0; i < __kmp_stg_count; ++i) { | |||
4974 | if (strcmp(__kmp_stg_table[i].name, name) == 0) { | |||
4975 | return &__kmp_stg_table[i]; | |||
4976 | } | |||
4977 | } | |||
4978 | } | |||
4979 | return NULL__null; | |||
4980 | ||||
4981 | } // __kmp_stg_find | |||
4982 | ||||
4983 | static int __kmp_stg_cmp(void const *_a, void const *_b) { | |||
4984 | const kmp_setting_t *a = RCAST(const kmp_setting_t *, _a)reinterpret_cast<const kmp_setting_t *>(_a); | |||
4985 | const kmp_setting_t *b = RCAST(const kmp_setting_t *, _b)reinterpret_cast<const kmp_setting_t *>(_b); | |||
4986 | ||||
4987 | // Process KMP_AFFINITY last. | |||
4988 | // It needs to come after OMP_PLACES and GOMP_CPU_AFFINITY. | |||
4989 | if (strcmp(a->name, "KMP_AFFINITY") == 0) { | |||
4990 | if (strcmp(b->name, "KMP_AFFINITY") == 0) { | |||
4991 | return 0; | |||
4992 | } | |||
4993 | return 1; | |||
4994 | } else if (strcmp(b->name, "KMP_AFFINITY") == 0) { | |||
4995 | return -1; | |||
4996 | } | |||
4997 | return strcmp(a->name, b->name); | |||
4998 | } // __kmp_stg_cmp | |||
4999 | ||||
5000 | static void __kmp_stg_init(void) { | |||
5001 | ||||
5002 | static int initialized = 0; | |||
5003 | ||||
5004 | if (!initialized) { | |||
5005 | ||||
5006 | // Sort table. | |||
5007 | qsort(__kmp_stg_table, __kmp_stg_count - 1, sizeof(kmp_setting_t), | |||
5008 | __kmp_stg_cmp); | |||
5009 | ||||
5010 | { // Initialize *_STACKSIZE data. | |||
5011 | kmp_setting_t *kmp_stacksize = | |||
5012 | __kmp_stg_find("KMP_STACKSIZE"); // 1st priority. | |||
5013 | #ifdef KMP_GOMP_COMPAT | |||
5014 | kmp_setting_t *gomp_stacksize = | |||
5015 | __kmp_stg_find("GOMP_STACKSIZE"); // 2nd priority. | |||
5016 | #endif | |||
5017 | kmp_setting_t *omp_stacksize = | |||
5018 | __kmp_stg_find("OMP_STACKSIZE"); // 3rd priority. | |||
5019 | ||||
5020 | // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround. | |||
5021 | // !!! Compiler does not understand rivals is used and optimizes out | |||
5022 | // assignments | |||
5023 | // !!! rivals[ i ++ ] = ...; | |||
5024 | static kmp_setting_t *volatile rivals[4]; | |||
5025 | static kmp_stg_ss_data_t kmp_data = {1, CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals)}; | |||
5026 | #ifdef KMP_GOMP_COMPAT | |||
5027 | static kmp_stg_ss_data_t gomp_data = {1024, | |||
5028 | CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals)}; | |||
5029 | #endif | |||
5030 | static kmp_stg_ss_data_t omp_data = {1024, | |||
5031 | CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals)}; | |||
5032 | int i = 0; | |||
5033 | ||||
5034 | rivals[i++] = kmp_stacksize; | |||
5035 | #ifdef KMP_GOMP_COMPAT | |||
5036 | if (gomp_stacksize != NULL__null) { | |||
5037 | rivals[i++] = gomp_stacksize; | |||
5038 | } | |||
5039 | #endif | |||
5040 | rivals[i++] = omp_stacksize; | |||
5041 | rivals[i++] = NULL__null; | |||
5042 | ||||
5043 | kmp_stacksize->data = &kmp_data; | |||
5044 | #ifdef KMP_GOMP_COMPAT | |||
5045 | if (gomp_stacksize != NULL__null) { | |||
5046 | gomp_stacksize->data = &gomp_data; | |||
5047 | } | |||
5048 | #endif | |||
5049 | omp_stacksize->data = &omp_data; | |||
5050 | } | |||
5051 | ||||
5052 | { // Initialize KMP_LIBRARY and OMP_WAIT_POLICY data. | |||
5053 | kmp_setting_t *kmp_library = | |||
5054 | __kmp_stg_find("KMP_LIBRARY"); // 1st priority. | |||
5055 | kmp_setting_t *omp_wait_policy = | |||
5056 | __kmp_stg_find("OMP_WAIT_POLICY"); // 2nd priority. | |||
5057 | ||||
5058 | // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround. | |||
5059 | static kmp_setting_t *volatile rivals[3]; | |||
5060 | static kmp_stg_wp_data_t kmp_data = {0, CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals)}; | |||
5061 | static kmp_stg_wp_data_t omp_data = {1, CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals)}; | |||
5062 | int i = 0; | |||
5063 | ||||
5064 | rivals[i++] = kmp_library; | |||
5065 | if (omp_wait_policy != NULL__null) { | |||
5066 | rivals[i++] = omp_wait_policy; | |||
5067 | } | |||
5068 | rivals[i++] = NULL__null; | |||
5069 | ||||
5070 | kmp_library->data = &kmp_data; | |||
5071 | if (omp_wait_policy != NULL__null) { | |||
5072 | omp_wait_policy->data = &omp_data; | |||
5073 | } | |||
5074 | } | |||
5075 | ||||
5076 | { // Initialize KMP_DEVICE_THREAD_LIMIT and KMP_ALL_THREADS | |||
5077 | kmp_setting_t *kmp_device_thread_limit = | |||
5078 | __kmp_stg_find("KMP_DEVICE_THREAD_LIMIT"); // 1st priority. | |||
5079 | kmp_setting_t *kmp_all_threads = | |||
5080 | __kmp_stg_find("KMP_ALL_THREADS"); // 2nd priority. | |||
5081 | ||||
5082 | // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround. | |||
5083 | static kmp_setting_t *volatile rivals[3]; | |||
5084 | int i = 0; | |||
5085 | ||||
5086 | rivals[i++] = kmp_device_thread_limit; | |||
5087 | rivals[i++] = kmp_all_threads; | |||
5088 | rivals[i++] = NULL__null; | |||
5089 | ||||
5090 | kmp_device_thread_limit->data = CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals); | |||
5091 | kmp_all_threads->data = CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals); | |||
5092 | } | |||
5093 | ||||
5094 | { // Initialize KMP_HW_SUBSET and KMP_PLACE_THREADS | |||
5095 | // 1st priority | |||
5096 | kmp_setting_t *kmp_hw_subset = __kmp_stg_find("KMP_HW_SUBSET"); | |||
5097 | // 2nd priority | |||
5098 | kmp_setting_t *kmp_place_threads = __kmp_stg_find("KMP_PLACE_THREADS"); | |||
5099 | ||||
5100 | // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround. | |||
5101 | static kmp_setting_t *volatile rivals[3]; | |||
5102 | int i = 0; | |||
5103 | ||||
5104 | rivals[i++] = kmp_hw_subset; | |||
5105 | rivals[i++] = kmp_place_threads; | |||
5106 | rivals[i++] = NULL__null; | |||
5107 | ||||
5108 | kmp_hw_subset->data = CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals); | |||
5109 | kmp_place_threads->data = CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals); | |||
5110 | } | |||
5111 | ||||
5112 | #if KMP_AFFINITY_SUPPORTED1 | |||
5113 | { // Initialize KMP_AFFINITY, GOMP_CPU_AFFINITY, and OMP_PROC_BIND data. | |||
5114 | kmp_setting_t *kmp_affinity = | |||
5115 | __kmp_stg_find("KMP_AFFINITY"); // 1st priority. | |||
5116 | KMP_DEBUG_ASSERT(kmp_affinity != NULL)if (!(kmp_affinity != __null)) { __kmp_debug_assert("kmp_affinity != __null" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5116); }; | |||
5117 | ||||
5118 | #ifdef KMP_GOMP_COMPAT | |||
5119 | kmp_setting_t *gomp_cpu_affinity = | |||
5120 | __kmp_stg_find("GOMP_CPU_AFFINITY"); // 2nd priority. | |||
5121 | KMP_DEBUG_ASSERT(gomp_cpu_affinity != NULL)if (!(gomp_cpu_affinity != __null)) { __kmp_debug_assert("gomp_cpu_affinity != __null" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5121); }; | |||
5122 | #endif | |||
5123 | ||||
5124 | kmp_setting_t *omp_proc_bind = | |||
5125 | __kmp_stg_find("OMP_PROC_BIND"); // 3rd priority. | |||
5126 | KMP_DEBUG_ASSERT(omp_proc_bind != NULL)if (!(omp_proc_bind != __null)) { __kmp_debug_assert("omp_proc_bind != __null" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5126); }; | |||
5127 | ||||
5128 | // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround. | |||
5129 | static kmp_setting_t *volatile rivals[4]; | |||
5130 | int i = 0; | |||
5131 | ||||
5132 | rivals[i++] = kmp_affinity; | |||
5133 | ||||
5134 | #ifdef KMP_GOMP_COMPAT | |||
5135 | rivals[i++] = gomp_cpu_affinity; | |||
5136 | gomp_cpu_affinity->data = CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals); | |||
5137 | #endif | |||
5138 | ||||
5139 | rivals[i++] = omp_proc_bind; | |||
5140 | omp_proc_bind->data = CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals); | |||
5141 | rivals[i++] = NULL__null; | |||
5142 | ||||
5143 | #if OMP_40_ENABLED(50 >= 40) | |||
5144 | static kmp_setting_t *volatile places_rivals[4]; | |||
5145 | i = 0; | |||
5146 | ||||
5147 | kmp_setting_t *omp_places = __kmp_stg_find("OMP_PLACES"); // 3rd priority. | |||
5148 | KMP_DEBUG_ASSERT(omp_places != NULL)if (!(omp_places != __null)) { __kmp_debug_assert("omp_places != __null" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5148); }; | |||
5149 | ||||
5150 | places_rivals[i++] = kmp_affinity; | |||
5151 | #ifdef KMP_GOMP_COMPAT | |||
5152 | places_rivals[i++] = gomp_cpu_affinity; | |||
5153 | #endif | |||
5154 | places_rivals[i++] = omp_places; | |||
5155 | omp_places->data = CCAST(kmp_setting_t **, places_rivals)const_cast<kmp_setting_t **>(places_rivals); | |||
5156 | places_rivals[i++] = NULL__null; | |||
5157 | #endif | |||
5158 | } | |||
5159 | #else | |||
5160 | // KMP_AFFINITY not supported, so OMP_PROC_BIND has no rivals. | |||
5161 | // OMP_PLACES not supported yet. | |||
5162 | #endif // KMP_AFFINITY_SUPPORTED | |||
5163 | ||||
5164 | { // Initialize KMP_DETERMINISTIC_REDUCTION and KMP_FORCE_REDUCTION data. | |||
5165 | kmp_setting_t *kmp_force_red = | |||
5166 | __kmp_stg_find("KMP_FORCE_REDUCTION"); // 1st priority. | |||
5167 | kmp_setting_t *kmp_determ_red = | |||
5168 | __kmp_stg_find("KMP_DETERMINISTIC_REDUCTION"); // 2nd priority. | |||
5169 | ||||
5170 | // !!! volatile keyword is Intel(R) C Compiler bug CQ49908 workaround. | |||
5171 | static kmp_setting_t *volatile rivals[3]; | |||
5172 | static kmp_stg_fr_data_t force_data = {1, | |||
5173 | CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals)}; | |||
5174 | static kmp_stg_fr_data_t determ_data = {0, | |||
5175 | CCAST(kmp_setting_t **, rivals)const_cast<kmp_setting_t **>(rivals)}; | |||
5176 | int i = 0; | |||
5177 | ||||
5178 | rivals[i++] = kmp_force_red; | |||
5179 | if (kmp_determ_red != NULL__null) { | |||
5180 | rivals[i++] = kmp_determ_red; | |||
5181 | } | |||
5182 | rivals[i++] = NULL__null; | |||
5183 | ||||
5184 | kmp_force_red->data = &force_data; | |||
5185 | if (kmp_determ_red != NULL__null) { | |||
5186 | kmp_determ_red->data = &determ_data; | |||
5187 | } | |||
5188 | } | |||
5189 | ||||
5190 | initialized = 1; | |||
5191 | } | |||
5192 | ||||
5193 | // Reset flags. | |||
5194 | int i; | |||
5195 | for (i = 0; i < __kmp_stg_count; ++i) { | |||
5196 | __kmp_stg_table[i].set = 0; | |||
5197 | } | |||
5198 | ||||
5199 | } // __kmp_stg_init | |||
5200 | ||||
5201 | static void __kmp_stg_parse(char const *name, char const *value) { | |||
5202 | // On Windows* OS there are some nameless variables like "C:=C:\" (yeah, | |||
5203 | // really nameless, they are presented in environment block as | |||
5204 | // "=C:=C\\\x00=D:=D:\\\x00...", so let us skip them. | |||
5205 | if (name[0] == 0) { | |||
5206 | return; | |||
5207 | } | |||
5208 | ||||
5209 | if (value != NULL__null) { | |||
5210 | kmp_setting_t *setting = __kmp_stg_find(name); | |||
5211 | if (setting != NULL__null) { | |||
5212 | setting->parse(name, value, setting->data); | |||
5213 | setting->defined = 1; | |||
5214 | } | |||
5215 | } | |||
5216 | ||||
5217 | } // __kmp_stg_parse | |||
5218 | ||||
5219 | static int __kmp_stg_check_rivals( // 0 -- Ok, 1 -- errors found. | |||
5220 | char const *name, // Name of variable. | |||
5221 | char const *value, // Value of the variable. | |||
5222 | kmp_setting_t **rivals // List of rival settings (must include current one). | |||
5223 | ) { | |||
5224 | ||||
5225 | if (rivals == NULL__null) { | |||
5226 | return 0; | |||
5227 | } | |||
5228 | ||||
5229 | // Loop thru higher priority settings (listed before current). | |||
5230 | int i = 0; | |||
5231 | for (; strcmp(rivals[i]->name, name) != 0; i++) { | |||
5232 | KMP_DEBUG_ASSERT(rivals[i] != NULL)if (!(rivals[i] != __null)) { __kmp_debug_assert("rivals[i] != __null" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5232); }; | |||
5233 | ||||
5234 | #if KMP_AFFINITY_SUPPORTED1 | |||
5235 | if (rivals[i] == __kmp_affinity_notype) { | |||
5236 | // If KMP_AFFINITY is specified without a type name, | |||
5237 | // it does not rival OMP_PROC_BIND or GOMP_CPU_AFFINITY. | |||
5238 | continue; | |||
5239 | } | |||
5240 | #endif | |||
5241 | ||||
5242 | if (rivals[i]->set) { | |||
5243 | KMP_WARNING(StgIgnored, name, rivals[i]->name)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_StgIgnored , name, rivals[i]->name), __kmp_msg_null); | |||
5244 | return 1; | |||
5245 | } | |||
5246 | } | |||
5247 | ||||
5248 | ++i; // Skip current setting. | |||
5249 | return 0; | |||
5250 | ||||
5251 | } // __kmp_stg_check_rivals | |||
5252 | ||||
5253 | static int __kmp_env_toPrint(char const *name, int flag) { | |||
5254 | int rc = 0; | |||
5255 | kmp_setting_t *setting = __kmp_stg_find(name); | |||
5256 | if (setting != NULL__null) { | |||
5257 | rc = setting->defined; | |||
5258 | if (flag >= 0) { | |||
5259 | setting->defined = flag; | |||
5260 | } | |||
5261 | } | |||
5262 | return rc; | |||
5263 | } | |||
5264 | ||||
5265 | static void __kmp_aux_env_initialize(kmp_env_blk_t *block) { | |||
5266 | ||||
5267 | char const *value; | |||
5268 | ||||
5269 | /* OMP_NUM_THREADS */ | |||
5270 | value = __kmp_env_blk_var(block, "OMP_NUM_THREADS"); | |||
5271 | if (value) { | |||
5272 | ompc_set_num_threads(__kmp_dflt_team_nth); | |||
5273 | } | |||
5274 | ||||
5275 | /* KMP_BLOCKTIME */ | |||
5276 | value = __kmp_env_blk_var(block, "KMP_BLOCKTIME"); | |||
5277 | if (value) { | |||
5278 | kmpc_set_blocktime(__kmp_dflt_blocktime); | |||
5279 | } | |||
5280 | ||||
5281 | /* OMP_NESTED */ | |||
5282 | value = __kmp_env_blk_var(block, "OMP_NESTED"); | |||
5283 | if (value) { | |||
5284 | ompc_set_nested(__kmp_dflt_nested); | |||
5285 | } | |||
5286 | ||||
5287 | /* OMP_DYNAMIC */ | |||
5288 | value = __kmp_env_blk_var(block, "OMP_DYNAMIC"); | |||
5289 | if (value) { | |||
5290 | ompc_set_dynamic(__kmp_global.g.g_dynamic); | |||
5291 | } | |||
5292 | } | |||
5293 | ||||
5294 | void __kmp_env_initialize(char const *string) { | |||
5295 | ||||
5296 | kmp_env_blk_t block; | |||
5297 | int i; | |||
5298 | ||||
5299 | __kmp_stg_init(); | |||
5300 | ||||
5301 | // Hack!!! | |||
5302 | if (string == NULL__null) { | |||
5303 | // __kmp_max_nth = __kmp_sys_max_nth; | |||
5304 | __kmp_threads_capacity = | |||
5305 | __kmp_initial_threads_capacity(__kmp_dflt_team_nth_ub); | |||
5306 | } | |||
5307 | __kmp_env_blk_init(&block, string); | |||
5308 | ||||
5309 | // update the set flag on all entries that have an env var | |||
5310 | for (i = 0; i < block.count; ++i) { | |||
5311 | if ((block.vars[i].name == NULL__null) || (*block.vars[i].name == '\0')) { | |||
5312 | continue; | |||
5313 | } | |||
5314 | if (block.vars[i].value == NULL__null) { | |||
5315 | continue; | |||
5316 | } | |||
5317 | kmp_setting_t *setting = __kmp_stg_find(block.vars[i].name); | |||
5318 | if (setting != NULL__null) { | |||
5319 | setting->set = 1; | |||
5320 | } | |||
5321 | } | |||
5322 | ||||
5323 | // We need to know if blocktime was set when processing OMP_WAIT_POLICY | |||
5324 | blocktime_str = __kmp_env_blk_var(&block, "KMP_BLOCKTIME"); | |||
5325 | ||||
5326 | // Special case. If we parse environment, not a string, process KMP_WARNINGS | |||
5327 | // first. | |||
5328 | if (string == NULL__null) { | |||
5329 | char const *name = "KMP_WARNINGS"; | |||
5330 | char const *value = __kmp_env_blk_var(&block, name); | |||
5331 | __kmp_stg_parse(name, value); | |||
5332 | } | |||
5333 | ||||
5334 | #if KMP_AFFINITY_SUPPORTED1 | |||
5335 | // Special case. KMP_AFFINITY is not a rival to other affinity env vars | |||
5336 | // if no affinity type is specified. We want to allow | |||
5337 | // KMP_AFFINITY=[no],verbose/[no]warnings/etc. to be enabled when | |||
5338 | // specifying the affinity type via GOMP_CPU_AFFINITY or the OMP 4.0 | |||
5339 | // affinity mechanism. | |||
5340 | __kmp_affinity_notype = NULL__null; | |||
5341 | char const *aff_str = __kmp_env_blk_var(&block, "KMP_AFFINITY"); | |||
5342 | if (aff_str != NULL__null) { | |||
5343 | // Check if the KMP_AFFINITY type is specified in the string. | |||
5344 | // We just search the string for "compact", "scatter", etc. | |||
5345 | // without really parsing the string. The syntax of the | |||
5346 | // KMP_AFFINITY env var is such that none of the affinity | |||
5347 | // type names can appear anywhere other that the type | |||
5348 | // specifier, even as substrings. | |||
5349 | // | |||
5350 | // I can't find a case-insensitive version of strstr on Windows* OS. | |||
5351 | // Use the case-sensitive version for now. | |||
5352 | ||||
5353 | #if KMP_OS_WINDOWS0 | |||
5354 | #define FIND strstr | |||
5355 | #else | |||
5356 | #define FIND strcasestr | |||
5357 | #endif | |||
5358 | ||||
5359 | if ((FIND(aff_str, "none") == NULL__null) && | |||
5360 | (FIND(aff_str, "physical") == NULL__null) && | |||
5361 | (FIND(aff_str, "logical") == NULL__null) && | |||
5362 | (FIND(aff_str, "compact") == NULL__null) && | |||
5363 | (FIND(aff_str, "scatter") == NULL__null) && | |||
5364 | (FIND(aff_str, "explicit") == NULL__null) && | |||
5365 | (FIND(aff_str, "balanced") == NULL__null) && | |||
5366 | (FIND(aff_str, "disabled") == NULL__null)) { | |||
5367 | __kmp_affinity_notype = __kmp_stg_find("KMP_AFFINITY"); | |||
5368 | } else { | |||
5369 | // A new affinity type is specified. | |||
5370 | // Reset the affinity flags to their default values, | |||
5371 | // in case this is called from kmp_set_defaults(). | |||
5372 | __kmp_affinity_type = affinity_default; | |||
5373 | __kmp_affinity_gran = affinity_gran_default; | |||
5374 | __kmp_affinity_top_method = affinity_top_method_default; | |||
5375 | __kmp_affinity_respect_mask = affinity_respect_mask_default(-1); | |||
5376 | } | |||
5377 | #undef FIND | |||
5378 | ||||
5379 | #if OMP_40_ENABLED(50 >= 40) | |||
5380 | // Also reset the affinity flags if OMP_PROC_BIND is specified. | |||
5381 | aff_str = __kmp_env_blk_var(&block, "OMP_PROC_BIND"); | |||
5382 | if (aff_str != NULL__null) { | |||
5383 | __kmp_affinity_type = affinity_default; | |||
5384 | __kmp_affinity_gran = affinity_gran_default; | |||
5385 | __kmp_affinity_top_method = affinity_top_method_default; | |||
5386 | __kmp_affinity_respect_mask = affinity_respect_mask_default(-1); | |||
5387 | } | |||
5388 | #endif /* OMP_40_ENABLED */ | |||
5389 | } | |||
5390 | ||||
5391 | #endif /* KMP_AFFINITY_SUPPORTED */ | |||
5392 | ||||
5393 | #if OMP_40_ENABLED(50 >= 40) | |||
5394 | // Set up the nested proc bind type vector. | |||
5395 | if (__kmp_nested_proc_bind.bind_types == NULL__null) { | |||
5396 | __kmp_nested_proc_bind.bind_types = | |||
5397 | (kmp_proc_bind_t *)KMP_INTERNAL_MALLOC(sizeof(kmp_proc_bind_t))malloc(sizeof(kmp_proc_bind_t)); | |||
5398 | if (__kmp_nested_proc_bind.bind_types == NULL__null) { | |||
5399 | KMP_FATAL(MemoryAllocFailed)__kmp_fatal(__kmp_msg_format(kmp_i18n_msg_MemoryAllocFailed), __kmp_msg_null); | |||
5400 | } | |||
5401 | __kmp_nested_proc_bind.size = 1; | |||
5402 | __kmp_nested_proc_bind.used = 1; | |||
5403 | #if KMP_AFFINITY_SUPPORTED1 | |||
5404 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_default; | |||
5405 | #else | |||
5406 | // default proc bind is false if affinity not supported | |||
5407 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; | |||
5408 | #endif | |||
5409 | } | |||
5410 | #endif /* OMP_40_ENABLED */ | |||
5411 | ||||
5412 | // Now process all of the settings. | |||
5413 | for (i = 0; i < block.count; ++i) { | |||
5414 | __kmp_stg_parse(block.vars[i].name, block.vars[i].value); | |||
5415 | } | |||
5416 | ||||
5417 | // If user locks have been allocated yet, don't reset the lock vptr table. | |||
5418 | if (!__kmp_init_user_locks) { | |||
5419 | if (__kmp_user_lock_kind == lk_default) { | |||
5420 | __kmp_user_lock_kind = lk_queuing; | |||
5421 | } | |||
5422 | #if KMP_USE_DYNAMIC_LOCK1 | |||
5423 | __kmp_init_dynamic_user_locks(); | |||
5424 | #else | |||
5425 | __kmp_set_user_lock_vptrs(__kmp_user_lock_kind); | |||
5426 | #endif | |||
5427 | } else { | |||
5428 | KMP_DEBUG_ASSERT(string != NULL)if (!(string != __null)) { __kmp_debug_assert("string != __null" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5428); }; // kmp_set_defaults() was called | |||
5429 | KMP_DEBUG_ASSERT(__kmp_user_lock_kind != lk_default)if (!(__kmp_user_lock_kind != lk_default)) { __kmp_debug_assert ("__kmp_user_lock_kind != lk_default", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5429); }; | |||
5430 | // Binds lock functions again to follow the transition between different | |||
5431 | // KMP_CONSISTENCY_CHECK values. Calling this again is harmless as long | |||
5432 | // as we do not allow lock kind changes after making a call to any | |||
5433 | // user lock functions (true). | |||
5434 | #if KMP_USE_DYNAMIC_LOCK1 | |||
5435 | __kmp_init_dynamic_user_locks(); | |||
5436 | #else | |||
5437 | __kmp_set_user_lock_vptrs(__kmp_user_lock_kind); | |||
5438 | #endif | |||
5439 | } | |||
5440 | ||||
5441 | #if KMP_AFFINITY_SUPPORTED1 | |||
5442 | ||||
5443 | if (!TCR_4(__kmp_init_middle)(__kmp_init_middle)) { | |||
5444 | #if KMP_USE_HWLOC0 | |||
5445 | // Force using hwloc when either tiles or numa nodes requested within | |||
5446 | // KMP_HW_SUBSET and no other topology method is requested | |||
5447 | if ((__kmp_hws_node.num > 0 || __kmp_hws_tile.num > 0 || | |||
5448 | __kmp_affinity_gran == affinity_gran_tile) && | |||
5449 | (__kmp_affinity_top_method == affinity_top_method_default)) { | |||
5450 | __kmp_affinity_top_method = affinity_top_method_hwloc; | |||
5451 | } | |||
5452 | #endif | |||
5453 | // Determine if the machine/OS is actually capable of supporting | |||
5454 | // affinity. | |||
5455 | const char *var = "KMP_AFFINITY"; | |||
5456 | KMPAffinity::pick_api(); | |||
5457 | #if KMP_USE_HWLOC0 | |||
5458 | // If Hwloc topology discovery was requested but affinity was also disabled, | |||
5459 | // then tell user that Hwloc request is being ignored and use default | |||
5460 | // topology discovery method. | |||
5461 | if (__kmp_affinity_top_method == affinity_top_method_hwloc && | |||
5462 | __kmp_affinity_dispatch->get_api_type() != KMPAffinity::HWLOC) { | |||
5463 | KMP_WARNING(AffIgnoringHwloc, var)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffIgnoringHwloc , var), __kmp_msg_null); | |||
5464 | __kmp_affinity_top_method = affinity_top_method_all; | |||
5465 | } | |||
5466 | #endif | |||
5467 | if (__kmp_affinity_type == affinity_disabled) { | |||
5468 | KMP_AFFINITY_DISABLE()(__kmp_affin_mask_size = 0); | |||
5469 | } else if (!KMP_AFFINITY_CAPABLE()(__kmp_affin_mask_size > 0)) { | |||
5470 | __kmp_affinity_dispatch->determine_capable(var); | |||
5471 | if (!KMP_AFFINITY_CAPABLE()(__kmp_affin_mask_size > 0)) { | |||
5472 | if (__kmp_affinity_verbose || | |||
5473 | (__kmp_affinity_warnings && | |||
5474 | (__kmp_affinity_type != affinity_default) && | |||
5475 | (__kmp_affinity_type != affinity_none) && | |||
5476 | (__kmp_affinity_type != affinity_disabled))) { | |||
5477 | KMP_WARNING(AffNotSupported, var)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffNotSupported , var), __kmp_msg_null); | |||
5478 | } | |||
5479 | __kmp_affinity_type = affinity_disabled; | |||
5480 | __kmp_affinity_respect_mask = 0; | |||
5481 | __kmp_affinity_gran = affinity_gran_fine; | |||
5482 | } | |||
5483 | } | |||
5484 | ||||
5485 | #if OMP_40_ENABLED(50 >= 40) | |||
5486 | if (__kmp_affinity_type == affinity_disabled) { | |||
5487 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; | |||
5488 | } else if (__kmp_nested_proc_bind.bind_types[0] == proc_bind_true) { | |||
5489 | // OMP_PROC_BIND=true maps to OMP_PROC_BIND=spread. | |||
5490 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_spread; | |||
5491 | } | |||
5492 | #endif /* OMP_40_ENABLED */ | |||
5493 | ||||
5494 | if (KMP_AFFINITY_CAPABLE()(__kmp_affin_mask_size > 0)) { | |||
5495 | ||||
5496 | #if KMP_GROUP_AFFINITY0 | |||
5497 | // This checks to see if the initial affinity mask is equal | |||
5498 | // to a single windows processor group. If it is, then we do | |||
5499 | // not respect the initial affinity mask and instead, use the | |||
5500 | // entire machine. | |||
5501 | bool exactly_one_group = false; | |||
5502 | if (__kmp_num_proc_groups > 1) { | |||
5503 | int group; | |||
5504 | bool within_one_group; | |||
5505 | // Get the initial affinity mask and determine if it is | |||
5506 | // contained within a single group. | |||
5507 | kmp_affin_mask_t *init_mask; | |||
5508 | KMP_CPU_ALLOC(init_mask)(init_mask = __kmp_affinity_dispatch->allocate_mask()); | |||
5509 | __kmp_get_system_affinity(init_mask, TRUE)(init_mask)->get_system_affinity((!0)); | |||
5510 | group = __kmp_get_proc_group(init_mask)(init_mask)->get_proc_group(); | |||
5511 | within_one_group = (group >= 0); | |||
5512 | // If the initial affinity is within a single group, | |||
5513 | // then determine if it is equal to that single group. | |||
5514 | if (within_one_group) { | |||
5515 | DWORD num_bits_in_group = __kmp_GetActiveProcessorCount(group); | |||
5516 | int num_bits_in_mask = 0; | |||
5517 | for (int bit = init_mask->begin(); bit != init_mask->end(); | |||
5518 | bit = init_mask->next(bit)) | |||
5519 | num_bits_in_mask++; | |||
5520 | exactly_one_group = (num_bits_in_group == num_bits_in_mask); | |||
5521 | } | |||
5522 | KMP_CPU_FREE(init_mask)__kmp_affinity_dispatch->deallocate_mask(init_mask); | |||
5523 | } | |||
5524 | ||||
5525 | // Handle the Win 64 group affinity stuff if there are multiple | |||
5526 | // processor groups, or if the user requested it, and OMP 4.0 | |||
5527 | // affinity is not in effect. | |||
5528 | if (((__kmp_num_proc_groups > 1) && | |||
5529 | (__kmp_affinity_type == affinity_default) | |||
5530 | #if OMP_40_ENABLED(50 >= 40) | |||
5531 | && (__kmp_nested_proc_bind.bind_types[0] == proc_bind_default)) | |||
5532 | #endif | |||
5533 | || (__kmp_affinity_top_method == affinity_top_method_group)) { | |||
5534 | if (__kmp_affinity_respect_mask == affinity_respect_mask_default(-1) && | |||
5535 | exactly_one_group) { | |||
5536 | __kmp_affinity_respect_mask = FALSE0; | |||
5537 | } | |||
5538 | if (__kmp_affinity_type == affinity_default) { | |||
5539 | __kmp_affinity_type = affinity_compact; | |||
5540 | #if OMP_40_ENABLED(50 >= 40) | |||
5541 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; | |||
5542 | #endif | |||
5543 | } | |||
5544 | if (__kmp_affinity_top_method == affinity_top_method_default) { | |||
5545 | if (__kmp_affinity_gran == affinity_gran_default) { | |||
5546 | __kmp_affinity_top_method = affinity_top_method_group; | |||
5547 | __kmp_affinity_gran = affinity_gran_group; | |||
5548 | } else if (__kmp_affinity_gran == affinity_gran_group) { | |||
5549 | __kmp_affinity_top_method = affinity_top_method_group; | |||
5550 | } else { | |||
5551 | __kmp_affinity_top_method = affinity_top_method_all; | |||
5552 | } | |||
5553 | } else if (__kmp_affinity_top_method == affinity_top_method_group) { | |||
5554 | if (__kmp_affinity_gran == affinity_gran_default) { | |||
5555 | __kmp_affinity_gran = affinity_gran_group; | |||
5556 | } else if ((__kmp_affinity_gran != affinity_gran_group) && | |||
5557 | (__kmp_affinity_gran != affinity_gran_fine) && | |||
5558 | (__kmp_affinity_gran != affinity_gran_thread)) { | |||
5559 | const char *str = NULL__null; | |||
5560 | switch (__kmp_affinity_gran) { | |||
5561 | case affinity_gran_core: | |||
5562 | str = "core"; | |||
5563 | break; | |||
5564 | case affinity_gran_package: | |||
5565 | str = "package"; | |||
5566 | break; | |||
5567 | case affinity_gran_node: | |||
5568 | str = "node"; | |||
5569 | break; | |||
5570 | case affinity_gran_tile: | |||
5571 | str = "tile"; | |||
5572 | break; | |||
5573 | default: | |||
5574 | KMP_DEBUG_ASSERT(0)if (!(0)) { __kmp_debug_assert("0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5574); }; | |||
5575 | } | |||
5576 | KMP_WARNING(AffGranTopGroup, var, str)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffGranTopGroup , var, str), __kmp_msg_null); | |||
5577 | __kmp_affinity_gran = affinity_gran_fine; | |||
5578 | } | |||
5579 | } else { | |||
5580 | if (__kmp_affinity_gran == affinity_gran_default) { | |||
5581 | __kmp_affinity_gran = affinity_gran_core; | |||
5582 | } else if (__kmp_affinity_gran == affinity_gran_group) { | |||
5583 | const char *str = NULL__null; | |||
5584 | switch (__kmp_affinity_type) { | |||
5585 | case affinity_physical: | |||
5586 | str = "physical"; | |||
5587 | break; | |||
5588 | case affinity_logical: | |||
5589 | str = "logical"; | |||
5590 | break; | |||
5591 | case affinity_compact: | |||
5592 | str = "compact"; | |||
5593 | break; | |||
5594 | case affinity_scatter: | |||
5595 | str = "scatter"; | |||
5596 | break; | |||
5597 | case affinity_explicit: | |||
5598 | str = "explicit"; | |||
5599 | break; | |||
5600 | // No MIC on windows, so no affinity_balanced case | |||
5601 | default: | |||
5602 | KMP_DEBUG_ASSERT(0)if (!(0)) { __kmp_debug_assert("0", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5602); }; | |||
5603 | } | |||
5604 | KMP_WARNING(AffGranGroupType, var, str)__kmp_msg(kmp_ms_warning, __kmp_msg_format(kmp_i18n_msg_AffGranGroupType , var, str), __kmp_msg_null); | |||
5605 | __kmp_affinity_gran = affinity_gran_core; | |||
5606 | } | |||
5607 | } | |||
5608 | } else | |||
5609 | ||||
5610 | #endif /* KMP_GROUP_AFFINITY */ | |||
5611 | ||||
5612 | { | |||
5613 | if (__kmp_affinity_respect_mask == affinity_respect_mask_default(-1)) { | |||
5614 | #if KMP_GROUP_AFFINITY0 | |||
5615 | if (__kmp_num_proc_groups > 1 && exactly_one_group) { | |||
5616 | __kmp_affinity_respect_mask = FALSE0; | |||
5617 | } else | |||
5618 | #endif /* KMP_GROUP_AFFINITY */ | |||
5619 | { | |||
5620 | __kmp_affinity_respect_mask = TRUE(!0); | |||
5621 | } | |||
5622 | } | |||
5623 | #if OMP_40_ENABLED(50 >= 40) | |||
5624 | if ((__kmp_nested_proc_bind.bind_types[0] != proc_bind_intel) && | |||
5625 | (__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)) { | |||
5626 | if (__kmp_affinity_type == affinity_default) { | |||
5627 | __kmp_affinity_type = affinity_compact; | |||
5628 | __kmp_affinity_dups = FALSE0; | |||
5629 | } | |||
5630 | } else | |||
5631 | #endif /* OMP_40_ENABLED */ | |||
5632 | if (__kmp_affinity_type == affinity_default) { | |||
5633 | #if OMP_40_ENABLED(50 >= 40) | |||
5634 | #if KMP_MIC_SUPPORTED((0 || 1) && (1 || 0)) | |||
5635 | if (__kmp_mic_type != non_mic) { | |||
5636 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_intel; | |||
5637 | } else | |||
5638 | #endif | |||
5639 | { | |||
5640 | __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; | |||
5641 | } | |||
5642 | #endif /* OMP_40_ENABLED */ | |||
5643 | #if KMP_MIC_SUPPORTED((0 || 1) && (1 || 0)) | |||
5644 | if (__kmp_mic_type != non_mic) { | |||
5645 | __kmp_affinity_type = affinity_scatter; | |||
5646 | } else | |||
5647 | #endif | |||
5648 | { | |||
5649 | __kmp_affinity_type = affinity_none; | |||
5650 | } | |||
5651 | } | |||
5652 | if ((__kmp_affinity_gran == affinity_gran_default) && | |||
5653 | (__kmp_affinity_gran_levels < 0)) { | |||
5654 | #if KMP_MIC_SUPPORTED((0 || 1) && (1 || 0)) | |||
5655 | if (__kmp_mic_type != non_mic) { | |||
5656 | __kmp_affinity_gran = affinity_gran_fine; | |||
5657 | } else | |||
5658 | #endif | |||
5659 | { | |||
5660 | __kmp_affinity_gran = affinity_gran_core; | |||
5661 | } | |||
5662 | } | |||
5663 | if (__kmp_affinity_top_method == affinity_top_method_default) { | |||
5664 | __kmp_affinity_top_method = affinity_top_method_all; | |||
5665 | } | |||
5666 | } | |||
5667 | } | |||
5668 | ||||
5669 | K_DIAG(1, ("__kmp_affinity_type == %d\n", __kmp_affinity_type)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_affinity_type == %d\n" , __kmp_affinity_type); } }; | |||
5670 | K_DIAG(1, ("__kmp_affinity_compact == %d\n", __kmp_affinity_compact)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_affinity_compact == %d\n" , __kmp_affinity_compact); } }; | |||
5671 | K_DIAG(1, ("__kmp_affinity_offset == %d\n", __kmp_affinity_offset)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_affinity_offset == %d\n" , __kmp_affinity_offset); } }; | |||
5672 | K_DIAG(1, ("__kmp_affinity_verbose == %d\n", __kmp_affinity_verbose)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_affinity_verbose == %d\n" , __kmp_affinity_verbose); } }; | |||
5673 | K_DIAG(1, ("__kmp_affinity_warnings == %d\n", __kmp_affinity_warnings)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_affinity_warnings == %d\n" , __kmp_affinity_warnings); } }; | |||
5674 | K_DIAG(1, ("__kmp_affinity_respect_mask == %d\n",{ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_affinity_respect_mask == %d\n" , __kmp_affinity_respect_mask); } } | |||
5675 | __kmp_affinity_respect_mask)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_affinity_respect_mask == %d\n" , __kmp_affinity_respect_mask); } }; | |||
5676 | K_DIAG(1, ("__kmp_affinity_gran == %d\n", __kmp_affinity_gran)){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_affinity_gran == %d\n" , __kmp_affinity_gran); } }; | |||
5677 | ||||
5678 | KMP_DEBUG_ASSERT(__kmp_affinity_type != affinity_default)if (!(__kmp_affinity_type != affinity_default)) { __kmp_debug_assert ("__kmp_affinity_type != affinity_default", "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5678); }; | |||
5679 | #if OMP_40_ENABLED(50 >= 40) | |||
5680 | KMP_DEBUG_ASSERT(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default)if (!(__kmp_nested_proc_bind.bind_types[0] != proc_bind_default )) { __kmp_debug_assert("__kmp_nested_proc_bind.bind_types[0] != proc_bind_default" , "/build/llvm-toolchain-snapshot-8~svn345461/projects/openmp/runtime/src/kmp_settings.cpp" , 5680); }; | |||
5681 | K_DIAG(1, ("__kmp_nested_proc_bind.bind_types[0] == %d\n",{ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_nested_proc_bind.bind_types[0] == %d\n" , __kmp_nested_proc_bind.bind_types[0]); } } | |||
5682 | __kmp_nested_proc_bind.bind_types[0])){ if (kmp_diag == 1) { __kmp_debug_printf_stdout ("__kmp_nested_proc_bind.bind_types[0] == %d\n" , __kmp_nested_proc_bind.bind_types[0]); } }; | |||
5683 | #endif | |||
5684 | } | |||
5685 | ||||
5686 | #endif /* KMP_AFFINITY_SUPPORTED */ | |||
5687 | ||||
5688 | if (__kmp_version) { | |||
5689 | __kmp_print_version_1(); | |||
5690 | } | |||
5691 | ||||
5692 | // Post-initialization step: some env. vars need their value's further | |||
5693 | // processing | |||
5694 | if (string != NULL__null) { // kmp_set_defaults() was called | |||
5695 | __kmp_aux_env_initialize(&block); | |||
5696 | } | |||
5697 | ||||
5698 | __kmp_env_blk_free(&block); | |||
5699 | ||||
5700 | KMP_MB(); | |||
5701 | ||||
5702 | } // __kmp_env_initialize | |||
5703 | ||||
5704 | void __kmp_env_print() { | |||
5705 | ||||
5706 | kmp_env_blk_t block; | |||
5707 | int i; | |||
5708 | kmp_str_buf_t buffer; | |||
5709 | ||||
5710 | __kmp_stg_init(); | |||
5711 | __kmp_str_buf_init(&buffer){ (&buffer)->str = (&buffer)->bulk; (&buffer )->size = sizeof((&buffer)->bulk); (&buffer)-> used = 0; (&buffer)->bulk[0] = 0; }; | |||
5712 | ||||
5713 | __kmp_env_blk_init(&block, NULL__null); | |||
5714 | __kmp_env_blk_sort(&block); | |||
5715 | ||||
5716 | // Print real environment values. | |||
5717 | __kmp_str_buf_print(&buffer, "\n%s\n\n", KMP_I18N_STR(UserSettings)__kmp_i18n_catgets(kmp_i18n_str_UserSettings)); | |||
5718 | for (i = 0; i < block.count; ++i) { | |||
5719 | char const *name = block.vars[i].name; | |||
5720 | char const *value = block.vars[i].value; | |||
5721 | if ((KMP_STRLENstrlen(name) > 4 && strncmp(name, "KMP_", 4) == 0) || | |||
5722 | strncmp(name, "OMP_", 4) == 0 | |||
5723 | #ifdef KMP_GOMP_COMPAT | |||
5724 | || strncmp(name, "GOMP_", 5) == 0 | |||
5725 | #endif // KMP_GOMP_COMPAT | |||
5726 | ) { | |||
5727 | __kmp_str_buf_print(&buffer, " %s=%s\n", name, value); | |||
5728 | } | |||
5729 | } | |||
5730 | __kmp_str_buf_print(&buffer, "\n"); | |||
5731 | ||||
5732 | // Print internal (effective) settings. | |||
5733 | __kmp_str_buf_print(&buffer, "%s\n\n", KMP_I18N_STR(EffectiveSettings)__kmp_i18n_catgets(kmp_i18n_str_EffectiveSettings)); | |||
5734 | for (int i = 0; i < __kmp_stg_count; ++i) { | |||
5735 | if (__kmp_stg_table[i].print != NULL__null) { | |||
5736 | __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name, | |||
5737 | __kmp_stg_table[i].data); | |||
5738 | } | |||
5739 | } | |||
5740 | ||||
5741 | __kmp_printf("%s", buffer.str); | |||
5742 | ||||
5743 | __kmp_env_blk_free(&block); | |||
5744 | __kmp_str_buf_free(&buffer); | |||
5745 | ||||
5746 | __kmp_printf("\n"); | |||
5747 | ||||
5748 | } // __kmp_env_print | |||
5749 | ||||
5750 | #if OMP_40_ENABLED(50 >= 40) | |||
5751 | void __kmp_env_print_2() { | |||
5752 | ||||
5753 | kmp_env_blk_t block; | |||
5754 | kmp_str_buf_t buffer; | |||
5755 | ||||
5756 | __kmp_env_format = 1; | |||
5757 | ||||
5758 | __kmp_stg_init(); | |||
5759 | __kmp_str_buf_init(&buffer){ (&buffer)->str = (&buffer)->bulk; (&buffer )->size = sizeof((&buffer)->bulk); (&buffer)-> used = 0; (&buffer)->bulk[0] = 0; }; | |||
5760 | ||||
5761 | __kmp_env_blk_init(&block, NULL__null); | |||
5762 | __kmp_env_blk_sort(&block); | |||
5763 | ||||
5764 | __kmp_str_buf_print(&buffer, "\n%s\n", KMP_I18N_STR(DisplayEnvBegin)__kmp_i18n_catgets(kmp_i18n_str_DisplayEnvBegin)); | |||
5765 | __kmp_str_buf_print(&buffer, " _OPENMP='%d'\n", __kmp_openmp_version); | |||
5766 | ||||
5767 | for (int i = 0; i < __kmp_stg_count; ++i) { | |||
5768 | if (__kmp_stg_table[i].print != NULL__null && | |||
5769 | ((__kmp_display_env && | |||
5770 | strncmp(__kmp_stg_table[i].name, "OMP_", 4) == 0) || | |||
5771 | __kmp_display_env_verbose)) { | |||
5772 | __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name, | |||
5773 | __kmp_stg_table[i].data); | |||
5774 | } | |||
5775 | } | |||
5776 | ||||
5777 | __kmp_str_buf_print(&buffer, "%s\n", KMP_I18N_STR(DisplayEnvEnd)__kmp_i18n_catgets(kmp_i18n_str_DisplayEnvEnd)); | |||
5778 | __kmp_str_buf_print(&buffer, "\n"); | |||
5779 | ||||
5780 | __kmp_printf("%s", buffer.str); | |||
5781 | ||||
5782 | __kmp_env_blk_free(&block); | |||
5783 | __kmp_str_buf_free(&buffer); | |||
5784 | ||||
5785 | __kmp_printf("\n"); | |||
5786 | ||||
5787 | } // __kmp_env_print_2 | |||
5788 | #endif // OMP_40_ENABLED | |||
5789 | ||||
5790 | // end of file |