From bd0362990b048b8125df28ea9049a9791a0a8775 Mon Sep 17 00:00:00 2001 From: "Mrozek, Michal" Date: Wed, 14 Mar 2018 18:11:45 +0100 Subject: [PATCH] [16/n] Internal 4GB allocator. - Make sure that kernel allocation is deleted asynchronously. Change-Id: Ia98ae9fdbd56c7de82f92d62e0395ef181ebceef --- runtime/program/program.cpp | 2 +- unit_tests/program/program_tests.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/runtime/program/program.cpp b/runtime/program/program.cpp index 39621acaff..5f3eafb427 100644 --- a/runtime/program/program.cpp +++ b/runtime/program/program.cpp @@ -413,7 +413,7 @@ void Program::freeBlockResources() { void Program::cleanCurrentKernelInfo() { for (auto &kernelInfo : kernelInfoArray) { if (kernelInfo->kernelAllocation) { - this->pDevice->getMemoryManager()->freeGraphicsMemory(kernelInfo->kernelAllocation); + this->pDevice->getMemoryManager()->checkGpuUsageAndDestroyGraphicsAllocations(kernelInfo->kernelAllocation); } delete kernelInfo; } diff --git a/unit_tests/program/program_tests.cpp b/unit_tests/program/program_tests.cpp index c76509687e..1c54f9ff4e 100644 --- a/unit_tests/program/program_tests.cpp +++ b/unit_tests/program/program_tests.cpp @@ -627,6 +627,19 @@ TEST_P(ProgramFromBinaryTest, givenProgramWhenCleanKernelInfoIsCalledThenKernelA 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) ////////////////////////////////////////////////////////////////////////////////