Dynamically read timestamp resolution on Linux.

Related-To: NEO-2492
Change-Id: Ic76815496289ccecd8a76484e417e71b78b04932
Signed-off-by: Zdunowski, Piotr <piotr.zdunowski@intel.com>
This commit is contained in:
Zdunowski, Piotr
2019-06-10 15:50:14 +02:00
committed by sys_ocldev
parent 474c25eca6
commit 4f9840246f
3 changed files with 59 additions and 0 deletions

View File

@@ -194,6 +194,40 @@ TEST_F(DrmTimeTest, detect) {
delete drm;
}
TEST_F(DrmTimeTest, givenGpuTimestampResolutionQueryWhenIoctlFailsThenDefaultResolutionIsReturned) {
auto defaultResolution = platformDevices[0]->capabilityTable.defaultProfilingTimerResolution;
auto drm = std::make_unique<DrmMockCustom>();
osTime->updateDrm(drm.get());
drm->getParamRetValue = 0;
drm->ioctl_res = -1;
auto result = osTime->getDynamicDeviceTimerResolution(*platformDevices[0]);
EXPECT_DOUBLE_EQ(result, defaultResolution);
}
TEST_F(DrmTimeTest, givenGpuTimestampResolutionQueryWhenNoDrmThenDefaultResolutionIsReturned) {
osTime->updateDrm(nullptr);
auto defaultResolution = platformDevices[0]->capabilityTable.defaultProfilingTimerResolution;
auto result = osTime->getDynamicDeviceTimerResolution(*platformDevices[0]);
EXPECT_DOUBLE_EQ(result, defaultResolution);
}
TEST_F(DrmTimeTest, givenGpuTimestampResolutionQueryWhenIoctlSuccedsThenCorrectResolutionIsReturned) {
auto drm = std::make_unique<DrmMockCustom>();
osTime->updateDrm(drm.get());
// 19200000 is frequency yelding 52.083ns resolution
drm->getParamRetValue = 19200000;
drm->ioctl_res = 0;
auto result = osTime->getDynamicDeviceTimerResolution(*platformDevices[0]);
EXPECT_DOUBLE_EQ(result, 52.08333333333333);
}
TEST_F(DrmTimeTest, givenAlwaysFailingResolutionFuncWhenGetHostTimerResolutionIsCalledThenReturnsZero) {
osTime->setResolutionFunc(resolutionFuncFalse);
auto retVal = osTime->getHostTimerResolution();