diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2022-08-01 17:03:27 -0500 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2022-10-28 15:21:06 -0500 |
commit | 174502fc14d08ad4aeee81a2ff7e551138b77152 (patch) | |
tree | 028351e07d929a04525bb1b18570ad4c194b8db6 /openmp/runtime/src/z_Linux_util.cpp | |
parent | 71cf48a62a6d2930d4e782545764aeb725df12f7 (diff) | |
download | llvm-174502fc14d08ad4aeee81a2ff7e551138b77152.zip llvm-174502fc14d08ad4aeee81a2ff7e551138b77152.tar.gz llvm-174502fc14d08ad4aeee81a2ff7e551138b77152.tar.bz2 |
[OpenMP][libomp] Parameterize affinity functions
This patch parameterizes the affinity initialization code to allow multiple
affinity settings. Almost all global affinity settings are consolidated
and put into a structure kmp_affinity_t. This is in anticipation of the
addition of hidden helper affinity which will have the same syntax and
semantics as KMP_AFFINITY only for the hidden helper team.
Differential Revision: https://reviews.llvm.org/D135109
Diffstat (limited to 'openmp/runtime/src/z_Linux_util.cpp')
-rw-r--r-- | openmp/runtime/src/z_Linux_util.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp index 6fd2f34a..7b027a2 100644 --- a/openmp/runtime/src/z_Linux_util.cpp +++ b/openmp/runtime/src/z_Linux_util.cpp @@ -135,6 +135,9 @@ void __kmp_affinity_determine_capable(const char *env_var) { long gCode; unsigned char *buf; buf = (unsigned char *)KMP_INTERNAL_MALLOC(KMP_CPU_SET_SIZE_LIMIT); + int verbose = __kmp_affinity.flags.verbose; + int warnings = __kmp_affinity.flags.warnings; + enum affinity_type type = __kmp_affinity.type; // If the syscall returns a suggestion for the size, // then we don't have to search for an appropriate size. @@ -145,10 +148,9 @@ void __kmp_affinity_determine_capable(const char *env_var) { if (gCode < 0 && errno != EINVAL) { // System call not supported - if (__kmp_affinity_verbose || - (__kmp_affinity_warnings && (__kmp_affinity_type != affinity_none) && - (__kmp_affinity_type != affinity_default) && - (__kmp_affinity_type != affinity_disabled))) { + if (verbose || + (warnings && (type != affinity_none) && (type != affinity_default) && + (type != affinity_disabled))) { int error = errno; kmp_msg_t err_code = KMP_ERR(error); __kmp_msg(kmp_ms_warning, KMP_MSG(GetAffSysCallNotSupported, env_var), @@ -188,11 +190,9 @@ void __kmp_affinity_determine_capable(const char *env_var) { "inconsistent OS call behavior: errno == ENOSYS for mask " "size %d\n", size)); - if (__kmp_affinity_verbose || - (__kmp_affinity_warnings && - (__kmp_affinity_type != affinity_none) && - (__kmp_affinity_type != affinity_default) && - (__kmp_affinity_type != affinity_disabled))) { + if (verbose || + (warnings && (type != affinity_none) && + (type != affinity_default) && (type != affinity_disabled))) { int error = errno; kmp_msg_t err_code = KMP_ERR(error); __kmp_msg(kmp_ms_warning, KMP_MSG(GetAffSysCallNotSupported, env_var), @@ -239,10 +239,8 @@ void __kmp_affinity_determine_capable(const char *env_var) { KMP_AFFINITY_DISABLE(); KA_TRACE(10, ("__kmp_affinity_determine_capable: " "cannot determine mask size - affinity not supported\n")); - if (__kmp_affinity_verbose || - (__kmp_affinity_warnings && (__kmp_affinity_type != affinity_none) && - (__kmp_affinity_type != affinity_default) && - (__kmp_affinity_type != affinity_disabled))) { + if (verbose || (warnings && (type != affinity_none) && + (type != affinity_default) && (type != affinity_disabled))) { KMP_WARNING(AffCantGetMaskSize, env_var); } } @@ -1230,12 +1228,12 @@ static void __kmp_atfork_child(void) { // Set default not to bind threads tightly in the child (we're expecting // over-subscription after the fork and this can improve things for // scripting languages that use OpenMP inside process-parallel code). - __kmp_affinity_type = affinity_none; if (__kmp_nested_proc_bind.bind_types != NULL) { __kmp_nested_proc_bind.bind_types[0] = proc_bind_false; } - __kmp_affinity_masks = NULL; - __kmp_affinity_num_masks = 0; + __kmp_affinity = KMP_AFFINITY_INIT("KMP_AFFINITY"); + __kmp_affin_fullMask = nullptr; + __kmp_affin_origMask = nullptr; #endif // KMP_AFFINITY_SUPPORTED #if KMP_USE_MONITOR |