From ee544e251560687a60b47df7d4537f7f5e283e89 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Fri, 29 Nov 2019 13:03:35 +0100 Subject: [PATCH] Reorder members and methods in Device class Related-To: NEO-3938 Change-Id: I18e6ed4b301d5e221263ced5a3213b54dd21745a Signed-off-by: Mateusz Jablonski --- runtime/device/device.h | 74 +++++++++---------- unit_tests/mocks/mock_device.h | 2 + .../os_interface/linux/device_os_tests.cpp | 2 +- .../os_interface/windows/device_os_tests.cpp | 2 +- 4 files changed, 39 insertions(+), 41 deletions(-) diff --git a/runtime/device/device.h b/runtime/device/device.h index cb7ffc1e1a..d42df0e440 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -30,15 +30,8 @@ class Device : public BaseObject<_cl_device_id> { public: static const cl_ulong objectMagic = 0x8055832341AC8D08LL; - template - static DeviceT *create(ArgsT &&... args) { - DeviceT *device = new DeviceT(std::forward(args)...); - return createDeviceInternals(device); - } - Device &operator=(const Device &) = delete; Device(const Device &) = delete; - ~Device() override; // API entry points @@ -47,16 +40,6 @@ class Device : public BaseObject<_cl_device_id> { void *paramValue, size_t *paramValueSizeRet); - bool getDeviceAndHostTimer(uint64_t *deviceTimestamp, uint64_t *hostTimestamp) const; - bool getHostTimer(uint64_t *hostTimestamp) const; - - // Helper functions - const HardwareInfo &getHardwareInfo() const; - const DeviceInfo &getDeviceInfo() const; - - EngineControl &getEngine(aub_stream::EngineType engineType, bool lowPriority); - EngineControl &getDefaultEngine(); - // This helper template is meant to simplify getDeviceInfo template void getCap(const void *&src, @@ -67,41 +50,55 @@ class Device : public BaseObject<_cl_device_id> { void getStr(const void *&src, size_t &size, size_t &retSize); - - MemoryManager *getMemoryManager() const; - GmmHelper *getGmmHelper() const; - - OSTime *getOSTime() const { return osTime.get(); }; - double getProfilingTimerResolution(); unsigned int getEnabledClVersion() const { return enabledClVersion; }; unsigned int getSupportedClVersion() const; + + template + static DeviceT *create(ArgsT &&... args) { + DeviceT *device = new DeviceT(std::forward(args)...); + return createDeviceInternals(device); + } + + bool getDeviceAndHostTimer(uint64_t *deviceTimestamp, uint64_t *hostTimestamp) const; + bool getHostTimer(uint64_t *hostTimestamp) const; + const HardwareInfo &getHardwareInfo() const; + const DeviceInfo &getDeviceInfo() const; + EngineControl &getEngine(aub_stream::EngineType engineType, bool lowPriority); + EngineControl &getDefaultEngine(); + MemoryManager *getMemoryManager() const; + GmmHelper *getGmmHelper() const; + OSTime *getOSTime() const { return osTime.get(); }; + double getProfilingTimerResolution(); double getPlatformHostTimerResolution() const; bool isSimulation() const; GFXCORE_FAMILY getRenderCoreFamily() const; PerformanceCounters *getPerformanceCounters() { return performanceCounters.get(); } - static decltype(&PerformanceCounters::create) createPerformanceCountersFunc; PreemptionMode getPreemptionMode() const { return preemptionMode; } - std::vector simultaneousInterops; - std::string deviceExtensions; - std::string name; MOCKABLE_VIRTUAL bool isSourceLevelDebuggerActive() const; SourceLevelDebugger *getSourceLevelDebugger() { return executionEnvironment->sourceLevelDebugger.get(); } ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; } const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; } - virtual uint32_t getRootDeviceIndex() const = 0; bool isFullRangeSvm() const { return executionEnvironment->isFullRangeSvm(); } bool areSharedSystemAllocationsAllowed() const { return this->deviceInfo.sharedSystemMemCapabilities != 0u; } + + virtual uint32_t getRootDeviceIndex() const = 0; virtual uint32_t getNumAvailableDevices() const = 0; virtual Device *getDeviceById(uint32_t deviceId) const = 0; + static decltype(&PerformanceCounters::create) createPerformanceCountersFunc; + protected: Device() = delete; Device(ExecutionEnvironment *executionEnvironment); + MOCKABLE_VIRTUAL void initializeCaps(); + void setupFp64Flags(); + void appendOSExtensions(std::string &deviceExtensions); + template static T *createDeviceInternals(T *device) { if (false == device->createDeviceImpl()) { @@ -112,27 +109,26 @@ class Device : public BaseObject<_cl_device_id> { } virtual bool createDeviceImpl(); - virtual DeviceBitfield getDeviceBitfieldForOsContext() const = 0; virtual bool createEngines(); bool createEngine(uint32_t deviceCsrIndex, aub_stream::EngineType engineType); - MOCKABLE_VIRTUAL std::unique_ptr createCommandStreamReceiver() const; - MOCKABLE_VIRTUAL void initializeCaps(); - void setupFp64Flags(); - void appendOSExtensions(std::string &deviceExtensions); - unsigned int enabledClVersion = 0u; - HardwareCapabilities hardwareCapabilities = {}; + virtual DeviceBitfield getDeviceBitfieldForOsContext() const = 0; + + std::vector simultaneousInterops; + unsigned int enabledClVersion = 0u; + std::string deviceExtensions; + std::string exposedBuiltinKernels = ""; + DeviceInfo deviceInfo; + + std::string name; + HardwareCapabilities hardwareCapabilities = {}; std::unique_ptr osTime; std::unique_ptr driverInfo; std::unique_ptr performanceCounters; - std::vector> commandStreamReceivers; std::vector engines; - - std::string exposedBuiltinKernels = ""; - PreemptionMode preemptionMode; ExecutionEnvironment *executionEnvironment = nullptr; uint32_t defaultEngineIndex = 0; diff --git a/unit_tests/mocks/mock_device.h b/unit_tests/mocks/mock_device.h index e2bddae8ef..ab5a64a7a1 100644 --- a/unit_tests/mocks/mock_device.h +++ b/unit_tests/mocks/mock_device.h @@ -39,6 +39,8 @@ class MockDevice : public RootDevice { using Device::engines; using Device::executionEnvironment; using Device::initializeCaps; + using Device::name; + using Device::simultaneousInterops; using RootDevice::createEngines; using RootDevice::subdevices; diff --git a/unit_tests/os_interface/linux/device_os_tests.cpp b/unit_tests/os_interface/linux/device_os_tests.cpp index 8f0be03914..dd1145299f 100644 --- a/unit_tests/os_interface/linux/device_os_tests.cpp +++ b/unit_tests/os_interface/linux/device_os_tests.cpp @@ -39,7 +39,7 @@ TEST(DeviceOsTest, osSpecificExtensions) { } TEST(DeviceOsTest, supportedSimultaneousInterops) { - auto pDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); + auto pDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); std::vector expected = {0}; diff --git a/unit_tests/os_interface/windows/device_os_tests.cpp b/unit_tests/os_interface/windows/device_os_tests.cpp index 5318b3fb20..bcb0f3d592 100644 --- a/unit_tests/os_interface/windows/device_os_tests.cpp +++ b/unit_tests/os_interface/windows/device_os_tests.cpp @@ -35,7 +35,7 @@ TEST(DeviceOsTest, osSpecificExtensions) { } TEST(DeviceOsTest, supportedSimultaneousInterops) { - auto pDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); + auto pDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); std::vector expected = {CL_GL_CONTEXT_KHR, CL_WGL_HDC_KHR,