diff options
author | AndreyChurbanov <andrey.churbanov@intel.com> | 2021-02-26 00:44:51 +0300 |
---|---|---|
committer | AndreyChurbanov <andrey.churbanov@intel.com> | 2021-02-26 00:44:51 +0300 |
commit | 1df6e58e55a33991054f4041d87200bf1b217197 (patch) | |
tree | 8807cf36888ae33b8c5945be790b57ab30afc86e | |
parent | b889ef4214bc6dc8880fdd4badc0dcd9a3197753 (diff) | |
download | llvm-1df6e58e55a33991054f4041d87200bf1b217197.zip llvm-1df6e58e55a33991054f4041d87200bf1b217197.tar.gz llvm-1df6e58e55a33991054f4041d87200bf1b217197.tar.bz2 |
[OpenMP] libomp minor cleanup
Cleanup changes:
- check value read from file;
- remove dead code;
- make unsigned variable to read hexadecimal number to;
- add debug assertion to check ref count.
Differential Revision: https://reviews.llvm.org/D96893
-rw-r--r-- | openmp/runtime/src/kmp_affinity.cpp | 6 | ||||
-rw-r--r-- | openmp/runtime/src/kmp_runtime.cpp | 2 | ||||
-rw-r--r-- | openmp/runtime/src/kmp_taskdeps.h | 1 |
3 files changed, 6 insertions, 3 deletions
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp index e5e1d21..0242861 100644 --- a/openmp/runtime/src/kmp_affinity.cpp +++ b/openmp/runtime/src/kmp_affinity.cpp @@ -2176,6 +2176,10 @@ static int __kmp_affinity_create_cpuinfo_map(AddrUnsPair **address2os, // FIXME - this will match "node_<n> <garbage>" unsigned level; if (KMP_SSCANF(buf, "node_%u id", &level) == 1) { + // validate the input fisrt: + if (level > (unsigned)__kmp_xproc) { // level is too big + level = __kmp_xproc; + } if (nodeIdIndex + level >= maxIndex) { maxIndex = nodeIdIndex + level; } @@ -4346,8 +4350,6 @@ static void __kmp_aux_affinity_initialize(void) { depth = __kmp_affinity_create_hwloc_map(&address2os, &msg_id); if (depth == 0) { KMP_EXIT_AFF_NONE; - } else if (depth < 0 && __kmp_affinity_verbose) { - KMP_INFORM(AffIgnoringHwloc, "KMP_AFFINITY"); } } else if (__kmp_affinity_verbose) { KMP_INFORM(AffIgnoringHwloc, "KMP_AFFINITY"); diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp index fa18091..57e3b7d 100644 --- a/openmp/runtime/src/kmp_runtime.cpp +++ b/openmp/runtime/src/kmp_runtime.cpp @@ -6487,7 +6487,7 @@ void __kmp_register_library_startup(void) { file_name = tail; if (tail != NULL) { long *flag_addr = 0; - long flag_val = 0; + unsigned long flag_val = 0; KMP_SSCANF(flag_addr_str, "%p", RCAST(void **, &flag_addr)); KMP_SSCANF(flag_val_str, "%lx", &flag_val); if (flag_addr != 0 && flag_val != 0 && strcmp(file_name, "") != 0) { diff --git a/openmp/runtime/src/kmp_taskdeps.h b/openmp/runtime/src/kmp_taskdeps.h index 34db94f..83820c1 100644 --- a/openmp/runtime/src/kmp_taskdeps.h +++ b/openmp/runtime/src/kmp_taskdeps.h @@ -23,6 +23,7 @@ static inline void __kmp_node_deref(kmp_info_t *thread, kmp_depnode_t *node) { return; kmp_int32 n = KMP_ATOMIC_DEC(&node->dn.nrefs) - 1; + KMP_DEBUG_ASSERT(n >= 0); if (n == 0) { KMP_ASSERT(node->dn.nrefs == 0); #if USE_FAST_MEMORY |