Skip to content

Commit 61a7202

Browse files
fix: align counter allocation for overflow
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com> Source: b0cdaac
1 parent 20b96ef commit 61a7202

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

level_zero/core/source/cmdlist/cmdlist_hw.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void CommandListCoreFamily<gfxCoreFamily>::handleInOrderCounterOverflow(bool cop
216216
uint32_t newOffset = 0;
217217
if (inOrderExecInfo->getAllocationOffset() == 0) {
218218
// multitile immediate writes are uint64_t aligned
219-
newOffset = this->partitionCount * device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset();
219+
newOffset = alignUp(this->partitionCount * device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset(), MemoryConstants::cacheLineSize * 4);
220220
}
221221

222222
inOrderExecInfo->setAllocationOffset(newOffset);

level_zero/core/source/device/device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ NEO::TagAllocatorBase *getInOrderCounterAllocator(std::unique_ptr<NEO::TagAlloca
3838

3939
const size_t maxPartitionCount = neoDevice.getDeviceBitfield().count();
4040

41-
const size_t nodeSize = immediateWritePostSyncOffset * maxPartitionCount * 2; // Multiplied by 2 to handle 32b overflow
41+
const size_t nodeSize = alignUp(immediateWritePostSyncOffset * maxPartitionCount, MemoryConstants::cacheLineSize * 4) * 2; // Multiplied by 2 to handle 32b overflow
4242

4343
DEBUG_BREAK_IF(alignUp(nodeSize, MemoryConstants::cacheLineSize) * NodeT::defaultAllocatorTagCount > MemoryConstants::pageSize64k);
4444

level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_1.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,9 @@ HWTEST_F(InOrderCmdListTests, whenCreatingInOrderExecInfoThenReuseDeviceAlloc) {
762762
auto immCmdList2 = createImmCmdList<FamilyType::gfxCoreFamily>();
763763
auto gpuVa2 = immCmdList2->inOrderExecInfo->getBaseDeviceAddress();
764764

765-
EXPECT_EQ(alignUp(gpuVa1 + (device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset() * 2), MemoryConstants::cacheLineSize), gpuVa2);
765+
auto offset = alignUp(device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset(), MemoryConstants::cacheLineSize * 4) * 2;
766+
767+
EXPECT_EQ(alignUp(gpuVa1 + offset, MemoryConstants::cacheLineSize), gpuVa2);
766768

767769
// allocation from the same allocator
768770
EXPECT_EQ(immCmdList1->inOrderExecInfo->getDeviceCounterAllocation(), tag->getBaseGraphicsAllocation()->getGraphicsAllocation(0));
@@ -4657,7 +4659,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, InOrderCmdListTests, givenInOrderModeWhenProgrammin
46574659
expectedCounter += static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()) - 1;
46584660
} else {
46594661
expectedCounter = 1;
4660-
expectedOffset = useZeroOffset ? 0 : device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset();
4662+
expectedOffset = useZeroOffset ? 0 : alignUp(device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset(), MemoryConstants::cacheLineSize * 4);
46614663
}
46624664

46634665
EXPECT_EQ(expectedCounter, immCmdList->inOrderExecInfo->getCounterValue());
@@ -4737,7 +4739,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, InOrderCmdListTests, givenInOrderModeWhenProgrammin
47374739
EXPECT_EQ(immCmdList->inOrderExecInfo->getBaseDeviceAddress(), postSync.getDestinationAddress());
47384740
}
47394741
} else {
4740-
offset = device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset();
4742+
offset = alignUp(device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset(), MemoryConstants::cacheLineSize * 4);
47414743
if (isCompactEvent) {
47424744
auto pcItor = find<PIPE_CONTROL *>(walkerItor, cmdList.end());
47434745
ASSERT_NE(cmdList.end(), pcItor);

0 commit comments

Comments
 (0)