diff options
| author | Callum Fare <callum@codeplay.com> | 2025-08-22 14:31:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-22 14:31:16 +0100 |
| commit | 0b18d2da70096fcd28e82dbce8f853232454856e (patch) | |
| tree | 10d33baef4dcc804885e06559410efc4422b6dec /offload/plugins-nextgen/amdgpu | |
| parent | 3768ec309bbbc54a5e93257cf83f0b6a19a0f050 (diff) | |
[Offload] Implement olMemFill (#154102)
Implement olMemFill to support filling device memory with arbitrary
length patterns. AMDGPU support will be added in a follow-up PR.
Diffstat (limited to 'offload/plugins-nextgen/amdgpu')
| -rw-r--r-- | offload/plugins-nextgen/amdgpu/src/rtl.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp b/offload/plugins-nextgen/amdgpu/src/rtl.cpp index b2c7a08f2d63..7ba55715ff58 100644 --- a/offload/plugins-nextgen/amdgpu/src/rtl.cpp +++ b/offload/plugins-nextgen/amdgpu/src/rtl.cpp @@ -2608,6 +2608,31 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy { return Plugin::success(); } + Error dataFillImpl(void *TgtPtr, const void *PatternPtr, int64_t PatternSize, + int64_t Size, + AsyncInfoWrapperTy &AsyncInfoWrapper) override { + hsa_status_t Status; + + // We can use hsa_amd_memory_fill for this size, but it's not async so the + // queue needs to be synchronized first + if (PatternSize == 4) { + if (AsyncInfoWrapper.hasQueue()) + if (auto Err = synchronize(AsyncInfoWrapper)) + return Err; + Status = hsa_amd_memory_fill(TgtPtr, + *static_cast<const uint32_t *>(PatternPtr), + Size / PatternSize); + + if (auto Err = + Plugin::check(Status, "error in hsa_amd_memory_fill: %s\n")) + return Err; + } else { + // TODO: Implement for AMDGPU. Most likely by doing the fill in pinned + // memory and copying to the device in one go. + return Plugin::error(ErrorCode::UNSUPPORTED, "Unsupported fill size"); + } + } + /// Initialize the async info for interoperability purposes. Error initAsyncInfoImpl(AsyncInfoWrapperTy &AsyncInfoWrapper) override { // TODO: Implement this function. |
