mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Fix event profiling for marker commands
Related-To: NEO-5799 Signed-off-by: Konstanty Misiak <konstanty.misiak@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
816e95443f
commit
ad19eda689
@ -5,6 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
|
||||
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_ostime.h"
|
||||
|
||||
@ -111,4 +113,106 @@ TEST(MockOSTime, GivenNullWhenSettingOsTimeThenResolutionIsZero) {
|
||||
|
||||
delete mDev;
|
||||
}
|
||||
|
||||
TEST(MockOSTime, givenDeviceTimestampBaseNotEnabledWhenGetDeviceAndHostTimerThenCpuTimestampIsReturned) {
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
mockDevice->setOSTime(new MockOSTimeWithConstTimestamp());
|
||||
|
||||
uint64_t deviceTS = 0u, hostTS = 0u;
|
||||
mockDevice->getDeviceAndHostTimer(&deviceTS, &hostTS);
|
||||
|
||||
EXPECT_EQ(deviceTS, MockDeviceTimeWithConstTimestamp::CPU_TIME_IN_NS);
|
||||
EXPECT_EQ(deviceTS, hostTS);
|
||||
}
|
||||
|
||||
TEST(MockOSTime, givenDeviceTimestampBaseEnabledWhenGetDeviceAndHostTimerThenGpuTimestampIsReturned) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.EnableDeviceBasedTimestamps.set(true);
|
||||
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
mockDevice->setOSTime(new MockOSTimeWithConstTimestamp());
|
||||
|
||||
uint64_t deviceTS = 0u, hostTS = 0u;
|
||||
mockDevice->getDeviceAndHostTimer(&deviceTS, &hostTS);
|
||||
|
||||
EXPECT_EQ(deviceTS, MockDeviceTimeWithConstTimestamp::GPU_TIMESTAMP);
|
||||
EXPECT_NE(deviceTS, hostTS);
|
||||
}
|
||||
|
||||
class FailingMockOSTime : public OSTime {
|
||||
public:
|
||||
FailingMockOSTime() {
|
||||
this->deviceTime = std::make_unique<MockDeviceTime>();
|
||||
}
|
||||
|
||||
bool getCpuTime(uint64_t *timeStamp) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
double getHostTimerResolution() const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t getCpuRawTimestamp() override {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(MockOSTime, givenFailingOSTimeWhenGetDeviceAndHostTimerThenFalseIsReturned) {
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
mockDevice->setOSTime(new FailingMockOSTime());
|
||||
|
||||
uint64_t deviceTS = 0u, hostTS = 0u;
|
||||
bool retVal = mockDevice->getDeviceAndHostTimer(&deviceTS, &hostTS);
|
||||
|
||||
EXPECT_FALSE(retVal);
|
||||
EXPECT_EQ(deviceTS, 0u);
|
||||
EXPECT_EQ(hostTS, 0u);
|
||||
}
|
||||
|
||||
class FailingMockDeviceTime : public DeviceTime {
|
||||
public:
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override {
|
||||
return static_cast<uint64_t>(1000000000.0 / OSTime::getDeviceTimerResolution(hwInfo));
|
||||
}
|
||||
};
|
||||
|
||||
class MockOSTimeWithFailingDeviceTime : public OSTime {
|
||||
public:
|
||||
MockOSTimeWithFailingDeviceTime() {
|
||||
this->deviceTime = std::make_unique<FailingMockDeviceTime>();
|
||||
}
|
||||
|
||||
bool getCpuTime(uint64_t *timeStamp) override {
|
||||
return true;
|
||||
}
|
||||
|
||||
double getHostTimerResolution() const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t getCpuRawTimestamp() override {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(MockOSTime, givenFailingDeviceTimeWhenGetDeviceAndHostTimerThenFalseIsReturned) {
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
mockDevice->setOSTime(new MockOSTimeWithFailingDeviceTime());
|
||||
|
||||
uint64_t deviceTS = 0u, hostTS = 0u;
|
||||
bool retVal = mockDevice->getDeviceAndHostTimer(&deviceTS, &hostTS);
|
||||
|
||||
EXPECT_FALSE(retVal);
|
||||
EXPECT_EQ(deviceTS, 0u);
|
||||
}
|
||||
|
||||
} // namespace ULT
|
||||
|
Reference in New Issue
Block a user