[llvm] [libsycl] Implement fill & memset queue API (PR #217933)
Kseniya Tikhomirova via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 04:51:27 PDT 2026
================
@@ -413,6 +413,87 @@ class _LIBSYCL_EXPORT queue {
event memcpy(void *dest, const void *src, std::size_t numBytes,
const std::vector<event> &depEvents);
+ /// Submits a memset operation for USM accessible on the device associated
+ /// with the queue. Equivalent to a fill operation with an unsigned char
+ /// pattern.
+ ///
+ /// \param ptr is the pointer to memory to be set.
+ /// \param value is the value the memory should be filled with, interpreted
+ /// as an unsigned char.
+ /// \param numBytes is the number of bytes to set.
+ event memset(void *ptr, int value, std::size_t numBytes) {
+ return memset(ptr, value, numBytes, std::vector<event>{});
+ }
+
+ /// Submits a memset operation for USM accessible on the device associated
+ /// with the queue. Equivalent to a fill operation with an unsigned char
+ /// pattern.
+ ///
+ /// \param ptr is the pointer to memory to be set.
+ /// \param value is the value the memory should be filled with, interpreted
+ /// as an unsigned char.
+ /// \param numBytes is the number of bytes to set.
+ /// \param depEvent is an event that represents a dependency for the
+ /// operation.
+ event memset(void *ptr, int value, std::size_t numBytes, event depEvent) {
+ return memset(ptr, value, numBytes, std::vector<event>{depEvent});
+ }
+
+ /// Submits a memset operation for USM accessible on the device associated
+ /// with the queue. Equivalent to a fill operation with an unsigned char
+ /// pattern.
+ ///
+ /// \param ptr is the pointer to memory to be set.
+ /// \param value is the value the memory should be filled with, interpreted
+ /// as an unsigned char.
+ /// \param numBytes is the number of bytes to set.
+ /// \param depEvents is a vector of events that represent dependencies for the
+ /// operation.
+ event memset(void *ptr, int value, std::size_t numBytes,
+ const std::vector<event> &depEvents) {
+ return fill(ptr, static_cast<unsigned char>(value), numBytes, depEvents);
+ }
+
+ /// Submits a fill operation that replicates a pattern into USM accessible
+ /// on the device associated with the queue.
+ ///
+ /// \param ptr is the pointer to memory to be filled.
+ /// \param pattern is the pattern to be replicated.
+ /// \param count is the number of times the pattern is filled.
+ /// \param depEvents is a vector of events that represent dependencies for the
+ /// operation.
+ template <typename T>
+ event fill(void *ptr, const T &pattern, std::size_t count) {
+ return fill(ptr, pattern, count, std::vector<event>{});
+ }
+
+ /// Submits a fill operation that replicates a pattern into USM accessible
+ /// on the device associated with the queue.
+ ///
+ /// \param ptr is the pointer to memory to be filled.
+ /// \param pattern is the pattern to be replicated.
+ /// \param count is the number of times the pattern is filled.
+ /// \param depEvent is an event that represents a dependency for the
+ /// operation.
+ template <typename T>
+ event fill(void *ptr, const T &pattern, std::size_t count, event depEvent) {
+ return fill(ptr, pattern, count, std::vector<event>{depEvent});
+ }
+
+ /// Submits a fill operation that replicates a pattern into USM accessible
+ /// on the device associated with the queue.
+ ///
+ /// \param ptr is the pointer to memory to be filled.
+ /// \param pattern is the pattern to be replicated.
+ /// \param count is the number of times the pattern is filled.
+ /// \param depEvents is a vector of events that represent dependencies for the
+ /// operation.
+ template <typename T>
+ event fill(void *ptr, const T &pattern, std::size_t count,
+ const std::vector<event> &depEvents) {
+ return fillImpl(ptr, &pattern, sizeof(T), count, depEvents);
+ }
+
----------------
KseniyaTikhomirova wrote:
yes, accessor is out of scope for the early stages. It is a huge feature and Accessor with dependent APIs will be implemented later. No comments is needed in code IMHO.
https://github.com/llvm/llvm-project/pull/217933
More information about the llvm-commits
mailing list