[llvm] [libsycl] Fix prefetch pointer argument constness (PR #228442)

Sergey Semenov via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 06:55:43 PDT 2026


https://github.com/sergey-semenov created https://github.com/llvm/llvm-project/pull/228442

None

>From fad7bbf61fd2346de78d4051706cfb5910170bf0 Mon Sep 17 00:00:00 2001
From: Sergey Semenov <sergey.semenov at intel.com>
Date: Fri, 2 Oct 2026 06:41:16 -0700
Subject: [PATCH] [libsycl] Fix prefetch pointer argument constness

---
 libsycl/include/sycl/__impl/queue.hpp | 6 +++---
 libsycl/src/detail/queue_impl.cpp     | 2 +-
 libsycl/src/detail/queue_impl.hpp     | 2 +-
 libsycl/unittests/queue/prefetch.cpp  | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libsycl/include/sycl/__impl/queue.hpp b/libsycl/include/sycl/__impl/queue.hpp
index cbcba218b104e4..286f0d6d636728 100644
--- a/libsycl/include/sycl/__impl/queue.hpp
+++ b/libsycl/include/sycl/__impl/queue.hpp
@@ -637,7 +637,7 @@ class _LIBSYCL_EXPORT queue : private detail::KernelSubmissionBase<queue> {
   /// \param ptr is a USM pointer to the memory to be prefetched to the device.
   /// \param numBytes is a number of bytes to be prefetched.
   /// \return an event representing prefetch operation.
-  event prefetch(void *ptr, std::size_t numBytes) {
+  event prefetch(const void *ptr, std::size_t numBytes) {
     return prefetch(ptr, numBytes, std::vector<event>{});
   }
 
@@ -649,7 +649,7 @@ class _LIBSYCL_EXPORT queue : private detail::KernelSubmissionBase<queue> {
   /// \param numBytes is a number of bytes to be prefetched.
   /// \param depEvent is an event that specifies the kernel dependencies.
   /// \return an event representing prefetch operation.
-  event prefetch(void *ptr, std::size_t numBytes, event depEvent) {
+  event prefetch(const void *ptr, std::size_t numBytes, event depEvent) {
     return prefetch(ptr, numBytes, std::vector<event>{depEvent});
   }
 
@@ -662,7 +662,7 @@ class _LIBSYCL_EXPORT queue : private detail::KernelSubmissionBase<queue> {
   /// \param depEvents is a vector of events that specify the kernel
   /// dependencies.
   /// \return an event representing prefetch operation.
-  event prefetch(void *ptr, std::size_t numBytes,
+  event prefetch(const void *ptr, std::size_t numBytes,
                  const std::vector<event> &depEvents);
 
 private:
diff --git a/libsycl/src/detail/queue_impl.cpp b/libsycl/src/detail/queue_impl.cpp
index aa9dca26038ff1..8fb0eed67ffcd2 100644
--- a/libsycl/src/detail/queue_impl.cpp
+++ b/libsycl/src/detail/queue_impl.cpp
@@ -231,7 +231,7 @@ EventImplPtr QueueImpl::fill(void *Ptr, const void *Pattern,
   return createEvent();
 }
 
-EventImplPtr QueueImpl::prefetch(void *Ptr, std::size_t NumBytes,
+EventImplPtr QueueImpl::prefetch(const void *Ptr, std::size_t NumBytes,
                                  const std::vector<EventImplPtr> &DepEvents) {
   assert(MContext && "Context impl ptr can't be nullptr");
   checkEventsPlatformMatch(DepEvents, *MContext);
diff --git a/libsycl/src/detail/queue_impl.hpp b/libsycl/src/detail/queue_impl.hpp
index 34fc6391ae92b2..c4dd79972aa540 100644
--- a/libsycl/src/detail/queue_impl.hpp
+++ b/libsycl/src/detail/queue_impl.hpp
@@ -167,7 +167,7 @@ class QueueImpl : public std::enable_shared_from_this<QueueImpl> {
   /// \param NumBytes is a number of bytes to be prefetched.
   /// \param DepEvents is a vector of dependencies for the operation.
   /// \return an event impl object that represents the status of the operation.
-  EventImplPtr prefetch(void *Ptr, std::size_t NumBytes,
+  EventImplPtr prefetch(const void *Ptr, std::size_t NumBytes,
                         const std::vector<EventImplPtr> &DepEvents);
 
 private:
diff --git a/libsycl/unittests/queue/prefetch.cpp b/libsycl/unittests/queue/prefetch.cpp
index 32ffd2e1760ecc..3990d50dd69472 100644
--- a/libsycl/unittests/queue/prefetch.cpp
+++ b/libsycl/unittests/queue/prefetch.cpp
@@ -25,7 +25,7 @@ TEST(Queue, TwoPrefetches) {
   mock::MockWrapper Mock;
   queue Q;
 
-  void *Ptr = reinterpret_cast<void *>(1);
+  const void *Ptr = reinterpret_cast<void *>(1);
 
   constexpr ol_mem_migration_flags_t ExpectedFlag =
       OL_MEM_MIGRATION_FLAG_HOST_TO_DEVICE;



More information about the llvm-commits mailing list