diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2018-09-07 18:25:49 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2018-09-07 18:25:49 +0000 |
commit | 92ca61884b6a675a3c2be33244ef3dfca61f94ae (patch) | |
tree | 256075a55b79eed432512c0f4c2264ba0d5b8c5c /openmp/runtime/src/kmp_settings.cpp | |
parent | b97d18945b821fe4f9b4c7059eb87e2a8734ab5d (diff) | |
download | bcm5719-llvm-92ca61884b6a675a3c2be33244ef3dfca61f94ae.tar.gz bcm5719-llvm-92ca61884b6a675a3c2be33244ef3dfca61f94ae.zip |
[OpenMP] Initial implementation of OMP 5.0 Memory Management routines
Implemented omp_alloc, omp_free, omp_{set,get}_default_allocator entries,
and OMP_ALLOCATOR environment variable.
Added support for HBW memory on Linux if libmemkind.so library is accessible
(dynamic library only, no support for static libraries).
Only used stable API (hbwmalloc) of the memkind library
though we may consider using experimental API in future.
The ICV def-allocator-var is implemented per implicit task similar to
place-partition-var. In the absence of a requested allocator, the uses the
default allocator.
Predefined allocators (the only ones currently available) are made similar
for C and Fortran, - pointers (long integers) with values 1 to 8.
Patch by Andrey Churbanov
Differential Revision: https://reviews.llvm.org/D51232
llvm-svn: 341687
Diffstat (limited to 'openmp/runtime/src/kmp_settings.cpp')
-rw-r--r-- | openmp/runtime/src/kmp_settings.cpp | 149 |
1 files changed, 148 insertions, 1 deletions
diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp index 72b779438ec..9a7d8dba88f 100644 --- a/openmp/runtime/src/kmp_settings.cpp +++ b/openmp/runtime/src/kmp_settings.cpp @@ -3251,6 +3251,149 @@ static void __kmp_stg_print_proc_bind(kmp_str_buf_t *buffer, char const *name, #endif /* OMP_40_ENABLED */ +#if OMP_50_ENABLED + +// OMP_ALLOCATOR sets default allocator +static void __kmp_stg_parse_allocator(char const *name, char const *value, + void *data) { + /* + The value can be any predefined allocator: + omp_default_mem_alloc = 1; + omp_large_cap_mem_alloc = 2; + omp_const_mem_alloc = 3; + omp_high_bw_mem_alloc = 4; + omp_low_lat_mem_alloc = 5; + omp_cgroup_mem_alloc = 6; + omp_pteam_mem_alloc = 7; + omp_thread_mem_alloc = 8; + Acceptable value is either a digit or a string. + */ + const char *buf = value; + const char *next; + int num; + SKIP_WS(buf); + if ((*buf > '0') && (*buf < '9')) { + next = buf; + SKIP_DIGITS(next); + num = __kmp_str_to_int(buf, *next); + KMP_ASSERT(num > 0); + switch (num) { + case 4: + if (__kmp_hbw_mem_available) { + __kmp_def_allocator = omp_high_bw_mem_alloc; + } else { + __kmp_msg(kmp_ms_warning, + KMP_MSG(OmpNoAllocator, "omp_high_bw_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + } + break; + case 1: + __kmp_def_allocator = omp_default_mem_alloc; + break; + case 2: + __kmp_msg(kmp_ms_warning, + KMP_MSG(OmpNoAllocator, "omp_large_cap_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + break; + case 3: + __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_const_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + break; + case 5: + __kmp_msg(kmp_ms_warning, + KMP_MSG(OmpNoAllocator, "omp_low_lat_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + break; + case 6: + __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_cgroup_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + break; + case 7: + __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_pteam_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + break; + case 8: + __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_thread_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + break; + } + return; + } + next = buf; + if (__kmp_match_str("omp_high_bw_mem_alloc", buf, &next)) { + if (__kmp_hbw_mem_available) { + __kmp_def_allocator = omp_high_bw_mem_alloc; + } else { + __kmp_msg(kmp_ms_warning, + KMP_MSG(OmpNoAllocator, "omp_high_bw_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + } + } else if (__kmp_match_str("omp_default_mem_alloc", buf, &next)) { + __kmp_def_allocator = omp_default_mem_alloc; + } else if (__kmp_match_str("omp_large_cap_mem_alloc", buf, &next)) { + __kmp_msg(kmp_ms_warning, + KMP_MSG(OmpNoAllocator, "omp_large_cap_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + } else if (__kmp_match_str("omp_const_mem_alloc", buf, &next)) { + __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_const_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + } else if (__kmp_match_str("omp_low_lat_mem_alloc", buf, &next)) { + __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_low_lat_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + } else if (__kmp_match_str("omp_cgroup_mem_alloc", buf, &next)) { + __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_cgroup_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + } else if (__kmp_match_str("omp_pteam_mem_alloc", buf, &next)) { + __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_pteam_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + } else if (__kmp_match_str("omp_thread_mem_alloc", buf, &next)) { + __kmp_msg(kmp_ms_warning, KMP_MSG(OmpNoAllocator, "omp_thread_mem_alloc"), + __kmp_msg_null); + __kmp_def_allocator = omp_default_mem_alloc; + } + buf = next; + SKIP_WS(buf); + if (*buf != '\0') { + KMP_WARNING(ParseExtraCharsWarn, name, buf); + } +} + +static void __kmp_stg_print_allocator(kmp_str_buf_t *buffer, char const *name, + void *data) { + if (__kmp_def_allocator == omp_default_mem_alloc) { + __kmp_stg_print_str(buffer, name, "omp_default_mem_alloc"); + } else if (__kmp_def_allocator == omp_high_bw_mem_alloc) { + __kmp_stg_print_str(buffer, name, "omp_high_bw_mem_alloc"); + } else if (__kmp_def_allocator == omp_large_cap_mem_alloc) { + __kmp_stg_print_str(buffer, name, "omp_large_cap_mem_alloc"); + } else if (__kmp_def_allocator == omp_const_mem_alloc) { + __kmp_stg_print_str(buffer, name, "omp_const_mem_alloc"); + } else if (__kmp_def_allocator == omp_low_lat_mem_alloc) { + __kmp_stg_print_str(buffer, name, "omp_low_lat_mem_alloc"); + } else if (__kmp_def_allocator == omp_cgroup_mem_alloc) { + __kmp_stg_print_str(buffer, name, "omp_cgroup_mem_alloc"); + } else if (__kmp_def_allocator == omp_pteam_mem_alloc) { + __kmp_stg_print_str(buffer, name, "omp_pteam_mem_alloc"); + } else if (__kmp_def_allocator == omp_thread_mem_alloc) { + __kmp_stg_print_str(buffer, name, "omp_thread_mem_alloc"); + } +} + +#endif /* OMP_50_ENABLED */ + // ----------------------------------------------------------------------------- // OMP_DYNAMIC @@ -4707,7 +4850,6 @@ static kmp_setting_t __kmp_stg_table[] = { {"OMP_PROC_BIND", __kmp_stg_parse_proc_bind, NULL, /* no print */ NULL, 0, 0}, #endif /* OMP_40_ENABLED */ - {"KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method, __kmp_stg_print_topology_method, NULL, 0, 0}, @@ -4791,6 +4933,11 @@ static kmp_setting_t __kmp_stg_table[] = { __kmp_stg_print_omp_cancellation, NULL, 0, 0}, #endif +#if OMP_50_ENABLED + {"OMP_ALLOCATOR", __kmp_stg_parse_allocator, __kmp_stg_print_allocator, + NULL, 0, 0}, +#endif + #if OMP_50_ENABLED && OMPT_SUPPORT {"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries, __kmp_stg_print_omp_tool_libraries, NULL, 0, 0}, |