P4 to Git Change 1579735 by gandryey@gera-w8 on 2018/07/12 14:22:40

SWDEV-158730 - [CQE OCL][ocltst][WIN] OCLMemoryInfo[1] a sub-test of ocltst oclruntime module is failed
	- Update free memory calculation for APU systems. There is still an issue in GSL with multiple alloc/free passes

Affected files ...

... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#595 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#96 edit


[ROCm/clr commit: 0b08fa4a4e]
This commit is contained in:
foreman
2018-07-12 14:31:30 -04:00
parent 705bd72c1a
commit fc3625d738
2 changed files with 29 additions and 34 deletions
@@ -1800,28 +1800,29 @@ bool Device::globalFreeMemory(size_t* freeMemory) const {
return false;
}
gslMemInfo memInfo = {0};
gslMemInfo memInfo = { 0 };
gslCtx()->getMemInfo(&memInfo, GSL_MEMINFO_BASIC);
// Fill free memory info
freeMemory[TotalFreeMemory] =
(memInfo.cardMemAvailableBytes + memInfo.cardExtMemAvailableBytes +
resourceCache().lclCacheSize()) / Ki;
freeMemory[TotalFreeMemory] = (memInfo.cardMemAvailableBytes + memInfo.cardExtMemAvailableBytes +
resourceCache().lclCacheSize()) / Ki;
freeMemory[LargestFreeBlock] =
std::max(memInfo.cardLargestFreeBlockBytes, memInfo.cardExtLargestFreeBlockBytes) / Ki;
std::max(memInfo.cardLargestFreeBlockBytes, memInfo.cardExtLargestFreeBlockBytes) / Ki;
if (settings().apuSystem_) {
uint64_t sysMem = 0;
if ((memInfo.agpMemAvailableBytes + resourceCache().cacheSize()) > resourceCache().lclCacheSize()) {
sysMem = (memInfo.agpMemAvailableBytes + resourceCache().cacheSize()) - resourceCache().lclCacheSize();
}
sysMem /= Ki;
freeMemory[TotalFreeMemory] += sysMem;
if (settings().viPlus_) {
// for viPlus_, OCL is using remote instead remoteUSWC to avoid extra copy
freeMemory[TotalFreeMemory] += (memInfo.agpMemAvailableCacheableBytes -
resourceCache().lclCacheSize() + resourceCache().cacheSize()) / Ki;
freeMemory[LargestFreeBlock] += memInfo.agpCacheableLargestFreeBlockBytes / Ki;
} else {
freeMemory[TotalFreeMemory] += (memInfo.agpMemAvailableBytes -
resourceCache().lclCacheSize() + resourceCache().cacheSize()) / Ki;
freeMemory[LargestFreeBlock] += memInfo.agpLargestFreeBlockBytes / Ki;
}
}
return true;
}
@@ -1678,35 +1678,29 @@ bool Device::globalFreeMemory(size_t* freeMemory) const {
Pal::gpusize local = allocedMem[Pal::GpuHeapLocal];
Pal::gpusize invisible = allocedMem[Pal::GpuHeapInvisible] - resourceCache().lclCacheSize();
// Calculate free memory
if (local >= heaps_[Pal::GpuHeapLocal].heapSize) {
local = 0;
} else {
local = heaps_[Pal::GpuHeapLocal].heapSize - local;
}
if (invisible >= info().maxMemAllocSize_) {
invisible = 0;
} else {
invisible = info().maxMemAllocSize_ - invisible;
}
// Fill free memory info
freeMemory[TotalFreeMemory] = static_cast<size_t>((local + invisible) / Ki);
freeMemory[LargestFreeBlock] = static_cast<size_t>(std::max(local, invisible) / Ki);
freeMemory[TotalFreeMemory] = static_cast<size_t>((info().globalMemSize_ -
(local + invisible)) / Ki);
if (invisible >= heaps_[Pal::GpuHeapInvisible].heapSize) {
invisible = 0;
}
else {
invisible = heaps_[Pal::GpuHeapInvisible].heapSize - invisible;
}
freeMemory[LargestFreeBlock] = static_cast<size_t>(invisible) / Ki;
if (settings().apuSystem_) {
Pal::GpuHeap heap = settings().viPlus_ ? Pal::GpuHeapGartCacheable: Pal::GpuHeapGartUswc;
Pal::gpusize sysMem = allocedMem[heap];
if (sysMem >= heaps_[heap].heapSize) {
sysMem = 0;
} else {
sysMem = heaps_[heap].heapSize - sysMem +
resourceCache().cacheSize() - resourceCache().lclCacheSize();
}
Pal::gpusize sysMem = allocedMem[Pal::GpuHeapGartCacheable] + allocedMem[Pal::GpuHeapGartUswc] -
resourceCache().cacheSize() + resourceCache().lclCacheSize();
sysMem /= Ki;
freeMemory[TotalFreeMemory] += static_cast<size_t>(sysMem);
if (freeMemory[LargestFreeBlock] < sysMem) {
freeMemory[LargestFreeBlock] = static_cast<size_t>(sysMem);
if (sysMem >= freeMemory[TotalFreeMemory]) {
freeMemory[TotalFreeMemory] = 0;
} else {
freeMemory[TotalFreeMemory] -= sysMem;
}
if (freeMemory[LargestFreeBlock] < freeMemory[TotalFreeMemory]) {
freeMemory[LargestFreeBlock] = freeMemory[TotalFreeMemory];
}
}