[Openmp-commits] [openmp] 95e11a9 - [OpenMP][FIX] Unbreak a fencing issue
Johannes Doerfert via Openmp-commits
openmp-commits at lists.llvm.org
Thu Nov 2 15:04:18 PDT 2023
Author: Johannes Doerfert
Date: 2023-11-02T15:04:10-07:00
New Revision: 95e11a97f6666400e89c66bdf9a61bb87ede5708
URL: https://github.com/llvm/llvm-project/commit/95e11a97f6666400e89c66bdf9a61bb87ede5708
DIFF: https://github.com/llvm/llvm-project/commit/95e11a97f6666400e89c66bdf9a61bb87ede5708.diff
LOG: [OpenMP][FIX] Unbreak a fencing issue
A recent update caused the fences to be team only while we always need
kernel fences. Broke OpenMC on NVIDIA A100.
Added:
Modified:
openmp/libomptarget/DeviceRTL/src/Reduction.cpp
Removed:
################################################################################
diff --git a/openmp/libomptarget/DeviceRTL/src/Reduction.cpp b/openmp/libomptarget/DeviceRTL/src/Reduction.cpp
index efa09cafa879ec1..bae4237194590d6 100644
--- a/openmp/libomptarget/DeviceRTL/src/Reduction.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Reduction.cpp
@@ -220,17 +220,20 @@ int32_t __kmpc_nvptx_teams_reduce_nowait_v2(
} else
lgredFct(GlobalBuffer, ModBockId, reduce_data);
+ // Propagate the memory writes above to the world.
+ fence::kernel(atomic::release);
+
// Increment team counter.
// This counter is incremented by all teams in the current
- // BUFFER_SIZE chunk.
+ // num_of_records chunk.
ChunkTeamCount = atomic::inc(&Cnt, num_of_records - 1u, atomic::seq_cst,
atomic::MemScopeTy::device);
}
- // Synchronize
+
+ // Synchronize in SPMD mode as in generic mode all but 1 threads are in the
+ // state machine.
if (mapping::isSPMDMode())
synchronize::threadsAligned(atomic::acq_rel);
- else
- fence::kernel(atomic::acq_rel);
// reduce_data is global or shared so before being reduced within the
// warp we need to bring it in local memory:
@@ -257,6 +260,9 @@ int32_t __kmpc_nvptx_teams_reduce_nowait_v2(
// Check if this is the very last team.
unsigned NumRecs = kmpcMin(NumTeams, uint32_t(num_of_records));
if (ChunkTeamCount == NumTeams - Bound - 1) {
+ // Ensure we see the global memory writes by other teams
+ fence::kernel(atomic::aquire);
+
//
// Last team processing.
//
More information about the Openmp-commits
mailing list