Skip to content

Commit c637431

Browse files
feature: signal correct TS node for combined CB Event
Related-To: NEO-13971 Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
1 parent dce4ca8 commit c637431

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

level_zero/core/source/event/event.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,14 +553,14 @@ void Event::disableImplicitCounterBasedMode() {
553553

554554
uint64_t Event::getGpuAddress(Device *device) const {
555555
if (!inOrderTimestampNode.empty()) {
556-
return inOrderTimestampNode[0]->getGpuAddress();
556+
return inOrderTimestampNode.back()->getGpuAddress();
557557
}
558558
return getAllocation(device)->getGpuAddress() + this->eventPoolOffset;
559559
}
560560

561561
void *Event::getHostAddress() const {
562562
if (!inOrderTimestampNode.empty()) {
563-
return inOrderTimestampNode[0]->getCpuBase();
563+
return inOrderTimestampNode.back()->getCpuBase();
564564
}
565565

566566
return this->hostAddressFromPool;
@@ -570,7 +570,7 @@ NEO::GraphicsAllocation *Event::getAllocation(Device *device) const {
570570
auto rootDeviceIndex = device->getNEODevice()->getRootDeviceIndex();
571571

572572
if (!inOrderTimestampNode.empty()) {
573-
return inOrderTimestampNode[0]->getBaseGraphicsAllocation()->getGraphicsAllocation(rootDeviceIndex);
573+
return inOrderTimestampNode.back()->getBaseGraphicsAllocation()->getGraphicsAllocation(rootDeviceIndex);
574574
} else if (eventPoolAllocation) {
575575
return eventPoolAllocation->getGraphicsAllocation(rootDeviceIndex);
576576
}

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5495,6 +5495,66 @@ HWTEST2_F(InOrderCmdListTests, givenExternalSyncStorageWhenCallingAppendMoreThan
54955495
context->freeMem(devAddress);
54965496
}
54975497

5498+
HWTEST2_F(InOrderCmdListTests, givenExternalSyncStorageWhenCallingSplitAppendThenSetCorrectGpuVa, MatchAny) {
5499+
using TagSizeT = typename FamilyType::TimestampPacketType;
5500+
using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM;
5501+
5502+
constexpr uint64_t counterValue = 4;
5503+
constexpr uint64_t incValue = 2;
5504+
5505+
auto devAddress = reinterpret_cast<uint64_t *>(allocDeviceMem(sizeof(uint64_t)));
5506+
auto eventObj = createExternalSyncStorageEvent(counterValue, incValue, devAddress);
5507+
eventObj->isTimestampEvent = true;
5508+
eventObj->setSinglePacketSize(NEO::TimestampPackets<TagSizeT, 1>::getSinglePacketSize());
5509+
5510+
auto handle = eventObj->toHandle();
5511+
5512+
auto immCmdList = createImmCmdList<gfxCoreFamily>();
5513+
auto cmdStream = immCmdList->getCmdContainer().getCommandStream();
5514+
5515+
auto offset = cmdStream->getUsed();
5516+
5517+
const size_t ptrBaseSize = 128;
5518+
const size_t copyOffset = 1;
5519+
auto alignedPtr = alignedMalloc(ptrBaseSize, MemoryConstants::cacheLineSize);
5520+
auto unalignedPtr = ptrOffset(alignedPtr, copyOffset);
5521+
5522+
immCmdList->appendMemoryCopy(unalignedPtr, unalignedPtr, ptrBaseSize - copyOffset, handle, 0, nullptr, copyParams);
5523+
5524+
ASSERT_EQ(1u, eventObj->inOrderTimestampNode.size());
5525+
auto expectedAddress0 = eventObj->inOrderTimestampNode[0]->getGpuAddress() + eventObj->getGlobalStartOffset();
5526+
5527+
{
5528+
GenCmdList cmdList;
5529+
ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(cmdList, ptrOffset(cmdStream->getCpuBase(), offset), cmdStream->getUsed() - offset));
5530+
5531+
auto itor = find<MI_STORE_REGISTER_MEM *>(cmdList.begin(), cmdList.end());
5532+
ASSERT_NE(cmdList.end(), itor);
5533+
auto srmCmd = genCmdCast<MI_STORE_REGISTER_MEM *>(*itor);
5534+
5535+
EXPECT_EQ(expectedAddress0, srmCmd->getMemoryAddress());
5536+
}
5537+
5538+
offset = cmdStream->getUsed();
5539+
immCmdList->appendMemoryCopy(unalignedPtr, unalignedPtr, ptrBaseSize - copyOffset, handle, 0, nullptr, copyParams);
5540+
ASSERT_EQ(2u, eventObj->inOrderTimestampNode.size());
5541+
auto expectedAddress1 = eventObj->inOrderTimestampNode[1]->getGpuAddress() + eventObj->getGlobalStartOffset();
5542+
5543+
{
5544+
GenCmdList cmdList;
5545+
ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(cmdList, ptrOffset(cmdStream->getCpuBase(), offset), cmdStream->getUsed() - offset));
5546+
5547+
auto itor = find<MI_STORE_REGISTER_MEM *>(cmdList.begin(), cmdList.end());
5548+
ASSERT_NE(cmdList.end(), itor);
5549+
auto srmCmd = genCmdCast<MI_STORE_REGISTER_MEM *>(*itor);
5550+
5551+
EXPECT_EQ(expectedAddress1, srmCmd->getMemoryAddress());
5552+
}
5553+
5554+
context->freeMem(devAddress);
5555+
alignedFree(alignedPtr);
5556+
}
5557+
54985558
HWTEST2_F(InOrderCmdListTests, givenExternalSyncStorageWhenCallingAppendSignalInOrderDependencyCounterThenProgramAtomicOperation, MatchAny) {
54995559
using MI_ATOMIC = typename FamilyType::MI_ATOMIC;
55005560
using ATOMIC_OPCODES = typename FamilyType::MI_ATOMIC::ATOMIC_OPCODES;

0 commit comments

Comments
 (0)