summaryrefslogtreecommitdiff
path: root/offload/liboffload
diff options
context:
space:
mode:
authorCallum Fare <callum@codeplay.com>2025-08-22 14:31:16 +0100
committerGitHub <noreply@github.com>2025-08-22 14:31:16 +0100
commit0b18d2da70096fcd28e82dbce8f853232454856e (patch)
tree10d33baef4dcc804885e06559410efc4422b6dec /offload/liboffload
parent3768ec309bbbc54a5e93257cf83f0b6a19a0f050 (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/liboffload')
-rw-r--r--offload/liboffload/API/Memory.td20
-rw-r--r--offload/liboffload/src/OffloadImpl.cpp6
2 files changed, 26 insertions, 0 deletions
diff --git a/offload/liboffload/API/Memory.td b/offload/liboffload/API/Memory.td
index 248d9621b651..276713057596 100644
--- a/offload/liboffload/API/Memory.td
+++ b/offload/liboffload/API/Memory.td
@@ -59,3 +59,23 @@ def olMemcpy : Function {
];
let returns = [];
}
+
+def : Function {
+ let name = "olMemFill";
+ let desc = "Fill memory with copies of the given pattern";
+ let details = [
+ "Filling with patterns larger than 4 bytes may be less performant",
+ "The destination pointer and queue must be associated with the same device",
+ "The fill size must be a multiple of the pattern size",
+ ];
+ let params = [
+ Param<"ol_queue_handle_t", "Queue", "handle of the queue", PARAM_IN_OPTIONAL>,
+ Param<"void*", "Ptr", "destination pointer to start filling at", PARAM_IN>,
+ Param<"size_t", "PatternSize", "the size of the pattern in bytes", PARAM_IN>,
+ Param<"const void*", "PatternPtr", "", PARAM_IN>,
+ Param<"size_t", "FillSize", "number of bytes to fill", PARAM_IN>,
+ ];
+ let returns = [
+ Return<"OL_ERRC_INVALID_SIZE", ["`FillSize % PatternSize != 0`"]>
+ ];
+}
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index 1f34c9d86cb0..9d342e06127a 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -760,6 +760,12 @@ Error olMemcpy_impl(ol_queue_handle_t Queue, void *DstPtr,
return Error::success();
}
+Error olMemFill_impl(ol_queue_handle_t Queue, void *Ptr, size_t PatternSize,
+ const void *PatternPtr, size_t FillSize) {
+ return Queue->Device->Device->dataFill(Ptr, PatternPtr, PatternSize, FillSize,
+ Queue->AsyncInfo);
+}
+
Error olCreateProgram_impl(ol_device_handle_t Device, const void *ProgData,
size_t ProgDataSize, ol_program_handle_t *Program) {
// Make a copy of the program binary in case it is released by the caller.