mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
fix: add mechanism to detect gpu timestamp overflows
unify naming CpuGpu to GpuCpu Related-To: NEO-8394 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
26666d8c6f
commit
4dfa12c8eb
@@ -935,7 +935,7 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties)
|
||||
|
||||
ze_result_t DeviceImp::getGlobalTimestamps(uint64_t *hostTimestamp, uint64_t *deviceTimestamp) {
|
||||
NEO::TimeStampData queueTimeStamp;
|
||||
bool retVal = this->neoDevice->getOSTime()->getCpuGpuTime(&queueTimeStamp);
|
||||
bool retVal = this->neoDevice->getOSTime()->getGpuCpuTime(&queueTimeStamp);
|
||||
if (!retVal)
|
||||
return ZE_RESULT_ERROR_DEVICE_LOST;
|
||||
|
||||
|
||||
@@ -415,7 +415,7 @@ void Event::setReferenceTs(uint64_t currentCpuTimeStamp) {
|
||||
const auto recalculate =
|
||||
(currentCpuTimeStamp - referenceTs.cpuTimeinNS) > timestampRefreshIntervalInNanoSec;
|
||||
if (referenceTs.cpuTimeinNS == 0 || recalculate) {
|
||||
device->getNEODevice()->getOSTime()->getCpuGpuTime(&referenceTs);
|
||||
device->getNEODevice()->getOSTime()->getGpuCpuTime(&referenceTs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,9 +186,9 @@ struct SingleRootMultiSubDeviceFixtureWithImplicitScaling : public SingleRootMul
|
||||
SingleRootMultiSubDeviceFixtureWithImplicitScaling() : SingleRootMultiSubDeviceFixtureWithImplicitScalingImpl(copyEngineCount, implicitScalingArg){};
|
||||
};
|
||||
|
||||
class FalseCpuGpuDeviceTime : public NEO::DeviceTime {
|
||||
class FalseGpuCpuDeviceTime : public NEO::DeviceTime {
|
||||
public:
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
return false;
|
||||
}
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override {
|
||||
@@ -199,10 +199,10 @@ class FalseCpuGpuDeviceTime : public NEO::DeviceTime {
|
||||
}
|
||||
};
|
||||
|
||||
class FalseCpuGpuTime : public NEO::OSTime {
|
||||
class FalseGpuCpuTime : public NEO::OSTime {
|
||||
public:
|
||||
FalseCpuGpuTime() {
|
||||
this->deviceTime = std::make_unique<FalseCpuGpuDeviceTime>();
|
||||
FalseGpuCpuTime() {
|
||||
this->deviceTime = std::make_unique<FalseGpuCpuDeviceTime>();
|
||||
}
|
||||
|
||||
bool getCpuTime(uint64_t *timeStamp) override {
|
||||
@@ -215,7 +215,7 @@ class FalseCpuGpuTime : public NEO::OSTime {
|
||||
return 0;
|
||||
}
|
||||
static std::unique_ptr<OSTime> create() {
|
||||
return std::unique_ptr<OSTime>(new FalseCpuGpuTime());
|
||||
return std::unique_ptr<OSTime>(new FalseGpuCpuTime());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1533,11 +1533,11 @@ struct GlobalTimestampTest : public ::testing::Test {
|
||||
const uint32_t numRootDevices = 2u;
|
||||
};
|
||||
|
||||
TEST_F(GlobalTimestampTest, whenGetGlobalTimestampCalledAndGetCpuGpuTimeIsFalseReturnError) {
|
||||
TEST_F(GlobalTimestampTest, whenGetGlobalTimestampCalledAndGetGpuCpuTimeIsFalseReturnError) {
|
||||
uint64_t hostTs = 0u;
|
||||
uint64_t deviceTs = 0u;
|
||||
|
||||
neoDevice->setOSTime(new FalseCpuGpuTime());
|
||||
neoDevice->setOSTime(new FalseGpuCpuTime());
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
@@ -1549,7 +1549,7 @@ TEST_F(GlobalTimestampTest, whenGetGlobalTimestampCalledAndGetCpuGpuTimeIsFalseR
|
||||
}
|
||||
|
||||
TEST_F(GlobalTimestampTest, whenGetProfilingTimerClockandProfilingTimerResolutionThenVerifyRelation) {
|
||||
neoDevice->setOSTime(new FalseCpuGpuTime());
|
||||
neoDevice->setOSTime(new FalseGpuCpuTime());
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
@@ -1563,7 +1563,7 @@ TEST_F(GlobalTimestampTest, whenGetProfilingTimerClockandProfilingTimerResolutio
|
||||
}
|
||||
|
||||
TEST_F(GlobalTimestampTest, whenQueryingForTimerResolutionWithLegacyDevicePropertiesStructThenDefaultTimerResolutionInNanoSecondsIsReturned) {
|
||||
neoDevice->setOSTime(new FalseCpuGpuTime());
|
||||
neoDevice->setOSTime(new FalseGpuCpuTime());
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
std::unique_ptr<L0::DriverHandleImp> driverHandle = std::make_unique<L0::DriverHandleImp>();
|
||||
@@ -1579,7 +1579,7 @@ TEST_F(GlobalTimestampTest, whenQueryingForTimerResolutionWithLegacyDeviceProper
|
||||
}
|
||||
|
||||
TEST_F(GlobalTimestampTest, whenQueryingForTimerResolutionWithDeviceProperties_1_2_StructThenDefaultTimerResolutionInCyclesPerSecondsIsReturned) {
|
||||
neoDevice->setOSTime(new FalseCpuGpuTime());
|
||||
neoDevice->setOSTime(new FalseGpuCpuTime());
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
std::unique_ptr<L0::DriverHandleImp> driverHandle = std::make_unique<L0::DriverHandleImp>();
|
||||
@@ -1598,7 +1598,7 @@ TEST_F(GlobalTimestampTest, whenQueryingForTimerResolutionWithUseCyclesPerSecond
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.UseCyclesPerSecondTimer.set(1u);
|
||||
|
||||
neoDevice->setOSTime(new FalseCpuGpuTime());
|
||||
neoDevice->setOSTime(new FalseGpuCpuTime());
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
std::unique_ptr<L0::DriverHandleImp> driverHandle = std::make_unique<L0::DriverHandleImp>();
|
||||
@@ -1615,7 +1615,7 @@ TEST_F(GlobalTimestampTest, whenQueryingForTimerResolutionWithUseCyclesPerSecond
|
||||
|
||||
class FalseCpuDeviceTime : public NEO::DeviceTime {
|
||||
public:
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, NEO::OSTime *) override {
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, NEO::OSTime *) override {
|
||||
pGpuCpuTime->cpuTimeinNS = mockCpuTimeInNs;
|
||||
pGpuCpuTime->gpuTimeStamp = mockGpuTimeInNs;
|
||||
return true;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_driver_info.h"
|
||||
#include "shared/test/common/mocks/mock_driver_model.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
@@ -312,22 +313,6 @@ TEST_F(SysmanMultiDeviceFixture, GivenValidEffectiveUserIdCheckWhetherPermission
|
||||
}
|
||||
}
|
||||
|
||||
class UnknownDriverModel : public DriverModel {
|
||||
public:
|
||||
UnknownDriverModel() : DriverModel(DriverModelType::UNKNOWN) {}
|
||||
void setGmmInputArgs(void *args) override {}
|
||||
uint32_t getDeviceHandle() const override { return 0u; }
|
||||
PhysicalDevicePciBusInfo getPciBusInfo() const override {
|
||||
PhysicalDevicePciBusInfo pciBusInfo(PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue);
|
||||
return pciBusInfo;
|
||||
}
|
||||
PhysicalDevicePciSpeedInfo getPciSpeedInfo() const override { return {}; }
|
||||
|
||||
bool isGpuHangDetected(OsContext &osContext) override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(SysmanUnknownDriverModelTest, GivenDriverModelTypeIsNotDrmWhenExecutingSysmanOnLinuxThenErrorIsReturned) {
|
||||
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
|
||||
hwInfo.capabilityTable.levelZeroSupported = true;
|
||||
@@ -335,7 +320,7 @@ TEST(SysmanUnknownDriverModelTest, GivenDriverModelTypeIsNotDrmWhenExecutingSysm
|
||||
execEnv->prepareRootDeviceEnvironments(1);
|
||||
execEnv->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(NEO::defaultHwInfo.get());
|
||||
execEnv->rootDeviceEnvironments[0]->osInterface = std::make_unique<NEO::OSInterface>();
|
||||
execEnv->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::make_unique<UnknownDriverModel>());
|
||||
execEnv->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::make_unique<NEO::MockDriverModel>());
|
||||
|
||||
auto pSysmanDeviceImp = std::make_unique<L0::Sysman::SysmanDeviceImp>(execEnv, 0);
|
||||
auto pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pSysmanDeviceImp->pOsSysman);
|
||||
|
||||
@@ -299,11 +299,11 @@ TEST_F(MetricIpSamplingTimestampTest, GivenEnumerationIsSuccessfulWhenReadingMet
|
||||
EXPECT_NE(metricTimestamp, 0UL);
|
||||
}
|
||||
|
||||
TEST_F(MetricIpSamplingTimestampTest, GivenGetCpuGpuTimeIsFalseWhenReadingMetricsFrequencyThenValuesAreZero) {
|
||||
TEST_F(MetricIpSamplingTimestampTest, GivenGetGpuCpuTimeIsFalseWhenReadingMetricsFrequencyThenValuesAreZero) {
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, device->getMetricDeviceContext().enableMetricApi());
|
||||
|
||||
neoDevice->setOSTime(new FalseCpuGpuTime());
|
||||
neoDevice->setOSTime(new FalseGpuCpuTime());
|
||||
|
||||
ze_device_properties_t deviceProps = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2, nullptr};
|
||||
device->getProperties(&deviceProps);
|
||||
|
||||
@@ -786,7 +786,7 @@ TEST_F(MetricEnumerationTest, GivenEnumerationIsSuccessfulWhenFailingToReadMetri
|
||||
|
||||
globalTimestamp = 1;
|
||||
metricTimestamp = 1;
|
||||
neoDevice->setOSTime(new FalseCpuGpuTime());
|
||||
neoDevice->setOSTime(new FalseGpuCpuTime());
|
||||
EXPECT_EQ(L0::zetMetricGroupGetGlobalTimestampsExp(metricGroupHandle, synchronizedWithHost, &globalTimestamp, &metricTimestamp), ZE_RESULT_ERROR_DEVICE_LOST);
|
||||
EXPECT_EQ(globalTimestamp, 0UL);
|
||||
EXPECT_EQ(metricTimestamp, 0UL);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_driver_info.h"
|
||||
#include "shared/test/common/mocks/mock_driver_model.h"
|
||||
#include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
@@ -800,27 +801,11 @@ TEST_F(SysmanMultiDeviceFixture, GivenSysmanEnvironmentVariableSetWhenCreateL0De
|
||||
EXPECT_EQ(device->getSysmanHandle(), nullptr);
|
||||
}
|
||||
|
||||
class UnknownDriverModel : public DriverModel {
|
||||
public:
|
||||
UnknownDriverModel() : DriverModel(DriverModelType::UNKNOWN) {}
|
||||
void setGmmInputArgs(void *args) override {}
|
||||
uint32_t getDeviceHandle() const override { return 0u; }
|
||||
PhysicalDevicePciBusInfo getPciBusInfo() const override {
|
||||
PhysicalDevicePciBusInfo pciBusInfo(PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue, PhysicalDevicePciBusInfo::invalidValue);
|
||||
return pciBusInfo;
|
||||
}
|
||||
PhysicalDevicePciSpeedInfo getPciSpeedInfo() const override { return {}; }
|
||||
|
||||
bool isGpuHangDetected(OsContext &osContext) override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
using SysmanUnknownDriverModelTest = Test<DeviceFixture>;
|
||||
TEST_F(SysmanUnknownDriverModelTest, GivenDriverModelTypeIsNotDrmWhenExecutingSysmanOnLinuxThenErrorIsReturned) {
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique<NEO::OSInterface>();
|
||||
auto &osInterface = device->getOsInterface();
|
||||
osInterface.setDriverModel(std::make_unique<UnknownDriverModel>());
|
||||
osInterface.setDriverModel(std::make_unique<NEO::MockDriverModel>());
|
||||
auto pSysmanDeviceImp = std::make_unique<SysmanDeviceImp>(device->toHandle());
|
||||
auto pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pSysmanDeviceImp->pOsSysman);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxSysmanImp->init());
|
||||
|
||||
@@ -227,7 +227,7 @@ void CommandQueueHw<Family>::setupEvent(EventBuilder &eventBuilder, cl_event *ou
|
||||
|
||||
if (eventObj->isProfilingEnabled()) {
|
||||
TimeStampData queueTimeStamp;
|
||||
getDevice().getOSTime()->getCpuGpuTime(&queueTimeStamp);
|
||||
getDevice().getOSTime()->getGpuCpuTime(&queueTimeStamp);
|
||||
eventObj->setQueueTimeStamp(queueTimeStamp);
|
||||
|
||||
if (isCommandWithoutKernel(cmdType) && cmdType != CL_COMMAND_MARKER) {
|
||||
|
||||
@@ -61,7 +61,7 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
eventBuilder.create<Event>(this, transferProperties.cmdType, CompletionStamp::notReady, CompletionStamp::notReady);
|
||||
outEventObj = eventBuilder.getEvent();
|
||||
TimeStampData queueTimeStamp;
|
||||
getDevice().getOSTime()->getCpuGpuTime(&queueTimeStamp);
|
||||
getDevice().getOSTime()->getGpuCpuTime(&queueTimeStamp);
|
||||
outEventObj->setQueueTimeStamp(queueTimeStamp);
|
||||
outEventObj->setCPUProfilingPath(true);
|
||||
*eventsRequest.outEvent = outEventObj;
|
||||
@@ -99,7 +99,7 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
|
||||
if (outEventObj) {
|
||||
TimeStampData submitTimeStamp;
|
||||
getDevice().getOSTime()->getCpuGpuTime(&submitTimeStamp);
|
||||
getDevice().getOSTime()->getGpuCpuTime(&submitTimeStamp);
|
||||
outEventObj->setSubmitTimeStamp(submitTimeStamp);
|
||||
}
|
||||
// wait for the completness of previous commands
|
||||
|
||||
@@ -421,7 +421,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
|
||||
|
||||
if (eventBuilder.getEvent() && isProfilingEnabled()) {
|
||||
TimeStampData submitTimeStamp;
|
||||
getDevice().getOSTime()->getCpuGpuTime(&submitTimeStamp);
|
||||
getDevice().getOSTime()->getGpuCpuTime(&submitTimeStamp);
|
||||
eventBuilder.getEvent()->setSubmitTimeStamp(submitTimeStamp);
|
||||
eventBuilder.getEvent()->setStartTimeStamp();
|
||||
}
|
||||
@@ -851,7 +851,7 @@ CompletionStamp CommandQueueHw<GfxFamily>::enqueueNonBlocked(
|
||||
|
||||
if (isProfilingEnabled() && eventBuilder.getEvent()) {
|
||||
TimeStampData submitTimeStamp;
|
||||
getDevice().getOSTime()->getCpuGpuTime(&submitTimeStamp);
|
||||
getDevice().getOSTime()->getGpuCpuTime(&submitTimeStamp);
|
||||
eventBuilder.getEvent()->setSubmitTimeStamp(submitTimeStamp);
|
||||
|
||||
auto hwTimestampNode = eventBuilder.getEvent()->getHwTimeStampNode();
|
||||
@@ -1118,7 +1118,7 @@ CompletionStamp CommandQueueHw<GfxFamily>::enqueueCommandWithoutKernel(
|
||||
|
||||
if (eventBuilder.getEvent() && isProfilingEnabled()) {
|
||||
TimeStampData submitTimeStamp;
|
||||
getDevice().getOSTime()->getCpuGpuTime(&submitTimeStamp);
|
||||
getDevice().getOSTime()->getGpuCpuTime(&submitTimeStamp);
|
||||
eventBuilder.getEvent()->setSubmitTimeStamp(submitTimeStamp);
|
||||
eventBuilder.getEvent()->setStartTimeStamp();
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ void Event::calculateProfilingDataInternal(uint64_t contextStartTS, uint64_t con
|
||||
|
||||
if (DebugManager.flags.EnableDeviceBasedTimestamps.get()) {
|
||||
startTimeStamp = static_cast<uint64_t>(globalStartTS * frequency);
|
||||
if (startTimeStamp < gpuQueueTimeStamp) {
|
||||
while (startTimeStamp < gpuQueueTimeStamp) {
|
||||
startTimeStamp += static_cast<uint64_t>((1ULL << gfxCoreHelper.getGlobalTimeStampBits()) * frequency);
|
||||
}
|
||||
} else {
|
||||
@@ -612,7 +612,7 @@ void Event::submitCommand(bool abortTasks) {
|
||||
this->cmdQueue->getGpgpuCommandStreamReceiver().makeResident(*timeStampNode->getBaseGraphicsAllocation());
|
||||
cmdToProcess->timestamp = timeStampNode;
|
||||
}
|
||||
this->cmdQueue->getDevice().getOSTime()->getCpuGpuTime(&submitTimeStamp);
|
||||
this->cmdQueue->getDevice().getOSTime()->getGpuCpuTime(&submitTimeStamp);
|
||||
if (profilingCpuPath) {
|
||||
setStartTimeStamp();
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
using namespace NEO;
|
||||
|
||||
struct FailDeviceTime : public MockDeviceTime {
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *) override {
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *) override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -164,7 +164,7 @@ class FailingMockOSTime : public OSTime {
|
||||
|
||||
class FailingMockDeviceTime : public DeviceTime {
|
||||
public:
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class MyDeviceTime : public DeviceTime {
|
||||
EXPECT_FALSE(true);
|
||||
return 0;
|
||||
}
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *) override {
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *) override {
|
||||
EXPECT_FALSE(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -42,9 +42,11 @@ void PerformanceCountersFixture::setUp() {
|
||||
device = std::make_unique<MockClDevice>(new MockDevice());
|
||||
context = std::make_unique<MockContext>(device.get());
|
||||
queue = std::make_unique<MockCommandQueue>(context.get(), device.get(), &queueProperties, false);
|
||||
osInterface = std::unique_ptr<OSInterface>(new OSInterface());
|
||||
osInterface->setDriverModel(std::unique_ptr<DriverModel>(new DrmMock(*device->getExecutionEnvironment()->rootDeviceEnvironments[0])));
|
||||
device->setOSTime(new MockOSTimeLinux(osInterface.get()));
|
||||
auto &rootDeviceEnvironment = *device->getExecutionEnvironment()->rootDeviceEnvironments[0];
|
||||
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
rootDeviceEnvironment.osInterface->setDriverModel(std::unique_ptr<DriverModel>(new DrmMock(rootDeviceEnvironment)));
|
||||
|
||||
device->setOSTime(new MockOSTimeLinux(*rootDeviceEnvironment.osInterface));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -36,5 +36,5 @@ TEST_F(PerformanceCountersLinuxTest, WhenCreatingPerformanceCountersThenDrmFileD
|
||||
auto performanceCountersLinux = static_cast<PerformanceCountersLinux *>(performanceCounters.get());
|
||||
|
||||
EXPECT_EQ(LinuxAdapterType::DrmFileDescriptor, performanceCountersLinux->adapter.Type);
|
||||
EXPECT_EQ(osInterface->getDriverModel()->as<NEO::Drm>()->getFileDescriptor(), performanceCountersLinux->adapter.DrmFileDescriptor);
|
||||
EXPECT_EQ(device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>()->getFileDescriptor(), performanceCountersLinux->adapter.DrmFileDescriptor);
|
||||
}
|
||||
|
||||
@@ -361,8 +361,6 @@ void PerformanceCountersMetricsLibraryFixture::tearDown() {
|
||||
//////////////////////////////////////////////////////
|
||||
PerformanceCountersFixture::PerformanceCountersFixture() {
|
||||
executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
rootDeviceEnvironment = std::make_unique<RootDeviceEnvironment>(*executionEnvironment);
|
||||
rootDeviceEnvironment->setHwInfoAndInitHelpers(defaultHwInfo.get());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
@@ -226,8 +226,6 @@ struct PerformanceCountersFixture {
|
||||
std::unique_ptr<MockContext> context;
|
||||
std::unique_ptr<MockCommandQueue> queue;
|
||||
std::unique_ptr<MockExecutionEnvironment> executionEnvironment;
|
||||
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironment;
|
||||
std::unique_ptr<OSInterface> osInterface;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
@@ -215,9 +215,10 @@ struct PerformanceCountersMetricsLibraryTest : public PerformanceCountersMetrics
|
||||
public:
|
||||
void SetUp() override {
|
||||
PerformanceCountersMetricsLibraryFixture::setUp();
|
||||
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
|
||||
auto &gfxCoreHelper = rootDeviceEnvironment->getHelper<GfxCoreHelper>();
|
||||
osContext = std::make_unique<MockOsContext>(0, EngineDescriptorHelper::getDefaultDescriptor(gfxCoreHelper.getGpgpuEngineInstances(*rootDeviceEnvironment)[0],
|
||||
auto &rootDeviceEnvironment = *executionEnvironment->rootDeviceEnvironments[0];
|
||||
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
|
||||
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
|
||||
osContext = std::make_unique<MockOsContext>(0, EngineDescriptorHelper::getDefaultDescriptor(gfxCoreHelper.getGpgpuEngineInstances(rootDeviceEnvironment)[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(*hwInfo)));
|
||||
queue->getGpgpuCommandStreamReceiver().setupContext(*osContext);
|
||||
}
|
||||
|
||||
@@ -42,9 +42,10 @@ void PerformanceCountersFixture::setUp() {
|
||||
device = std::make_unique<MockClDevice>(new MockDevice());
|
||||
context = std::make_unique<MockContext>(device.get());
|
||||
queue = std::make_unique<MockCommandQueue>(context.get(), device.get(), &queueProperties, false);
|
||||
osInterface = std::unique_ptr<OSInterface>(new OSInterface());
|
||||
osInterface->setDriverModel(std::unique_ptr<DriverModel>(new WddmMock(*rootDeviceEnvironment)));
|
||||
device->setOSTime(new MockOSTimeWin(osInterface.get()));
|
||||
auto &rootDeviceEnvironment = *device->getExecutionEnvironment()->rootDeviceEnvironments[0];
|
||||
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
rootDeviceEnvironment.osInterface->setDriverModel(std::unique_ptr<DriverModel>(new WddmMock(rootDeviceEnvironment)));
|
||||
device->setOSTime(new MockOSTimeWin(*rootDeviceEnvironment.osInterface));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
@@ -505,7 +505,7 @@ class MyOSDeviceTime : public DeviceTime {
|
||||
EXPECT_FALSE(true);
|
||||
return 0;
|
||||
}
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *) override {
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *) override {
|
||||
EXPECT_FALSE(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ bool Device::createDeviceImpl() {
|
||||
|
||||
initializeCaps();
|
||||
|
||||
if (getOSTime()->getOSInterface()) {
|
||||
if (getRootDeviceEnvironment().osInterface) {
|
||||
if (hwInfo.capabilityTable.instrumentationEnabled) {
|
||||
performanceCounters = createPerformanceCountersFunc(this);
|
||||
}
|
||||
@@ -512,7 +512,7 @@ EngineControl &Device::getEngine(uint32_t index) {
|
||||
|
||||
bool Device::getDeviceAndHostTimer(uint64_t *deviceTimestamp, uint64_t *hostTimestamp) const {
|
||||
TimeStampData timeStamp;
|
||||
auto retVal = getOSTime()->getCpuGpuTime(&timeStamp);
|
||||
auto retVal = getOSTime()->getGpuCpuTime(&timeStamp);
|
||||
if (retVal) {
|
||||
*hostTimestamp = timeStamp.cpuTimeinNS;
|
||||
if (DebugManager.flags.EnableDeviceBasedTimestamps.get()) {
|
||||
|
||||
@@ -126,9 +126,7 @@ inline uint32_t GfxCoreHelperHw<GfxFamily>::calculateMaxWorkGroupSize(const Kern
|
||||
|
||||
template <typename GfxFamily>
|
||||
uint64_t GfxCoreHelperHw<GfxFamily>::getGpuTimeStampInNS(uint64_t timeStamp, double frequency) const {
|
||||
constexpr uint64_t mask = static_cast<uint64_t>(std::numeric_limits<typename GfxFamily::TimestampPacketType>::max());
|
||||
|
||||
return static_cast<uint64_t>((timeStamp & mask) * frequency);
|
||||
return static_cast<uint64_t>(timeStamp * frequency);
|
||||
}
|
||||
|
||||
constexpr uint32_t planarYuvMaxHeight = 16128;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace NEO {
|
||||
|
||||
std::unique_ptr<OSTime> OSTime::create(OSInterface *osInterface) {
|
||||
if (osInterface) {
|
||||
return OSTimeLinux::create(osInterface, std::make_unique<DeviceTimeDrm>(osInterface));
|
||||
return OSTimeLinux::create(*osInterface, std::make_unique<DeviceTimeDrm>(*osInterface));
|
||||
}
|
||||
|
||||
return std::make_unique<OSTime>(std::make_unique<DeviceTime>());
|
||||
|
||||
@@ -17,10 +17,10 @@ std::unique_ptr<OSTime> OSTime::create(OSInterface *osInterface) {
|
||||
if (nullptr == osInterface) {
|
||||
return std::make_unique<OSTime>(std::make_unique<DeviceTime>());
|
||||
} else if (osInterface->getDriverModel()->getDriverModelType() == DriverModelType::DRM) {
|
||||
return OSTimeLinux::create(osInterface, std::make_unique<DeviceTimeDrm>(osInterface));
|
||||
return OSTimeLinux::create(*osInterface, std::make_unique<DeviceTimeDrm>(*osInterface));
|
||||
} else {
|
||||
auto wddm = osInterface->getDriverModel()->as<Wddm>();
|
||||
return OSTimeLinux::create(osInterface, std::make_unique<DeviceTimeWddm>(wddm));
|
||||
return OSTimeLinux::create(*osInterface, std::make_unique<DeviceTimeWddm>(wddm));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace NEO {
|
||||
|
||||
std::unique_ptr<OSTime> OSTime::create(OSInterface *osInterface) {
|
||||
if (osInterface) {
|
||||
return OSTimeWin::create(osInterface);
|
||||
return OSTimeWin::create(*osInterface);
|
||||
}
|
||||
|
||||
return std::make_unique<OSTime>(std::make_unique<DeviceTime>());
|
||||
|
||||
@@ -17,10 +17,8 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
DeviceTimeDrm::DeviceTimeDrm(OSInterface *osInterface) {
|
||||
if (osInterface) {
|
||||
pDrm = osInterface->getDriverModel()->as<Drm>();
|
||||
}
|
||||
DeviceTimeDrm::DeviceTimeDrm(OSInterface &osInterface) {
|
||||
pDrm = osInterface.getDriverModel()->as<Drm>();
|
||||
timestampTypeDetect();
|
||||
}
|
||||
|
||||
@@ -28,9 +26,6 @@ void DeviceTimeDrm::timestampTypeDetect() {
|
||||
RegisterRead reg = {};
|
||||
int err;
|
||||
|
||||
if (pDrm == nullptr)
|
||||
return;
|
||||
|
||||
reg.offset = (REG_GLOBAL_TIMESTAMP_LDW | 1);
|
||||
auto ioctlHelper = pDrm->getIoctlHelper();
|
||||
err = ioctlHelper->ioctl(DrmIoctl::RegRead, ®);
|
||||
@@ -98,7 +93,11 @@ bool DeviceTimeDrm::getGpuTimeSplitted(uint64_t *timestamp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceTimeDrm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
std::optional<uint64_t> initialGpuTimeStamp{};
|
||||
bool waitingForGpuTimeStampOverflow = false;
|
||||
uint64_t gpuTimeStampOverflowCounter = 0;
|
||||
|
||||
bool DeviceTimeDrm::getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
if (nullptr == this->getGpuTime) {
|
||||
return false;
|
||||
}
|
||||
@@ -108,7 +107,6 @@ bool DeviceTimeDrm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
if (!osTime->getCpuTime(&pGpuCpuTime->cpuTimeinNS)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ class Drm;
|
||||
|
||||
class DeviceTimeDrm : public DeviceTime {
|
||||
public:
|
||||
DeviceTimeDrm(OSInterface *osInterface);
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override;
|
||||
DeviceTimeDrm(OSInterface &osInterface);
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) override;
|
||||
typedef bool (DeviceTimeDrm::*TimestampFunction)(uint64_t *);
|
||||
void timestampTypeDetect();
|
||||
TimestampFunction getGpuTime = nullptr;
|
||||
|
||||
@@ -1535,6 +1535,8 @@ void Drm::waitOnUserFences(const OsContextLinux &osContext, uint64_t address, ui
|
||||
completionFenceCpuAddress = ptrOffset(completionFenceCpuAddress, postSyncOffset);
|
||||
}
|
||||
}
|
||||
const HardwareInfo *Drm::getHardwareInfo() const { return rootDeviceEnvironment.getHardwareInfo(); }
|
||||
|
||||
template std::vector<uint16_t> Drm::query<uint16_t>(uint32_t queryId, uint32_t queryItemFlags);
|
||||
template std::vector<uint32_t> Drm::query<uint32_t>(uint32_t queryId, uint32_t queryItemFlags);
|
||||
template std::vector<uint64_t> Drm::query<uint64_t>(uint32_t queryId, uint32_t queryItemFlags);
|
||||
|
||||
@@ -195,6 +195,7 @@ class Drm : public DriverModel {
|
||||
const RootDeviceEnvironment &getRootDeviceEnvironment() const {
|
||||
return rootDeviceEnvironment;
|
||||
}
|
||||
const HardwareInfo *getHardwareInfo() const override;
|
||||
|
||||
bool resourceRegistrationEnabled() {
|
||||
return classHandles.size() > 0;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
#include "shared/source/os_interface/linux/os_time_linux.h"
|
||||
|
||||
#include "shared/source/os_interface/linux/device_time_drm.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
|
||||
#include <chrono>
|
||||
@@ -15,8 +16,13 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
OSTimeLinux::OSTimeLinux(OSInterface *osInterface, std::unique_ptr<DeviceTime> deviceTime) {
|
||||
this->osInterface = osInterface;
|
||||
OSTimeLinux::OSTimeLinux(OSInterface &osInterface, std::unique_ptr<DeviceTime> deviceTime) {
|
||||
this->osInterface = &osInterface;
|
||||
auto hwInfo = osInterface.getDriverModel()->getHardwareInfo();
|
||||
if (hwInfo->capabilityTable.timestampValidBits < 64) {
|
||||
this->maxGpuTimeStamp = 1ull << hwInfo->capabilityTable.timestampValidBits;
|
||||
}
|
||||
|
||||
resolutionFunc = &clock_getres;
|
||||
getTimeFunc = &clock_gettime;
|
||||
this->deviceTime = std::move(deviceTime);
|
||||
@@ -55,7 +61,7 @@ uint64_t OSTimeLinux::getCpuRawTimestamp() {
|
||||
return timesInNsec / ticksInNsec;
|
||||
}
|
||||
|
||||
std::unique_ptr<OSTime> OSTimeLinux::create(OSInterface *osInterface, std::unique_ptr<DeviceTime> deviceTime) {
|
||||
std::unique_ptr<OSTime> OSTimeLinux::create(OSInterface &osInterface, std::unique_ptr<DeviceTime> deviceTime) {
|
||||
return std::unique_ptr<OSTime>(new OSTimeLinux(osInterface, std::move(deviceTime)));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ namespace NEO {
|
||||
|
||||
class OSTimeLinux : public OSTime {
|
||||
public:
|
||||
OSTimeLinux(OSInterface *osInterface, std::unique_ptr<DeviceTime> deviceTime);
|
||||
OSTimeLinux(OSInterface &osInterface, std::unique_ptr<DeviceTime> deviceTime);
|
||||
bool getCpuTime(uint64_t *timeStamp) override;
|
||||
double getHostTimerResolution() const override;
|
||||
uint64_t getCpuRawTimestamp() override;
|
||||
|
||||
static std::unique_ptr<OSTime> create(OSInterface *osInterface, std::unique_ptr<DeviceTime> deviceTime);
|
||||
static std::unique_ptr<OSTime> create(OSInterface &osInterface, std::unique_ptr<DeviceTime> deviceTime);
|
||||
|
||||
protected:
|
||||
typedef int (*resolutionFunc_t)(clockid_t, struct timespec *);
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/device/sub_device.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/os_time_linux.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
|
||||
namespace NEO {
|
||||
@@ -20,7 +20,7 @@ namespace NEO {
|
||||
////////////////////////////////////////////////////
|
||||
std::unique_ptr<PerformanceCounters> PerformanceCounters::create(Device *device) {
|
||||
auto counter = std::make_unique<PerformanceCountersLinux>();
|
||||
auto drm = device->getOSTime()->getOSInterface()->getDriverModel()->as<Drm>();
|
||||
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<Drm>();
|
||||
auto &gfxCoreHelper = device->getGfxCoreHelper();
|
||||
UNRECOVERABLE_IF(counter == nullptr);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
namespace NEO {
|
||||
struct PhysicalDevicePciBusInfo;
|
||||
struct PhysicalDevicePciSpeedInfo;
|
||||
struct HardwareInfo;
|
||||
enum class DriverModelType;
|
||||
class ExecutionEnvironment;
|
||||
class MemoryManager;
|
||||
@@ -95,6 +96,8 @@ class DriverModel : public NonCopyableClass {
|
||||
virtual void cleanup() {}
|
||||
|
||||
virtual bool isGpuHangDetected(OsContext &osContext) = 0;
|
||||
virtual const HardwareInfo *getHardwareInfo() const = 0;
|
||||
|
||||
const TopologyMap &getTopologyMap() {
|
||||
return topologyMap;
|
||||
};
|
||||
|
||||
@@ -9,13 +9,15 @@
|
||||
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
double OSTime::getDeviceTimerResolution(HardwareInfo const &hwInfo) {
|
||||
return hwInfo.capabilityTable.defaultProfilingTimerResolution;
|
||||
};
|
||||
|
||||
bool DeviceTime::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
bool DeviceTime::getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
pGpuCpuTime->cpuTimeinNS = 0;
|
||||
pGpuCpuTime->gpuTimeStamp = 0;
|
||||
|
||||
@@ -29,6 +31,33 @@ uint64_t DeviceTime::getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) cons
|
||||
return static_cast<uint64_t>(1000000000.0 / OSTime::getDeviceTimerResolution(hwInfo));
|
||||
}
|
||||
|
||||
bool DeviceTime::getGpuCpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
if (!getGpuCpuTimeImpl(pGpuCpuTime, osTime)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto maxGpuTimeStampValue = osTime->getMaxGpuTimeStamp();
|
||||
|
||||
static std::mutex gpuTimeStampOverflowCounterMutex;
|
||||
std::lock_guard<std::mutex> lock(gpuTimeStampOverflowCounterMutex);
|
||||
pGpuCpuTime->gpuTimeStamp &= (maxGpuTimeStampValue - 1);
|
||||
if (!initialGpuTimeStamp) {
|
||||
initialGpuTimeStamp = pGpuCpuTime->gpuTimeStamp;
|
||||
waitingForGpuTimeStampOverflow = true;
|
||||
} else {
|
||||
if (waitingForGpuTimeStampOverflow && pGpuCpuTime->gpuTimeStamp < *initialGpuTimeStamp) {
|
||||
gpuTimeStampOverflowCounter++;
|
||||
waitingForGpuTimeStampOverflow = false;
|
||||
}
|
||||
if (!waitingForGpuTimeStampOverflow && pGpuCpuTime->gpuTimeStamp > *initialGpuTimeStamp) {
|
||||
waitingForGpuTimeStampOverflow = true;
|
||||
}
|
||||
|
||||
pGpuCpuTime->gpuTimeStamp += gpuTimeStampOverflowCounter * maxGpuTimeStampValue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OSTime::getCpuTime(uint64_t *timeStamp) {
|
||||
*timeStamp = 0;
|
||||
return true;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#define NSEC_PER_SEC (1000000000ULL)
|
||||
|
||||
@@ -25,9 +26,14 @@ class OSTime;
|
||||
class DeviceTime {
|
||||
public:
|
||||
virtual ~DeviceTime() = default;
|
||||
virtual bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime);
|
||||
bool getGpuCpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime);
|
||||
virtual bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime);
|
||||
virtual double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const;
|
||||
virtual uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const;
|
||||
|
||||
std::optional<uint64_t> initialGpuTimeStamp{};
|
||||
bool waitingForGpuTimeStampOverflow = false;
|
||||
uint64_t gpuTimeStampOverflowCounter = 0;
|
||||
};
|
||||
|
||||
class OSTime {
|
||||
@@ -39,13 +45,10 @@ class OSTime {
|
||||
virtual bool getCpuTime(uint64_t *timeStamp);
|
||||
virtual double getHostTimerResolution() const;
|
||||
virtual uint64_t getCpuRawTimestamp();
|
||||
OSInterface *getOSInterface() const {
|
||||
return osInterface;
|
||||
}
|
||||
|
||||
static double getDeviceTimerResolution(HardwareInfo const &hwInfo);
|
||||
bool getCpuGpuTime(TimeStampData *gpuCpuTime) {
|
||||
return deviceTime->getCpuGpuTime(gpuCpuTime, this);
|
||||
bool getGpuCpuTime(TimeStampData *gpuCpuTime) {
|
||||
return deviceTime->getGpuCpuTime(gpuCpuTime, this);
|
||||
}
|
||||
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const {
|
||||
@@ -56,9 +59,12 @@ class OSTime {
|
||||
return deviceTime->getDynamicDeviceTimerClock(hwInfo);
|
||||
}
|
||||
|
||||
uint64_t getMaxGpuTimeStamp() const { return maxGpuTimeStamp; }
|
||||
|
||||
protected:
|
||||
OSTime() = default;
|
||||
OSInterface *osInterface = nullptr;
|
||||
std::unique_ptr<DeviceTime> deviceTime;
|
||||
uint64_t maxGpuTimeStamp = 0;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||
|
||||
namespace NEO {
|
||||
bool DeviceTimeWddm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
bool DeviceTimeWddm::getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
bool retVal = false;
|
||||
|
||||
pGpuCpuTime->cpuTimeinNS = 0;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||
|
||||
namespace NEO {
|
||||
bool DeviceTimeWddm::getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
bool DeviceTimeWddm::getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
||||
bool retVal = false;
|
||||
|
||||
pGpuCpuTime->cpuTimeinNS = 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ struct TimeStampDataHeader;
|
||||
class DeviceTimeWddm : public DeviceTime {
|
||||
public:
|
||||
DeviceTimeWddm(Wddm *wddm);
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override;
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) override;
|
||||
double getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const override;
|
||||
uint64_t getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const override;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/source/os_interface/windows/os_time_win.h"
|
||||
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/windows/device_time_wddm.h"
|
||||
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||
|
||||
@@ -24,13 +25,17 @@ bool OSTimeWin::getCpuTime(uint64_t *timeStamp) {
|
||||
return true;
|
||||
};
|
||||
|
||||
std::unique_ptr<OSTime> OSTimeWin::create(OSInterface *osInterface) {
|
||||
std::unique_ptr<OSTime> OSTimeWin::create(OSInterface &osInterface) {
|
||||
return std::unique_ptr<OSTime>(new OSTimeWin(osInterface));
|
||||
}
|
||||
|
||||
OSTimeWin::OSTimeWin(OSInterface *osInterface) {
|
||||
this->osInterface = osInterface;
|
||||
Wddm *wddm = osInterface ? osInterface->getDriverModel()->as<Wddm>() : nullptr;
|
||||
OSTimeWin::OSTimeWin(OSInterface &osInterface) {
|
||||
this->osInterface = &osInterface;
|
||||
Wddm *wddm = osInterface.getDriverModel()->as<Wddm>();
|
||||
auto hwInfo = wddm->getHardwareInfo();
|
||||
if (hwInfo->capabilityTable.timestampValidBits < 64) {
|
||||
maxGpuTimeStamp = 1ull << hwInfo->capabilityTable.timestampValidBits;
|
||||
}
|
||||
this->deviceTime = std::make_unique<DeviceTimeWddm>(wddm);
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/os_time.h"
|
||||
#include "shared/source/os_interface/windows/gfx_escape_wrapper.h"
|
||||
#include "shared/source/os_interface/windows/windows_wrapper.h"
|
||||
@@ -17,12 +16,12 @@ class Wddm;
|
||||
class OSTimeWin : public OSTime {
|
||||
|
||||
public:
|
||||
OSTimeWin(OSInterface *osInterface);
|
||||
OSTimeWin(OSInterface &osInterface);
|
||||
bool getCpuTime(uint64_t *timeStamp) override;
|
||||
double getHostTimerResolution() const override;
|
||||
uint64_t getCpuRawTimestamp() override;
|
||||
|
||||
static std::unique_ptr<OSTime> create(OSInterface *osInterface);
|
||||
static std::unique_ptr<OSTime> create(OSInterface &osInterface);
|
||||
|
||||
protected:
|
||||
LARGE_INTEGER frequency;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/windows/os_time_win.h"
|
||||
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
||||
|
||||
namespace NEO {
|
||||
@@ -20,7 +19,7 @@ namespace NEO {
|
||||
/////////////////////////////////////////////////////
|
||||
std::unique_ptr<PerformanceCounters> PerformanceCounters::create(Device *device) {
|
||||
auto counter = std::make_unique<PerformanceCountersWin>();
|
||||
auto wddm = device->getOSTime()->getOSInterface()->getDriverModel()->as<Wddm>();
|
||||
auto wddm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<Wddm>();
|
||||
auto &gfxCoreHelper = device->getGfxCoreHelper();
|
||||
UNRECOVERABLE_IF(counter == nullptr);
|
||||
|
||||
|
||||
@@ -185,6 +185,7 @@ class Wddm : public DriverModel {
|
||||
}
|
||||
|
||||
const RootDeviceEnvironment &getRootDeviceEnvironment() const { return rootDeviceEnvironment; }
|
||||
const HardwareInfo *getHardwareInfo() const override { return rootDeviceEnvironment.getHardwareInfo(); }
|
||||
|
||||
uint32_t getTimestampFrequency() const { return timestampFrequency; }
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
||||
#include "shared/source/gmm_helper/gmm_interface.h"
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
@@ -418,6 +419,8 @@ int main(int argc, char **argv) {
|
||||
sipInitialized = true;
|
||||
}
|
||||
|
||||
Device::createPerformanceCountersFunc = [](Device *) -> std::unique_ptr<NEO::PerformanceCounters> { return {}; };
|
||||
|
||||
retVal = RUN_ALL_TESTS();
|
||||
|
||||
if (showTestStats) {
|
||||
|
||||
@@ -14,15 +14,26 @@
|
||||
namespace NEO {
|
||||
class MockDeviceTimeDrm : public DeviceTimeDrm {
|
||||
public:
|
||||
using DeviceTimeDrm::DeviceTimeDrm;
|
||||
using DeviceTimeDrm::pDrm;
|
||||
MockDeviceTimeDrm() : DeviceTimeDrm(nullptr) {
|
||||
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
if (callBaseGetGpuCpuTimeImpl) {
|
||||
return DeviceTimeDrm::getGpuCpuTimeImpl(pGpuCpuTime, osTime);
|
||||
}
|
||||
*pGpuCpuTime = gpuCpuTimeValue;
|
||||
return getGpuCpuTimeImplResult;
|
||||
}
|
||||
bool callBaseGetGpuCpuTimeImpl = true;
|
||||
bool getGpuCpuTimeImplResult = true;
|
||||
TimeStampData gpuCpuTimeValue{};
|
||||
};
|
||||
|
||||
class MockOSTimeLinux : public OSTimeLinux {
|
||||
public:
|
||||
MockOSTimeLinux(OSInterface *osInterface)
|
||||
: OSTimeLinux(osInterface, std::make_unique<MockDeviceTimeDrm>()) {
|
||||
using OSTimeLinux::maxGpuTimeStamp;
|
||||
MockOSTimeLinux(OSInterface &osInterface)
|
||||
: OSTimeLinux(osInterface, std::make_unique<MockDeviceTimeDrm>(osInterface)) {
|
||||
}
|
||||
void setResolutionFunc(resolutionFunc_t func) {
|
||||
this->resolutionFunc = func;
|
||||
@@ -35,7 +46,7 @@ class MockOSTimeLinux : public OSTimeLinux {
|
||||
static_cast<MockDeviceTimeDrm *>(this->deviceTime.get())->pDrm = drm;
|
||||
static_cast<MockDeviceTimeDrm *>(this->deviceTime.get())->timestampTypeDetect();
|
||||
}
|
||||
static std::unique_ptr<MockOSTimeLinux> create(OSInterface *osInterface) {
|
||||
static std::unique_ptr<MockOSTimeLinux> create(OSInterface &osInterface) {
|
||||
return std::unique_ptr<MockOSTimeLinux>(new MockOSTimeLinux(osInterface));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "shared/source/helpers/driver_model_type.h"
|
||||
#include "shared/source/os_interface/driver_info.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
@@ -41,6 +42,8 @@ class MockDriverModel : public NEO::DriverModel {
|
||||
|
||||
PhysicalDevicePciSpeedInfo getPciSpeedInfo() const override { return pciSpeedInfo; }
|
||||
|
||||
const HardwareInfo *getHardwareInfo() const override { return nullptr; }
|
||||
|
||||
PhysicalDevicePciSpeedInfo pciSpeedInfo{};
|
||||
PhysicalDevicePciBusInfo pciBusInfo{};
|
||||
bool isGpuHangDetectedToReturn{};
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace NEO {
|
||||
static int PerfTicks = 0;
|
||||
constexpr uint64_t convertToNs = 100;
|
||||
class MockDeviceTime : public DeviceTime {
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
pGpuCpuTime->gpuTimeStamp = ++PerfTicks;
|
||||
pGpuCpuTime->cpuTimeinNS = PerfTicks * convertToNs;
|
||||
return true;
|
||||
@@ -54,7 +54,7 @@ class MockDeviceTimeWithConstTimestamp : public DeviceTime {
|
||||
static constexpr uint64_t cpuTimeInNs = 1u;
|
||||
static constexpr uint64_t gpuTimestamp = 2u;
|
||||
|
||||
bool getCpuGpuTime(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
pGpuCpuTime->gpuTimeStamp = gpuTimestamp;
|
||||
pGpuCpuTime->cpuTimeinNS = cpuTimeInNs;
|
||||
return true;
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
namespace NEO {
|
||||
class MockOSTimeWin : public OSTimeWin {
|
||||
public:
|
||||
MockOSTimeWin(OSInterface *osInterface) : OSTimeWin(osInterface){};
|
||||
using OSTimeWin::deviceTime;
|
||||
using OSTimeWin::maxGpuTimeStamp;
|
||||
MockOSTimeWin(OSInterface &osInterface) : OSTimeWin(osInterface){};
|
||||
|
||||
void overrideQueryPerformanceCounterFunction(decltype(&QueryPerformanceCounter) function) {
|
||||
this->QueryPerfomanceCounterFnc = function;
|
||||
|
||||
@@ -78,7 +78,7 @@ class DrmMockTime : public DrmMockSuccess {
|
||||
using DrmMockSuccess::DrmMockSuccess;
|
||||
int ioctl(DrmIoctl request, void *arg) override {
|
||||
auto *reg = reinterpret_cast<NEO::RegisterRead *>(arg);
|
||||
reg->value = getVal() << 32;
|
||||
reg->value = getVal() << 32 | 0x1;
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "shared/test/common/mocks/mock_compiler_interface.h"
|
||||
#include "shared/test/common/mocks/mock_compilers.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_driver_model.h"
|
||||
#include "shared/test/common/mocks/mock_io_functions.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_product_helper.h"
|
||||
@@ -392,29 +393,13 @@ TEST_F(DeviceGetCapsTest, givenDeviceWithMidThreadPreemptionWhenDeviceIsCreatedT
|
||||
}
|
||||
|
||||
TEST_F(DeviceGetCapsTest, whenDriverModelHasLimitationForMaxMemoryAllocationSizeThenTakeItIntoAccount) {
|
||||
struct MockDriverModel : NEO::DriverModel {
|
||||
size_t maxAllocSize;
|
||||
|
||||
MockDriverModel(size_t maxAllocSize) : NEO::DriverModel(NEO::DriverModelType::UNKNOWN), maxAllocSize(maxAllocSize) {}
|
||||
|
||||
void setGmmInputArgs(void *args) override {}
|
||||
uint32_t getDeviceHandle() const override { return {}; }
|
||||
PhysicalDevicePciBusInfo getPciBusInfo() const override { return {}; }
|
||||
bool isGpuHangDetected(NEO::OsContext &osContext) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t getMaxMemAllocSize() const override {
|
||||
return maxAllocSize;
|
||||
}
|
||||
PhysicalDevicePciSpeedInfo getPciSpeedInfo() const override { return {}; }
|
||||
};
|
||||
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
size_t maxAllocSizeTestValue = 512;
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
||||
device->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface());
|
||||
device->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::make_unique<MockDriverModel>(maxAllocSizeTestValue));
|
||||
auto driverModel = std::make_unique<MockDriverModel>();
|
||||
driverModel->maxAllocSize = maxAllocSizeTestValue;
|
||||
device->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::move(driverModel));
|
||||
device->initializeCaps();
|
||||
const auto &caps = device->getDeviceInfo();
|
||||
EXPECT_EQ(maxAllocSizeTestValue, caps.maxMemAllocSize);
|
||||
|
||||
@@ -120,7 +120,7 @@ TEST(RootDeviceEnvironment, whenCreatingRootDeviceEnvironmentThenCreateOsAgnosti
|
||||
EXPECT_EQ(0u, rootDeviceEnvironment->osTime->getCpuRawTimestamp());
|
||||
|
||||
TimeStampData tsData{1, 2};
|
||||
EXPECT_TRUE(rootDeviceEnvironment->osTime->getCpuGpuTime(&tsData));
|
||||
EXPECT_TRUE(rootDeviceEnvironment->osTime->getGpuCpuTime(&tsData));
|
||||
EXPECT_EQ(0u, tsData.cpuTimeinNS);
|
||||
EXPECT_EQ(0u, tsData.gpuTimeStamp);
|
||||
|
||||
|
||||
@@ -41,22 +41,22 @@ using namespace NEO;
|
||||
struct DrmTimeTest : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() override {
|
||||
osInterface = std::unique_ptr<OSInterface>(new OSInterface());
|
||||
osTime = MockOSTimeLinux::create(osInterface.get());
|
||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
||||
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
rootDeviceEnvironment.osInterface->setDriverModel(std::make_unique<DrmMockTime>(mockFd, rootDeviceEnvironment));
|
||||
osTime = MockOSTimeLinux::create(*rootDeviceEnvironment.osInterface);
|
||||
osTime->setResolutionFunc(resolutionFuncTrue);
|
||||
osTime->setGetTimeFunc(getTimeFuncTrue);
|
||||
deviceTime = osTime->getDeviceTime();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
}
|
||||
MockDeviceTimeDrm *deviceTime = nullptr;
|
||||
std::unique_ptr<MockOSTimeLinux> osTime;
|
||||
std::unique_ptr<OSInterface> osInterface;
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
};
|
||||
|
||||
TEST_F(DrmTimeTest, GivenMockOsTimeThenInitializes) {
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, WhenGettingCpuTimeThenSucceeds) {
|
||||
uint64_t time = 0;
|
||||
auto error = osTime->getCpuTime(&time);
|
||||
@@ -98,60 +98,125 @@ TEST_F(DrmTimeTest, GivenInvalidDrmWhenGettingGpuTimeThenFails) {
|
||||
EXPECT_FALSE(error);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, WhenGettingCpuGpuTimeThenSucceeds) {
|
||||
TimeStampData cpuGpuTime01 = {0, 0};
|
||||
TimeStampData cpuGpuTime02 = {0, 0};
|
||||
TEST_F(DrmTimeTest, WhenGettingGpuCpuTimeThenSucceeds) {
|
||||
TimeStampData gpuCpuTime01 = {0, 0};
|
||||
TimeStampData gpuCpuTime02 = {0, 0};
|
||||
auto pDrm = new DrmMockTime(mockFd, *executionEnvironment.rootDeviceEnvironments[0]);
|
||||
osTime->updateDrm(pDrm);
|
||||
auto error = osTime->getCpuGpuTime(&cpuGpuTime01);
|
||||
auto error = osTime->getGpuCpuTime(&gpuCpuTime01);
|
||||
EXPECT_TRUE(error);
|
||||
EXPECT_NE(0ULL, cpuGpuTime01.cpuTimeinNS);
|
||||
EXPECT_NE(0ULL, cpuGpuTime01.gpuTimeStamp);
|
||||
error = osTime->getCpuGpuTime(&cpuGpuTime02);
|
||||
EXPECT_NE(0ULL, gpuCpuTime01.cpuTimeinNS);
|
||||
EXPECT_NE(0ULL, gpuCpuTime01.gpuTimeStamp);
|
||||
error = osTime->getGpuCpuTime(&gpuCpuTime02);
|
||||
EXPECT_TRUE(error);
|
||||
EXPECT_NE(0ULL, cpuGpuTime02.cpuTimeinNS);
|
||||
EXPECT_NE(0ULL, cpuGpuTime02.gpuTimeStamp);
|
||||
EXPECT_GT(cpuGpuTime02.gpuTimeStamp, cpuGpuTime01.gpuTimeStamp);
|
||||
EXPECT_GT(cpuGpuTime02.cpuTimeinNS, cpuGpuTime01.cpuTimeinNS);
|
||||
EXPECT_NE(0ULL, gpuCpuTime02.cpuTimeinNS);
|
||||
EXPECT_NE(0ULL, gpuCpuTime02.gpuTimeStamp);
|
||||
EXPECT_GT(gpuCpuTime02.gpuTimeStamp, gpuCpuTime01.gpuTimeStamp);
|
||||
EXPECT_GT(gpuCpuTime02.cpuTimeinNS, gpuCpuTime01.cpuTimeinNS);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, GivenDrmWhenGettingCpuGpuTimeThenSucceeds) {
|
||||
TimeStampData cpuGpuTime01 = {0, 0};
|
||||
TimeStampData cpuGpuTime02 = {0, 0};
|
||||
TEST_F(DrmTimeTest, GivenDrmWhenGettingGpuCpuTimeThenSucceeds) {
|
||||
TimeStampData gpuCpuTime01 = {0, 0};
|
||||
TimeStampData gpuCpuTime02 = {0, 0};
|
||||
auto pDrm = new DrmMockTime(mockFd, *executionEnvironment.rootDeviceEnvironments[0]);
|
||||
osTime->updateDrm(pDrm);
|
||||
auto error = osTime->getCpuGpuTime(&cpuGpuTime01);
|
||||
auto error = osTime->getGpuCpuTime(&gpuCpuTime01);
|
||||
EXPECT_TRUE(error);
|
||||
EXPECT_NE(0ULL, cpuGpuTime01.cpuTimeinNS);
|
||||
EXPECT_NE(0ULL, cpuGpuTime01.gpuTimeStamp);
|
||||
error = osTime->getCpuGpuTime(&cpuGpuTime02);
|
||||
EXPECT_NE(0ULL, gpuCpuTime01.cpuTimeinNS);
|
||||
EXPECT_NE(0ULL, gpuCpuTime01.gpuTimeStamp);
|
||||
error = osTime->getGpuCpuTime(&gpuCpuTime02);
|
||||
EXPECT_TRUE(error);
|
||||
EXPECT_NE(0ULL, cpuGpuTime02.cpuTimeinNS);
|
||||
EXPECT_NE(0ULL, cpuGpuTime02.gpuTimeStamp);
|
||||
EXPECT_GT(cpuGpuTime02.gpuTimeStamp, cpuGpuTime01.gpuTimeStamp);
|
||||
EXPECT_GT(cpuGpuTime02.cpuTimeinNS, cpuGpuTime01.cpuTimeinNS);
|
||||
EXPECT_NE(0ULL, gpuCpuTime02.cpuTimeinNS);
|
||||
EXPECT_NE(0ULL, gpuCpuTime02.gpuTimeStamp);
|
||||
EXPECT_GT(gpuCpuTime02.gpuTimeStamp, gpuCpuTime01.gpuTimeStamp);
|
||||
EXPECT_GT(gpuCpuTime02.cpuTimeinNS, gpuCpuTime01.cpuTimeinNS);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, givenGetCpuGpuTimeWhenItIsUnavailableThenReturnFalse) {
|
||||
TimeStampData cpuGpuTime = {0, 0};
|
||||
auto error = osTime->getCpuGpuTime(&cpuGpuTime);
|
||||
TEST_F(DrmTimeTest, givenGetGpuCpuTimeWhenItIsUnavailableThenReturnFalse) {
|
||||
TimeStampData gpuCpuTime = {0, 0};
|
||||
|
||||
deviceTime->callBaseGetGpuCpuTimeImpl = false;
|
||||
deviceTime->getGpuCpuTimeImplResult = false;
|
||||
auto error = osTime->getGpuCpuTime(&gpuCpuTime);
|
||||
EXPECT_FALSE(error);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, GivenInvalidDrmWhenGettingCpuGpuTimeThenFails) {
|
||||
TimeStampData cpuGpuTime01 = {0, 0};
|
||||
TEST_F(DrmTimeTest, given36BitGpuTimeStampWhenGpuTimeStampOverflowThenGpuTimeDoesNotDecrease) {
|
||||
TimeStampData gpuCpuTime = {0ull, 0ull};
|
||||
|
||||
deviceTime->callBaseGetGpuCpuTimeImpl = false;
|
||||
deviceTime->gpuCpuTimeValue = {100ull, 100ull};
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(100ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 200ll;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(200ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
osTime->maxGpuTimeStamp = 1ull << 36;
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 10ull; // read below initial value
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(osTime->maxGpuTimeStamp + 10ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 30ull; // second read below initial value
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(osTime->maxGpuTimeStamp + 30ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 110ull;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(osTime->maxGpuTimeStamp + 110ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 70ull; // second overflow
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(2ull * osTime->maxGpuTimeStamp + 70ull, gpuCpuTime.gpuTimeStamp);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, given64BitGpuTimeStampWhenGpuTimeStampOverflowThenOverflowsAreNotDetected) {
|
||||
TimeStampData gpuCpuTime = {0ull, 0ull};
|
||||
|
||||
deviceTime->callBaseGetGpuCpuTimeImpl = false;
|
||||
deviceTime->gpuCpuTimeValue = {100ull, 100ull};
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(100ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 200ull;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(200ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
osTime->maxGpuTimeStamp = 0ull;
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 10ull; // read below initial value
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(10ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 30ull;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(30ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 110ull;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(110ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 70ull;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(70ull, gpuCpuTime.gpuTimeStamp);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, GivenInvalidDrmWhenGettingGpuCpuTimeThenFails) {
|
||||
TimeStampData gpuCpuTime01 = {0, 0};
|
||||
auto pDrm = new DrmMockFail(*executionEnvironment.rootDeviceEnvironments[0]);
|
||||
osTime->updateDrm(pDrm);
|
||||
auto error = osTime->getCpuGpuTime(&cpuGpuTime01);
|
||||
auto error = osTime->getGpuCpuTime(&gpuCpuTime01);
|
||||
EXPECT_FALSE(error);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, GivenInvalidFuncTimeWhenGettingCpuGpuTimeCpuThenFails) {
|
||||
TimeStampData cpuGpuTime01 = {0, 0};
|
||||
TEST_F(DrmTimeTest, GivenInvalidFuncTimeWhenGettingGpuCpuTimeCpuThenFails) {
|
||||
TimeStampData gpuCpuTime01 = {0, 0};
|
||||
auto pDrm = new DrmMockTime(mockFd, *executionEnvironment.rootDeviceEnvironments[0]);
|
||||
osTime->setGetTimeFunc(getTimeFuncFalse);
|
||||
osTime->updateDrm(pDrm);
|
||||
auto error = osTime->getCpuGpuTime(&cpuGpuTime01);
|
||||
auto error = osTime->getGpuCpuTime(&gpuCpuTime01);
|
||||
EXPECT_FALSE(error);
|
||||
}
|
||||
|
||||
@@ -221,15 +286,6 @@ TEST_F(DrmTimeTest, givenGetDynamicDeviceTimerClockWhenIoctlSucceedsThenNonDefau
|
||||
EXPECT_EQ(result, frequency);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, givenGpuTimestampResolutionQueryWhenNoDrmThenDefaultResolutionIsReturned) {
|
||||
osTime->updateDrm(nullptr);
|
||||
|
||||
auto defaultResolution = defaultHwInfo->capabilityTable.defaultProfilingTimerResolution;
|
||||
|
||||
auto result = osTime->getDynamicDeviceTimerResolution(*defaultHwInfo);
|
||||
EXPECT_DOUBLE_EQ(result, defaultResolution);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, givenGpuTimestampResolutionQueryWhenIoctlSuccedsThenCorrectResolutionIsReturned) {
|
||||
auto drm = new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0]);
|
||||
osTime->updateDrm(drm);
|
||||
@@ -265,8 +321,18 @@ TEST_F(DrmTimeTest, givenAlwaysFailingGetTimeFuncWhenGetCpuRawTimestampIsCalledT
|
||||
auto retVal = osTime->getCpuRawTimestamp();
|
||||
EXPECT_EQ(0ull, retVal);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, givenAlwaysPassingResolutionFuncWhenGetCpuRawTimestampIsCalledThenReturnsNonzero) {
|
||||
actualTime = 4;
|
||||
auto retVal = osTime->getCpuRawTimestamp();
|
||||
EXPECT_EQ(1ull, retVal);
|
||||
}
|
||||
|
||||
TEST_F(DrmTimeTest, whenGettingMaxGpuTimeStampValueThenHwInfoBasedValueIsReturned) {
|
||||
if (defaultHwInfo->capabilityTable.timestampValidBits < 64) {
|
||||
auto expectedMaxGpuTimeStampValue = 1ull << defaultHwInfo->capabilityTable.timestampValidBits;
|
||||
EXPECT_EQ(expectedMaxGpuTimeStampValue, osTime->getMaxGpuTimeStamp());
|
||||
} else {
|
||||
EXPECT_EQ(0ull, osTime->getMaxGpuTimeStamp());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -797,7 +797,7 @@ TEST_F(WddmLinuxTest, whenCheckedIfResourcesCleanupCanBeSkippedAndDeviceIsLostTh
|
||||
|
||||
class MockOsTimeLinux : public NEO::OSTimeLinux {
|
||||
public:
|
||||
MockOsTimeLinux(NEO::OSInterface *osInterface, std::unique_ptr<NEO::DeviceTime> deviceTime) : NEO::OSTimeLinux(osInterface, std::move(deviceTime)) {}
|
||||
MockOsTimeLinux(NEO::OSInterface &osInterface, std::unique_ptr<NEO::DeviceTime> deviceTime) : NEO::OSTimeLinux(osInterface, std::move(deviceTime)) {}
|
||||
bool getCpuTime(uint64_t *timeStamp) override {
|
||||
osTimeGetCpuTimeWasCalled = true;
|
||||
*timeStamp = 0x1234;
|
||||
@@ -814,27 +814,27 @@ class MockDeviceTimeWddm : public NEO::DeviceTimeWddm {
|
||||
}
|
||||
};
|
||||
|
||||
TEST(OSTimeWinLinuxTests, givenOSInterfaceWhenGetCpuGpuTimeThenGetCpuTimeFromOsTimeWasCalled) {
|
||||
TEST(OSTimeWinLinuxTests, givenOSInterfaceWhenGetGpuCpuTimeThenGetCpuTimeFromOsTimeWasCalled) {
|
||||
|
||||
NEO::TimeStampData cpuGpuTime01 = {0};
|
||||
NEO::TimeStampData gpuCpuTime01 = {0};
|
||||
|
||||
std::unique_ptr<NEO::HwDeviceIdWddm> hwDeviceIdIn;
|
||||
auto osEnvironment = std::make_unique<NEO::OsEnvironmentWin>();
|
||||
osEnvironment->gdi->closeAdapter = closeAdapterMock;
|
||||
osEnvironment->gdi->reserveGpuVirtualAddress = reserveDeviceAddressSpaceMock;
|
||||
NEO::MockExecutionEnvironment mockExecEnv;
|
||||
NEO::MockRootDeviceEnvironment mockRootDeviceEnvironment{mockExecEnv};
|
||||
auto &rootDeviceEnvironment = *mockExecEnv.rootDeviceEnvironments[0];
|
||||
hwDeviceIdIn.reset(new NEO::HwDeviceIdWddm(NULL_HANDLE, LUID{}, 1u, osEnvironment.get(), std::make_unique<NEO::UmKmDataTranslator>()));
|
||||
|
||||
std::unique_ptr<NEO::OSInterface> osInterface(new NEO::OSInterface());
|
||||
rootDeviceEnvironment.osInterface = std::make_unique<NEO::OSInterface>();
|
||||
|
||||
std::unique_ptr<MockWddmLinux> wddm = std::make_unique<MockWddmLinux>(std::move(hwDeviceIdIn), mockRootDeviceEnvironment);
|
||||
std::unique_ptr<MockWddmLinux> wddm = std::make_unique<MockWddmLinux>(std::move(hwDeviceIdIn), rootDeviceEnvironment);
|
||||
static_cast<PLATFORM &>(*wddm->gfxPlatform) = NEO::defaultHwInfo->platform;
|
||||
mockRootDeviceEnvironment.setHwInfoAndInitHelpers(NEO::defaultHwInfo.get());
|
||||
rootDeviceEnvironment.setHwInfoAndInitHelpers(NEO::defaultHwInfo.get());
|
||||
auto mockDeviceTimeWddm = std::make_unique<MockDeviceTimeWddm>(wddm.get());
|
||||
osInterface->setDriverModel(std::move(wddm));
|
||||
rootDeviceEnvironment.osInterface->setDriverModel(std::move(wddm));
|
||||
std::unique_ptr<NEO::DeviceTime> deviceTime = std::unique_ptr<NEO::DeviceTime>(mockDeviceTimeWddm.release());
|
||||
auto osTime = std::unique_ptr<MockOsTimeLinux>(new MockOsTimeLinux(osInterface.get(), std::move(deviceTime)));
|
||||
osTime->getCpuGpuTime(&cpuGpuTime01);
|
||||
auto osTime = std::unique_ptr<MockOsTimeLinux>(new MockOsTimeLinux(*rootDeviceEnvironment.osInterface, std::move(deviceTime)));
|
||||
osTime->getGpuCpuTime(&gpuCpuTime01);
|
||||
EXPECT_TRUE(osTime->osTimeGetCpuTimeWasCalled);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/mocks/mock_ostime.h"
|
||||
#include "shared/test/common/mocks/windows/mock_os_time_win.h"
|
||||
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
|
||||
|
||||
@@ -25,17 +26,97 @@ BOOL WINAPI QueryPerformanceCounterMock(
|
||||
return true;
|
||||
};
|
||||
|
||||
class MockDeviceTimeWin : public MockDeviceTime {
|
||||
public:
|
||||
bool getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) override {
|
||||
*pGpuCpuTime = gpuCpuTimeValue;
|
||||
return true;
|
||||
}
|
||||
TimeStampData gpuCpuTimeValue{};
|
||||
};
|
||||
|
||||
struct OSTimeWinTest : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() override {
|
||||
osTime = std::unique_ptr<MockOSTimeWin>(new MockOSTimeWin(nullptr));
|
||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
||||
auto wddm = new WddmMock(rootDeviceEnvironment);
|
||||
rootDeviceEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
rootDeviceEnvironment.osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
||||
osTime = std::unique_ptr<MockOSTimeWin>(new MockOSTimeWin(*rootDeviceEnvironment.osInterface));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
}
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
std::unique_ptr<MockOSTimeWin> osTime;
|
||||
};
|
||||
|
||||
TEST_F(OSTimeWinTest, given36BitGpuTimeStampWhenGpuTimeStampOverflowThenGpuTimeDoesNotDecrease) {
|
||||
auto deviceTime = new MockDeviceTimeWin();
|
||||
osTime->deviceTime.reset(deviceTime);
|
||||
|
||||
TimeStampData gpuCpuTime = {0ull, 0ull};
|
||||
|
||||
deviceTime->gpuCpuTimeValue = {100ull, 100ull};
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(100ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 200ll;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(200ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
osTime->maxGpuTimeStamp = 1ull << 36;
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 10ull; // read below initial value
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(osTime->maxGpuTimeStamp + 10ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 30ull; // second read below initial value
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(osTime->maxGpuTimeStamp + 30ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 110ull;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(osTime->maxGpuTimeStamp + 110ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 70ull; // second overflow
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(2ull * osTime->maxGpuTimeStamp + 70ull, gpuCpuTime.gpuTimeStamp);
|
||||
}
|
||||
|
||||
TEST_F(OSTimeWinTest, given64BitGpuTimeStampWhenGpuTimeStampOverflowThenOverflowsAreNotDetected) {
|
||||
auto deviceTime = new MockDeviceTimeWin();
|
||||
osTime->deviceTime.reset(deviceTime);
|
||||
|
||||
TimeStampData gpuCpuTime = {0ull, 0ull};
|
||||
|
||||
deviceTime->gpuCpuTimeValue = {100ull, 100ull};
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(100ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 200ull;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(200ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
osTime->maxGpuTimeStamp = 0ull;
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 10ull; // read below initial value
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(10ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 30ull;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(30ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 110ull;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(110ull, gpuCpuTime.gpuTimeStamp);
|
||||
|
||||
deviceTime->gpuCpuTimeValue.gpuTimeStamp = 70ull;
|
||||
EXPECT_TRUE(osTime->getGpuCpuTime(&gpuCpuTime));
|
||||
EXPECT_EQ(70ull, gpuCpuTime.gpuTimeStamp);
|
||||
}
|
||||
|
||||
TEST_F(OSTimeWinTest, givenZeroFrequencyWhenGetHostTimerFuncIsCalledThenReturnsZero) {
|
||||
LARGE_INTEGER frequency;
|
||||
frequency.QuadPart = 0;
|
||||
@@ -77,33 +158,41 @@ TEST(OSTimeWinTests, givenNoOSInterfaceWhenGetCpuTimeThenReturnsSuccess) {
|
||||
EXPECT_EQ(0u, time);
|
||||
}
|
||||
|
||||
TEST(OSTimeWinTests, givenNoOSInterfaceWhenGetCpuGpuTimeThenReturnsSuccess) {
|
||||
TimeStampData CPUGPUTime = {0};
|
||||
TEST(OSTimeWinTests, givenNoOSInterfaceWhenGetGpuCpuTimeThenReturnsSuccess) {
|
||||
TimeStampData gpuCpuTime = {0};
|
||||
auto osTime(OSTime::create(nullptr));
|
||||
auto success = osTime->getCpuGpuTime(&CPUGPUTime);
|
||||
auto success = osTime->getGpuCpuTime(&gpuCpuTime);
|
||||
EXPECT_TRUE(success);
|
||||
EXPECT_EQ(0u, CPUGPUTime.cpuTimeinNS);
|
||||
EXPECT_EQ(0u, CPUGPUTime.gpuTimeStamp);
|
||||
EXPECT_EQ(0u, gpuCpuTime.cpuTimeinNS);
|
||||
EXPECT_EQ(0u, gpuCpuTime.gpuTimeStamp);
|
||||
}
|
||||
|
||||
TEST(OSTimeWinTests, givenOSInterfaceWhenGetCpuGpuTimeThenReturnsSuccess) {
|
||||
TEST(OSTimeWinTests, givenOSInterfaceWhenGetGpuCpuTimeThenReturnsSuccess) {
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
|
||||
rootDeviceEnvironment.setHwInfoAndInitHelpers(defaultHwInfo.get());
|
||||
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
||||
auto wddm = new WddmMock(rootDeviceEnvironment);
|
||||
TimeStampData CPUGPUTime01 = {0};
|
||||
TimeStampData CPUGPUTime02 = {0};
|
||||
TimeStampData gpuCpuTime01 = {0};
|
||||
TimeStampData gpuCpuTime02 = {0};
|
||||
std::unique_ptr<OSInterface> osInterface(new OSInterface());
|
||||
osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
|
||||
auto osTime = OSTime::create(osInterface.get());
|
||||
auto success = osTime->getCpuGpuTime(&CPUGPUTime01);
|
||||
auto success = osTime->getGpuCpuTime(&gpuCpuTime01);
|
||||
EXPECT_TRUE(success);
|
||||
EXPECT_NE(0u, CPUGPUTime01.cpuTimeinNS);
|
||||
EXPECT_NE(0u, CPUGPUTime01.gpuTimeStamp);
|
||||
success = osTime->getCpuGpuTime(&CPUGPUTime02);
|
||||
EXPECT_NE(0u, gpuCpuTime01.cpuTimeinNS);
|
||||
EXPECT_NE(0u, gpuCpuTime01.gpuTimeStamp);
|
||||
success = osTime->getGpuCpuTime(&gpuCpuTime02);
|
||||
EXPECT_TRUE(success);
|
||||
EXPECT_NE(0u, CPUGPUTime02.cpuTimeinNS);
|
||||
EXPECT_NE(0u, CPUGPUTime02.gpuTimeStamp);
|
||||
EXPECT_GT(CPUGPUTime02.gpuTimeStamp, CPUGPUTime01.gpuTimeStamp);
|
||||
EXPECT_GT(CPUGPUTime02.cpuTimeinNS, CPUGPUTime01.cpuTimeinNS);
|
||||
EXPECT_NE(0u, gpuCpuTime02.cpuTimeinNS);
|
||||
EXPECT_NE(0u, gpuCpuTime02.gpuTimeStamp);
|
||||
EXPECT_GT(gpuCpuTime02.gpuTimeStamp, gpuCpuTime01.gpuTimeStamp);
|
||||
EXPECT_GT(gpuCpuTime02.cpuTimeinNS, gpuCpuTime01.cpuTimeinNS);
|
||||
}
|
||||
|
||||
TEST_F(OSTimeWinTest, whenGettingMaxGpuTimeStampValueThenHwInfoBasedValueIsReturned) {
|
||||
if (defaultHwInfo->capabilityTable.timestampValidBits < 64) {
|
||||
auto expectedMaxGpuTimeStampValue = 1ull << defaultHwInfo->capabilityTable.timestampValidBits;
|
||||
EXPECT_EQ(expectedMaxGpuTimeStampValue, osTime->getMaxGpuTimeStamp());
|
||||
} else {
|
||||
EXPECT_EQ(0ull, osTime->getMaxGpuTimeStamp());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user