mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-12 09:30:36 +08:00
fix: use proper pointer inside appendWriteGlobalTimestamp
Resolves: NEO-8105 Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
96a7f63371
commit
e71db368db
@@ -2539,12 +2539,18 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(
|
||||
|
||||
appendEventForProfiling(signalEvent, true, false);
|
||||
|
||||
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.alignedAllocationPtr,
|
||||
0,
|
||||
args);
|
||||
makeResidentDummyAllocation();
|
||||
@@ -2555,7 +2561,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(
|
||||
NEO::MemorySynchronizationCommands<GfxFamily>::addBarrierWithPostSyncOperation(
|
||||
*commandContainer.getCommandStream(),
|
||||
NEO::PostSyncMode::Timestamp,
|
||||
reinterpret_cast<uint64_t>(dstptr),
|
||||
allocationStruct.alignedAllocationPtr,
|
||||
0,
|
||||
this->device->getNEODevice()->getRootDeviceEnvironment(),
|
||||
args);
|
||||
@@ -2568,12 +2574,6 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(
|
||||
handleInOrderDependencyCounter();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -39,13 +39,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,
|
||||
@@ -57,9 +65,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;
|
||||
}
|
||||
}
|
||||
@@ -100,6 +108,40 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenAppendWriteGlobalTimestampCalle
|
||||
EXPECT_TRUE(foundTimestampPipeControl);
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandListCreate, givenMovedDstptrWhenAppendWriteGlobalTimestampCalledThenPipeControlWithProperTimestampEncoded, IsAtLeastSkl) {
|
||||
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
||||
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
|
||||
ze_result_t returnValue;
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue));
|
||||
auto &commandContainer = commandList->getCmdContainer();
|
||||
|
||||
uint64_t timestampAddress = 0x123456785500;
|
||||
uint64_t *dstptr = reinterpret_cast<uint64_t *>(timestampAddress) + 1;
|
||||
uint64_t expectedTimestampAddress = timestampAddress + sizeof(uint64_t);
|
||||
const auto commandStreamOffset = commandContainer.getCommandStream()->getUsed();
|
||||
commandList->appendWriteGlobalTimestamp(dstptr, nullptr, 0, nullptr);
|
||||
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList,
|
||||
ptrOffset(commandContainer.getCommandStream()->getCpuBase(), commandStreamOffset),
|
||||
commandContainer.getCommandStream()->getUsed() - commandStreamOffset));
|
||||
|
||||
auto pcList = findAll<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(0u, pcList.size());
|
||||
bool foundTimestampPipeControl = false;
|
||||
for (auto it : pcList) {
|
||||
auto cmd = genCmdCast<PIPE_CONTROL *>(*it);
|
||||
if (cmd->getPostSyncOperation() == POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_TIMESTAMP) {
|
||||
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
|
||||
EXPECT_FALSE(cmd->getDcFlushEnable());
|
||||
EXPECT_EQ(expectedTimestampAddress, NEO::UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress(*cmd));
|
||||
foundTimestampPipeControl = true;
|
||||
}
|
||||
}
|
||||
EXPECT_TRUE(foundTimestampPipeControl);
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandListCreate, givenCommandListWhenAppendWriteGlobalTimestampCalledThenTimestampAllocationIsInsideResidencyContainer, IsAtLeastSkl) {
|
||||
ze_result_t returnValue;
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue));
|
||||
|
||||
@@ -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++;
|
||||
@@ -482,8 +489,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;
|
||||
|
||||
@@ -493,6 +504,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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user