mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
Fix for incorrect timestamp offset calculation in event profiling info
Change-Id: I634c29daf4734b24e4075542dc6550c531977f0a Signed-off-by: Pawel Wilma <pawel.wilma@intel.com>
This commit is contained in:
@@ -106,12 +106,12 @@ void GpgpuWalkerHelper<GfxFamily>::dispatchProfilingCommandsStart(
|
||||
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
||||
|
||||
// PIPE_CONTROL for global timestamp
|
||||
uint64_t TimeStampAddress = hwTimeStamps.getGraphicsAllocation()->getGpuAddress() + ptrDiff(&hwTimeStamps.tag->GlobalStartTS, hwTimeStamps.tag);
|
||||
uint64_t TimeStampAddress = hwTimeStamps.getGraphicsAllocation()->getGpuAddress() + ptrDiff(&hwTimeStamps.tag->GlobalStartTS, hwTimeStamps.getGraphicsAllocation()->getUnderlyingBuffer());
|
||||
|
||||
PipeControlHelper<GfxFamily>::obtainPipeControlAndProgramPostSyncOperation(commandStream, PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_TIMESTAMP, TimeStampAddress, 0llu);
|
||||
|
||||
//MI_STORE_REGISTER_MEM for context local timestamp
|
||||
TimeStampAddress = hwTimeStamps.getGraphicsAllocation()->getGpuAddress() + ptrDiff(&hwTimeStamps.tag->ContextStartTS, hwTimeStamps.tag);
|
||||
TimeStampAddress = hwTimeStamps.getGraphicsAllocation()->getGpuAddress() + ptrDiff(&hwTimeStamps.tag->ContextStartTS, hwTimeStamps.getGraphicsAllocation()->getUnderlyingBuffer());
|
||||
|
||||
//low part
|
||||
auto pMICmdLow = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
||||
@@ -134,7 +134,7 @@ void GpgpuWalkerHelper<GfxFamily>::dispatchProfilingCommandsEnd(
|
||||
pPipeControlCmd->setCommandStreamerStallEnable(true);
|
||||
|
||||
//MI_STORE_REGISTER_MEM for context local timestamp
|
||||
uint64_t TimeStampAddress = hwTimeStamps.getGraphicsAllocation()->getGpuAddress() + ptrDiff(&hwTimeStamps.tag->ContextEndTS, hwTimeStamps.tag);
|
||||
uint64_t TimeStampAddress = hwTimeStamps.getGraphicsAllocation()->getGpuAddress() + ptrDiff(&hwTimeStamps.tag->ContextEndTS, hwTimeStamps.getGraphicsAllocation()->getUnderlyingBuffer());
|
||||
|
||||
//low part
|
||||
auto pMICmdLow = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -216,7 +216,7 @@ void DeviceQueueHw<GfxFamily>::addExecutionModelCleanUpSection(Kernel *parentKer
|
||||
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
|
||||
|
||||
if (hwTimeStamp != nullptr) {
|
||||
uint64_t TimeStampAddress = hwTimeStamp->getGraphicsAllocation()->getGpuAddress() + ptrDiff(&hwTimeStamp->tag->ContextCompleteTS, hwTimeStamp->tag);
|
||||
uint64_t TimeStampAddress = hwTimeStamp->getGraphicsAllocation()->getGpuAddress() + ptrDiff(&hwTimeStamp->tag->ContextCompleteTS, hwTimeStamp->getGraphicsAllocation()->getUnderlyingBuffer());
|
||||
igilQueue->m_controls.m_EventTimestampAddress = TimeStampAddress;
|
||||
|
||||
addProfilingEndCmds(TimeStampAddress);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/kernel_commands.h"
|
||||
#include "runtime/helpers/task_information.h"
|
||||
#include "runtime/utilities/tag_allocator.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/command_queue/command_queue_fixture.h"
|
||||
#include "unit_tests/libult/mock_gfx_family.h"
|
||||
@@ -1143,3 +1144,87 @@ HWTEST_F(DispatchWalkerTest, givenKernelWhenAuxTranslationWithoutParentKernelThe
|
||||
auto itorCmd = find<typename FamilyType::PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorCmd);
|
||||
}
|
||||
|
||||
struct ProfilingCommandsTest : public DispatchWalkerTest, ::testing::WithParamInterface<bool> {
|
||||
void SetUp() override {
|
||||
DispatchWalkerTest::SetUp();
|
||||
}
|
||||
void TearDown() override {
|
||||
DispatchWalkerTest::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
HWTEST_P(ProfilingCommandsTest, givenKernelWhenProfilingCommandStartIsTakenThenTimeStampAddressIsProgrammedCorrectly) {
|
||||
using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM;
|
||||
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
||||
bool checkForStart = GetParam();
|
||||
|
||||
auto &cmdStream = pCmdQ->getCS(0);
|
||||
TagAllocator<HwTimeStamps> timeStampAllocator(this->pDevice->getMemoryManager(), 10, MemoryConstants::cacheLineSize);
|
||||
|
||||
auto hwTimeStamp1 = timeStampAllocator.getTag();
|
||||
ASSERT_NE(nullptr, hwTimeStamp1);
|
||||
if (checkForStart) {
|
||||
GpgpuWalkerHelper<FamilyType>::dispatchProfilingCommandsStart(*hwTimeStamp1, &cmdStream);
|
||||
} else {
|
||||
GpgpuWalkerHelper<FamilyType>::dispatchProfilingCommandsEnd(*hwTimeStamp1, &cmdStream);
|
||||
}
|
||||
|
||||
auto hwTimeStamp2 = timeStampAllocator.getTag();
|
||||
ASSERT_NE(nullptr, hwTimeStamp2);
|
||||
if (checkForStart) {
|
||||
GpgpuWalkerHelper<FamilyType>::dispatchProfilingCommandsStart(*hwTimeStamp2, &cmdStream);
|
||||
} else {
|
||||
GpgpuWalkerHelper<FamilyType>::dispatchProfilingCommandsEnd(*hwTimeStamp2, &cmdStream);
|
||||
}
|
||||
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(cmdList, cmdStream.getCpuBase(), cmdStream.getUsed()));
|
||||
|
||||
auto itorStoreReg = find<typename FamilyType::MI_STORE_REGISTER_MEM *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorStoreReg);
|
||||
auto storeReg = genCmdCast<MI_STORE_REGISTER_MEM *>(*itorStoreReg);
|
||||
ASSERT_NE(nullptr, storeReg);
|
||||
|
||||
uint64_t gpuAddress = storeReg->getMemoryAddress();
|
||||
auto timestampFieldAddress = checkForStart ? &hwTimeStamp1->tag->ContextStartTS : &hwTimeStamp1->tag->ContextEndTS;
|
||||
uint64_t expectedAddress = hwTimeStamp1->getGraphicsAllocation()->getGpuAddress() + ptrDiff(timestampFieldAddress, hwTimeStamp1->getGraphicsAllocation()->getUnderlyingBuffer());
|
||||
EXPECT_EQ(expectedAddress, gpuAddress);
|
||||
|
||||
itorStoreReg++;
|
||||
itorStoreReg = find<typename FamilyType::MI_STORE_REGISTER_MEM *>(itorStoreReg, cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorStoreReg);
|
||||
storeReg = genCmdCast<MI_STORE_REGISTER_MEM *>(*itorStoreReg);
|
||||
ASSERT_NE(nullptr, storeReg);
|
||||
|
||||
gpuAddress = storeReg->getMemoryAddress();
|
||||
timestampFieldAddress = checkForStart ? &hwTimeStamp2->tag->ContextStartTS : &hwTimeStamp2->tag->ContextEndTS;
|
||||
expectedAddress = hwTimeStamp2->getGraphicsAllocation()->getGpuAddress() + ptrDiff(timestampFieldAddress, hwTimeStamp2->getGraphicsAllocation()->getUnderlyingBuffer());
|
||||
EXPECT_EQ(expectedAddress, gpuAddress);
|
||||
|
||||
if (checkForStart) {
|
||||
auto itorPipeCtrl = find<typename FamilyType::PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorPipeCtrl);
|
||||
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*itorPipeCtrl);
|
||||
ASSERT_NE(nullptr, pipeControl);
|
||||
|
||||
gpuAddress = static_cast<uint64_t>(pipeControl->getAddress()) | (static_cast<uint64_t>(pipeControl->getAddressHigh()) << 32);
|
||||
timestampFieldAddress = checkForStart ? &hwTimeStamp1->tag->GlobalStartTS : &hwTimeStamp1->tag->GlobalEndTS;
|
||||
expectedAddress = hwTimeStamp1->getGraphicsAllocation()->getGpuAddress() + ptrDiff(timestampFieldAddress, hwTimeStamp1->getGraphicsAllocation()->getUnderlyingBuffer());
|
||||
EXPECT_EQ(expectedAddress, gpuAddress);
|
||||
|
||||
itorPipeCtrl++;
|
||||
itorPipeCtrl = find<typename FamilyType::PIPE_CONTROL *>(itorPipeCtrl, cmdList.end());
|
||||
ASSERT_NE(cmdList.end(), itorPipeCtrl);
|
||||
pipeControl = genCmdCast<PIPE_CONTROL *>(*itorPipeCtrl);
|
||||
ASSERT_NE(nullptr, pipeControl);
|
||||
|
||||
gpuAddress = static_cast<uint64_t>(pipeControl->getAddress()) | static_cast<uint64_t>(pipeControl->getAddressHigh()) << 32;
|
||||
timestampFieldAddress = checkForStart ? &hwTimeStamp2->tag->GlobalStartTS : &hwTimeStamp2->tag->GlobalEndTS;
|
||||
expectedAddress = hwTimeStamp2->getGraphicsAllocation()->getGpuAddress() + ptrDiff(timestampFieldAddress, hwTimeStamp2->getGraphicsAllocation()->getUnderlyingBuffer());
|
||||
EXPECT_EQ(expectedAddress, gpuAddress);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(StartEndFlag,
|
||||
ProfilingCommandsTest, ::testing::Values(true, false));
|
||||
|
||||
Reference in New Issue
Block a user