fix: enable setting timestamp via submission on tbx mode

Resolves: NEO-16293
Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
Katarzyna Cencelewska
2025-10-02 15:16:00 +00:00
committed by Compute-Runtime-Automation
parent 1f7839f16f
commit 0f866e24e6
4 changed files with 68 additions and 6 deletions

View File

@@ -1198,12 +1198,15 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties)
ze_result_t DeviceImp::getGlobalTimestamps(uint64_t *hostTimestamp, uint64_t *deviceTimestamp) {
bool method = 0;
if (NEO::debugManager.flags.EnableGlobalTimestampViaSubmission.get() != -1) {
method = NEO::debugManager.flags.EnableGlobalTimestampViaSubmission.get();
bool useTimestampViaSubmission = false;
auto csrType = obtainCsrTypeFromIntegerValue(NEO::debugManager.flags.SetCommandStreamReceiver.get(), NEO::CommandStreamReceiverType::hardware);
if (csrType == NEO::CommandStreamReceiverType::tbx ||
csrType == NEO::CommandStreamReceiverType::tbxWithAub ||
NEO::debugManager.flags.EnableGlobalTimestampViaSubmission.get() == 1) {
useTimestampViaSubmission = true;
}
if (method == 0) {
if (useTimestampViaSubmission == false) {
auto ret = getGlobalTimestampsUsingOsInterface(hostTimestamp, deviceTimestamp);
if (ret != ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
return ret;

View File

@@ -1739,6 +1739,65 @@ TEST_F(DeviceTest, givenInvalidPciBusInfoWhenPciPropertiesIsCalledThenUninitiali
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, res);
}
}
struct GetGlobalTimestampTest : public DeviceTest {
struct MockCommandListAppendWriteGlobalTimestamp : public MockCommandList {
ze_result_t appendWriteGlobalTimestamp(uint64_t *dstptr, ze_event_handle_t hEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) override {
isAppendWriteGlobalTimestampCalled = true;
*dstptr = 123456u; // dummy value
return ZE_RESULT_SUCCESS;
}
bool isAppendWriteGlobalTimestampCalled = false;
};
void SetUp() override {
DeviceTest::SetUp();
mockCommandList = std::make_unique<GetGlobalTimestampTest::MockCommandListAppendWriteGlobalTimestamp>();
uint64_t hostTs = 0u;
uint64_t deviceTs = 0u;
// initialize globalTimestampAllocation
debugManager.flags.EnableGlobalTimestampViaSubmission.set(1);
device->getGlobalTimestamps(&hostTs, &deviceTs);
debugManager.flags.EnableGlobalTimestampViaSubmission.set(0);
deviceImp = static_cast<DeviceImp *>(device);
actualGlobalTimestampCommandList = deviceImp->globalTimestampCommandList;
// Swap the command list with the mock command list.
deviceImp->globalTimestampCommandList = static_cast<ze_command_list_handle_t>(mockCommandList.get());
}
void TearDown() override {
// Swap back the command list.
deviceImp->globalTimestampCommandList = actualGlobalTimestampCommandList;
DeviceTest::TearDown();
}
std::unique_ptr<GetGlobalTimestampTest::MockCommandListAppendWriteGlobalTimestamp> mockCommandList = nullptr;
ze_command_list_handle_t actualGlobalTimestampCommandList = nullptr;
DeviceImp *deviceImp = nullptr;
};
TEST_F(GetGlobalTimestampTest, whenTbxModeThenSetGlobalTimestampViaSubmission) {
uint64_t hostTs = 0u;
uint64_t deviceTs = 0u;
debugManager.flags.SetCommandStreamReceiver.set(static_cast<int32_t>(NEO::CommandStreamReceiverType::tbx));
ze_result_t result = device->getGlobalTimestamps(&hostTs, &deviceTs);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(0u, hostTs);
EXPECT_NE(0u, deviceTs);
EXPECT_TRUE(mockCommandList->isAppendWriteGlobalTimestampCalled);
debugManager.flags.SetCommandStreamReceiver.set(static_cast<int32_t>(NEO::CommandStreamReceiverType::tbxWithAub));
mockCommandList->isAppendWriteGlobalTimestampCalled = false;
result = device->getGlobalTimestamps(&hostTs, &deviceTs);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(0u, hostTs);
EXPECT_NE(0u, deviceTs);
EXPECT_TRUE(mockCommandList->isAppendWriteGlobalTimestampCalled);
}
TEST_F(DeviceTest, whenGetGlobalTimestampIsCalledWithOsInterfaceThenSuccessIsReturnedAndValuesSetCorrectly) {
uint64_t hostTs = 0u;

View File

@@ -680,7 +680,7 @@ DECLARE_DEBUG_VARIABLE(std::string, FinalizerInputType, std::string("unk"), "unk
DECLARE_DEBUG_VARIABLE(std::string, FinalizerLibraryName, std::string("unk"), "Library name for finalizer")
DECLARE_DEBUG_VARIABLE(std::string, IgcLibraryName, std::string("unk"), "Library name for igc")
DECLARE_DEBUG_SCOPED_V(int32_t, UseIgcAsFcl, 0, S_RT | S_OCLOC, "0: platform default, 1: force use IGC, 2: force use FCL")
DECLARE_DEBUG_VARIABLE(int32_t, EnableGlobalTimestampViaSubmission, -1, "-1: OS Interface, 0: OS Interface, 1: Submission. This flag sets the type of method to get timestamp for getGlobalTimestamps");
DECLARE_DEBUG_VARIABLE(bool, EnableGlobalTimestampViaSubmission, 0, "0: OS Interface, 1: Submission. This flag sets the type of method to get timestamp for getGlobalTimestamps");
/* Binary Cache */
DECLARE_DEBUG_VARIABLE(bool, BinaryCacheTrace, false, "enable cl_cache to produce .trace files with information about hash computation")

View File

@@ -618,7 +618,7 @@ SetAssumeNotInUse = 1
ForceNonWalkerSplitMemoryCopy = -1
FinalizerInputType = unk
FinalizerLibraryName = unk
EnableGlobalTimestampViaSubmission = -1
EnableGlobalTimestampViaSubmission = 0
DirectSubmissionSwitchSemaphoreMode = -1
DisableProgrammableMetricsSupport = 0
IgnoreZebinUnknownAttributes = 0