fix: use proper pointer inside appendWriteGlobalTimestamp

Related-To: NEO-8105
Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
Katarzyna Cencelewska
2023-08-09 10:06:46 +00:00
committed by Compute-Runtime-Automation
parent 820e94e89c
commit 5a235af209
8 changed files with 72 additions and 33 deletions

View File

@@ -2431,12 +2431,18 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(
appendEventForProfiling(signalEvent, true);
auto allocationStruct = getAlignedAllocationData(this->device, dstptr, sizeof(uint64_t), false);
if (allocationStruct.alloc == nullptr) {
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
}
commandContainer.addToResidencyContainer(allocationStruct.alloc);
if (isCopyOnly()) {
NEO::MiFlushArgs args{this->dummyBlitWa};
args.timeStampOperation = true;
args.commandWithPostSync = true;
NEO::EncodeMiFlushDW<GfxFamily>::programWithWa(*commandContainer.getCommandStream(),
reinterpret_cast<uint64_t>(dstptr),
allocationStruct.alloc->getGpuAddress(),
0,
args);
makeResidentDummyAllocation();
@@ -2447,7 +2453,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(
NEO::MemorySynchronizationCommands<GfxFamily>::addBarrierWithPostSyncOperation(
*commandContainer.getCommandStream(),
NEO::PostSyncMode::Timestamp,
reinterpret_cast<uint64_t>(dstptr),
allocationStruct.alloc->getGpuAddress(),
0,
this->device->getNEODevice()->getRootDeviceEnvironment(),
args);
@@ -2455,12 +2461,6 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(
appendSignalEventPostWalker(signalEvent);
auto allocationStruct = getAlignedAllocationData(this->device, dstptr, sizeof(uint64_t), false);
if (allocationStruct.alloc == nullptr) {
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
}
commandContainer.addToResidencyContainer(allocationStruct.alloc);
addToMappedEventList(signalEvent);
return ZE_RESULT_SUCCESS;

View File

@@ -37,13 +37,21 @@ HWTEST2_F(CommandListCreate, givenCopyOnlyCommandListWhenAppendWriteGlobalTimest
ze_result_t returnValue;
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Copy, 0u, returnValue));
auto &commandContainer = commandList->getCmdContainer();
auto memoryManager = static_cast<MockMemoryManager *>(neoDevice->getMemoryManager());
memoryManager->returnFakeAllocation = true;
uint64_t timestampAddress = 0xfffffffffff0L;
uint64_t *dstptr = reinterpret_cast<uint64_t *>(timestampAddress);
uint64_t dstAddress = 0xfffffffffff0L;
uint64_t *dstptr = reinterpret_cast<uint64_t *>(dstAddress);
commandContainer.getResidencyContainer().clear();
const auto commandStreamOffset = commandContainer.getCommandStream()->getUsed();
commandList->appendWriteGlobalTimestamp(dstptr, nullptr, 0, nullptr);
auto residencyContainer = commandContainer.getResidencyContainer();
auto timestampAlloc = residencyContainer[0];
EXPECT_EQ(dstAddress, reinterpret_cast<uint64_t>(timestampAlloc->getUnderlyingBuffer()));
auto timestampAddress = timestampAlloc->getGpuAddress();
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList,
@@ -55,9 +63,9 @@ HWTEST2_F(CommandListCreate, givenCopyOnlyCommandListWhenAppendWriteGlobalTimest
ASSERT_NE(0u, iterator.size());
for (auto it : iterator) {
auto cmd = genCmdCast<MI_FLUSH_DW *>(*it);
auto postSyncDestAddress = cmd->getDestinationAddress();
if ((cmd->getPostSyncOperation() == MI_FLUSH_DW::POST_SYNC_OPERATION_WRITE_TIMESTAMP_REGISTER) &&
(cmd->getDestinationAddress() == timestampAddress)) {
(postSyncDestAddress == timestampAddress)) {
postSyncFound = true;
}
}

View File

@@ -109,8 +109,10 @@ HWTEST2_F(CommandListAppendSignalEvent, givenCommandListWhenAppendWriteGlobalTim
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
auto &commandContainer = commandList->getCmdContainer();
uint64_t timestampAddress = 0x12345678555500;
uint64_t *dstptr = reinterpret_cast<uint64_t *>(timestampAddress);
uint64_t dstAddress = 0x12345678555500;
uint64_t *dstptr = reinterpret_cast<uint64_t *>(dstAddress);
commandContainer.getResidencyContainer().clear();
commandList->appendWriteGlobalTimestamp(dstptr, event->toHandle(), 0, nullptr);
@@ -118,6 +120,9 @@ HWTEST2_F(CommandListAppendSignalEvent, givenCommandListWhenAppendWriteGlobalTim
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), commandContainer.getCommandStream()->getUsed()));
auto residencyContainer = commandContainer.getResidencyContainer();
auto timestampAlloc = residencyContainer[0];
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
EXPECT_NE(cmdList.end(), itorPC);
auto cmd = genCmdCast<PIPE_CONTROL *>(*itorPC);
@@ -129,6 +134,8 @@ HWTEST2_F(CommandListAppendSignalEvent, givenCommandListWhenAppendWriteGlobalTim
}
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
EXPECT_FALSE(cmd->getDcFlushEnable());
EXPECT_EQ(dstAddress, reinterpret_cast<uint64_t>(timestampAlloc->getUnderlyingBuffer()));
auto timestampAddress = timestampAlloc->getGpuAddress();
EXPECT_EQ(timestampAddress, NEO::UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress(*cmd));
itorPC++;
@@ -419,8 +426,12 @@ HWTEST2_F(CommandListAppendUsedPacketSignalEvent,
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
auto &commandContainer = commandList->getCmdContainer();
uint64_t timestampAddress = 0x12345678555500;
uint64_t *dstptr = reinterpret_cast<uint64_t *>(timestampAddress);
auto memoryManager = static_cast<MockMemoryManager *>(neoDevice->getMemoryManager());
memoryManager->returnFakeAllocation = true;
uint64_t dstAddress = 0x123456785500;
uint64_t *dstptr = reinterpret_cast<uint64_t *>(dstAddress);
commandContainer.getResidencyContainer().clear();
constexpr uint32_t packets = 2u;
@@ -430,6 +441,11 @@ HWTEST2_F(CommandListAppendUsedPacketSignalEvent,
commandList->appendWriteGlobalTimestamp(dstptr, event->toHandle(), 0, nullptr);
EXPECT_EQ(packets, event->getPacketsInUse());
auto residencyContainer = commandContainer.getResidencyContainer();
auto timestampAlloc = residencyContainer[1];
EXPECT_EQ(dstAddress, reinterpret_cast<uint64_t>(timestampAlloc->getUnderlyingBuffer()));
auto timestampAddress = timestampAlloc->getGpuAddress();
auto eventGpuAddress = event->getGpuAddress(device);
uint64_t contextStartAddress = eventGpuAddress + event->getContextStartOffset();
uint64_t globalStartAddress = eventGpuAddress + event->getGlobalStartOffset();

View File

@@ -479,16 +479,27 @@ HWTEST2_F(CommandListAppendWaitOnEvent, givenCommandListWhenAppendWriteGlobalTim
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
uint64_t timestampAddress = 0x12345678555500;
uint64_t *dstptr = reinterpret_cast<uint64_t *>(timestampAddress);
auto memoryManager = static_cast<MockMemoryManager *>(neoDevice->getMemoryManager());
memoryManager->returnFakeAllocation = true;
uint64_t dstAddress = 0x123456785500;
uint64_t *dstptr = reinterpret_cast<uint64_t *>(dstAddress);
auto &commandContainer = commandList->getCmdContainer();
commandContainer.getResidencyContainer().clear();
ze_event_handle_t hEventHandle = event->toHandle();
commandList->appendWriteGlobalTimestamp(dstptr, nullptr, 1, &hEventHandle);
auto residencyContainer = commandContainer.getResidencyContainer();
auto timestampAlloc = residencyContainer[1];
EXPECT_EQ(dstAddress, reinterpret_cast<uint64_t>(timestampAlloc->getUnderlyingBuffer()));
auto timestampAddress = timestampAlloc->getGpuAddress();
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0),
commandList->getCmdContainer().getCommandStream()->getUsed()));
cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0),
commandContainer.getCommandStream()->getUsed()));
auto itor = find<MI_SEMAPHORE_WAIT *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), itor);