[llvm] [Offload] Update allocations to include device (PR #154733)
Ross Brunton via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 26 03:46:58 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:
Currently, the implementation of `urEnqueueUSMMemcpy` contains this:
```c++
auto GetDevice = [&](const void *Ptr) {
auto Res = hQueue->UrContext->getAllocType(Ptr);
if (!Res)
return Adapter->HostDevice;
return Res->Type == OL_ALLOC_TYPE_HOST ? Adapter->HostDevice
: hQueue->OffloadDevice;
};
return doMemcpy(UR_COMMAND_USM_MEMCPY, hQueue, pDst, GetDevice(pDst), pSrc,
GetDevice(pSrc), size, blocking, numEventsInWaitList,
phEventWaitList, phEvent);
```
We need to look up whether the allocation is from the host or the device inside liboffload. Afaik, all UR functions working on USM pointers don't require the pointer to be at the start of an allocation, so we'd need to be able to look up the allocation type from anywhere in the buffer.
https://github.com/llvm/llvm-project/pull/154733
More information about the llvm-commits
mailing list