[Openmp-commits] [llvm] [openmp] [offload] Pool host and shared allocations (PR #214754)

Robert Imschweiler via Openmp-commits openmp-commits at lists.llvm.org
Fri Aug 21 23:37:16 PDT 2026


================
@@ -4529,6 +4535,12 @@ Expected<void *> AMDGPUDeviceTy::allocate(size_t Size, void *,
     // Enable all valid kernel agents to access the buffer.
     if (auto Err = MemoryPool->enableAccess(Alloc, Size, Agents))
       return std::move(Err);
+
+    // Register host / shared memory as pinned memory, so that transfers reading
+    // from it can take a device-accessible path.
+    if (Kind == TARGET_ALLOC_HOST || Kind == TARGET_ALLOC_SHARED)
+      if (auto Err = PinnedAllocs.registerHostBuffer(Alloc, Alloc, Size))
+        return std::move(Err);
----------------
ro-i wrote:

Afaics, the other plugins have not yet been using `PinnedAllocs` yet, only the amdgpu plugin:

```
$ grep -rn PinnedAllocs
plugins-nextgen/amdgpu/src/rtl.cpp:2845:            PinnedAllocs.getDeviceAccessiblePtrFromPinnedBuffer(HstPtr)) {
plugins-nextgen/amdgpu/src/rtl.cpp:2904:            PinnedAllocs.getDeviceAccessiblePtrFromPinnedBuffer(HstPtr)) {
plugins-nextgen/common/include/PluginInterface.h:1057:    return PinnedAllocs.registerMemory(HstPtr, Size, LockMemory);
plugins-nextgen/common/include/PluginInterface.h:1062:    return PinnedAllocs.unregisterMemory(HstPtr, UnlockMemory);
plugins-nextgen/common/include/PluginInterface.h:1078:    auto Err = PinnedAllocs.registerMemory(HstPtr, Size, LockMappedBuffers);
plugins-nextgen/common/include/PluginInterface.h:1088:    auto Err = PinnedAllocs.unregisterMemory(HstPtr, LockMappedBuffers);
plugins-nextgen/common/include/PluginInterface.h:1484:  PinnedAllocationMapTy PinnedAllocs;
plugins-nextgen/common/src/PluginInterface.cpp:462:      PinnedAllocs(*this), RPCServer(nullptr) {
plugins-nextgen/common/src/PluginInterface.cpp:1008:    if (auto Err = PinnedAllocs.registerHostBuffer(Alloc, Alloc, Size))
plugins-nextgen/common/src/PluginInterface.cpp:1084:    if (auto Err = PinnedAllocs.unregisterHostBuffer(TgtPtr))
```

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


More information about the Openmp-commits mailing list