P4 to Git Change 1503207 by wchau@wchau_OCL_boltzmann on 2018/01/12 14:51:08

SWDEV-140733 - OpenCL Runtime Support for Raven BU in ROCm
	- Fix OCLMemoryInfo issue of incorrect free memory info
	- Fix OCLPerfMemCreate failure due to memory leak

Affected files ...

... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.cpp#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.cpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.hpp#12 edit


[ROCm/clr commit: 074f37ac4d]
This commit is contained in:
foreman
2018-01-12 14:59:13 -05:00
szülő 2b2b4b036d
commit aeb94403c7
3 fájl változott, egészen pontosan 32 új sor hozzáadva és 10 régi sor törölve
@@ -579,17 +579,25 @@ void Buffer::destroy() {
return; return;
} }
#endif #endif
if ((deviceMemory_ != nullptr) && (deviceMemory_ != owner()->getHostMem())) { if (deviceMemory_ != nullptr) {
// if they are identical, the host pointer will be if (deviceMemory_ != owner()->getHostMem()) {
// deallocated later on => avoid double deallocation // if they are identical, the host pointer will be
if (isHostMemDirectAccess()) { // deallocated later on => avoid double deallocation
if (memFlags & (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR)) { if (isHostMemDirectAccess()) {
if (dev().agent_profile() != HSA_PROFILE_FULL) { if (memFlags & (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR)) {
hsa_amd_memory_unlock(owner()->getHostMem()); if (dev().agent_profile() != HSA_PROFILE_FULL) {
hsa_amd_memory_unlock(owner()->getHostMem());
}
} }
} else {
dev().memFree(deviceMemory_, size());
const_cast<Device&>(dev()).updateFreeMemory(size(), true);
}
}
else if (dev().settings().apuSystem_) {
if (!(memFlags & (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR))) {
dev().memFree(deviceMemory_, size());
} }
} else {
dev().memFree(deviceMemory_, size());
const_cast<Device&>(dev()).updateFreeMemory(size(), true); const_cast<Device&>(dev()).updateFreeMemory(size(), true);
} }
} }
@@ -672,6 +680,10 @@ bool Buffer::create() {
deviceMemory_ = dev().hostAlloc(size(), 1, false); deviceMemory_ = dev().hostAlloc(size(), 1, false);
owner()->setHostMem(deviceMemory_); owner()->setHostMem(deviceMemory_);
if (dev().settings().apuSystem_) {
const_cast<Device&>(dev()).updateFreeMemory(size(), false);
}
} }
else { else {
const_cast<Device&>(dev()).updateFreeMemory(size(), false); const_cast<Device&>(dev()).updateFreeMemory(size(), false);
@@ -938,6 +950,9 @@ bool Image::create() {
if (originalDeviceMemory_ == nullptr) { if (originalDeviceMemory_ == nullptr) {
originalDeviceMemory_ = dev().hostAlloc(alloc_size, 1, false); originalDeviceMemory_ = dev().hostAlloc(alloc_size, 1, false);
if (dev().settings().apuSystem_) {
const_cast<Device&>(dev()).updateFreeMemory(alloc_size, false);
}
} }
else { else {
const_cast<Device&>(dev()).updateFreeMemory(alloc_size, false); const_cast<Device&>(dev()).updateFreeMemory(alloc_size, false);
@@ -72,6 +72,8 @@ Settings::Settings() {
// Don't support Denormals for single precision by default // Don't support Denormals for single precision by default
singleFpDenorm_ = false; singleFpDenorm_ = false;
apuSystem_ = false;
} }
bool Settings::create(bool fullProfile, int gfxipVersion) { bool Settings::create(bool fullProfile, int gfxipVersion) {
@@ -124,6 +126,10 @@ bool Settings::create(bool fullProfile, int gfxipVersion) {
} }
#endif // WITH_LIGHTNING_COMPILER #endif // WITH_LIGHTNING_COMPILER
if (gfxipVersion == 902) {
apuSystem_ = true;
}
// Override current device settings // Override current device settings
override(); override();
@@ -29,7 +29,8 @@ class Settings : public device::Settings {
uint stagedXferRead_ : 1; //!< Uses a staged buffer read uint stagedXferRead_ : 1; //!< Uses a staged buffer read
uint stagedXferWrite_ : 1; //!< Uses a staged buffer write uint stagedXferWrite_ : 1; //!< Uses a staged buffer write
uint singleFpDenorm_ : 1; //!< Support Single FP Denorm uint singleFpDenorm_ : 1; //!< Support Single FP Denorm
uint reserved_ : 21; uint apuSystem_ : 1; //!< APU system
uint reserved_ : 20;
}; };
uint value_; uint value_;
}; };