[Openmp-commits] [openmp] 7086a1d - [libomptarget] [amdgpu] Hostcall offset check should consider implicit args
Dhruva Chakrabarti via Openmp-commits
openmp-commits at lists.llvm.org
Thu Apr 14 17:54:34 PDT 2022
Author: Dhruva Chakrabarti
Date: 2022-04-15T00:53:47Z
New Revision: 7086a1db80e1e09463744f6f6840eb771e3faeef
URL: https://github.com/llvm/llvm-project/commit/7086a1db80e1e09463744f6f6840eb771e3faeef
DIFF: https://github.com/llvm/llvm-project/commit/7086a1db80e1e09463744f6f6840eb771e3faeef.diff
LOG: [libomptarget] [amdgpu] Hostcall offset check should consider implicit args
Fixed hostcall offset check to compare against kernarg segment size
and implicit arguments. Improved the corresponding debug print.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D123827
Added:
Modified:
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
Removed:
################################################################################
diff --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index fec8865b3c5e8..3086334f8ef63 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -1240,6 +1240,8 @@ int32_t runRegionLocked(int32_t device_id, void *tgt_entry_ptr, void **tgt_args,
return OFFLOAD_FAIL;
}
+ DP("Implicit argument count: %d\n",
+ KernelInfoEntry.implicit_argument_count);
if (KernelInfoEntry.implicit_argument_count >= 4) {
// Initialise pointer for implicit_argument_count != 0 ABI
// Guess that the right implicit argument is at offset 24 after
@@ -1247,8 +1249,10 @@ int32_t runRegionLocked(int32_t device_id, void *tgt_entry_ptr, void **tgt_args,
// the offset from msgpack. Clang is not annotating it at present.
uint64_t Offset =
sizeof(void *) * (KernelInfoEntry.explicit_argument_count + 3);
- if ((Offset + 8) > (ArgPool->kernarg_segment_size)) {
- DP("Bad offset of hostcall, exceeds kernarg segment size\n");
+ if ((Offset + 8) > ArgPool->kernarg_size_including_implicit()) {
+ DP("Bad offset of hostcall: %lu, exceeds kernarg size w/ implicit "
+ "args: %d\n",
+ Offset + 8, ArgPool->kernarg_size_including_implicit());
} else {
memcpy(static_cast<char *>(kernarg) + Offset, &buffer, 8);
}
More information about the Openmp-commits
mailing list