Move OsTime to RootDeviceEnvironment

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-09-24 10:51:57 +00:00
committed by Compute-Runtime-Automation
parent b46dc0a6f8
commit 7b564b5caa
5 changed files with 27 additions and 15 deletions

View File

@@ -229,15 +229,11 @@ bool Device::createDeviceImpl() {
}
executionEnvironment->memoryManager->setDefaultEngineIndex(getRootDeviceIndex(), defaultEngineIndexWithinMemoryManager);
auto osInterface = getRootDeviceEnvironment().osInterface.get();
if (!osTime) {
osTime = OSTime::create(osInterface);
}
getRootDeviceEnvironmentRef().initOsTime();
initializeCaps();
if (osTime->getOSInterface()) {
if (getOSTime()->getOSInterface()) {
if (hwInfo.capabilityTable.instrumentationEnabled) {
performanceCounters = createPerformanceCountersFunc(this);
}
@@ -365,11 +361,11 @@ const DeviceInfo &Device::getDeviceInfo() const {
}
double Device::getProfilingTimerResolution() {
return osTime->getDynamicDeviceTimerResolution(getHardwareInfo());
return getOSTime()->getDynamicDeviceTimerResolution(getHardwareInfo());
}
uint64_t Device::getProfilingTimerClock() {
return osTime->getDynamicDeviceTimerClock(getHardwareInfo());
return getOSTime()->getDynamicDeviceTimerClock(getHardwareInfo());
}
bool Device::isSimulation() const {
@@ -389,8 +385,10 @@ bool Device::isSimulation() const {
}
double Device::getPlatformHostTimerResolution() const {
if (osTime.get())
return osTime->getHostTimerResolution();
if (getOSTime()) {
return getOSTime()->getHostTimerResolution();
}
return 0.0;
}
@@ -569,4 +567,6 @@ void Device::initializeRayTracing() {
rtMemoryBackedBuffer = getMemoryManager()->allocateGraphicsMemoryWithProperties({getRootDeviceIndex(), size, GraphicsAllocation::AllocationType::BUFFER, getDeviceBitfield()});
}
}
OSTime *Device::getOSTime() const { return getRootDeviceEnvironment().osTime.get(); };
} // namespace NEO

View File

@@ -70,7 +70,7 @@ class Device : public ReferenceTrackedObject<Device> {
MemoryManager *getMemoryManager() const;
GmmHelper *getGmmHelper() const;
GmmClientContext *getGmmClientContext() const;
OSTime *getOSTime() const { return osTime.get(); };
OSTime *getOSTime() const;
double getProfilingTimerResolution();
uint64_t getProfilingTimerClock();
double getPlatformHostTimerResolution() const;
@@ -161,7 +161,6 @@ class Device : public ReferenceTrackedObject<Device> {
DeviceInfo deviceInfo = {};
HardwareCapabilities hardwareCapabilities = {};
std::unique_ptr<OSTime> osTime;
std::unique_ptr<PerformanceCounters> performanceCounters;
std::vector<std::unique_ptr<CommandStreamReceiver>> commandStreamReceivers;
std::vector<EngineControl> engines;

View File

@@ -20,6 +20,7 @@
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/memory_manager/memory_operations_handler.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/os_time.h"
#include "shared/source/utilities/software_tags_manager.h"
namespace NEO {
@@ -91,6 +92,12 @@ void RootDeviceEnvironment::initGmm() {
}
}
void RootDeviceEnvironment::initOsTime() {
if (!osTime) {
osTime = OSTime::create(osInterface.get());
}
}
BindlessHeapsHelper *RootDeviceEnvironment::getBindlessHeapsHelper() const {
return bindlessHeapsHelper.get();
}

View File

@@ -30,6 +30,7 @@ class HwDeviceId;
class MemoryManager;
class MemoryOperationsHandler;
class OSInterface;
class OSTime;
class SipKernel;
class SWTagsManager;
struct HardwareInfo;
@@ -50,6 +51,7 @@ struct RootDeviceEnvironment {
MOCKABLE_VIRTUAL void initAubCenter(bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType);
bool initOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex);
void initOsTime();
void initGmm();
void initDebugger();
MOCKABLE_VIRTUAL bool initAilConfiguration();
@@ -67,6 +69,7 @@ struct RootDeviceEnvironment {
std::unique_ptr<MemoryOperationsHandler> memoryOperationsInterface;
std::unique_ptr<AubCenter> aubCenter;
std::unique_ptr<BindlessHeapsHelper> bindlessHeapsHelper;
std::unique_ptr<OSTime> osTime;
std::unique_ptr<CompilerInterface> compilerInterface;
std::unique_ptr<BuiltIns> builtins;

View File

@@ -47,7 +47,10 @@ const char *MockDevice::getProductAbbrev() const {
MockDevice::MockDevice(ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex)
: RootDevice(executionEnvironment, rootDeviceIndex) {
UltDeviceFactory::initializeMemoryManager(*executionEnvironment);
this->osTime = MockOSTime::create();
if (!getOSTime()) {
getRootDeviceEnvironmentRef().osTime = MockOSTime::create();
}
auto &hwInfo = getHardwareInfo();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(&hwInfo);
initializeCaps();
@@ -62,8 +65,8 @@ bool MockDevice::createDeviceImpl() {
}
void MockDevice::setOSTime(OSTime *osTime) {
this->osTime.reset(osTime);
};
getRootDeviceEnvironmentRef().osTime.reset(osTime);
}
void MockDevice::injectMemoryManager(MemoryManager *memoryManager) {
executionEnvironment->memoryManager.reset(memoryManager);