Skip to content

Commit

Permalink
[libomptarget] [amdgpu] Hostcall offset check should consider implici…
Browse files Browse the repository at this point in the history
…t 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
  • Loading branch information
dhruvachak committed Apr 15, 2022
1 parent e33b07f commit 7086a1d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
Expand Up @@ -1240,15 +1240,19 @@ 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
// the explicit arguments. In the future, should be able to read
// 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);
}
Expand Down

0 comments on commit 7086a1d

Please sign in to comment.