mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Apply timerResolution mod for L0 V1.1
Signed-off-by: John Falkowski <john.falkowski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
85f93cd51b
commit
218387dd47
@ -392,7 +392,7 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties)
|
||||
|
||||
pDeviceProperties->numSlices = hardwareInfo.gtSystemInfo.SliceCount * ((this->numSubDevices > 0) ? this->numSubDevices : 1);
|
||||
|
||||
pDeviceProperties->timerResolution = this->neoDevice->getDeviceInfo().outProfilingTimerResolution;
|
||||
pDeviceProperties->timerResolution = this->neoDevice->getDeviceInfo().outProfilingTimerClock;
|
||||
|
||||
pDeviceProperties->timestampValidBits = hardwareInfo.capabilityTable.timestampValidBits;
|
||||
|
||||
|
@ -75,7 +75,7 @@ NEO::SVMAllocsManager *DriverHandleImp::getSvmAllocsManager() {
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::getApiVersion(ze_api_version_t *version) {
|
||||
*version = ZE_API_VERSION_1_0;
|
||||
*version = ZE_API_VERSION_1_1;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,8 @@ bool testKernelTimestampHostQuery(ze_context_handle_t &context,
|
||||
<< " Kernel start: " << std::dec << kernelTsResults.context.kernelStart << " cycles\n"
|
||||
<< " Kernel end: " << std::dec << kernelTsResults.context.kernelEnd << " cycles\n"
|
||||
<< " Global end: " << std::dec << kernelTsResults.global.kernelEnd << " cycles\n"
|
||||
<< " Kernel duration : " << std::dec << kernelDuration << " cycles, " << kernelDuration * timerResolution << " ns\n";
|
||||
<< " timerResolution clock: " << std::dec << timerResolution << " cycles/s\n"
|
||||
<< " Kernel duration : " << std::dec << kernelDuration << " cycles, " << kernelDuration * (1000000000.0 / static_cast<double>(timerResolution)) << " ns\n";
|
||||
|
||||
// Cleanup
|
||||
SUCCESS_OR_TERMINATE(zeMemFree(context, dstBuffer));
|
||||
@ -342,7 +343,8 @@ bool testKernelTimestampApendQuery(ze_context_handle_t &context,
|
||||
<< " Kernel start: " << std::dec << kernelTsResults->context.kernelStart << " cycles\n"
|
||||
<< " Kernel end: " << std::dec << kernelTsResults->context.kernelEnd << " cycles\n"
|
||||
<< " Global end: " << std::dec << kernelTsResults->global.kernelEnd << " cycles\n"
|
||||
<< " Kernel duration : " << std::dec << kernelDuration << " cycles, " << kernelDuration * timerResolution << " ns\n";
|
||||
<< " timerResolution clock: " << std::dec << timerResolution << " cycles/s\n"
|
||||
<< " Kernel duration : " << std::dec << kernelDuration << " cycles, " << kernelDuration * (1000000000.0 / static_cast<double>(timerResolution)) << " ns\n";
|
||||
|
||||
// Cleanup
|
||||
SUCCESS_OR_TERMINATE(zeMemFree(context, dstBuffer));
|
||||
|
@ -401,6 +401,9 @@ class FalseCpuGpuTime : public NEO::OSTime {
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override {
|
||||
return NEO::OSTime::getDeviceTimerResolution(hwInfo);
|
||||
}
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override {
|
||||
return static_cast<uint64_t>(1000000000.0 / OSTime::getDeviceTimerResolution(hwInfo));
|
||||
}
|
||||
uint64_t getCpuRawTimestamp() override {
|
||||
return 0;
|
||||
}
|
||||
@ -438,6 +441,20 @@ TEST_F(GlobalTimestampTest, whenGetGlobalTimestampCalledAndGetCpuGpuTimeIsFalseR
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, result);
|
||||
}
|
||||
|
||||
TEST_F(GlobalTimestampTest, whenGetProfilingTimerClockandProfilingTimerResolutionThenVerifyRelation) {
|
||||
neoDevice->setOSTime(new FalseCpuGpuTime());
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
|
||||
uint64_t timerClock = neoDevice->getProfilingTimerClock();
|
||||
EXPECT_NE(timerClock, 0u);
|
||||
double timerResolution = neoDevice->getProfilingTimerResolution();
|
||||
EXPECT_NE(timerResolution, 0.0);
|
||||
EXPECT_EQ(timerClock, static_cast<uint64_t>(1000000000.0 / timerResolution));
|
||||
}
|
||||
|
||||
class FalseCpuTime : public NEO::OSTime {
|
||||
public:
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime) override {
|
||||
@ -452,6 +469,9 @@ class FalseCpuTime : public NEO::OSTime {
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override {
|
||||
return NEO::OSTime::getDeviceTimerResolution(hwInfo);
|
||||
}
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override {
|
||||
return static_cast<uint64_t>(1000000000.0 / OSTime::getDeviceTimerResolution(hwInfo));
|
||||
}
|
||||
uint64_t getCpuRawTimestamp() override {
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -91,6 +91,10 @@ class MyOSTime : public OSTime {
|
||||
EXPECT_FALSE(true);
|
||||
return 1.0;
|
||||
}
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override {
|
||||
EXPECT_FALSE(true);
|
||||
return 0;
|
||||
}
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime) override {
|
||||
EXPECT_FALSE(true);
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -27,6 +27,9 @@ class MockOSTime : public OSTime {
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override {
|
||||
return OSTime::getDeviceTimerResolution(hwInfo);
|
||||
}
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override {
|
||||
return static_cast<uint64_t>(1000000000.0 / OSTime::getDeviceTimerResolution(hwInfo));
|
||||
}
|
||||
uint64_t getCpuRawTimestamp() override {
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -195,6 +195,31 @@ TEST_F(DrmTimeTest, givenGpuTimestampResolutionQueryWhenIoctlFailsThenDefaultRes
|
||||
EXPECT_DOUBLE_EQ(result, defaultResolution);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, givenGetDynamicDeviceTimerClockWhenIoctlFailsThenDefaultClockIsReturned) {
|
||||
auto defaultResolution = defaultHwInfo->capabilityTable.defaultProfilingTimerResolution;
|
||||
|
||||
auto drm = new DrmMockCustom();
|
||||
osTime->updateDrm(drm);
|
||||
|
||||
drm->getParamRetValue = 0;
|
||||
drm->ioctl_res = -1;
|
||||
|
||||
auto result = osTime->getDynamicDeviceTimerClock(*defaultHwInfo);
|
||||
auto expectedResult = static_cast<uint64_t>(1000000000.0 / defaultResolution);
|
||||
EXPECT_DOUBLE_EQ(result, expectedResult);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, givenGetDynamicDeviceTimerClockWhenIoctlSucceedsThenNonDefaultClockIsReturned) {
|
||||
auto drm = new DrmMockCustom();
|
||||
osTime->updateDrm(drm);
|
||||
|
||||
uint64_t frequency = 1500;
|
||||
drm->getParamRetValue = static_cast<int>(frequency);
|
||||
|
||||
auto result = osTime->getDynamicDeviceTimerClock(*defaultHwInfo);
|
||||
EXPECT_EQ(result, frequency);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, givenGpuTimestampResolutionQueryWhenNoDrmThenDefaultResolutionIsReturned) {
|
||||
osTime->updateDrm(nullptr);
|
||||
|
||||
|
@ -436,6 +436,10 @@ class MyOSTime : public OSTime {
|
||||
EXPECT_FALSE(true);
|
||||
return 1.0;
|
||||
}
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override {
|
||||
EXPECT_FALSE(true);
|
||||
return 0;
|
||||
}
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime) override {
|
||||
EXPECT_FALSE(true);
|
||||
return false;
|
||||
|
@ -208,6 +208,10 @@ double Device::getProfilingTimerResolution() {
|
||||
return osTime->getDynamicDeviceTimerResolution(getHardwareInfo());
|
||||
}
|
||||
|
||||
uint64_t Device::getProfilingTimerClock() {
|
||||
return osTime->getDynamicDeviceTimerClock(getHardwareInfo());
|
||||
}
|
||||
|
||||
bool Device::isSimulation() const {
|
||||
auto &hwInfo = getHardwareInfo();
|
||||
|
||||
|
@ -64,6 +64,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
||||
GmmClientContext *getGmmClientContext() const;
|
||||
OSTime *getOSTime() const { return osTime.get(); };
|
||||
double getProfilingTimerResolution();
|
||||
uint64_t getProfilingTimerClock();
|
||||
double getPlatformHostTimerResolution() const;
|
||||
bool isSimulation() const;
|
||||
GFXCORE_FAMILY getRenderCoreFamily() const;
|
||||
|
@ -71,6 +71,9 @@ void Device::initializeCaps() {
|
||||
deviceInfo.profilingTimerResolution = getProfilingTimerResolution();
|
||||
if (DebugManager.flags.OverrideProfilingTimerResolution.get() != -1) {
|
||||
deviceInfo.profilingTimerResolution = static_cast<double>(DebugManager.flags.OverrideProfilingTimerResolution.get());
|
||||
deviceInfo.outProfilingTimerClock = static_cast<size_t>(1000000000.0 / deviceInfo.profilingTimerResolution);
|
||||
} else {
|
||||
deviceInfo.outProfilingTimerClock = static_cast<size_t>(getProfilingTimerClock());
|
||||
}
|
||||
|
||||
deviceInfo.outProfilingTimerResolution = static_cast<size_t>(deviceInfo.profilingTimerResolution);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -30,6 +30,7 @@ struct DeviceInfo {
|
||||
size_t maxWorkGroupSize;
|
||||
size_t maxWorkItemSizes[3];
|
||||
size_t outProfilingTimerResolution;
|
||||
size_t outProfilingTimerClock;
|
||||
size_t printfBufferSize;
|
||||
uint32_t addressBits;
|
||||
uint32_t computeUnitsUsedForScratch;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -155,6 +155,22 @@ double OSTimeLinux::getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo)
|
||||
return OSTime::getDeviceTimerResolution(hwInfo);
|
||||
}
|
||||
|
||||
uint64_t OSTimeLinux::getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const {
|
||||
if (pDrm) {
|
||||
drm_i915_getparam_t getParam = {};
|
||||
int frequency = 0;
|
||||
|
||||
getParam.param = I915_PARAM_CS_TIMESTAMP_FREQUENCY;
|
||||
getParam.value = &frequency;
|
||||
auto error = pDrm->ioctl(DRM_IOCTL_I915_GETPARAM, &getParam);
|
||||
|
||||
if (!error) {
|
||||
return static_cast<uint64_t>(frequency);
|
||||
}
|
||||
}
|
||||
return static_cast<uint64_t>(1000000000.0 / OSTime::getDeviceTimerResolution(hwInfo));
|
||||
}
|
||||
|
||||
uint64_t OSTimeLinux::getCpuRawTimestamp() {
|
||||
uint64_t timesInNsec = 0;
|
||||
uint64_t ticksInNsec = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -30,6 +30,7 @@ class OSTimeLinux : public OSTime {
|
||||
bool getGpuTimeSplitted(uint64_t *timestamp);
|
||||
double getHostTimerResolution() const override;
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override;
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override;
|
||||
uint64_t getCpuRawTimestamp() override;
|
||||
|
||||
protected:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -29,6 +29,7 @@ class OSTime {
|
||||
virtual bool getCpuGpuTime(TimeStampData *pGpuCpuTime) = 0;
|
||||
virtual double getHostTimerResolution() const = 0;
|
||||
virtual double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const = 0;
|
||||
virtual uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const = 0;
|
||||
virtual uint64_t getCpuRawTimestamp() = 0;
|
||||
OSInterface *getOSInterface() const {
|
||||
return osInterface;
|
||||
|
@ -107,6 +107,15 @@ double OSTimeWin::getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) co
|
||||
return retVal;
|
||||
}
|
||||
|
||||
uint64_t OSTimeWin::getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const {
|
||||
uint64_t retVal = 0u;
|
||||
if (wddm) {
|
||||
retVal = static_cast<uint64_t>(wddm->getTimestampFrequency());
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
uint64_t OSTimeWin::getCpuRawTimestamp() {
|
||||
LARGE_INTEGER cpuRawTimestamp = {};
|
||||
this->QueryPerfomanceCounterFnc(&cpuRawTimestamp);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -22,6 +22,7 @@ class OSTimeWin : public OSTime {
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime) override;
|
||||
double getHostTimerResolution() const override;
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override;
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override;
|
||||
uint64_t getCpuRawTimestamp() override;
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user