[llvm] [Offload] Update allocations to include device (PR #154733)

Ross Brunton via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 29 07:30:15 PDT 2025


================
@@ -124,8 +125,8 @@ struct OffloadContext {
 
   bool TracingEnabled = false;
   bool ValidationEnabled = true;
-  DenseMap<void *, AllocInfo> AllocInfoMap{};
-  std::mutex AllocInfoMapMutex{};
+  SmallVector<AllocInfo> AllocInfoList{};
----------------
RossBrunton wrote:

UR does require the destination and source device - It needs to know which backend (AMD/CUDA/OpenCL/etc) to dispatch to, which is stored in ur_queue_handle_t. OpenCL also requires the `cl_intel_unified_shared_memory` extension to query the source and destination device.

Since the queue is optional in `olMemcpy`, a device to lookup the backend (AMD or Nvidia) is required. And if we need one device, we may as well have the user specify both instead of requiring the backend to support determining whether the copy is h2d/h2h/d2d. It also allows the API to be extended in the future to allow copying data between two platforms if needed.

I wasn't involved in the initial design for this, so @jhuber6 and @callumfare might be able to shed some more light on why it is how it is.

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


More information about the llvm-commits mailing list