fix: Add getDefaultDeviceHierarchy call to GfxCoreHelper

Added getDefaultDeviceHierarchy call that describes default device
hierarchy for a gfx core. Refactored L0 and OCL paths to use this
value by default and override this value when user sets
ZE_FLAT_DEVICE_HIERARCHY environment variable or
ReturnSubDevicesAsApiDevices debug key.

Updated ReturnSubDevicesAsApiDevices to force COMPOSITE device hierarchy
when set to 0.

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2023-10-05 23:12:34 +00:00
committed by Compute-Runtime-Automation
parent 238286d076
commit 08e92d154f
17 changed files with 149 additions and 33 deletions

View File

@@ -9,6 +9,7 @@
#include "shared/source/device/device.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/os_interface/debug_env_reader.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/pin/pin.h"
@@ -47,7 +48,7 @@ void DriverImp::initialize(ze_result_t *result) {
envVariables.fp64Emulation =
envReader.getSetting("NEO_FP64_EMULATION", false);
envVariables.deviceHierarchyMode =
envReader.getSetting("ZE_FLAT_DEVICE_HIERARCHY", std::string("COMPOSITE"));
envReader.getSetting("ZE_FLAT_DEVICE_HIERARCHY", std::string(NEO::deviceHierarchyUnk));
auto executionEnvironment = new NEO::ExecutionEnvironment();
UNRECOVERABLE_IF(nullptr == executionEnvironment);

View File

@@ -12,6 +12,7 @@
#include "shared/source/device/device.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/string.h"
#include "shared/source/helpers/string_helpers.h"
@@ -270,11 +271,15 @@ DriverHandle *DriverHandle::create(std::vector<std::unique_ptr<NEO::Device>> dev
driverHandle->enableProgramDebugging = static_cast<NEO::DebuggingMode>(envVariables.programDebugging);
driverHandle->enableSysman = envVariables.sysman;
driverHandle->enablePciIdDeviceOrder = envVariables.pciIdDeviceOrder;
if (strcmp(envVariables.deviceHierarchyMode.c_str(), "COMPOSITE") == 0) {
char const *preferredDeviceHierarchy = envVariables.deviceHierarchyMode.c_str();
if (strcmp(preferredDeviceHierarchy, NEO::deviceHierarchyUnk) == 0) {
preferredDeviceHierarchy = devices[0]->getGfxCoreHelper().getDefaultDeviceHierarchy();
}
if (strcmp(preferredDeviceHierarchy, "COMPOSITE") == 0) {
driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMPOSITE;
} else if (strcmp(envVariables.deviceHierarchyMode.c_str(), "FLAT") == 0) {
} else if (strcmp(preferredDeviceHierarchy, "FLAT") == 0) {
driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT;
} else if (strcmp(envVariables.deviceHierarchyMode.c_str(), "COMBINED") == 0) {
} else if (strcmp(preferredDeviceHierarchy, "COMBINED") == 0) {
driverHandle->deviceHierarchyMode = L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMBINED;
}
ze_result_t res = driverHandle->initialize(std::move(devices));

View File

@@ -7,6 +7,7 @@
#include "shared/source/built_ins/sip.h"
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/string.h"
#include "shared/source/memory_manager/allocation_properties.h"
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
@@ -473,7 +474,7 @@ TEST(DriverImpTest, givenEnabledProgramDebuggingWhenCreatingExecutionEnvironment
L0::GlobalDriver = nullptr;
}
TEST(DriverImpTest, givenDefaultFlatDeviceHierarchyWhenCreatingExecutionEnvironmentThenCompositeHierarchyIsEnabled) {
TEST(DriverImpTest, whenCreatingExecutionEnvironmentThenDefaultHierarchyIsEnabled) {
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
hwInfo.capabilityTable.levelZeroSupported = true;
@@ -482,7 +483,12 @@ TEST(DriverImpTest, givenDefaultFlatDeviceHierarchyWhenCreatingExecutionEnvironm
DriverImp driverImp;
driverImp.initialize(&result);
L0::DriverHandleImp *driverHandleImp = reinterpret_cast<L0::DriverHandleImp *>(L0::GlobalDriverHandle);
EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMPOSITE);
auto &gfxCoreHelper = driverHandleImp->memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[0]->getHelper<NEO::GfxCoreHelper>();
if (strcmp(gfxCoreHelper.getDefaultDeviceHierarchy(), "COMPOSITE") == 0) {
EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMPOSITE);
} else {
EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_FLAT);
}
ASSERT_NE(nullptr, L0::GlobalDriver);
ASSERT_NE(0u, L0::GlobalDriver->numDevices);
@@ -513,6 +519,28 @@ TEST(DriverImpTest, givenFlatDeviceHierarchyWhenCreatingExecutionEnvironmentThen
L0::GlobalDriver = nullptr;
}
TEST(DriverImpTest, givenCompositeDeviceHierarchyWhenCreatingExecutionEnvironmentThenCompositeHierarchyIsEnabled) {
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
hwInfo.capabilityTable.levelZeroSupported = true;
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
ze_result_t result = ZE_RESULT_ERROR_UNINITIALIZED;
DriverImp driverImp;
driverImp.initialize(&result);
L0::DriverHandleImp *driverHandleImp = reinterpret_cast<L0::DriverHandleImp *>(L0::GlobalDriverHandle);
EXPECT_EQ(driverHandleImp->deviceHierarchyMode, L0::L0DeviceHierarchyMode::L0_DEVICE_HIERARCHY_COMPOSITE);
ASSERT_NE(nullptr, L0::GlobalDriver);
ASSERT_NE(0u, L0::GlobalDriver->numDevices);
delete L0::GlobalDriver;
L0::GlobalDriverHandle = nullptr;
L0::GlobalDriver = nullptr;
}
TEST(DriverImpTest, givenCombinedDeviceHierarchyWhenCreatingExecutionEnvironmentThenCombinedHierarchyIsEnabled) {
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();

View File

@@ -7,6 +7,7 @@
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_io_functions.h"
#include "shared/test/common/test_macros/test.h"
#include "opencl/source/api/api.h"
@@ -114,6 +115,8 @@ TEST_F(ClCreateSubDevicesTests, GivenValidInputWhenCreatingSubDevicesThenSubDevi
}
TEST_F(ClCreateSubDevicesTests, GivenValidInputWhenCreatingSubDevicesThenDeviceApiReferenceCountIsIncreasedEveryTime) {
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
setup(2);
EXPECT_EQ(0, device->getSubDevice(0)->getRefApiCount());
@@ -131,6 +134,8 @@ TEST_F(ClCreateSubDevicesTests, GivenValidInputWhenCreatingSubDevicesThenDeviceA
}
TEST_F(ClCreateSubDevicesTests, GivenValidInputAndReturnSubDevicesAsApiDevicesIsSetWhenCreatingSubDevicesThenDeviceApiReferenceCountIsNotIncreased) {
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
DebugManager.flags.ReturnSubDevicesAsApiDevices.set(1);
setup(2);

View File

@@ -14,6 +14,7 @@
#include "shared/test/common/helpers/ult_hw_config.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/mock_io_functions.h"
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "shared/test/common/mocks/ult_device_factory.h"
#include "shared/test/common/test_macros/hw_test.h"
@@ -67,6 +68,8 @@ TEST(SubDevicesTest, givenCreateMultipleSubDevicesFlagSetWhenCreateRootDeviceThe
TEST(SubDevicesTest, givenDeviceWithSubDevicesWhenSubDeviceApiRefCountsAreChangedThenChangeIsPropagatedToRootDevice) {
DebugManagerStateRestore restorer;
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
DebugManager.flags.CreateMultipleSubDevices.set(2);
VariableBackup<bool> mockDeviceFlagBackup(&MockDevice::createSingleDevice, false);
initPlatform();

View File

@@ -18,6 +18,7 @@
#include "shared/test/common/helpers/ult_hw_config.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_io_functions.h"
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "shared/test/common/mocks/ult_device_factory.h"
#include "shared/test/common/test_macros/hw_test.h"
@@ -126,6 +127,9 @@ TEST_F(DeviceFactoryTest, givenDebugFlagSetWhenCreatingDevicesThenForceImagesSup
}
TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetWhenCreateDevicesThenProperNumberOfDevicesIsReturned) {
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleRootDevices.set(5);
DebugManager.flags.CreateMultipleSubDevices.set(4);
@@ -143,6 +147,9 @@ TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetWhenCreateDevicesThenProperNumbe
}
TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToGreaterRootDeviceThanAvailableWhenCreateDevicesThenProperNumberOfDevicesIsReturned) {
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleRootDevices.set(2);
DebugManager.flags.CreateMultipleSubDevices.set(4);
@@ -159,6 +166,9 @@ TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToGreaterRootDeviceThanAvailable
}
TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToGreaterSubDeviceThanAvailableWhenCreateDevicesThenProperNumberOfDevicesIsReturned) {
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleRootDevices.set(2);
DebugManager.flags.CreateMultipleSubDevices.set(4);
@@ -173,6 +183,9 @@ TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToGreaterSubDeviceThanAvailableW
}
TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToRootDevicesOnlyWhenCreateDevicesThenProperNumberOfDevicesIsReturned) {
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleRootDevices.set(2);
DebugManager.flags.CreateMultipleSubDevices.set(4);

View File

@@ -398,7 +398,7 @@ DECLARE_DEBUG_VARIABLE(bool, EngineInstancedSubDevices, false, "Create subdevice
DECLARE_DEBUG_VARIABLE(bool, AllowSingleTileEngineInstancedSubDevices, false, "Create subdevices assigned to specific engine on single tile config")
DECLARE_DEBUG_VARIABLE(bool, EnablePrivateBO, false, "Enable PRELIM_I915_GEM_CREATE_EXT_VM_PRIVATE extension creating VM_PRIVATE BOs")
DECLARE_DEBUG_VARIABLE(bool, UseDeprecatedClDeviceIpVersion, false, "When enabled, the deprecated ip version scheme distinguishing between families and integrated devices will be queried in OCL")
DECLARE_DEBUG_VARIABLE(int32_t, ReturnSubDevicesAsApiDevices, -1, "Expose each subdevice as a separate device during clGetDeviceIDs or zeDeviceGet API call")
DECLARE_DEBUG_VARIABLE(int32_t, ReturnSubDevicesAsApiDevices, -1, "Expose each subdevice as a separate device during clGetDeviceIDs or zeDeviceGet API call, -1:default, 0:disable, 1:enable")
DECLARE_DEBUG_VARIABLE(int32_t, ForceRunAloneContext, -1, "Control creation of run-alone HW context, -1:default, 0:disable, 1:enable")
DECLARE_DEBUG_VARIABLE(int32_t, AddClGlSharing, -1, "Add cl-gl extension")
DECLARE_DEBUG_VARIABLE(int32_t, EnableKernelTunning, -1, "Perform a tunning of enqueue kernel, -1:default(disabled), 0:disable, 1:enable simple kernel tunning, 2:enable full kernel tunning")

View File

@@ -287,6 +287,24 @@ void ExecutionEnvironment::sortNeoDevices() {
std::sort(rootDeviceEnvironments.begin(), rootDeviceEnvironments.end(), comparePciIdBusNumber);
}
void ExecutionEnvironment::setDeviceHierarchy(const GfxCoreHelper &gfxCoreHelper) {
NEO::EnvironmentVariableReader envReader;
std::string hierarchyModel = envReader.getSetting("ZE_FLAT_DEVICE_HIERARCHY", std::string(gfxCoreHelper.getDefaultDeviceHierarchy()));
if (strcmp(hierarchyModel.c_str(), "COMPOSITE") == 0) {
setExposeSubDevicesAsDevices(false);
}
if (strcmp(hierarchyModel.c_str(), "FLAT") == 0) {
setExposeSubDevicesAsDevices(true);
}
if (strcmp(hierarchyModel.c_str(), "COMBINED") == 0) {
setCombinedDeviceHierarchy(true);
}
if (NEO::DebugManager.flags.ReturnSubDevicesAsApiDevices.get() != -1) {
setExposeSubDevicesAsDevices(NEO::DebugManager.flags.ReturnSubDevicesAsApiDevices.get());
}
}
void ExecutionEnvironment::adjustCcsCountImpl(RootDeviceEnvironment *rootDeviceEnvironment) const {
auto hwInfo = rootDeviceEnvironment->getMutableHardwareInfo();
auto &productHelper = rootDeviceEnvironment->getHelper<ProductHelper>();
@@ -346,21 +364,6 @@ void ExecutionEnvironment::configureNeoEnvironment() {
DebugManager.flags.UseKmdMigration.setIfDefault(0);
DebugManager.flags.SplitBcsSize.setIfDefault(256);
}
NEO::EnvironmentVariableReader envReader;
std::string hierarchyModel = envReader.getSetting("ZE_FLAT_DEVICE_HIERARCHY", std::string("COMPOSITE"));
if (strcmp(hierarchyModel.c_str(), "COMPOSITE") == 0) {
setExposeSubDevicesAsDevices(false);
}
if (strcmp(hierarchyModel.c_str(), "FLAT") == 0) {
setExposeSubDevicesAsDevices(true);
}
if (strcmp(hierarchyModel.c_str(), "COMBINED") == 0) {
setCombinedDeviceHierarchy(true);
}
if (NEO::DebugManager.flags.ReturnSubDevicesAsApiDevices.get() == 1) {
setExposeSubDevicesAsDevices(true);
}
}
bool ExecutionEnvironment::comparePciIdBusNumber(std::unique_ptr<RootDeviceEnvironment> &rootDeviceEnvironment1, std::unique_ptr<RootDeviceEnvironment> &rootDeviceEnvironment2) {

View File

@@ -15,6 +15,7 @@
namespace NEO {
class DirectSubmissionController;
class GfxCoreHelper;
class MemoryManager;
struct OsEnvironment;
struct RootDeviceEnvironment;
@@ -33,6 +34,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
void adjustCcsCount();
void adjustCcsCount(const uint32_t rootDeviceIndex) const;
void sortNeoDevices();
void setDeviceHierarchy(const GfxCoreHelper &gfxCoreHelper);
void adjustRootDeviceEnvironments();
void prepareForCleanup() const;
void setDebuggingMode(DebuggingMode debuggingMode) {

View File

@@ -18,6 +18,10 @@ namespace NEO {
GfxCoreHelperCreateFunctionType gfxCoreHelperFactory[IGFX_MAX_CORE] = {};
const char *deviceHierarchyComposite = "COMPOSITE";
const char *deviceHierarchyFlat = "FLAT";
const char *deviceHierarchyUnk = "UNK";
std::unique_ptr<GfxCoreHelper> GfxCoreHelper::create(const GFXCORE_FAMILY gfxCoreFamily) {
auto createFunction = gfxCoreHelperFactory[gfxCoreFamily];

View File

@@ -48,6 +48,10 @@ class GfxCoreHelper;
using EngineInstancesContainer = StackVec<EngineTypeUsage, 32>;
using GfxCoreHelperCreateFunctionType = std::unique_ptr<GfxCoreHelper> (*)();
extern const char *deviceHierarchyComposite;
extern const char *deviceHierarchyFlat;
extern const char *deviceHierarchyUnk;
class GfxCoreHelper {
public:
static std::unique_ptr<GfxCoreHelper> create(const GFXCORE_FAMILY gfxCoreFamily);
@@ -168,6 +172,7 @@ class GfxCoreHelper {
virtual bool isRelaxedOrderingSupported() const = 0;
virtual uint32_t calculateNumThreadsPerThreadGroup(uint32_t simd, uint32_t totalWorkItems, uint32_t grfSize, bool isHwLocalIdGeneration) const = 0;
virtual uint32_t overrideMaxWorkGroupSize(uint32_t maxWG) const = 0;
virtual char const *getDefaultDeviceHierarchy() const = 0;
static bool isWorkaroundRequired(uint32_t lowestSteppingWithBug, uint32_t steppingWithFix, const HardwareInfo &hwInfo, const ProductHelper &productHelper);
virtual ~GfxCoreHelper() = default;
@@ -380,6 +385,7 @@ class GfxCoreHelperHw : public GfxCoreHelper {
bool isRelaxedOrderingSupported() const override;
uint32_t calculateNumThreadsPerThreadGroup(uint32_t simd, uint32_t totalWorkItems, uint32_t grfSize, bool isHwLocalIdGeneration) const override;
uint32_t overrideMaxWorkGroupSize(uint32_t maxWG) const override;
char const *getDefaultDeviceHierarchy() const override;
~GfxCoreHelperHw() override = default;
protected:

View File

@@ -709,4 +709,10 @@ template <typename GfxFamily>
uint32_t GfxCoreHelperHw<GfxFamily>::calculateNumThreadsPerThreadGroup(uint32_t simd, uint32_t totalWorkItems, uint32_t grfSize, bool isHwLocalIdGeneration) const {
return getThreadsPerWG(simd, totalWorkItems);
}
template <typename GfxFamily>
char const *GfxCoreHelperHw<GfxFamily>::getDefaultDeviceHierarchy() const {
return deviceHierarchyComposite;
}
} // namespace NEO

View File

@@ -116,6 +116,7 @@ bool DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(ExecutionE
}
}
executionEnvironment.setDeviceHierarchy(executionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>());
executionEnvironment.parseAffinityMask();
executionEnvironment.adjustCcsCount();
executionEnvironment.calculateMaxOsContextCount();
@@ -175,6 +176,7 @@ bool DeviceFactory::prepareDeviceEnvironments(ExecutionEnvironment &executionEnv
rootDeviceIndex++;
}
executionEnvironment.setDeviceHierarchy(executionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>());
executionEnvironment.sortNeoDevices();
executionEnvironment.parseAffinityMask();
executionEnvironment.adjustRootDeviceEnvironments();

View File

@@ -111,6 +111,7 @@ ExecutionEnvironment *MockDevice::prepareExecutionEnvironment(const HardwareInfo
executionEnvironment->rootDeviceEnvironments[i]->setHwInfoAndInitHelpers(pHwInfo);
executionEnvironment->rootDeviceEnvironments[i]->initGmm();
}
executionEnvironment->setDeviceHierarchy(executionEnvironment->rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>());
executionEnvironment->calculateMaxOsContextCount();
return executionEnvironment;
}
@@ -146,6 +147,7 @@ ExecutionEnvironment *MockDevice::prepareExecutionEnvironment(const HardwareInfo
auto hwInfo = pHwInfo ? pHwInfo : defaultHwInfo.get();
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(hwInfo);
executionEnvironment->setDeviceHierarchy(executionEnvironment->rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>());
MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]);
executionEnvironment->initializeMemoryManager();

View File

@@ -23,6 +23,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_io_functions.h"
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "shared/test/common/mocks/mock_product_helper.h"
#include "shared/test/common/mocks/ult_device_factory.h"
@@ -757,7 +758,10 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZeAffinityMaskSetAndTilesAsDevice
}
}
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZeAffinityMaskSetThenProperSubDeviceHierarchyMapisSet) {
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZeAffinityMaskSetThenProperSubDeviceHierarchyMapIsSet) {
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
VariableBackup<UltHwConfig> backup(&ultHwConfig);
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
DebugManagerStateRestore restorer;
@@ -795,6 +799,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZeAffinityMaskSetThenProperSubDev
}
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZeAffinityMaskSetWithoutTilesThenProperSubDeviceHierarchyMapisUnset) {
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
VariableBackup<UltHwConfig> backup(&ultHwConfig);
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
DebugManagerStateRestore restorer;

View File

@@ -41,18 +41,24 @@ TEST(ExecutionEnvironment, givenDefaultConstructorWhenItIsCalledThenExecutionEnv
EXPECT_EQ(0, environment.getRefApiCount());
}
TEST(ExecutionEnvironment, givenDefaultConstructorWhenItIsCalledThenSubDevicesAsDevicesIsFalse) {
ExecutionEnvironment environment;
EXPECT_FALSE(environment.isExposingSubDevicesAsDevices());
}
TEST(ExecutionEnvironment, givenDefaultConstructoWhenItIsCalledAndReturnSubDevicesAsApiDevicesIsSetThenSubDevicesAsDevicesIsTrue) {
TEST(ExecutionEnvironment, givenDefaultConstructoWhenItIsCalledAndReturnSubDevicesAsApiDevicesIsSetTrueThenSubDevicesAsDevicesIsTrue) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.ReturnSubDevicesAsApiDevices.set(1);
ExecutionEnvironment environment;
MockExecutionEnvironment environment;
environment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get());
environment.setDeviceHierarchy(environment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>());
EXPECT_TRUE(environment.isExposingSubDevicesAsDevices());
}
TEST(ExecutionEnvironment, givenDefaultConstructoWhenItIsCalledAndReturnSubDevicesAsApiDevicesIsSetFalseThenSubDevicesAsDevicesIsFalse) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.ReturnSubDevicesAsApiDevices.set(0);
MockExecutionEnvironment environment;
environment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get());
environment.setDeviceHierarchy(environment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>());
EXPECT_FALSE(environment.isExposingSubDevicesAsDevices());
}
TEST(ExecutionEnvironment, WhenCreatingDevicesThenThoseDevicesAddRefcountsToExecutionEnvironment) {
auto executionEnvironment = new ExecutionEnvironment();
@@ -488,11 +494,23 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenSettingFP64EmulationEnab
EXPECT_TRUE(executionEnvironment.isFP64EmulationEnabled());
}
TEST(ExecutionEnvironmentDeviceHierarchy, givenExecutionEnvironmentWithDefaultDeviceHierarchyThenExecutionEnvironmentIsInitializedCorrectly) {
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
MockExecutionEnvironment executionEnvironment;
executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get());
auto &gfxCoreHelper = executionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>();
executionEnvironment.setDeviceHierarchy(gfxCoreHelper);
EXPECT_EQ((strcmp(gfxCoreHelper.getDefaultDeviceHierarchy(), "COMPOSITE") != 0),
executionEnvironment.isExposingSubDevicesAsDevices());
}
TEST(ExecutionEnvironmentDeviceHierarchy, givenExecutionEnvironmentWithCompositeDeviceHierarchyThenExposeSubDevicesAsDevicesIsFalse) {
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
ExecutionEnvironment executionEnvironment{};
MockExecutionEnvironment executionEnvironment;
executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get());
executionEnvironment.setDeviceHierarchy(executionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>());
EXPECT_FALSE(executionEnvironment.isExposingSubDevicesAsDevices());
}
@@ -500,7 +518,9 @@ TEST(ExecutionEnvironmentDeviceHierarchy, givenExecutionEnvironmentWithFlatDevic
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "FLAT"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
ExecutionEnvironment executionEnvironment{};
MockExecutionEnvironment executionEnvironment;
executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get());
executionEnvironment.setDeviceHierarchy(executionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>());
EXPECT_TRUE(executionEnvironment.isExposingSubDevicesAsDevices());
}
@@ -508,7 +528,9 @@ TEST(ExecutionEnvironmentDeviceHierarchy, givenExecutionEnvironmentWithCombinedD
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMBINED"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
ExecutionEnvironment executionEnvironment{};
MockExecutionEnvironment executionEnvironment;
executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get());
executionEnvironment.setDeviceHierarchy(executionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>());
EXPECT_FALSE(executionEnvironment.isExposingSubDevicesAsDevices());
}

View File

@@ -15,6 +15,7 @@
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_driver_model.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_io_functions.h"
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "shared/test/common/mocks/ult_device_factory.h"
#include "shared/test/common/test_macros/hw_test.h"
@@ -37,6 +38,9 @@ struct MultipleDeviceBdfUuidTest : public ::testing::Test {
HWTEST2_F(MultipleDeviceBdfUuidTest, GivenValidBdfWithCombinationOfAffinityMaskThenUuidIsCorrectForRootAndSubDevices, MatchAny) {
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
std::unique_ptr<UltDeviceFactory> deviceFactory;
auto mockExecutionEnvironment = std::make_unique<MockExecutionEnvironment>(defaultHwInfo.get(), false, 1);
RAIIProductHelperFactory<MockProductHelperHw<productFamily>> raii(*mockExecutionEnvironment->rootDeviceEnvironments[0]);
@@ -238,6 +242,9 @@ HWTEST2_F(MultipleDeviceBdfUuidTest, GivenValidBdfWithOneBitEnabledInAffinityMas
HWTEST2_F(MultipleDeviceBdfUuidTest, GivenValidBdfWithOneBitEnabledInAffinityMaskSetToSubDeviceThenUuidOfRootDeviceIsBasedOnAffinityMask, MatchAny) {
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
std::unique_ptr<UltDeviceFactory> deviceFactory;
auto mockExecutionEnvironment = std::make_unique<MockExecutionEnvironment>(defaultHwInfo.get(), false, 1);
RAIIProductHelperFactory<MockProductHelperHw<productFamily>> raii(*mockExecutionEnvironment->rootDeviceEnvironments[0]);