[Openmp-commits] [openmp] 3303be6 - [OpenMP] Make sure mask is set to nullptr (#83299)
via Openmp-commits
openmp-commits at lists.llvm.org
Tue Mar 12 11:36:48 PDT 2024
Author: Jonathan Peyton
Date: 2024-03-12T11:36:43-07:00
New Revision: 3303be63fc2ac196568b03f58c146655e19183f6
URL: https://github.com/llvm/llvm-project/commit/3303be63fc2ac196568b03f58c146655e19183f6
DIFF: https://github.com/llvm/llvm-project/commit/3303be63fc2ac196568b03f58c146655e19183f6.diff
LOG: [OpenMP] Make sure mask is set to nullptr (#83299)
Added:
Modified:
openmp/runtime/src/kmp.h
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index 48d7124e56c57c..de758d37269dc7 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -825,7 +825,7 @@ class kmp_affinity_raii_t {
public:
kmp_affinity_raii_t(const kmp_affin_mask_t *new_mask = nullptr)
- : restored(false) {
+ : mask(nullptr), restored(false) {
if (KMP_AFFINITY_CAPABLE()) {
KMP_CPU_ALLOC(mask);
KMP_ASSERT(mask != NULL);
@@ -835,7 +835,7 @@ class kmp_affinity_raii_t {
}
}
void restore() {
- if (!restored && KMP_AFFINITY_CAPABLE()) {
+ if (mask && KMP_AFFINITY_CAPABLE() && !restored) {
__kmp_set_system_affinity(mask, /*abort_on_error=*/true);
KMP_CPU_FREE(mask);
}
More information about the Openmp-commits
mailing list