[Openmp-commits] [openmp] [OpenMP] Make sure mask is set to nullptr (PR #83299)
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Wed Feb 28 09:25:18 PST 2024
https://github.com/jpeyton52 created https://github.com/llvm/llvm-project/pull/83299
None
>From 5d19e63c7ecfe3b9dfc3a51afce4ae866c75c53d Mon Sep 17 00:00:00 2001
From: Jonathan Peyton <jonathan.l.peyton at intel.com>
Date: Tue, 27 Feb 2024 15:52:03 -0600
Subject: [PATCH] [OpenMP] Make sure mask is set to nullptr
---
openmp/runtime/src/kmp.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index 259c57b5afbca5..ff15fe19bcb11e 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -824,7 +824,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);
@@ -834,7 +834,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