From 18bfc3be8bced70c1ecec571debb817eaddb5c58 Mon Sep 17 00:00:00 2001 From: Lukasz Jobczyk Date: Wed, 20 Jan 2021 14:43:42 +0000 Subject: [PATCH] Revert "Extend ZE_AFFINITY_MASK to OCL" This reverts commit 452b53fb4d02ebf4205018b9fd982422e2d85f30. Signed-off-by: Lukasz Jobczyk --- level_zero/core/source/device/device_imp.cpp | 9 ++- .../core/source/driver/driver_handle_imp.cpp | 67 ++++++++++++++++- .../core/source/driver/driver_handle_imp.h | 2 + .../core/test/unit_tests/CMakeLists.txt | 23 ------ .../unit_tests/sources/driver/test_driver.cpp | 59 +++++++-------- .../os_interface/device_factory_tests.cpp | 63 ---------------- .../test/unit_test/test_files/igdrcl.config | 1 - .../debug_settings/release_variables.inl | 1 - shared/source/device/root_device.cpp | 9 +-- .../execution_environment.cpp | 73 ------------------- .../execution_environment.h | 1 - .../root_device_environment.h | 4 - shared/source/os_interface/device_factory.cpp | 1 - 13 files changed, 103 insertions(+), 210 deletions(-) diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index 402af8b8c0..840be6fb1b 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -45,8 +45,6 @@ #include "hw_helpers.h" -#include - namespace NEO { bool releaseFP64Override(); } // namespace NEO @@ -563,12 +561,15 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3 device->setDebugSurface(debugSurface); } - std::bitset<32> deviceMaskBitset(currentDeviceMask); - if (device->neoDevice->getNumAvailableDevices() == 1 && deviceMaskBitset.count() != 1u) { + if (device->neoDevice->getNumAvailableDevices() == 1) { device->numSubDevices = 0; } else { for (uint32_t i = 0; i < device->neoDevice->getNumAvailableDevices(); i++) { + if (!((1UL << i) & currentDeviceMask)) { + continue; + } + ze_device_handle_t subDevice = Device::create(driverHandle, device->neoDevice->getDeviceById(i), 0, diff --git a/level_zero/core/source/driver/driver_handle_imp.cpp b/level_zero/core/source/driver/driver_handle_imp.cpp index 73b90cdd51..2e8b35bf80 100644 --- a/level_zero/core/source/driver/driver_handle_imp.cpp +++ b/level_zero/core/source/driver/driver_handle_imp.cpp @@ -177,17 +177,80 @@ DriverHandleImp::~DriverHandleImp() { } } +uint32_t DriverHandleImp::parseAffinityMask(std::vector> &neoDevices) { + std::vector> affinityMaskBitSet(neoDevices.size()); + for (uint32_t i = 0; i < affinityMaskBitSet.size(); i++) { + affinityMaskBitSet[i].resize(neoDevices[i]->getNumAvailableDevices()); + } + + size_t pos = 0; + while (pos < this->affinityMaskString.size()) { + size_t posNextDot = this->affinityMaskString.find_first_of(".", pos); + size_t posNextComma = this->affinityMaskString.find_first_of(",", pos); + std::string rootDeviceString = this->affinityMaskString.substr(pos, std::min(posNextDot, posNextComma) - pos); + uint32_t rootDeviceIndex = static_cast(std::stoul(rootDeviceString, nullptr, 0)); + if (rootDeviceIndex < neoDevices.size()) { + pos += rootDeviceString.size(); + if (posNextDot != std::string::npos && + this->affinityMaskString.at(pos) == '.' && posNextDot < posNextComma) { + pos++; + std::string subDeviceString = this->affinityMaskString.substr(pos, posNextComma - pos); + uint32_t subDeviceIndex = static_cast(std::stoul(subDeviceString, nullptr, 0)); + if (subDeviceIndex < neoDevices[rootDeviceIndex]->getNumAvailableDevices()) { + affinityMaskBitSet[rootDeviceIndex][subDeviceIndex] = true; + } + } else { + std::fill(affinityMaskBitSet[rootDeviceIndex].begin(), + affinityMaskBitSet[rootDeviceIndex].end(), + true); + } + } + if (posNextComma == std::string::npos) { + break; + } + pos = posNextComma + 1; + } + + uint32_t offset = 0; + uint32_t affinityMask = 0; + for (uint32_t i = 0; i < affinityMaskBitSet.size(); i++) { + for (uint32_t j = 0; j < affinityMaskBitSet[i].size(); j++) { + if (affinityMaskBitSet[i][j] == true) { + affinityMask |= (1UL << offset); + } + offset++; + } + } + + return affinityMask; +} + ze_result_t DriverHandleImp::initialize(std::vector> neoDevices) { + uint32_t affinityMask = std::numeric_limits::max(); + if (enablePciIdDeviceOrder) { sortNeoDevices(neoDevices); } + if (this->affinityMaskString.length() > 0) { + affinityMask = parseAffinityMask(neoDevices); + } + + uint32_t currentMaskOffset = 0; for (auto &neoDevice : neoDevices) { if (!neoDevice->getHardwareInfo().capabilityTable.levelZeroSupported) { continue; } + uint32_t currentDeviceMask = (affinityMask >> currentMaskOffset) & ((1UL << neoDevice->getNumAvailableDevices()) - 1); + bool isDeviceExposed = currentDeviceMask ? true : false; + + currentMaskOffset += neoDevice->getNumAvailableDevices(); + if (!isDeviceExposed) { + continue; + } + if (this->memoryManager == nullptr) { this->memoryManager = neoDevice->getMemoryManager(); if (this->memoryManager == nullptr) { @@ -207,8 +270,7 @@ ze_result_t DriverHandleImp::initialize(std::vector this->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex()); this->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()}); - auto pNeoDevice = neoDevice.release(); - auto device = Device::create(this, pNeoDevice, pNeoDevice->getExecutionEnvironment()->rootDeviceEnvironments[pNeoDevice->getRootDeviceIndex()]->deviceAffinityMask, false); + auto device = Device::create(this, neoDevice.release(), currentDeviceMask, false); this->devices.push_back(device); } @@ -233,6 +295,7 @@ DriverHandle *DriverHandle::create(std::vector> dev DriverHandleImp *driverHandle = new DriverHandleImp; UNRECOVERABLE_IF(nullptr == driverHandle); + driverHandle->affinityMaskString = envVariables.affinityMask; driverHandle->enableProgramDebugging = envVariables.programDebugging; driverHandle->enableSysman = envVariables.sysman; driverHandle->enablePciIdDeviceOrder = envVariables.pciIdDeviceOrder; diff --git a/level_zero/core/source/driver/driver_handle_imp.h b/level_zero/core/source/driver/driver_handle_imp.h index 89c6e88aa5..67975af9cd 100644 --- a/level_zero/core/source/driver/driver_handle_imp.h +++ b/level_zero/core/source/driver/driver_handle_imp.h @@ -80,6 +80,7 @@ struct DriverHandleImp : public DriverHandle { size_t size, uint32_t rootDeviceIndex, uintptr_t *gpuAddress) override; + uint32_t parseAffinityMask(std::vector> &neoDevices); void createHostPointerManager(); void sortNeoDevices(std::vector> &neoDevices); @@ -90,6 +91,7 @@ struct DriverHandleImp : public DriverHandle { std::mutex sharedMakeResidentAllocationsLock; std::map sharedMakeResidentAllocations; + std::string affinityMaskString = ""; std::vector devices; // Spec extensions const std::vector> extensionsSupported = { diff --git a/level_zero/core/test/unit_tests/CMakeLists.txt b/level_zero/core/test/unit_tests/CMakeLists.txt index d56ebf6a9f..a58c8b6c86 100644 --- a/level_zero/core/test/unit_tests/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/CMakeLists.txt @@ -132,29 +132,6 @@ set(TEST_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/test_modules/test_kernel.cl ) -add_custom_target(copy_l0_test_files) - -add_custom_command(TARGET copy_l0_test_files - POST_BUILD - COMMAND echo deleting and re-creating "${CUSTOM_COMMAND_BINARY_DIR}/test_files" ... - COMMAND ${CMAKE_COMMAND} -E remove_directory "${CUSTOM_COMMAND_BINARY_DIR}/test_files" - COMMAND ${CMAKE_COMMAND} -E make_directory "${CUSTOM_COMMAND_BINARY_DIR}/test_files" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/test_files" -) -set_target_properties(copy_l0_test_files PROPERTIES FOLDER ${TARGET_NAME_L0}) - -if(UNIX) - add_custom_command(TARGET copy_l0_test_files - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory "${NEO_SOURCE_DIR}/opencl/test/unit_test/test_files/linux" "${CUSTOM_COMMAND_BINARY_DIR}/test_files/linux" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/test_files" - ) - - add_dependencies(${TARGET_NAME} - copy_l0_test_files - ) -endif() - macro(macro_for_each_gen) foreach(PLATFORM_TYPE ${PLATFORM_TYPES}) if(${GEN_TYPE}_HAS_${PLATFORM_TYPE}) diff --git a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp index 7526297af6..65d6d76a3b 100644 --- a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp +++ b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp @@ -9,7 +9,6 @@ #include "shared/source/os_interface/device_factory.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/test/unit_test/helpers/debug_manager_state_restore.h" -#include "shared/test/unit_test/helpers/ult_hw_config.h" #include "shared/test/unit_test/mocks/ult_device_factory.h" #include "opencl/test/unit_test/mocks/mock_io_functions.h" @@ -330,12 +329,24 @@ struct MaskArray { struct DriverTestMultipleDeviceWithAffinityMask : public ::testing::WithParamInterface>, public ::testing::Test { void SetUp() override { - DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices); DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices); VariableBackup mockDeviceFlagBackup(&MockDevice::createSingleDevice, false); + + NEO::ExecutionEnvironment *executionEnvironment = new NEO::ExecutionEnvironment(); + executionEnvironment->prepareRootDeviceEnvironments(numRootDevices); + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(NEO::defaultHwInfo.get()); + } + + for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { + devices.push_back(std::unique_ptr(NEO::MockDevice::createWithExecutionEnvironment( + NEO::defaultHwInfo.get(), + executionEnvironment, i))); + } } DebugManagerStateRestore restorer; + std::vector> devices; const uint32_t numRootDevices = 2u; const uint32_t numSubDevices = 4u; @@ -343,20 +354,17 @@ struct DriverTestMultipleDeviceWithAffinityMask : public ::testing::WithParamInt TEST_P(DriverTestMultipleDeviceWithAffinityMask, whenSettingAffinityMaskToRetrieveOneSubDeviceOnEachDeviceThenCorrectDevicesAreExposed) { - VariableBackup backup(&ultHwConfig); - ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; - L0::DriverHandleImp *driverHandle = new DriverHandleImp; std::string subDevice0String = std::get<0>(GetParam()); + uint32_t subDevice0Index = std::stoi(subDevice0String, nullptr, 0); + std::string subDevice1String = std::get<1>(GetParam()); + uint32_t subDevice1Index = std::stoi(subDevice1String, nullptr, 0); constexpr uint32_t totalRootDevices = 2; - DebugManager.flags.ZE_AFFINITY_MASK.set("0." + subDevice0String + "," + "1." + subDevice1String); - - NEO::ExecutionEnvironment *executionEnvironment = new NEO::ExecutionEnvironment(); - auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment); + driverHandle->affinityMaskString = "0." + subDevice0String + "," + "1." + subDevice1String; ze_result_t res = driverHandle->initialize(std::move(devices)); EXPECT_EQ(ZE_RESULT_SUCCESS, res); @@ -388,7 +396,11 @@ TEST_P(DriverTestMultipleDeviceWithAffinityMask, DeviceImp *subDevice = reinterpret_cast(L0::Device::fromHandle(hSubDevice)); - EXPECT_EQ(subDevice->neoDevice, device->neoDevice->getDeviceById(0u)); + if (i == 0) { + EXPECT_EQ(subDevice->neoDevice, device->neoDevice->getDeviceById(subDevice0Index)); + } else { + EXPECT_EQ(subDevice->neoDevice, device->neoDevice->getDeviceById(subDevice1Index)); + } } delete driverHandle; @@ -397,19 +409,14 @@ TEST_P(DriverTestMultipleDeviceWithAffinityMask, TEST_P(DriverTestMultipleDeviceWithAffinityMask, whenSettingAffinityMaskToRetrieveAllDevicesInOneDeviceAndOneSubDeviceInOtherThenCorrectDevicesAreExposed) { - VariableBackup backup(&ultHwConfig); - ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; - L0::DriverHandleImp *driverHandle = new DriverHandleImp; std::string subDevice1String = std::get<1>(GetParam()); + uint32_t subDevice1Index = std::stoi(subDevice1String, nullptr, 0); constexpr uint32_t totalRootDevices = 2; - DebugManager.flags.ZE_AFFINITY_MASK.set("0,1." + subDevice1String); - - NEO::ExecutionEnvironment *executionEnvironment = new NEO::ExecutionEnvironment(); - auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment); + driverHandle->affinityMaskString = "0,1." + subDevice1String; ze_result_t res = driverHandle->initialize(std::move(devices)); EXPECT_EQ(ZE_RESULT_SUCCESS, res); @@ -443,7 +450,7 @@ TEST_P(DriverTestMultipleDeviceWithAffinityMask, DeviceImp *subDevice = reinterpret_cast(L0::Device::fromHandle(hSubDevice)); EXPECT_EQ(1u, subDeviceCount); - EXPECT_EQ(subDevice->neoDevice, device->neoDevice->getDeviceById(0u)); + EXPECT_EQ(subDevice->neoDevice, device->neoDevice->getDeviceById(subDevice1Index)); } } @@ -460,17 +467,11 @@ INSTANTIATE_TEST_SUITE_P(DriverTestMultipleDeviceWithAffinityMaskTests, TEST_F(DriverTestMultipleDeviceWithAffinityMask, whenSettingAffinityMaskWithDeviceLargerThanAvailableDevicesThenRootDeviceValueIsIgnored) { - VariableBackup backup(&ultHwConfig); - ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; - L0::DriverHandleImp *driverHandle = new DriverHandleImp; constexpr uint32_t totalRootDevices = 2; uint32_t subDevice1Index = 0; - DebugManager.flags.ZE_AFFINITY_MASK.set("0,23,1." + std::to_string(subDevice1Index)); - - NEO::ExecutionEnvironment *executionEnvironment = new NEO::ExecutionEnvironment(); - auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment); + driverHandle->affinityMaskString = "0,23,1." + std::to_string(subDevice1Index); ze_result_t res = driverHandle->initialize(std::move(devices)); EXPECT_EQ(ZE_RESULT_SUCCESS, res); @@ -514,15 +515,9 @@ TEST_F(DriverTestMultipleDeviceWithAffinityMask, TEST_F(DriverTestMultipleDeviceWithAffinityMask, whenSettingAffinityMaskWithSubDeviceLargerThanAvailableSubDevicesThenSubDeviceValueIsIgnored) { - VariableBackup backup(&ultHwConfig); - ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; - L0::DriverHandleImp *driverHandle = new DriverHandleImp; - DebugManager.flags.ZE_AFFINITY_MASK.set("0,1.77"); - - NEO::ExecutionEnvironment *executionEnvironment = new NEO::ExecutionEnvironment(); - auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment); + driverHandle->affinityMaskString = "0,1.77"; ze_result_t res = driverHandle->initialize(std::move(devices)); EXPECT_EQ(ZE_RESULT_SUCCESS, res); diff --git a/opencl/test/unit_test/os_interface/device_factory_tests.cpp b/opencl/test/unit_test/os_interface/device_factory_tests.cpp index a1017b7392..c0524c8235 100644 --- a/opencl/test/unit_test/os_interface/device_factory_tests.cpp +++ b/opencl/test/unit_test/os_interface/device_factory_tests.cpp @@ -12,8 +12,6 @@ #include "shared/source/os_interface/os_interface.h" #include "shared/source/os_interface/os_library.h" #include "shared/test/unit_test/helpers/debug_manager_state_restore.h" -#include "shared/test/unit_test/helpers/ult_hw_config.h" -#include "shared/test/unit_test/helpers/variable_backup.h" #include "shared/test/unit_test/mocks/ult_device_factory.h" #include "opencl/source/platform/platform.h" @@ -96,67 +94,6 @@ TEST_F(DeviceFactoryTest, WhenOverridingUsingDebugManagerThenOverridesAreApplied hwInfo->capabilityTable.kmdNotifyProperties.delayQuickKmdSleepForSporadicWaitsMicroseconds); } -TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetWhenCreateDevicesThenProperNumberOfDevicesIsReturned) { - DebugManagerStateRestore restorer; - DebugManager.flags.CreateMultipleRootDevices.set(5); - DebugManager.flags.CreateMultipleSubDevices.set(4); - DebugManager.flags.ZE_AFFINITY_MASK.set("1.0,2.3,2.1,1.3,0,2.0,4.0,4.2,4.3,4.1"); - VariableBackup backup(&ultHwConfig); - ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; - - auto devices = DeviceFactory::createDevices(*executionEnvironment); - - EXPECT_EQ(devices.size(), 4u); - EXPECT_EQ(devices[0]->getNumAvailableDevices(), 4u); - EXPECT_EQ(devices[1]->getNumAvailableDevices(), 2u); - EXPECT_EQ(devices[2]->getNumAvailableDevices(), 3u); - EXPECT_EQ(devices[3]->getNumAvailableDevices(), 4u); -} - -TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToGreaterRootDeviceThanAvailableWhenCreateDevicesThenProperNumberOfDevicesIsReturned) { - DebugManagerStateRestore restorer; - DebugManager.flags.CreateMultipleRootDevices.set(2); - DebugManager.flags.CreateMultipleSubDevices.set(4); - DebugManager.flags.ZE_AFFINITY_MASK.set("0,92,1.1"); - VariableBackup backup(&ultHwConfig); - ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; - - auto devices = DeviceFactory::createDevices(*executionEnvironment); - - EXPECT_EQ(devices.size(), 2u); - EXPECT_EQ(devices[0]->getNumAvailableDevices(), 4u); - EXPECT_EQ(devices[1]->getNumAvailableDevices(), 1u); -} - -TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToGreaterSubDeviceThanAvailableWhenCreateDevicesThenProperNumberOfDevicesIsReturned) { - DebugManagerStateRestore restorer; - DebugManager.flags.CreateMultipleRootDevices.set(2); - DebugManager.flags.CreateMultipleSubDevices.set(4); - DebugManager.flags.ZE_AFFINITY_MASK.set("0,1.54"); - VariableBackup backup(&ultHwConfig); - ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; - - auto devices = DeviceFactory::createDevices(*executionEnvironment); - - EXPECT_EQ(devices.size(), 1u); - EXPECT_EQ(devices[0]->getNumAvailableDevices(), 4u); -} - -TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToRootDevicesOnlyWhenCreateDevicesThenProperNumberOfDevicesIsReturned) { - DebugManagerStateRestore restorer; - DebugManager.flags.CreateMultipleRootDevices.set(2); - DebugManager.flags.CreateMultipleSubDevices.set(4); - DebugManager.flags.ZE_AFFINITY_MASK.set("0,1"); - VariableBackup backup(&ultHwConfig); - ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; - - auto devices = DeviceFactory::createDevices(*executionEnvironment); - - EXPECT_EQ(devices.size(), 2u); - EXPECT_EQ(devices[0]->getNumAvailableDevices(), 4u); - EXPECT_EQ(devices[1]->getNumAvailableDevices(), 4u); -} - TEST_F(DeviceFactoryTest, WhenOverridingEngineTypeThenDebugEngineIsReported) { DebugManagerStateRestore dbgRestorer; int32_t debugEngineType = 2; diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 7acaf0de50..2181b8cdca 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -9,7 +9,6 @@ AUBDumpFilterKernelName = unk AUBDumpToggleFileName = unk OverrideGdiPath = unk AubDumpAddMmioRegistersList = unk -ZE_AFFINITY_MASK = default AUBDumpFilterNamedKernelStartIdx = 0 AUBDumpFilterNamedKernelEndIdx = -1 AUBDumpSubCaptureMode = 0 diff --git a/shared/source/debug_settings/release_variables.inl b/shared/source/debug_settings/release_variables.inl index 7d6de94941..871a45c562 100644 --- a/shared/source/debug_settings/release_variables.inl +++ b/shared/source/debug_settings/release_variables.inl @@ -12,4 +12,3 @@ DECLARE_DEBUG_VARIABLE(bool, MakeAllBuffersResident, false, "Make all buffers resident after creation") DECLARE_DEBUG_VARIABLE(int32_t, OverrideDefaultFP64Settings, -1, "-1: dont override, 0: disable, 1: enable.") DECLARE_DEBUG_VARIABLE(int32_t, EnableCrossDeviceAccess, -1, "-1: default behavior, 0: disabled, 1: enabled, Allows one device to access another device's memory") -DECLARE_DEBUG_VARIABLE(std::string, ZE_AFFINITY_MASK, std::string("default"), "Refer to the Level Zero Specification for a desricption") diff --git a/shared/source/device/root_device.cpp b/shared/source/device/root_device.cpp index 124594892b..95f661f2bf 100644 --- a/shared/source/device/root_device.cpp +++ b/shared/source/device/root_device.cpp @@ -72,15 +72,14 @@ bool RootDevice::createDeviceImpl() { numSubDevices = 0; } UNRECOVERABLE_IF(!subdevices.empty()); + subdevices.resize(numSubDevices, nullptr); for (auto i = 0u; i < numSubDevices; i++) { - if (!((1UL << i) & executionEnvironment->rootDeviceEnvironments[this->rootDeviceIndex]->deviceAffinityMask)) { - continue; - } - auto subDevice = createSubDevice(static_cast(subdevices.size())); + + auto subDevice = createSubDevice(i); if (!subDevice) { return false; } - subdevices.push_back(subDevice); + subdevices[i] = subDevice; } auto status = Device::createDeviceImpl(); if (!status) { diff --git a/shared/source/execution_environment/execution_environment.cpp b/shared/source/execution_environment/execution_environment.cpp index 79066739e6..5e30a7a124 100644 --- a/shared/source/execution_environment/execution_environment.cpp +++ b/shared/source/execution_environment/execution_environment.cpp @@ -78,77 +78,4 @@ void ExecutionEnvironment::prepareRootDeviceEnvironments(uint32_t numRootDevices } } } - -void ExecutionEnvironment::parseAffinityMask() { - auto affinityMaskString = DebugManager.flags.ZE_AFFINITY_MASK.get(); - - if (affinityMaskString.compare("default") == 0) { - return; - } - - std::vector> affinityMaskBitSet(rootDeviceEnvironments.size()); - for (uint32_t i = 0; i < affinityMaskBitSet.size(); i++) { - auto hwInfo = rootDeviceEnvironments[i]->getHardwareInfo(); - affinityMaskBitSet[i].resize(HwHelper::getSubDevicesCount(hwInfo)); - } - - size_t pos = 0; - while (pos < affinityMaskString.size()) { - size_t posNextDot = affinityMaskString.find_first_of(".", pos); - size_t posNextComma = affinityMaskString.find_first_of(",", pos); - std::string rootDeviceString = affinityMaskString.substr(pos, std::min(posNextDot, posNextComma) - pos); - uint32_t rootDeviceIndex = static_cast(std::stoul(rootDeviceString, nullptr, 0)); - if (rootDeviceIndex < rootDeviceEnvironments.size()) { - pos += rootDeviceString.size(); - if (posNextDot != std::string::npos && - affinityMaskString.at(pos) == '.' && posNextDot < posNextComma) { - pos++; - std::string subDeviceString = affinityMaskString.substr(pos, posNextComma - pos); - uint32_t subDeviceIndex = static_cast(std::stoul(subDeviceString, nullptr, 0)); - auto hwInfo = rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo(); - if (subDeviceIndex < HwHelper::getSubDevicesCount(hwInfo)) { - affinityMaskBitSet[rootDeviceIndex][subDeviceIndex] = true; - } - } else { - std::fill(affinityMaskBitSet[rootDeviceIndex].begin(), - affinityMaskBitSet[rootDeviceIndex].end(), - true); - } - } - if (posNextComma == std::string::npos) { - break; - } - pos = posNextComma + 1; - } - - uint32_t offset = 0; - uint32_t affinityMask = 0; - for (uint32_t i = 0; i < affinityMaskBitSet.size(); i++) { - for (uint32_t j = 0; j < affinityMaskBitSet[i].size(); j++) { - if (affinityMaskBitSet[i][j] == true) { - affinityMask |= (1UL << offset); - } - offset++; - } - } - - uint32_t currentMaskOffset = 0; - std::vector> filteredEnvironments; - for (size_t i = 0u; i < this->rootDeviceEnvironments.size(); i++) { - auto hwInfo = rootDeviceEnvironments[i]->getHardwareInfo(); - - uint32_t currentDeviceMask = (affinityMask >> currentMaskOffset) & ((1UL << HwHelper::getSubDevicesCount(hwInfo)) - 1); - bool isDeviceExposed = currentDeviceMask ? true : false; - - currentMaskOffset += HwHelper::getSubDevicesCount(hwInfo); - if (!isDeviceExposed) { - continue; - } - - rootDeviceEnvironments[i]->deviceAffinityMask = currentDeviceMask; - filteredEnvironments.emplace_back(rootDeviceEnvironments[i].release()); - } - - rootDeviceEnvironments.swap(filteredEnvironments); -} } // namespace NEO diff --git a/shared/source/execution_environment/execution_environment.h b/shared/source/execution_environment/execution_environment.h index 7929d5ac6d..263f581895 100644 --- a/shared/source/execution_environment/execution_environment.h +++ b/shared/source/execution_environment/execution_environment.h @@ -24,7 +24,6 @@ class ExecutionEnvironment : public ReferenceTrackedObject MOCKABLE_VIRTUAL bool initializeMemoryManager(); void calculateMaxOsContextCount(); void prepareRootDeviceEnvironments(uint32_t numRootDevices); - void parseAffinityMask(); void setDebuggingEnabled() { debuggingEnabled = true; } diff --git a/shared/source/execution_environment/root_device_environment.h b/shared/source/execution_environment/root_device_environment.h index 104884eba5..ce7cbc9978 100644 --- a/shared/source/execution_environment/root_device_environment.h +++ b/shared/source/execution_environment/root_device_environment.h @@ -28,8 +28,6 @@ class MemoryOperationsHandler; class OSInterface; struct HardwareInfo; -constexpr uint32_t allDevicesActive = std::numeric_limits::max(); - struct RootDeviceEnvironment { protected: std::unique_ptr hwInfo; @@ -64,8 +62,6 @@ struct RootDeviceEnvironment { std::unique_ptr debugger; ExecutionEnvironment &executionEnvironment; - uint32_t deviceAffinityMask = allDevicesActive; - private: std::mutex mtx; }; diff --git a/shared/source/os_interface/device_factory.cpp b/shared/source/os_interface/device_factory.cpp index 4a76abffc4..f3eb89d39b 100644 --- a/shared/source/os_interface/device_factory.cpp +++ b/shared/source/os_interface/device_factory.cpp @@ -119,7 +119,6 @@ bool DeviceFactory::prepareDeviceEnvironments(ExecutionEnvironment &executionEnv rootDeviceIndex++; } - executionEnvironment.parseAffinityMask(); executionEnvironment.calculateMaxOsContextCount(); return true;