diff --git a/rocclr/runtime/device/device.cpp b/rocclr/runtime/device/device.cpp index daa8726d27..0be2916483 100644 --- a/rocclr/runtime/device/device.cpp +++ b/rocclr/runtime/device/device.cpp @@ -58,29 +58,29 @@ namespace amd { std::vector* Device::devices_ = NULL; AppProfile Device::appProfile_; -amd::Monitor SvmManager::AllocatedLock_("Guards SVM allocation list"); -std::map SvmManager::svmBufferMap_; +amd::Monitor MemObjMap::AllocatedLock_("Guards SVM allocation list"); +std::map MemObjMap::MemObjMap_; -size_t SvmManager::size() { +size_t MemObjMap::size() { amd::ScopedLock lock(AllocatedLock_); - return svmBufferMap_.size(); + return MemObjMap_.size(); } -void SvmManager::AddSvmBuffer(const void* k, amd::Memory* v) { +void MemObjMap::AddMemObj(const void* k, amd::Memory* v) { amd::ScopedLock lock(AllocatedLock_); - svmBufferMap_.insert({reinterpret_cast(k), v}); + MemObjMap_.insert({reinterpret_cast(k), v}); } -void SvmManager::RemoveSvmBuffer(const void* k) { +void MemObjMap::RemoveMemObj(const void* k) { amd::ScopedLock lock(AllocatedLock_); - svmBufferMap_.erase(reinterpret_cast(k)); + MemObjMap_.erase(reinterpret_cast(k)); } -amd::Memory* SvmManager::FindSvmBuffer(const void* k) { +amd::Memory* MemObjMap::FindMemObj(const void* k) { amd::ScopedLock lock(AllocatedLock_); uintptr_t key = reinterpret_cast(k); - auto it = svmBufferMap_.upper_bound(key); - if (it == svmBufferMap_.begin()) { + auto it = MemObjMap_.upper_bound(key); + if (it == MemObjMap_.begin()) { return NULL; } diff --git a/rocclr/runtime/device/device.hpp b/rocclr/runtime/device/device.hpp index d6a18ff451..1b3d33f25a 100644 --- a/rocclr/runtime/device/device.hpp +++ b/rocclr/runtime/device/device.hpp @@ -1368,17 +1368,17 @@ class VirtualDevice : public amd::HeapObject { namespace amd { -//! SvmManager class -class SvmManager : public AllStatic { +//! MemoryObject map lookup class +class MemObjMap : public AllStatic { public: static size_t size(); //!< obtain the size of the container - static void AddSvmBuffer(const void* k, - amd::Memory* v); //!< add the svm pointer and buffer in the container - static void RemoveSvmBuffer(const void* k); //!< Remove an entry of svm info from the container - static amd::Memory* FindSvmBuffer( - const void* k); //!< find the svm buffer based on the input pointer + static void AddMemObj(const void* k, + 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 private: - static std::map svmBufferMap_; //!< the svm space information container + static std::map MemObjMap_; //!< the mem object<->hostptr information container static amd::Monitor AllocatedLock_; //!< amd monitor locker }; diff --git a/rocclr/runtime/device/gpu/gpudevice.cpp b/rocclr/runtime/device/gpu/gpudevice.cpp index 2033f7bc99..102ca45439 100644 --- a/rocclr/runtime/device/gpu/gpudevice.cpp +++ b/rocclr/runtime/device/gpu/gpudevice.cpp @@ -2102,11 +2102,11 @@ void* Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_ gpu::Memory* gpuMem = getGpuMemory(mem); // add the information to context so that we can use it later. - amd::SvmManager::AddSvmBuffer(mem->getSvmPtr(), mem); + amd::MemObjMap::AddMemObj(mem->getSvmPtr(), mem); svmPtr = mem->getSvmPtr(); } else { // find the existing amd::mem object - mem = amd::SvmManager::FindSvmBuffer(svmPtr); + mem = amd::MemObjMap::FindMemObj(svmPtr); if (NULL == mem) { return NULL; } @@ -2126,15 +2126,14 @@ void Device::svmFree(void* ptr) const { amd::Os::alignedFree(ptr); } else { amd::Memory* svmMem = NULL; - svmMem = amd::SvmManager::FindSvmBuffer(ptr); + svmMem = amd::MemObjMap::FindMemObj(ptr); if (NULL != svmMem) { svmMem->release(); - amd::SvmManager::RemoveSvmBuffer(ptr); + amd::MemObjMap::RemoveMemObj(ptr); } } } - Device::SrdManager::~SrdManager() { for (uint i = 0; i < pool_.size(); ++i) { pool_[i].buf_->unmap(NULL); diff --git a/rocclr/runtime/device/gpu/gpuvirtual.cpp b/rocclr/runtime/device/gpu/gpuvirtual.cpp index 9382b55e49..65b188c4b8 100644 --- a/rocclr/runtime/device/gpu/gpuvirtual.cpp +++ b/rocclr/runtime/device/gpu/gpuvirtual.cpp @@ -922,8 +922,8 @@ void VirtualGPU::submitSvmCopyMemory(amd::SvmCopyMemoryCommand& vcmd) { amd::BufferRect dstRect; bool result = false; - amd::Memory* srcMem = amd::SvmManager::FindSvmBuffer(vcmd.src()); - amd::Memory* dstMem = amd::SvmManager::FindSvmBuffer(vcmd.dst()); + amd::Memory* srcMem = amd::MemObjMap::FindMemObj(vcmd.src()); + amd::Memory* dstMem = amd::MemObjMap::FindMemObj(vcmd.dst()); device::Memory::SyncFlags syncFlags; if (nullptr != srcMem) { @@ -1327,7 +1327,7 @@ void VirtualGPU::submitSvmFillMemory(amd::SvmFillMemoryCommand& vcmd) { size_t patternSize = vcmd.patternSize(); size_t fillSize = patternSize * vcmd.times(); size_t offset = 0; - amd::Memory* dstMemory = amd::SvmManager::FindSvmBuffer(vcmd.dst()); + amd::Memory* dstMemory = amd::MemObjMap::FindMemObj(vcmd.dst()); assert(dstMemory && "No svm Buffer to fill with!"); offset = reinterpret_cast(vcmd.dst()) - reinterpret_cast(dstMemory->getSvmPtr()); @@ -2956,7 +2956,7 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p // get svm non arugment information void* const* svmPtrArray = reinterpret_cast(params + execInfoOffset); for (size_t i = 0; i < count; i++) { - memory = amd::SvmManager::FindSvmBuffer(svmPtrArray[i]); + memory = amd::MemObjMap::FindMemObj(svmPtrArray[i]); if (NULL == memory) { if (!supportFineGrainedSystem) { return false; diff --git a/rocclr/runtime/device/pal/paldevice.cpp b/rocclr/runtime/device/pal/paldevice.cpp index 1a37e2c2d7..0e9a895877 100644 --- a/rocclr/runtime/device/pal/paldevice.cpp +++ b/rocclr/runtime/device/pal/paldevice.cpp @@ -1966,11 +1966,11 @@ void* Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_ pal::Memory* gpuMem = getGpuMemory(mem); // add the information to context so that we can use it later. - amd::SvmManager::AddSvmBuffer(mem->getSvmPtr(), mem); + amd::MemObjMap::AddMemObj(mem->getSvmPtr(), mem); svmPtr = mem->getSvmPtr(); } else { // find the existing amd::mem object - mem = amd::SvmManager::FindSvmBuffer(svmPtr); + mem = amd::MemObjMap::FindMemObj(svmPtr); if (nullptr == mem) { return nullptr; } @@ -1989,10 +1989,10 @@ void Device::svmFree(void* ptr) const { if (freeCPUMem_) { amd::Os::alignedFree(ptr); } else { - amd::Memory* svmMem = amd::SvmManager::FindSvmBuffer(ptr); + amd::Memory* svmMem = amd::MemObjMap::FindMemObj(ptr); if (nullptr != svmMem) { svmMem->release(); - amd::SvmManager::RemoveSvmBuffer(ptr); + amd::MemObjMap::RemoveMemObj(ptr); } } } diff --git a/rocclr/runtime/device/pal/palvirtual.cpp b/rocclr/runtime/device/pal/palvirtual.cpp index b92edad6aa..80443ef28a 100644 --- a/rocclr/runtime/device/pal/palvirtual.cpp +++ b/rocclr/runtime/device/pal/palvirtual.cpp @@ -1316,8 +1316,8 @@ void VirtualGPU::submitSvmCopyMemory(amd::SvmCopyMemoryCommand& vcmd) { amd::BufferRect dstRect; bool result = false; - amd::Memory* srcMem = amd::SvmManager::FindSvmBuffer(vcmd.src()); - amd::Memory* dstMem = amd::SvmManager::FindSvmBuffer(vcmd.dst()); + amd::Memory* srcMem = amd::MemObjMap::FindMemObj(vcmd.src()); + amd::Memory* dstMem = amd::MemObjMap::FindMemObj(vcmd.dst()); device::Memory::SyncFlags syncFlags; if (nullptr != srcMem) { @@ -1727,7 +1727,7 @@ void VirtualGPU::submitSvmFillMemory(amd::SvmFillMemoryCommand& vcmd) { if (!dev().isFineGrainedSystem()) { size_t patternSize = vcmd.patternSize(); size_t fillSize = patternSize * vcmd.times(); - amd::Memory* dstMemory = amd::SvmManager::FindSvmBuffer(vcmd.dst()); + amd::Memory* dstMemory = amd::MemObjMap::FindMemObj(vcmd.dst()); assert(dstMemory && "No svm Buffer to fill with!"); size_t offset = reinterpret_cast(vcmd.dst()) - reinterpret_cast(dstMemory->getSvmPtr()); @@ -2959,7 +2959,7 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p void* const* svmPtrArray = reinterpret_cast( params + kernelParams.getExecInfoOffset()); for (size_t i = 0; i < count; i++) { - amd::Memory* memory = amd::SvmManager::FindSvmBuffer(svmPtrArray[i]); + amd::Memory* memory = amd::MemObjMap::FindMemObj(svmPtrArray[i]); if (nullptr == memory) { if (!supportFineGrainedSystem) { return false; diff --git a/rocclr/runtime/device/rocm/rocdevice.cpp b/rocclr/runtime/device/rocm/rocdevice.cpp index f1e6b5f3b9..0e1f7e22a3 100644 --- a/rocclr/runtime/device/rocm/rocdevice.cpp +++ b/rocclr/runtime/device/rocm/rocdevice.cpp @@ -1526,7 +1526,7 @@ void* Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_ } // add the information to context so that we can use it later. - amd::SvmManager::AddSvmBuffer(ptr, mem); + amd::MemObjMap::AddMemObj(ptr, mem); return ptr; } else { @@ -1535,7 +1535,7 @@ void* Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_ } else { // Copy paste from ORCA code. // Find the existing amd::mem object - mem = amd::SvmManager::FindSvmBuffer(svmPtr); + mem = amd::MemObjMap::FindMemObj(svmPtr); if (nullptr == mem) { return nullptr; @@ -1547,10 +1547,10 @@ void* Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_ void Device::svmFree(void* ptr) const { amd::Memory* svmMem = nullptr; - svmMem = amd::SvmManager::FindSvmBuffer(ptr); + svmMem = amd::MemObjMap::FindMemObj(ptr); if (nullptr != svmMem) { svmMem->release(); - amd::SvmManager::RemoveSvmBuffer(ptr); + amd::MemObjMap::RemoveMemObj(ptr); hostFree(ptr); } } diff --git a/rocclr/runtime/device/rocm/rocvirtual.cpp b/rocclr/runtime/device/rocm/rocvirtual.cpp index 33169dea09..924761a897 100644 --- a/rocclr/runtime/device/rocm/rocvirtual.cpp +++ b/rocclr/runtime/device/rocm/rocvirtual.cpp @@ -208,7 +208,7 @@ bool VirtualGPU::processMemObjects(const amd::Kernel& kernel, const_address para // get svm non arugment information void* const* svmPtrArray = reinterpret_cast(params + execInfoOffset); for (size_t i = 0; i < count; i++) { - memory = amd::SvmManager::FindSvmBuffer(svmPtrArray[i]); + memory = amd::MemObjMap::FindMemObj(svmPtrArray[i]); if (nullptr == memory) { if (!supportFineGrainedSystem) { return false; diff --git a/rocclr/runtime/platform/kernel.cpp b/rocclr/runtime/platform/kernel.cpp index 17d093b516..38fc9cabe0 100644 --- a/rocclr/runtime/platform/kernel.cpp +++ b/rocclr/runtime/platform/kernel.cpp @@ -77,7 +77,7 @@ void KernelParameters::set(size_t index, size_t size, const void* value, bool sv if (svmBound) { desc.info_.rawPointer_ = true; LP64_SWITCH(uint32_value, uint64_value) = *(LP64_SWITCH(uint32_t*, uint64_t*))value; - memoryObjects_[desc.info_.arrayIndex_] = amd::SvmManager::FindSvmBuffer( + memoryObjects_[desc.info_.arrayIndex_] = amd::MemObjMap::FindMemObj( *reinterpret_cast(value)); } else if ((value == NULL) || (static_cast(value) == NULL)) { desc.info_.rawPointer_ = false;