SWDEV-272382 - [OCL][LNX] OCLMemoryInfo[1] subtest of oclruntime is failing

1. Fix the size of the memory when releasing.
2. Make sure we only count the device memory

Change-Id: Ib4dcda79f313c4ee9cc1c7bab53f8076bce5f583
This commit is contained in:
Alex Xie
2021-02-22 17:33:05 -05:00
committed by AlexBin Xie
parent b7c0f180da
commit 639d67866c
2 changed files with 19 additions and 5 deletions
+14 -3
View File
@@ -1133,13 +1133,18 @@ bool Image::create() {
if (originalDeviceMemory_ == nullptr) {
originalDeviceMemory_ = dev().hostAlloc(alloc_size, 1, Device::MemorySegment::kNoAtomics);
if ((originalDeviceMemory_ != nullptr) && dev().settings().apuSystem_) {
const_cast<Device&>(dev()).updateFreeMemory(alloc_size, false);
if (originalDeviceMemory_ != nullptr) {
kind_ = MEMORY_KIND_HOST;
if (dev().settings().apuSystem_) {
const_cast<Device&>(dev()).updateFreeMemory(alloc_size, false);
}
}
}
else {
const_cast<Device&>(dev()).updateFreeMemory(alloc_size, false);
}
//record real size of the buffer so we will release and count it correctly.
deviceImageInfo_.size = alloc_size;
deviceMemory_ = reinterpret_cast<void*>(
amd::alignUp(reinterpret_cast<uintptr_t>(originalDeviceMemory_), deviceImageInfo_.alignment));
@@ -1316,7 +1321,13 @@ void Image::destroy() {
if (originalDeviceMemory_ != nullptr) {
dev().memFree(originalDeviceMemory_, deviceImageInfo_.size);
const_cast<Device&>(dev()).updateFreeMemory(size(), true);
if (kind_ == MEMORY_KIND_HOST) {
if (dev().settings().apuSystem_) {
const_cast<Device&>(dev()).updateFreeMemory(deviceImageInfo_.size, true);
}
} else {
const_cast<Device&>(dev()).updateFreeMemory(deviceImageInfo_.size, true);
}
}
}
+5 -2
View File
@@ -33,8 +33,11 @@ class Memory : public device::Memory {
public:
enum MEMORY_KIND {
MEMORY_KIND_NORMAL = 0,
MEMORY_KIND_LOCK,
MEMORY_KIND_GART,
// The memory is allocated by ROCclr in host memory. This flag is used by
// image class now. It may find more use in buffer class in future
MEMORY_KIND_HOST,
MEMORY_KIND_INTEROP,
MEMORY_KIND_PTRGIVEN
};