diff --git a/runtime/command_stream/create_command_stream_impl.cpp b/runtime/command_stream/create_command_stream_impl.cpp index 9f880476aa..64a8c6340d 100644 --- a/runtime/command_stream/create_command_stream_impl.cpp +++ b/runtime/command_stream/create_command_stream_impl.cpp @@ -61,7 +61,7 @@ CommandStreamReceiver *createCommandStreamImpl(const HardwareInfo *pHwInfo) { return commandStreamReceiver; } -bool getDevicesImpl(HardwareInfo **hwInfo, size_t &numDevicesReturned) { +bool getDevicesImpl(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) { bool result; int32_t csr = DebugManager.flags.SetCommandStreamReceiver.get(); if (csr) { @@ -78,12 +78,12 @@ bool getDevicesImpl(HardwareInfo **hwInfo, size_t &numDevicesReturned) { return true; } case CSR_HW_WITH_AUB: - return DeviceFactory::getDevices(hwInfo, numDevicesReturned); + return DeviceFactory::getDevices(hwInfo, numDevicesReturned, executionEnvironment); default: return false; } } - result = DeviceFactory::getDevices(hwInfo, numDevicesReturned); + result = DeviceFactory::getDevices(hwInfo, numDevicesReturned, executionEnvironment); DEBUG_BREAK_IF(result && (hwInfo == nullptr)); return result; } diff --git a/runtime/command_stream/create_command_stream_impl.h b/runtime/command_stream/create_command_stream_impl.h index 508724048d..c475673946 100644 --- a/runtime/command_stream/create_command_stream_impl.h +++ b/runtime/command_stream/create_command_stream_impl.h @@ -25,6 +25,7 @@ #include "runtime/helpers/hw_info.h" namespace OCLRT { +class ExecutionEnvironment; extern CommandStreamReceiver *createCommandStreamImpl(const HardwareInfo *pHwInfo); -extern bool getDevicesImpl(HardwareInfo **hwInfo, size_t &numDevicesReturned); +extern bool getDevicesImpl(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment); } // namespace OCLRT diff --git a/runtime/dll/create_command_stream.cpp b/runtime/dll/create_command_stream.cpp index 6d30788c49..ced099bc14 100644 --- a/runtime/dll/create_command_stream.cpp +++ b/runtime/dll/create_command_stream.cpp @@ -36,8 +36,8 @@ CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo) { return createCommandStreamImpl(pHwInfo); } -bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned) { - return getDevicesImpl(hwInfo, numDevicesReturned); +bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnviornment) { + return getDevicesImpl(hwInfo, numDevicesReturned, executionEnviornment); } } // namespace OCLRT diff --git a/runtime/os_interface/device_factory.h b/runtime/os_interface/device_factory.h index 14eda6580b..a7dc630bec 100644 --- a/runtime/os_interface/device_factory.h +++ b/runtime/os_interface/device_factory.h @@ -26,10 +26,11 @@ namespace OCLRT { struct HardwareInfo; +class ExecutionEnvironment; class DeviceFactory { public: - static bool getDevices(HardwareInfo **pHWInfos, size_t &numDevices); + static bool getDevices(HardwareInfo **pHWInfos, size_t &numDevices, ExecutionEnvironment &executionEnvironment); static void releaseDevices(); protected: diff --git a/runtime/os_interface/linux/device_factory.cpp b/runtime/os_interface/linux/device_factory.cpp index 7c8cbfaad0..b93f6aa859 100644 --- a/runtime/os_interface/linux/device_factory.cpp +++ b/runtime/os_interface/linux/device_factory.cpp @@ -38,7 +38,7 @@ namespace OCLRT { size_t DeviceFactory::numDevices = 0; HardwareInfo *DeviceFactory::hwInfos = nullptr; -bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) { +bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices, ExecutionEnvironment &executionEnvironment) { std::vector tHwInfos; unsigned int devNum = 0; size_t requiredDeviceCount = 1; diff --git a/runtime/os_interface/windows/device_factory.cpp b/runtime/os_interface/windows/device_factory.cpp index ef900237df..4addb4c8b9 100644 --- a/runtime/os_interface/windows/device_factory.cpp +++ b/runtime/os_interface/windows/device_factory.cpp @@ -36,7 +36,7 @@ extern const HardwareInfo *hardwareInfoTable[IGFX_MAX_PRODUCT]; size_t DeviceFactory::numDevices = 0; HardwareInfo *DeviceFactory::hwInfos = nullptr; -bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) { +bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices, ExecutionEnvironment &executionEnvironment) { auto totalDeviceCount = 1u; if (DebugManager.flags.CreateMultipleDevices.get()) { totalDeviceCount = DebugManager.flags.CreateMultipleDevices.get(); diff --git a/runtime/platform/platform.cpp b/runtime/platform/platform.cpp index 3688aec629..af3cbe01fd 100644 --- a/runtime/platform/platform.cpp +++ b/runtime/platform/platform.cpp @@ -42,7 +42,7 @@ namespace OCLRT { std::unique_ptr platformImpl; -bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned); +bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment); Platform *platform() { return platformImpl.get(); } @@ -138,7 +138,7 @@ bool Platform::initialize() { return true; } - state = OCLRT::getDevices(&hwInfo, numDevicesReturned) ? StateIniting : StateNone; + state = OCLRT::getDevices(&hwInfo, numDevicesReturned, *executionEnvironment) ? StateIniting : StateNone; if (state == StateNone) { return false; diff --git a/unit_tests/command_stream/get_devices_tests.cpp b/unit_tests/command_stream/get_devices_tests.cpp index 45cb2bd79f..5e984da3fd 100644 --- a/unit_tests/command_stream/get_devices_tests.cpp +++ b/unit_tests/command_stream/get_devices_tests.cpp @@ -21,6 +21,7 @@ */ #include "runtime/command_stream/command_stream_receiver.h" +#include "runtime/execution_environment/execution_environment.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" #include "runtime/os_interface/device_factory.h" #include "runtime/helpers/options.h" @@ -57,7 +58,8 @@ HWTEST_P(GetDevicesTest, givenGetDevicesWhenCsrIsSetToValidTypeThenTheFuntionRet int i = 0; size_t numDevices = 0; HardwareInfo *hwInfo = nullptr; - auto ret = getDevices(&hwInfo, numDevices); + ExecutionEnvironment executionEnvironment; + auto ret = getDevices(&hwInfo, numDevices, executionEnvironment); switch (csrType) { case CSR_HW: diff --git a/unit_tests/gen10/linux/device_factory_tests_gen10.cpp b/unit_tests/gen10/linux/device_factory_tests_gen10.cpp index 6331677ead..b09e127eb3 100644 --- a/unit_tests/gen10/linux/device_factory_tests_gen10.cpp +++ b/unit_tests/gen10/linux/device_factory_tests_gen10.cpp @@ -29,7 +29,7 @@ GEN10TEST_F(DeviceFactoryLinuxTestCnl, queryWhitelistedPreemptionRegister) { HardwareInfo *hwInfo = nullptr; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE(success); #if defined(I915_PARAM_HAS_PREEMPTION) EXPECT_TRUE(hwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580); @@ -45,7 +45,7 @@ GEN10TEST_F(DeviceFactoryLinuxTestCnl, queryNotWhitelistedPreemptionRegister) { HardwareInfo *hwInfo = nullptr; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE(success); EXPECT_FALSE(hwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580); diff --git a/unit_tests/gen10/windows/os_interface_tests_gen10.cpp b/unit_tests/gen10/windows/os_interface_tests_gen10.cpp index 98cce3407a..29b925c0fb 100644 --- a/unit_tests/gen10/windows/os_interface_tests_gen10.cpp +++ b/unit_tests/gen10/windows/os_interface_tests_gen10.cpp @@ -20,6 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/execution_environment/execution_environment.h" #include "unit_tests/os_interface/windows/os_interface_win_tests.h" #include "unit_tests/gen_common/test.h" @@ -30,7 +31,8 @@ GEN10TEST_F(OsInterfaceTestCnl, askKmdIfPreemptionRegisterWhitelisted) { const HardwareInfo *refHwinfo = *platformDevices; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + ExecutionEnvironment executionEnvironment; + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE(success); for (size_t i = 0u; i < numDevices; i++) { diff --git a/unit_tests/gen9/linux/device_factory_tests_gen9.cpp b/unit_tests/gen9/linux/device_factory_tests_gen9.cpp index c18ef59a02..7ff191fdf7 100644 --- a/unit_tests/gen9/linux/device_factory_tests_gen9.cpp +++ b/unit_tests/gen9/linux/device_factory_tests_gen9.cpp @@ -29,7 +29,7 @@ GEN9TEST_F(DeviceFactoryLinuxTestSkl, queryWhitelistedPreemptionRegister) { HardwareInfo *hwInfo = nullptr; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE(success); #if defined(I915_PARAM_HAS_PREEMPTION) EXPECT_TRUE(hwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580); @@ -45,7 +45,7 @@ GEN9TEST_F(DeviceFactoryLinuxTestSkl, queryNotWhitelistedPreemptionRegister) { HardwareInfo *hwInfo = nullptr; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE(success); EXPECT_FALSE(hwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580); diff --git a/unit_tests/gen9/windows/os_interface_tests_gen9.cpp b/unit_tests/gen9/windows/os_interface_tests_gen9.cpp index 080e54345e..c3653de898 100644 --- a/unit_tests/gen9/windows/os_interface_tests_gen9.cpp +++ b/unit_tests/gen9/windows/os_interface_tests_gen9.cpp @@ -20,6 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/execution_environment/execution_environment.h" #include "unit_tests/os_interface/windows/os_interface_win_tests.h" #include "unit_tests/gen_common/test.h" @@ -30,7 +31,8 @@ GEN9TEST_F(OsInterfaceTestSkl, askKmdIfPreemptionRegisterWhitelisted) { const HardwareInfo *refHwinfo = *platformDevices; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + ExecutionEnvironment executionEnvironment; + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE(success); for (size_t i = 0u; i < numDevices; i++) { diff --git a/unit_tests/libult/create_command_stream.cpp b/unit_tests/libult/create_command_stream.cpp index 766a0a37fa..2eb5a21656 100644 --- a/unit_tests/libult/create_command_stream.cpp +++ b/unit_tests/libult/create_command_stream.cpp @@ -52,13 +52,13 @@ CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo) { return commandStreamReceiver; } -bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned) { +bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) { if (overrideDeviceWithDefaultHardwareInfo) { *hwInfo = const_cast(*platformDevices); numDevicesReturned = numPlatformDevices; return getDevicesResult; } - return getDevicesImpl(hwInfo, numDevicesReturned); + return getDevicesImpl(hwInfo, numDevicesReturned, executionEnvironment); } } // namespace OCLRT diff --git a/unit_tests/libult/create_command_stream.h b/unit_tests/libult/create_command_stream.h index 6520570351..fbc136e20c 100644 --- a/unit_tests/libult/create_command_stream.h +++ b/unit_tests/libult/create_command_stream.h @@ -27,5 +27,5 @@ extern bool overrideCommandStreamReceiverCreation; extern bool overrideDeviceWithDefaultHardwareInfo; extern CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo); -extern bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned); +extern bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment); } // namespace OCLRT diff --git a/unit_tests/os_interface/device_factory_tests.cpp b/unit_tests/os_interface/device_factory_tests.cpp index 86d1086126..945e34b9be 100644 --- a/unit_tests/os_interface/device_factory_tests.cpp +++ b/unit_tests/os_interface/device_factory_tests.cpp @@ -20,6 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/execution_environment/execution_environment.h" #include "runtime/helpers/hw_info.h" #include "runtime/helpers/options.h" #include "runtime/os_interface/device_factory.h" @@ -45,13 +46,14 @@ struct DeviceFactoryTest : public ::testing::Test { protected: OsLibrary *mockGdiDll; + ExecutionEnvironment executionEnvironment; }; TEST_F(DeviceFactoryTest, GetDevices_Expect_True_If_Returned) { DeviceFactoryCleaner cleaner; HardwareInfo *hwInfo = nullptr; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE((numDevices > 0) ? success : !success); } @@ -60,7 +62,7 @@ TEST_F(DeviceFactoryTest, GetDevices_Check_HwInfo_Null) { DeviceFactoryCleaner cleaner; HardwareInfo *hwInfo = nullptr; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE((numDevices > 0) ? success : !success); if (numDevices > 0) { @@ -78,7 +80,7 @@ TEST_F(DeviceFactoryTest, GetDevices_Check_HwInfo_Platform) { const HardwareInfo *refHwinfo = *platformDevices; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE((numDevices > 0) ? success : !success); if (numDevices > 0) { @@ -97,7 +99,7 @@ TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) { HardwareInfo *hwInfoOverriden = nullptr; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfoReference, numDevices); + bool success = DeviceFactory::getDevices(&hwInfoReference, numDevices, executionEnvironment); ASSERT_TRUE(success); auto refEnableKmdNotify = hwInfoReference->capabilityTable.kmdNotifyProperties.enableKmdNotify; auto refDelayKmdNotifyMicroseconds = hwInfoReference->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds; @@ -116,7 +118,7 @@ TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) { DebugManager.flags.OverrideEnableQuickKmdSleepForSporadicWaits.set(!refEnableQuickKmdSleepForSporadicWaits); DebugManager.flags.OverrideDelayQuickKmdSleepForSporadicWaitsMicroseconds.set(static_cast(refDelayQuickKmdSleepForSporadicWaitsMicroseconds) + 12); - success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices); + success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices, executionEnvironment); ASSERT_TRUE(success); EXPECT_EQ(!refEnableKmdNotify, hwInfoOverriden->capabilityTable.kmdNotifyProperties.enableKmdNotify); @@ -139,7 +141,7 @@ TEST_F(DeviceFactoryTest, getEngineTypeDebugOverride) { HardwareInfo *hwInfoOverriden = nullptr; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices); + bool success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices, executionEnvironment); ASSERT_TRUE(success); ASSERT_NE(nullptr, hwInfoOverriden); int32_t actualEngineType = static_cast(hwInfoOverriden->capabilityTable.defaultEngineType); @@ -150,7 +152,7 @@ TEST_F(DeviceFactoryTest, givenPointerToHwInfoWhenGetDevicedCalledThenRequiedSur DeviceFactoryCleaner cleaner; HardwareInfo *hwInfo = nullptr; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); ASSERT_TRUE(success); EXPECT_EQ(hwInfo->pSysInfo->CsrSizeInMb * MemoryConstants::megaByte, hwInfo->capabilityTable.requiredPreemptionSurfaceSize); @@ -163,7 +165,7 @@ TEST_F(DeviceFactoryTest, givenCreateMultipleDevicesDebugFlagWhenGetDevicesIsCal DebugManager.flags.CreateMultipleDevices.set(requiredDeviceCount); HardwareInfo *hwInfo = nullptr; size_t numDevices = 0; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); ASSERT_NE(nullptr, hwInfo); for (auto deviceIndex = 0u; deviceIndex < requiredDeviceCount; deviceIndex++) { diff --git a/unit_tests/os_interface/linux/device_factory_tests.cpp b/unit_tests/os_interface/linux/device_factory_tests.cpp index ad06affedd..e6051a6461 100644 --- a/unit_tests/os_interface/linux/device_factory_tests.cpp +++ b/unit_tests/os_interface/linux/device_factory_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -30,7 +30,7 @@ TEST_F(DeviceFactoryLinuxTest, GetDevicesCheckEUCntSSCnt) { pDrm->StoredEUVal = 11; pDrm->StoredSSVal = 8; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE(success); EXPECT_EQ((int)numDevices, 1); @@ -52,7 +52,7 @@ TEST_F(DeviceFactoryLinuxTest, GetDevicesDrmCreateFailed) { size_t numDevices = 0; pushDrmMock(nullptr); - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_FALSE(success); popDrmMock(); @@ -64,7 +64,7 @@ TEST_F(DeviceFactoryLinuxTest, GetDevicesDrmCreateFailedConfigureHwInfo) { pDrm->StoredRetValForDeviceID = -1; - bool success = DeviceFactory::getDevices(&hwInfo, numDevices); + bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_FALSE(success); pDrm->StoredRetValForDeviceID = 0; @@ -83,7 +83,7 @@ TEST_F(DeviceFactoryLinuxTest, ReleaseDevices) { pDrm->StoredMinEUinPool = 9; pDrm->StoredRetVal = -1; - bool success = mockDeviceFactory.getDevices(&hwInfo, numDevices); + bool success = mockDeviceFactory.getDevices(&hwInfo, numDevices, executionEnvironment); EXPECT_TRUE(success); mockDeviceFactory.releaseDevices(); diff --git a/unit_tests/os_interface/linux/device_factory_tests.h b/unit_tests/os_interface/linux/device_factory_tests.h index 2764cd6208..ae74f3501b 100644 --- a/unit_tests/os_interface/linux/device_factory_tests.h +++ b/unit_tests/os_interface/linux/device_factory_tests.h @@ -23,6 +23,7 @@ #pragma once #include "runtime/device/device.h" +#include "runtime/execution_environment/execution_environment.h" #include "runtime/helpers/options.h" #include "runtime/os_interface/device_factory.h" #include "unit_tests/mocks/mock_device_factory.h" @@ -50,4 +51,5 @@ struct DeviceFactoryLinuxTest : public ::testing::Test { } DrmMock *pDrm; + ExecutionEnvironment executionEnvironment; }; diff --git a/unit_tests/tbx/main_tbx.cpp b/unit_tests/tbx/main_tbx.cpp index 1a8d056c43..29da3a0957 100644 --- a/unit_tests/tbx/main_tbx.cpp +++ b/unit_tests/tbx/main_tbx.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -20,6 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/execution_environment/execution_environment.h" #include "runtime/helpers/hw_info.h" #include "unit_tests/custom_event_listener.h" #include "unit_tests/helpers/debug_manager_state_restore.h" @@ -28,7 +29,7 @@ using namespace OCLRT; namespace OCLRT { -bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned); +bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment); } TEST(CSRTests, getDevices) { @@ -37,7 +38,8 @@ TEST(CSRTests, getDevices) { DebugManagerStateRestore dbgState; DebugManager.flags.SetCommandStreamReceiver.set(2); - OCLRT::getDevices(&hwInfo, numDevicesReturned); + ExecutionEnvironment executionEnvironment; + OCLRT::getDevices(&hwInfo, numDevicesReturned, executionEnvironment); ASSERT_NE(nullptr, hwInfo); ASSERT_NE(nullptr, hwInfo->pSysInfo);