Skip to content

Commit 2cfa921

Browse files
fix: align counter allocation for overflow
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com> Source: b0cdaac
1 parent 82bc8dd commit 2cfa921

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
@@ -207,7 +207,7 @@ void CommandListCoreFamily<gfxCoreFamily>::handleInOrderCounterOverflow(bool cop
207207
uint32_t newOffset = 0;
208208
if (inOrderExecInfo->getAllocationOffset() == 0) {
209209
// multitile immediate writes are uint64_t aligned
210-
newOffset = this->partitionCount * device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset();
210+
newOffset = alignUp(this->partitionCount * device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset(), MemoryConstants::cacheLineSize * 4);
211211
}
212212

213213
inOrderExecInfo->setAllocationOffset(newOffset);

level_zero/core/source/device/device.cpp

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

3636
const size_t maxPartitionCount = neoDevice.getDeviceBitfield().count();
3737

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

4040
DEBUG_BREAK_IF(alignUp(nodeSize, MemoryConstants::cacheLineSize) * NodeT::defaultAllocatorTagCount > MemoryConstants::pageSize64k);
4141

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
@@ -765,7 +765,9 @@ HWTEST_F(InOrderCmdListTests, whenCreatingInOrderExecInfoThenReuseDeviceAlloc) {
765765
auto immCmdList2 = createImmCmdList<FamilyType::gfxCoreFamily>();
766766
auto gpuVa2 = immCmdList2->inOrderExecInfo->getBaseDeviceAddress();
767767

768-
EXPECT_EQ(alignUp(gpuVa1 + (device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset() * 2), MemoryConstants::cacheLineSize), gpuVa2);
768+
auto offset = alignUp(device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset(), MemoryConstants::cacheLineSize * 4) * 2;
769+
770+
EXPECT_EQ(alignUp(gpuVa1 + offset, MemoryConstants::cacheLineSize), gpuVa2);
769771

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

46664668
EXPECT_EQ(expectedCounter, immCmdList->inOrderExecInfo->getCounterValue());
@@ -4740,7 +4742,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, InOrderCmdListTests, givenInOrderModeWhenProgrammin
47404742
EXPECT_EQ(immCmdList->inOrderExecInfo->getBaseDeviceAddress(), postSync.getDestinationAddress());
47414743
}
47424744
} else {
4743-
offset = device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset();
4745+
offset = alignUp(device->getL0GfxCoreHelper().getImmediateWritePostSyncOffset(), MemoryConstants::cacheLineSize * 4);
47444746
if (isCompactEvent) {
47454747
auto pcItor = find<PIPE_CONTROL *>(walkerItor, cmdList.end());
47464748
ASSERT_NE(cmdList.end(), pcItor);

0 commit comments

Comments
 (0)