diff --git a/projects/clr/rocclr/device/device.cpp b/projects/clr/rocclr/device/device.cpp index 3ca1014b60..2709febd8b 100644 --- a/projects/clr/rocclr/device/device.cpp +++ b/projects/clr/rocclr/device/device.cpp @@ -296,7 +296,7 @@ void MemObjMap::RemoveMemObj(const void* k) { } } -amd::Memory* MemObjMap::FindMemObj(const void* k) { +amd::Memory* MemObjMap::FindMemObj(const void* k, size_t* offset) { amd::ScopedLock lock(AllocatedLock_); uintptr_t key = reinterpret_cast(k); auto it = MemObjMap_.upper_bound(key); @@ -307,6 +307,9 @@ amd::Memory* MemObjMap::FindMemObj(const void* k) { --it; amd::Memory* mem = it->second; if (key >= it->first && key < (it->first + mem->getSize())) { + if (offset != nullptr) { + *offset = key - it->first; + } // the k is in the range return mem; } else { diff --git a/projects/clr/rocclr/device/device.hpp b/projects/clr/rocclr/device/device.hpp index 129a237720..fe276be2f4 100644 --- a/projects/clr/rocclr/device/device.hpp +++ b/projects/clr/rocclr/device/device.hpp @@ -1294,7 +1294,8 @@ class MemObjMap : public AllStatic { amd::Memory* v); //!< add the host mem pointer and buffer in the container static void RemoveMemObj(const void* k); //!< Remove an entry of mem object from the container static amd::Memory* FindMemObj( - const void* k); //!< find the mem object based on the input pointer + const void* k, //!< find the mem object based on the input pointer + size_t* offset = nullptr); //!< Offset in the memory location static void UpdateAccess(amd::Device *peerDev); static void Purge(amd::Device* dev); //!< Purge all user allocated memories on the given device