Limit overestimation in multi kernel scenarios.

- There was overestimation that resulted in each kernel getting
page aligned estimation size.
- After this change every kernel aligns only to cache line and final
size is aligned to page size.

Change-Id: Iee06bdd0083724ea7e9415f3d0fe70198acca407
Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
Mrozek, Michal
2019-04-23 15:57:23 +02:00
committed by sys_ocldev
parent 6cf2dc411d
commit c269bc062f
2 changed files with 31 additions and 1 deletions

View File

@@ -90,9 +90,10 @@ size_t getSizeRequired(const MultiDispatchInfo &multiDispatchInfo, SizeGetterT &
size_t totalSize = 0;
auto it = multiDispatchInfo.begin();
for (auto e = multiDispatchInfo.end(); it != e; ++it) {
totalSize = alignUp(totalSize, MemoryConstants::pageSize);
totalSize = alignUp(totalSize, MemoryConstants::cacheLineSize);
totalSize += getSize(*it, std::forward<ArgsT>(args)...);
}
totalSize = alignUp(totalSize, MemoryConstants::pageSize);
return totalSize;
}

View File

@@ -369,6 +369,35 @@ HWTEST_F(GetSizeRequiredBufferTest, enqueueWriteBufferBlocking) {
EXPECT_GE(expectedSizeSSH, usedAfterSSH - usedBeforeSSH);
}
HWTEST_F(GetSizeRequiredBufferTest, givenMultipleKernelRequiringSshWhenTotalSizeIsComputedThenItIsProperlyAligned) {
MultiDispatchInfo multiDispatchInfo;
auto &builder = pCmdQ->getDevice().getExecutionEnvironment()->getBuiltIns()->getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer,
pCmdQ->getContext(), pCmdQ->getDevice());
ASSERT_NE(nullptr, &builder);
BuiltinDispatchInfoBuilder::BuiltinOpParams dc;
dc.srcPtr = EnqueueWriteBufferTraits::hostPtr;
dc.dstMemObj = dstBuffer;
dc.dstOffset = {EnqueueWriteBufferTraits::offset, 0, 0};
dc.size = {dstBuffer->getSize(), 0, 0};
builder.buildDispatchInfos(multiDispatchInfo, dc);
builder.buildDispatchInfos(multiDispatchInfo, dc);
builder.buildDispatchInfos(multiDispatchInfo, dc);
builder.buildDispatchInfos(multiDispatchInfo, dc);
auto sizeSSH = multiDispatchInfo.begin()->getKernel()->getSurfaceStateHeapSize();
sizeSSH += sizeSSH ? FamilyType::BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE : 0;
sizeSSH = alignUp(sizeSSH, MemoryConstants::cacheLineSize);
sizeSSH *= 4u;
sizeSSH = alignUp(sizeSSH, MemoryConstants::pageSize);
EXPECT_EQ(4u, multiDispatchInfo.size());
auto expectedSizeSSH = KernelCommandsHelper<FamilyType>::getTotalSizeRequiredSSH(multiDispatchInfo);
EXPECT_EQ(sizeSSH, expectedSizeSSH);
}
HWTEST_F(GetSizeRequiredBufferTest, enqueueKernelHelloWorld) {
typedef HelloWorldKernelFixture KernelFixture;
auto &commandStream = pCmdQ->getCS(1024);