mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-31 12:11:31 +08:00
feature: add pooling of USM global/constant surface
Related-To: NEO-12287 Signed-off-by: Fabian Zwoliński <fabian.zwolinski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0b6b0e3954
commit
a1c5fa1a13
@@ -124,21 +124,8 @@ Program::~Program() {
|
||||
}
|
||||
|
||||
for (const auto &buildInfo : buildInfos) {
|
||||
if (auto &constantSurface = buildInfo.constantSurface; constantSurface) {
|
||||
if ((nullptr != context) && (nullptr != context->getSVMAllocsManager()) && (context->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(constantSurface->getGpuAddress())))) {
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(reinterpret_cast<void *>(constantSurface->getGpuAddress()));
|
||||
} else {
|
||||
this->executionEnvironment.memoryManager->checkGpuUsageAndDestroyGraphicsAllocations(constantSurface->getGraphicsAllocation());
|
||||
}
|
||||
}
|
||||
|
||||
if (auto &globalSurface = buildInfo.globalSurface; globalSurface) {
|
||||
if ((nullptr != context) && (nullptr != context->getSVMAllocsManager()) && (context->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(globalSurface->getGpuAddress())))) {
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(reinterpret_cast<void *>(globalSurface->getGpuAddress()));
|
||||
} else {
|
||||
this->executionEnvironment.memoryManager->checkGpuUsageAndDestroyGraphicsAllocations(globalSurface->getGraphicsAllocation());
|
||||
}
|
||||
}
|
||||
freeGlobalBufferAllocation(buildInfo.constantSurface);
|
||||
freeGlobalBufferAllocation(buildInfo.globalSurface);
|
||||
}
|
||||
|
||||
notifyModuleDestroy();
|
||||
@@ -148,6 +135,41 @@ Program::~Program() {
|
||||
}
|
||||
}
|
||||
|
||||
void Program::freeGlobalBufferAllocation(const std::unique_ptr<NEO::SharedPoolAllocation> &globalBuffer) {
|
||||
if (!globalBuffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto graphicsAllocation = globalBuffer->getGraphicsAllocation();
|
||||
if (!graphicsAllocation) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto gpuAddress = reinterpret_cast<void *>(globalBuffer->getGpuAddress());
|
||||
|
||||
for (const auto &device : clDevices) {
|
||||
if (auto usmPool = device->getDevice().getUsmConstantSurfaceAllocPool();
|
||||
usmPool && usmPool->isInPool(gpuAddress)) {
|
||||
[[maybe_unused]] auto ret = usmPool->freeSVMAlloc(gpuAddress, false);
|
||||
DEBUG_BREAK_IF(!ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto usmPool = device->getDevice().getUsmGlobalSurfaceAllocPool();
|
||||
usmPool && usmPool->isInPool(gpuAddress)) {
|
||||
[[maybe_unused]] auto ret = usmPool->freeSVMAlloc(gpuAddress, false);
|
||||
DEBUG_BREAK_IF(!ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((nullptr != context) && (nullptr != context->getSVMAllocsManager()) && (context->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(globalBuffer->getGpuAddress())))) {
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(reinterpret_cast<void *>(globalBuffer->getGpuAddress()));
|
||||
} else {
|
||||
this->executionEnvironment.memoryManager->checkGpuUsageAndDestroyGraphicsAllocations(globalBuffer->getGraphicsAllocation());
|
||||
}
|
||||
}
|
||||
|
||||
cl_int Program::createProgramFromBinary(
|
||||
const void *pBinary,
|
||||
size_t binarySize, ClDevice &clDevice) {
|
||||
|
||||
Reference in New Issue
Block a user