[15/n] Internal 4GB allocator.

- Make resident on kernel ISA for blocked and non blocked path.

Change-Id: I1fc4948f1abb73c6f7028ae15dccad820101b8dc
This commit is contained in:
Mrozek, Michal
2018-03-13 10:44:35 +01:00
committed by sys_ocldev
parent a1a20a3b34
commit 93fc48339b
8 changed files with 48 additions and 22 deletions

View File

@@ -941,6 +941,11 @@ void Kernel::makeResident(CommandStreamReceiver &commandStreamReceiver) {
makeArgsResident(commandStreamReceiver);
auto kernelIsaAllocation = this->kernelInfo.kernelAllocation;
if (kernelIsaAllocation) {
commandStreamReceiver.makeResident(*kernelIsaAllocation);
}
gtpinNotifyMakeResident(this, &commandStreamReceiver);
}
@@ -980,6 +985,12 @@ void Kernel::getResidency(std::vector<Surface *> &dst) {
}
}
auto kernelIsaAllocation = this->kernelInfo.kernelAllocation;
if (kernelIsaAllocation) {
GeneralSurface *surface = new GeneralSurface(kernelIsaAllocation);
dst.push_back(surface);
}
gtpinNotifyUpdateResidencyList(this, &dst);
}

View File

@@ -47,7 +47,7 @@ struct CopyBufferHw
typedef CopyBufferHw AUBCopyBuffer;
HWTEST_P(AUBCopyBuffer, simple) {
MockContext context;
MockContext context(&pCmdQ->getDevice());
cl_float srcMemory[] = {1.0f, 2.0f, 3.0f, 4.0f};
cl_float dstMemory[] = {0.0f, 0.0f, 0.0f, 0.0f};

View File

@@ -50,7 +50,7 @@ typedef FillBufferHw AUBFillBuffer;
HWTEST_P(AUBFillBuffer, simple) {
cl_float destMemory[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
auto pDestMemory = &destMemory[0];
MockContext context;
MockContext context(&this->pCmdQ->getDevice());
auto retVal = CL_INVALID_VALUE;
auto destBuffer = Buffer::create(
&context,

View File

@@ -48,7 +48,7 @@ struct WriteBufferHw
typedef WriteBufferHw AUBWriteBuffer;
HWTEST_P(AUBWriteBuffer, simple) {
MockContext context;
MockContext context(&this->pCmdQ->getDevice());
cl_float *srcMemory = new float[1024];
cl_float *destMemory = new float[1024];

View File

@@ -472,7 +472,7 @@ TEST_F(EnqueueSvmTest, enqueueTaskWithKernelExecInfo_success) {
EXPECT_EQ(1u, kernel->getKernelSvmGfxAllocations().size());
}
TEST_F(EnqueueSvmTest, enqueueTaskWithKernelExecInfoBlockedOnEvent_success) {
TEST_F(EnqueueSvmTest, givenEnqueueTaskBlockedOnUserEventWhenItIsEnqueuedThenSurfacesAreMadeResident) {
GraphicsAllocation *pSvmAlloc = context->getSVMAllocsManager()->getSVMAlloc(ptrSVM);
EXPECT_NE(nullptr, ptrSVM);
@@ -483,7 +483,7 @@ TEST_F(EnqueueSvmTest, enqueueTaskWithKernelExecInfoBlockedOnEvent_success) {
std::vector<Surface *> allSurfaces;
kernel->getResidency(allSurfaces);
EXPECT_EQ(0u, allSurfaces.size());
EXPECT_EQ(1u, allSurfaces.size());
kernel->setKernelExecInfo(pSvmAlloc);
@@ -503,7 +503,7 @@ TEST_F(EnqueueSvmTest, enqueueTaskWithKernelExecInfoBlockedOnEvent_success) {
EXPECT_EQ(CL_SUCCESS, retVal);
kernel->getResidency(allSurfaces);
EXPECT_EQ(1u, allSurfaces.size());
EXPECT_EQ(3u, allSurfaces.size());
for (auto &surface : allSurfaces)
delete surface;

View File

@@ -108,6 +108,7 @@ struct HelloWorldFixture : public FixtureFactory::IndirectHeapFixture,
}
virtual void TearDown() {
pCmdQ->flush();
delete BufferDefaults::context;
alignedFree(pSrcMemory);

View File

@@ -1534,12 +1534,17 @@ TEST_F(KernelDefaultDeviceQueueSurfaceTest, givenStatelessKernelWhenDefaultDevic
typedef Test<DeviceFixture> KernelResidencyTest;
TEST_F(KernelResidencyTest, test_MakeArgsResident) {
HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenKernelIsaIsMadeResident) {
ASSERT_NE(nullptr, pDevice);
char pCrossThreadData[64];
// define kernel info
KernelInfo *pKernelInfo = KernelInfo::create();
std::unique_ptr<KernelInfo> pKernelInfo(KernelInfo::create());
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.storeMakeResidentAllocations = true;
auto memoryManager = commandStreamReceiver.getMemoryManager();
pKernelInfo->kernelAllocation = memoryManager->allocateGraphicsMemory(MemoryConstants::pageSize, MemoryConstants::pageSize);
// setup kernel arg offsets
KernelArgPatchInfo kernelArgPatchInfo;
@@ -1554,15 +1559,16 @@ TEST_F(KernelResidencyTest, test_MakeArgsResident) {
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30;
MockProgram program;
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
std::unique_ptr<MockKernel> pKernel(new MockKernel(&program, *pKernelInfo, *pDevice));
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
pKernel->setCrossThreadData(pCrossThreadData, sizeof(pCrossThreadData));
// Currently just a sandbox for testing
EXPECT_EQ(0u, commandStreamReceiver.makeResidentAllocations.size());
pKernel->makeResident(pDevice->getCommandStreamReceiver());
EXPECT_EQ(1u, commandStreamReceiver.makeResidentAllocations.size());
EXPECT_EQ(commandStreamReceiver.makeResidentAllocations.begin()->first, pKernel->getKernelInfo().getGraphicsAllocation());
delete pKernel;
delete pKernelInfo;
memoryManager->freeGraphicsMemory(pKernelInfo->kernelAllocation);
}
HWTEST_F(KernelResidencyTest, test_MakeArgsResidentCheckImageFromImage) {

View File

@@ -1319,11 +1319,14 @@ class CommandStreamReceiverMock : public UltCommandStreamReceiver<FamilyType> {
residency.erase(graphicsAllocation.getUnderlyingBuffer());
CommandStreamReceiver::makeNonResident(graphicsAllocation);
}
ResidencyContainer &getResidencyContainer() {
return this->memoryManager->getResidencyAllocations();
}
std::map<const void *, size_t> residency;
};
HWTEST_F(PatchTokenTests, AllocateConstantSurface) {
HWTEST_F(PatchTokenTests, givenKernelRequiringConstantAllocationWhenMakeResidentIsCalledThenConstantAllocationIsMadeResident) {
cl_device_id device = pDevice;
CreateProgramFromBinary<Program>(pContext, &device, "test_constant_memory");
@@ -1349,11 +1352,7 @@ HWTEST_F(PatchTokenTests, AllocateConstantSurface) {
EXPECT_EQ(expected_values[0], constBuff[0]);
EXPECT_EQ(expected_values[1], constBuff[1]);
// create a kernel
auto pKernel = Kernel::create(
pProgram,
*pKernelInfo,
&retVal);
std::unique_ptr<Kernel> pKernel(Kernel::create(pProgram, *pKernelInfo, &retVal));
ASSERT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, pKernel);
@@ -1365,7 +1364,18 @@ HWTEST_F(PatchTokenTests, AllocateConstantSurface) {
pCommandStreamReceiver->residency.clear();
pKernel->makeResident(*pCommandStreamReceiver);
EXPECT_EQ(1u, pCommandStreamReceiver->residency.size());
EXPECT_EQ(2u, pCommandStreamReceiver->residency.size());
auto &residencyVector = pCommandStreamReceiver->getResidencyContainer();
//we expect kernel ISA here and constant allocation
auto kernelIsa = pKernel->getKernelInfo().getGraphicsAllocation();
auto constantAllocation = pProgram->getConstantSurface();
auto element = std::find(residencyVector.begin(), residencyVector.end(), kernelIsa);
EXPECT_NE(residencyVector.end(), element);
element = std::find(residencyVector.begin(), residencyVector.end(), constantAllocation);
EXPECT_NE(residencyVector.end(), element);
auto crossThreadData = pKernel->getCrossThreadData();
uint32_t *constBuffGpuAddr = reinterpret_cast<uint32_t *>(pProgram->getConstantSurface()->getGpuAddressToPatch());
@@ -1379,13 +1389,11 @@ HWTEST_F(PatchTokenTests, AllocateConstantSurface) {
std::vector<Surface *> surfaces;
pKernel->getResidency(surfaces);
EXPECT_EQ(1u, surfaces.size());
EXPECT_EQ(2u, surfaces.size());
for (Surface *surface : surfaces) {
delete surface;
}
delete pKernel;
}
TEST_F(PatchTokenTests, DataParamGWS) {