[16/n] Internal 4GB allocator.

- Make sure that kernel allocation is deleted asynchronously.

Change-Id: Ia98ae9fdbd56c7de82f92d62e0395ef181ebceef
This commit is contained in:
Mrozek, Michal
2018-03-14 18:11:45 +01:00
committed by sys_ocldev
parent dede44f0dd
commit bd0362990b
2 changed files with 14 additions and 1 deletions

View File

@@ -413,7 +413,7 @@ void Program::freeBlockResources() {
void Program::cleanCurrentKernelInfo() { void Program::cleanCurrentKernelInfo() {
for (auto &kernelInfo : kernelInfoArray) { for (auto &kernelInfo : kernelInfoArray) {
if (kernelInfo->kernelAllocation) { if (kernelInfo->kernelAllocation) {
this->pDevice->getMemoryManager()->freeGraphicsMemory(kernelInfo->kernelAllocation); this->pDevice->getMemoryManager()->checkGpuUsageAndDestroyGraphicsAllocations(kernelInfo->kernelAllocation);
} }
delete kernelInfo; delete kernelInfo;
} }

View File

@@ -627,6 +627,19 @@ TEST_P(ProgramFromBinaryTest, givenProgramWhenCleanKernelInfoIsCalledThenKernelA
EXPECT_EQ(0u, pProgram->getNumKernels()); EXPECT_EQ(0u, pProgram->getNumKernels());
} }
TEST_P(ProgramFromBinaryTest, givenProgramWhenCleanCurrentKernelInfoIsCalledButGpuIsNotYetDoneThenKernelAllocationIsPutOnDefferedFreeList) {
cl_device_id device = pDevice;
auto memoryManager = pDevice->getMemoryManager();
EXPECT_TRUE(memoryManager->graphicsAllocations.peekIsEmpty());
pProgram->build(1, &device, nullptr, nullptr, nullptr, true);
auto kernelAllocation = pProgram->getKernelInfo(size_t(0))->getGraphicsAllocation();
kernelAllocation->taskCount = 100;
*pDevice->getTagAddress() = 0;
pProgram->cleanCurrentKernelInfo();
EXPECT_FALSE(memoryManager->graphicsAllocations.peekIsEmpty());
EXPECT_EQ(memoryManager->graphicsAllocations.peekHead(), kernelAllocation);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Program::Build (source) // Program::Build (source)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////