[Openmp-commits] [PATCH] D110679: [libomptarget] [amdgpu] After a kernel dispatch packet is published, its contents must not be accessed.
Dhruva Chakrabarti via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Tue Sep 28 23:59:56 PDT 2021
dhruvachak created this revision.
dhruvachak added reviewers: JonChesterfield, t-tye, ronlieb.
Herald added subscribers: kerbowa, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
dhruvachak requested review of this revision.
Herald added subscribers: openmp-commits, wdng.
Herald added a project: OpenMP.
Fixes: SWDEV-275232
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110679
Files:
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
===================================================================
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -2185,6 +2185,7 @@
packet->completion_signal = {0}; // may want a pool of signals
KernelArgPool *ArgPool = nullptr;
+ void *kernarg = nullptr;
{
auto it = KernelArgPoolMap.find(std::string(KernelInfo->Name));
if (it != KernelArgPoolMap.end()) {
@@ -2196,7 +2197,6 @@
device_id);
}
{
- void *kernarg = nullptr;
if (ArgPool) {
assert(ArgPool->kernarg_segment_size == (arg_num * sizeof(void *)));
kernarg = ArgPool->allocate(arg_num);
@@ -2240,29 +2240,29 @@
packet->kernarg_address = kernarg;
}
- {
- hsa_signal_t s = DeviceInfo.FreeSignalPool.pop();
- if (s.handle == 0) {
- DP("Failed to get signal instance\n");
- return OFFLOAD_FAIL;
- }
- packet->completion_signal = s;
- hsa_signal_store_relaxed(packet->completion_signal, 1);
+ hsa_signal_t s = DeviceInfo.FreeSignalPool.pop();
+ if (s.handle == 0) {
+ DP("Failed to get signal instance\n");
+ return OFFLOAD_FAIL;
}
+ packet->completion_signal = s;
+ hsa_signal_store_relaxed(packet->completion_signal, 1);
+ // Publish the packet indicating it is ready to be processed
core::packet_store_release(reinterpret_cast<uint32_t *>(packet),
core::create_header(), packet->setup);
+ // Since the packet is already published, its contents must not be
+ // accessed any more
hsa_signal_store_relaxed(queue->doorbell_signal, packet_id);
- while (hsa_signal_wait_scacquire(packet->completion_signal,
- HSA_SIGNAL_CONDITION_EQ, 0, UINT64_MAX,
+ while (hsa_signal_wait_scacquire(s, HSA_SIGNAL_CONDITION_EQ, 0, UINT64_MAX,
HSA_WAIT_STATE_BLOCKED) != 0)
;
assert(ArgPool);
- ArgPool->deallocate(packet->kernarg_address);
- DeviceInfo.FreeSignalPool.push(packet->completion_signal);
+ ArgPool->deallocate(kernarg);
+ DeviceInfo.FreeSignalPool.push(s);
}
DP("Kernel completed\n");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110679.375790.patch
Type: text/x-patch
Size: 2285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210929/765ca275/attachment.bin>
More information about the Openmp-commits
mailing list