[llvm] [libsycl] Initial prefetch implementation for queue (PR #212104)

Sergey Semenov via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 07:47:10 PDT 2026


================
@@ -199,6 +199,35 @@ QueueImpl::memcpy(void *Dest, const void *Src, std::size_t NumBytes,
   return createEvent();
 }
 
+EventImplPtr QueueImpl::prefetch(void *Ptr, std::size_t NumBytes,
+                                 const std::vector<EventImplPtr> &DepEvents) {
+  checkEventsPlatformMatch(DepEvents, MDevice.getPlatformImpl());
+
+  if (NumBytes == 0) {
+    handleEventDependencies(DepEvents);
+    return createEvent();
+  }
+  if (!Ptr) {
+    throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
+                          "Nullptr argument in prefetch operation");
+  }
+
+  auto [TargetDevice, IsHost] = getAllocDevice(Ptr);
----------------
sergey-semenov wrote:

I don't think what device the memory was allocated for makes any practical difference here. We definitely can't use it to infer the current location of the memory.

https://github.com/llvm/llvm-project/pull/212104


More information about the llvm-commits mailing list