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

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 07:27:22 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);
----------------
Robertkq wrote:

I initially wanted the information returned by `getAllocDevice` as I thought some logic might be needed to deduce where the `Ptr`'s location is (device vs host) and to select the flag accordingly.. I am not sure exactly what the best way to proceed here is

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


More information about the llvm-commits mailing list