P4 to Git Change 1333973 by rili@rili-opencl-pal-stg on 2016/10/31 10:41:30

SWDEV-95903 -  Implement SVM on PAL feature.
	1. Implement SVM Coarse Grain
	2. Implement SVM Fine Grain Buffer

	Review:http://ocltc.amd.com/reviews/r/11706/

Affected files ...

... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#17 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.hpp#8 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palsettings.cpp#8 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#36 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#259 edit
This commit is contained in:
foreman
2016-10-31 10:47:23 -04:00
والد a432789fb0
کامیت b925842e4e
6فایلهای تغییر یافته به همراه69 افزوده شده و 3 حذف شده
@@ -1063,8 +1063,12 @@ Device::init()
info.flags.disableGpuTimeout = true;
#ifdef ATI_BITS_32
info.flags.force32BitVaSpace = true;
info.flags.enableSvmMode = false;
#else
info.flags.enableSvmMode = true;
#endif
info.pSettingsPath = "OCL";
info.maxSvmSize = static_cast<Pal::gpusize>(OCL_SET_SVM_SIZE * Mi);
// PAL init
if (Pal::Result::Success !=
@@ -80,6 +80,32 @@ GpuMemoryReference::Create(
return memRef;
}
GpuMemoryReference*
GpuMemoryReference::Create(
const Device& dev,
const Pal::SvmGpuMemoryCreateInfo& createInfo)
{
Pal::Result result;
size_t gpuMemSize = dev.iDev()->GetSvmGpuMemorySize(createInfo, &result);
if (result != Pal::Result::Success) {
return nullptr;
}
GpuMemoryReference* memRef = new (gpuMemSize) GpuMemoryReference();
if (memRef != nullptr) {
result = dev.iDev()->CreateSvmGpuMemory(createInfo,
&memRef[1], &memRef->gpuMem_);
if (result != Pal::Result::Success) {
memRef->release();
return nullptr;
}
}
// Update free memory size counters
const_cast<Device&>(dev).updateFreeMemory(
Pal::GpuHeap::GpuHeapGartCacheable, createInfo.size, false);
return memRef;
}
GpuMemoryReference*
GpuMemoryReference::Create(
const Device& dev,
@@ -997,6 +1023,36 @@ Resource::create(MemoryType memType, CreateParams* params)
return true;
}
if ((nullptr != params) &&
(nullptr != params->owner_) &&
(nullptr != params->owner_->getSvmPtr())) {
// @todo 64K alignment is too big
uint allocSize = amd::alignUp(desc().width_ * elementSize_, MaxGpuAlignment);
if (memoryType() == Remote) {
Pal::SvmGpuMemoryCreateInfo createInfo = {};
createInfo.size = allocSize;
createInfo.alignment = MaxGpuAlignment;
memRef_ = GpuMemoryReference::Create(dev(), createInfo);
}
else {
Pal::GpuMemoryCreateInfo createInfo = {};
createInfo.size = allocSize;
createInfo.alignment = MaxGpuAlignment;
createInfo.vaRange = Pal::VaRange::Svm;
createInfo.priority = Pal::GpuMemPriority::Normal;
memTypeToHeap(&createInfo);
memRef_ = GpuMemoryReference::Create(dev(), createInfo);
}
if (nullptr == memRef_) {
LogError("Failed PAL memory allocation!");
return false;
}
desc_.cardMemory_ = false;
desc_.SVMRes_ = true;
params->owner_->setSvmPtr(reinterpret_cast<void*>(memRef_->iMem()->Desc().gpuVirtAddr));
return true;
}
Pal::GpuMemoryCreateInfo createInfo = {};
createInfo.size = desc().width_ * elementSize_;
// @todo 64K alignment is too big
@@ -28,6 +28,10 @@ public:
const Device& dev,
const Pal::PinnedGpuMemoryCreateInfo& createInfo);
static GpuMemoryReference* Create(
const Device& dev,
const Pal::SvmGpuMemoryCreateInfo& createInfo);
static GpuMemoryReference* Create(
const Device& dev,
const Pal::ExternalResourceOpenInfo& openInfo);
@@ -74,6 +74,9 @@ Settings::Settings()
// GPU device by default
apuSystem_ = false;
// Fine-Grained System is disabled by default
svmFineGrainSystem_ = false;
// Disable 64 bit pointers support by default
use64BitPtr_ = false;
@@ -3192,8 +3192,7 @@ VirtualGPU::processMemObjectsHSA(
svmMem = amd::SvmManager::FindSvmBuffer(
*reinterpret_cast<void* const*>(params + desc.offset_));
if (!svmMem) {
Unimplemented();
//flushCUCaches();
flushCUCaches();
// Clear memory dependency state
const static bool All = true;
memoryDependency().clear(!All);