P4 to Git Change 1594574 by vsytchen@vsytchen-win10 on 2018/08/16 13:43:33
SWDEV-159881 - [OCL][ROCm] Add SVM coarse-grain buffer support with device memory (Part 2)
1. Implement clEnqueueSvmMap/Unmap using a staging buffer
2. Enable device memory coarse grain SVM for OCL only with single device contexts.
ReviewBoardURL = http://ocltc.amd.com/reviews/r/15616/diff/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#94 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.cpp#38 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#63 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.hpp#19 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#296 edit
[ROCm/clr commit: 8dcc948d37]
This commit is contained in:
@@ -105,11 +105,6 @@ void* Memory::allocMapTarget(const amd::Coord3D& origin, const amd::Coord3D& reg
|
||||
if (IsPersistentDirectMap()) {
|
||||
return (static_cast<char*>(persistent_host_ptr_) + origin[0]);
|
||||
}
|
||||
// Otherwise, check for host memory.
|
||||
void* hostMem = owner()->getHostMem();
|
||||
if (hostMem != nullptr) {
|
||||
return (static_cast<char*>(hostMem) + origin[0]);
|
||||
}
|
||||
|
||||
// Allocate one if needed.
|
||||
if (indirectMapCount_ == 1) {
|
||||
@@ -124,7 +119,17 @@ void* Memory::allocMapTarget(const amd::Coord3D& origin, const amd::Coord3D& reg
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return reinterpret_cast<address>(mapMemory_->getHostMem()) + origin[0];
|
||||
|
||||
void* mappedMemory = nullptr;
|
||||
|
||||
if (owner()->getSvmPtr() != nullptr) {
|
||||
owner()->commitSvmMemory();
|
||||
mappedMemory = owner()->getSvmPtr();
|
||||
} else {
|
||||
mappedMemory = reinterpret_cast<address>(mapMemory_->getHostMem()) + origin[0];
|
||||
}
|
||||
|
||||
return mappedMemory;
|
||||
}
|
||||
|
||||
void Memory::decIndMapCount() {
|
||||
@@ -584,7 +589,7 @@ void Buffer::destroy() {
|
||||
cl_mem_flags memFlags = owner()->getMemFlags();
|
||||
|
||||
if (owner()->getSvmPtr() != nullptr) {
|
||||
if (!dev().settings().enableCoarseGrainSVM_) {
|
||||
if (dev().forceFineGrain(owner())) {
|
||||
memFlags |= CL_MEM_SVM_FINE_GRAIN_BUFFER;
|
||||
}
|
||||
const bool isFineGrain = memFlags & CL_MEM_SVM_FINE_GRAIN_BUFFER;
|
||||
@@ -652,7 +657,7 @@ bool Buffer::create() {
|
||||
cl_mem_flags memFlags = owner()->getMemFlags();
|
||||
|
||||
if (owner()->getSvmPtr() != nullptr) {
|
||||
if (!dev().settings().enableCoarseGrainSVM_) {
|
||||
if (dev().forceFineGrain(owner())) {
|
||||
memFlags |= CL_MEM_SVM_FINE_GRAIN_BUFFER;
|
||||
flags_ |= HostMemoryDirectAccess;
|
||||
}
|
||||
@@ -669,6 +674,12 @@ bool Buffer::create() {
|
||||
deviceMemory_ = owner()->getSvmPtr();
|
||||
}
|
||||
|
||||
if (!isFineGrain &&
|
||||
(owner()->parent() != nullptr) &&
|
||||
(owner()->parent()->getSvmPtr() != nullptr)) {
|
||||
owner()->parent()->commitSvmMemory();
|
||||
}
|
||||
|
||||
if (dev().settings().apuSystem_ || !isFineGrain) {
|
||||
const_cast<Device&>(dev()).updateFreeMemory(size(), false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user