P4 to Git Change 1193093 by xcui@merged_opencl_jxcwin on 2015/09/22 13:29:55
SWDEV-59579 - refactory the Coare-grained SVM and fine grain buffer SVM code path, so that if the device SVM running on supports fine grain system, then the SVM API operation will be on system memory, no need to go through GPU backend. In addition, added support for PX system with CZ on windows 10, which supports SVM fine grain system. Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#13 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#256 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#525 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#150 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#380 edit
This commit is contained in:
@@ -2174,10 +2174,14 @@ Device::fillHwSampler(
|
||||
}
|
||||
|
||||
void*
|
||||
Device::hostAlloc(size_t size, size_t alignment, bool atomics) const
|
||||
Device::hostAlloc(size_t size, size_t alignment, bool atomics, void* ptr, bool commit) const
|
||||
{
|
||||
//for discrete gpu, we only reserve,no commit yet.
|
||||
return amd::Os::reserveMemory(NULL, size, alignment, amd::Os::MEM_PROT_NONE);
|
||||
void* allocPtr = amd::Os::reserveMemory((address)ptr, size, alignment, amd::Os::MEM_PROT_NONE);
|
||||
if (commit) {
|
||||
amd::Os::commitMemory(allocPtr, size, amd::Os::MEM_PROT_RW);
|
||||
}
|
||||
return allocPtr;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2198,7 +2202,13 @@ Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_svm_me
|
||||
|
||||
size = amd::alignUp(size, alignment);
|
||||
amd::Memory* mem = NULL;
|
||||
freeCPUMem_ = false;
|
||||
if (NULL == svmPtr) {
|
||||
if (isFineGrainedSystem()) {
|
||||
freeCPUMem_ = true;
|
||||
return hostAlloc(size, alignment, false, NULL, true);
|
||||
}
|
||||
|
||||
//create a hidden buffer, which will allocated on the device later
|
||||
mem = new (context)amd::Buffer(context, flags, size, reinterpret_cast<void*>(1));
|
||||
if (mem == NULL) {
|
||||
@@ -2211,10 +2221,12 @@ Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_svm_me
|
||||
mem->release();
|
||||
return NULL;
|
||||
}
|
||||
//if the device supports SVM FGS, return the committed CPU address directly.
|
||||
gpu::Memory* gpuMem = getGpuMemory(mem);
|
||||
|
||||
//add the information to context so that we can use it later.
|
||||
amd::SvmManager::AddSvmBuffer(mem->getSvmPtr(), mem);
|
||||
|
||||
svmPtr = mem->getSvmPtr();
|
||||
}
|
||||
else {
|
||||
//find the existing amd::mem object
|
||||
@@ -2222,20 +2234,31 @@ Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_svm_me
|
||||
if (NULL == mem) {
|
||||
return NULL;
|
||||
}
|
||||
gpu::Memory* gpuMem = getGpuMemory(mem);
|
||||
//commit the CPU memory for FGS device.
|
||||
if (isFineGrainedSystem()) {
|
||||
mem->commitSvmMemory();
|
||||
}
|
||||
else {
|
||||
gpu::Memory* gpuMem = getGpuMemory(mem);
|
||||
}
|
||||
svmPtr = mem->getSvmPtr();
|
||||
}
|
||||
|
||||
return mem->getSvmPtr();
|
||||
return svmPtr;
|
||||
}
|
||||
|
||||
void
|
||||
Device::svmFree(void *ptr) const
|
||||
{
|
||||
amd::Memory * svmMem = NULL;
|
||||
svmMem = amd::SvmManager::FindSvmBuffer(ptr);
|
||||
if (NULL != svmMem) {
|
||||
svmMem->release();
|
||||
amd::SvmManager::RemoveSvmBuffer(ptr);
|
||||
if (freeCPUMem_) {
|
||||
hostFree(ptr, 0);
|
||||
}
|
||||
else {
|
||||
amd::Memory * svmMem = NULL;
|
||||
svmMem = amd::SvmManager::FindSvmBuffer(ptr);
|
||||
if (NULL != svmMem) {
|
||||
svmMem->release();
|
||||
amd::SvmManager::RemoveSvmBuffer(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user