Move surface allocations from Program to BuildInfo

Related-To: NEO-5001
Change-Id: Icf011698fc166285d049b052d59c709c7419e105
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-09-15 17:34:49 +02:00
committed by sys_ocldev
parent 394e626db9
commit 1f240862ce
11 changed files with 163 additions and 145 deletions

View File

@ -2007,8 +2007,8 @@ TEST_F(ReflectionSurfaceConstantValuesPatchingTest, GivenBlockWithGlobalMemoryAn
MockContext context(pClDevice);
MockParentKernel *parentKernel = MockParentKernel::create(context, false, true, false);
if (parentKernel->mockProgram->getGlobalSurface()) {
pDevice->getMemoryManager()->freeGraphicsMemory(parentKernel->mockProgram->getGlobalSurface());
if (parentKernel->mockProgram->getGlobalSurface(pClDevice->getRootDeviceIndex())) {
pDevice->getMemoryManager()->freeGraphicsMemory(parentKernel->mockProgram->getGlobalSurface(pClDevice->getRootDeviceIndex()));
parentKernel->mockProgram->setGlobalSurface(nullptr);
}
@ -2083,8 +2083,8 @@ TEST_F(ReflectionSurfaceConstantValuesPatchingTest, GivenBlockWithConstantMemory
MockContext context(pClDevice);
MockParentKernel *parentKernel = MockParentKernel::create(context, false, false, true);
if (parentKernel->mockProgram->getConstantSurface()) {
pDevice->getMemoryManager()->freeGraphicsMemory(parentKernel->mockProgram->getConstantSurface());
if (parentKernel->mockProgram->getConstantSurface(pClDevice->getRootDeviceIndex())) {
pDevice->getMemoryManager()->freeGraphicsMemory(parentKernel->mockProgram->getConstantSurface(pClDevice->getRootDeviceIndex()));
parentKernel->mockProgram->setConstantSurface(nullptr);
}
@ -2127,7 +2127,7 @@ using KernelReflectionMultiDeviceTest = MultiRootDeviceFixture;
TEST_F(KernelReflectionMultiDeviceTest, GivenNoKernelArgsWhenObtainingKernelReflectionSurfaceThenParamsAreCorrect) {
REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device.get());
MockProgram program(*device->getExecutionEnvironment());
MockProgram program(*device->getExecutionEnvironment(), context.get(), false, &device->getDevice());
KernelInfo *blockInfo = new KernelInfo;
KernelInfo &info = *blockInfo;
cl_queue_properties properties[1] = {0};
@ -2176,7 +2176,7 @@ TEST_F(KernelReflectionMultiDeviceTest, GivenNoKernelArgsWhenObtainingKernelRefl
TEST_F(KernelReflectionMultiDeviceTest, GivenDeviceQueueKernelArgWhenObtainingKernelReflectionSurfaceThenParamsAreCorrect) {
REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device.get());
MockProgram program(*device->getExecutionEnvironment());
MockProgram program(*device->getExecutionEnvironment(), context.get(), false, &device->getDevice());
KernelInfo *blockInfo = new KernelInfo;
KernelInfo &info = *blockInfo;

View File

@ -1681,7 +1681,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenExportedFun
MockProgram program(*pDevice->getExecutionEnvironment());
auto exportedFunctionsSurface = std::make_unique<MockGraphicsAllocation>();
program.exportedFunctionsSurface = exportedFunctionsSurface.get();
program.buildInfos[pDevice->getRootDeviceIndex()].exportedFunctionsSurface = exportedFunctionsSurface.get();
MockContext ctx;
program.setContext(&ctx);
std::unique_ptr<MockKernel> pKernel(new MockKernel(&program, *pKernelInfo, *pClDevice));
@ -1689,7 +1689,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenExportedFun
EXPECT_EQ(0u, commandStreamReceiver.makeResidentAllocations.size());
pKernel->makeResident(pDevice->getGpgpuCommandStreamReceiver());
EXPECT_TRUE(commandStreamReceiver.isMadeResident(program.exportedFunctionsSurface));
EXPECT_TRUE(commandStreamReceiver.isMadeResident(program.buildInfos[pDevice->getRootDeviceIndex()].exportedFunctionsSurface));
// check getResidency as well
std::vector<NEO::Surface *> residencySurfaces;
@ -1720,13 +1720,13 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenGlobalBuffe
MockProgram program(*pDevice->getExecutionEnvironment());
MockContext ctx;
program.setContext(&ctx);
program.globalSurface = new MockGraphicsAllocation();
program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface = new MockGraphicsAllocation();
std::unique_ptr<MockKernel> pKernel(new MockKernel(&program, *pKernelInfo, *pClDevice));
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
EXPECT_EQ(0u, commandStreamReceiver.makeResidentAllocations.size());
pKernel->makeResident(pDevice->getGpgpuCommandStreamReceiver());
EXPECT_TRUE(commandStreamReceiver.isMadeResident(program.globalSurface));
EXPECT_TRUE(commandStreamReceiver.isMadeResident(program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface));
std::vector<NEO::Surface *> residencySurfaces;
pKernel->getResidency(residencySurfaces);
@ -1738,7 +1738,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenGlobalBuffe
s->makeResident(csrMock);
delete s;
}
EXPECT_EQ(1U, csrMock.residency.count(program.globalSurface->getUnderlyingBuffer()));
EXPECT_EQ(1U, csrMock.residency.count(program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface->getUnderlyingBuffer()));
mockCsrExecEnv = std::move(csrMock.mockExecutionEnvironment);
}