P4 to Git Change 1562960 by skudchad@skudchad_test2_win_opencl on 2018/06/01 14:46:26
SWDEV-145570 - [HIP] - Rename SVManager to be more genric. The same functionality can be used for HIP without needing additonal map ReviewBoardURL = http://ocltc.amd.com/reviews/r/15054/diff/ Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_memobj.cpp#83 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#27 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#220 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#306 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#591 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#419 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#92 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#104 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#87 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#53 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/kernel.cpp#29 edit
This commit is contained in:
@@ -58,29 +58,29 @@ namespace amd {
|
||||
std::vector<Device*>* Device::devices_ = NULL;
|
||||
AppProfile Device::appProfile_;
|
||||
|
||||
amd::Monitor SvmManager::AllocatedLock_("Guards SVM allocation list");
|
||||
std::map<uintptr_t, amd::Memory*> SvmManager::svmBufferMap_;
|
||||
amd::Monitor MemObjMap::AllocatedLock_("Guards SVM allocation list");
|
||||
std::map<uintptr_t, amd::Memory*> 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<uintptr_t>(k), v});
|
||||
MemObjMap_.insert({reinterpret_cast<uintptr_t>(k), v});
|
||||
}
|
||||
|
||||
void SvmManager::RemoveSvmBuffer(const void* k) {
|
||||
void MemObjMap::RemoveMemObj(const void* k) {
|
||||
amd::ScopedLock lock(AllocatedLock_);
|
||||
svmBufferMap_.erase(reinterpret_cast<uintptr_t>(k));
|
||||
MemObjMap_.erase(reinterpret_cast<uintptr_t>(k));
|
||||
}
|
||||
|
||||
amd::Memory* SvmManager::FindSvmBuffer(const void* k) {
|
||||
amd::Memory* MemObjMap::FindMemObj(const void* k) {
|
||||
amd::ScopedLock lock(AllocatedLock_);
|
||||
uintptr_t key = reinterpret_cast<uintptr_t>(k);
|
||||
auto it = svmBufferMap_.upper_bound(key);
|
||||
if (it == svmBufferMap_.begin()) {
|
||||
auto it = MemObjMap_.upper_bound(key);
|
||||
if (it == MemObjMap_.begin()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<uintptr_t, amd::Memory*> svmBufferMap_; //!< the svm space information container
|
||||
static std::map<uintptr_t, amd::Memory*> MemObjMap_; //!< the mem object<->hostptr information container
|
||||
static amd::Monitor AllocatedLock_; //!< amd monitor locker
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<uintptr_t>(vcmd.dst()) -
|
||||
reinterpret_cast<uintptr_t>(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<void* const*>(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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<uintptr_t>(vcmd.dst()) -
|
||||
reinterpret_cast<uintptr_t>(dstMemory->getSvmPtr());
|
||||
@@ -2959,7 +2959,7 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p
|
||||
void* const* svmPtrArray = reinterpret_cast<void* const*>(
|
||||
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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ bool VirtualGPU::processMemObjects(const amd::Kernel& kernel, const_address para
|
||||
// get svm non arugment information
|
||||
void* const* svmPtrArray = reinterpret_cast<void* const*>(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;
|
||||
|
||||
@@ -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<const void* const*>(value));
|
||||
} else if ((value == NULL) || (static_cast<const cl_mem*>(value) == NULL)) {
|
||||
desc.info_.rawPointer_ = false;
|
||||
|
||||
Referens i nytt ärende
Block a user