[Openmp-commits] [openmp] 9b1c496 - [OpenMP] Fixup while loops to avoid bad NULL check (#83302)
via Openmp-commits
openmp-commits at lists.llvm.org
Mon Mar 11 08:32:53 PDT 2024
Author: Jonathan Peyton
Date: 2024-03-11T10:28:12-05:00
New Revision: 9b1c496898cbefdce74eb1cf1a0911eb3230d65b
URL: https://github.com/llvm/llvm-project/commit/9b1c496898cbefdce74eb1cf1a0911eb3230d65b
DIFF: https://github.com/llvm/llvm-project/commit/9b1c496898cbefdce74eb1cf1a0911eb3230d65b.diff
LOG: [OpenMP] Fixup while loops to avoid bad NULL check (#83302)
Added:
Modified:
openmp/runtime/src/kmp_affinity.cpp
openmp/runtime/src/kmp_tasking.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp
index ae0b6459d79ed0..b79b57eafd6a81 100644
--- a/openmp/runtime/src/kmp_affinity.cpp
+++ b/openmp/runtime/src/kmp_affinity.cpp
@@ -1829,14 +1829,8 @@ static bool __kmp_affinity_create_hwloc_map(kmp_i18n_id_t *const msg_id) {
// Figure out the depth and types in the topology
depth = 0;
- pu = hwloc_get_pu_obj_by_os_index(tp, __kmp_affin_fullMask->begin());
- KMP_ASSERT(pu);
- obj = pu;
- types[depth] = KMP_HW_THREAD;
- hwloc_types[depth] = obj->type;
- depth++;
- while (obj != root && obj != NULL) {
- obj = obj->parent;
+ obj = hwloc_get_pu_obj_by_os_index(tp, __kmp_affin_fullMask->begin());
+ while (obj && obj != root) {
#if HWLOC_API_VERSION >= 0x00020000
if (obj->memory_arity) {
hwloc_obj_t memory;
@@ -1858,6 +1852,7 @@ static bool __kmp_affinity_create_hwloc_map(kmp_i18n_id_t *const msg_id) {
hwloc_types[depth] = obj->type;
depth++;
}
+ obj = obj->parent;
}
KMP_ASSERT(depth > 0);
diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp
index 6e8b948efa064f..155e17ba7ec874 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -2662,8 +2662,8 @@ void *__kmpc_task_reduction_get_th_data(int gtid, void *tskgrp, void *data) {
if (tg == NULL)
tg = thread->th.th_current_task->td_taskgroup;
KMP_ASSERT(tg != NULL);
- kmp_taskred_data_t *arr = (kmp_taskred_data_t *)(tg->reduce_data);
- kmp_int32 num = tg->reduce_num_data;
+ kmp_taskred_data_t *arr;
+ kmp_int32 num;
kmp_int32 tid = thread->th.th_info.ds.ds_tid;
#if OMPX_TASKGRAPH
@@ -2680,6 +2680,8 @@ void *__kmpc_task_reduction_get_th_data(int gtid, void *tskgrp, void *data) {
KMP_ASSERT(data != NULL);
while (tg != NULL) {
+ arr = (kmp_taskred_data_t *)(tg->reduce_data);
+ num = tg->reduce_num_data;
for (int i = 0; i < num; ++i) {
if (!arr[i].flags.lazy_priv) {
if (data == arr[i].reduce_shar ||
@@ -2713,8 +2715,6 @@ void *__kmpc_task_reduction_get_th_data(int gtid, void *tskgrp, void *data) {
}
KMP_ASSERT(tg->parent);
tg = tg->parent;
- arr = (kmp_taskred_data_t *)(tg->reduce_data);
- num = tg->reduce_num_data;
}
KMP_ASSERT2(0, "Unknown task reduction item");
return NULL; // ERROR, this line never executed
More information about the Openmp-commits
mailing list