diff --git a/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp b/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp index 9814727f14..6713e1ae1b 100644 --- a/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp +++ b/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp @@ -154,6 +154,70 @@ void SingleRootMultiSubDeviceFixture::SetUp() { device = driverHandle->devices[0]; neoDevice = device->getNEODevice(); } +void SingleRootMultiSubDeviceFixtureWithImplicitScalingImpl::SetUp() { + DebugManagerStateRestore restorer; + DebugManager.flags.EnableImplicitScaling.set(implicitScaling); + DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices); + DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices); + + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.featureTable.flags.ftrRcsNode = false; + hwInfo.featureTable.flags.ftrCCSNode = true; + + if (expectedCopyEngineCount != 0) { + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.featureTable.ftrBcsInfo = maxNBitValue(expectedCopyEngineCount); + } else { + hwInfo.capabilityTable.blitterOperationsSupported = false; + } + + if (implicitScaling) { + expectedComputeEngineCount = 1u; + } else { + expectedComputeEngineCount = hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; + } + + MockDevice *mockDevice = MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0); + + NEO::DeviceVector devices; + devices.push_back(std::unique_ptr(mockDevice)); + + driverHandle = std::make_unique>(); + ze_result_t res = driverHandle->initialize(std::move(devices)); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + + ze_context_handle_t hContext; + ze_context_desc_t desc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, nullptr, 0}; + res = driverHandle->createContext(&desc, 0u, nullptr, &hContext); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + context = static_cast(Context::fromHandle(hContext)); + + device = driverHandle->devices[0]; + neoDevice = device->getNEODevice(); + deviceImp = static_cast(device); + + NEO::Device *activeDevice = deviceImp->getActiveDevice(); + auto &engineGroups = activeDevice->getRegularEngineGroups(); + numEngineGroups = static_cast(engineGroups.size()); + + if (activeDevice->getSubDevices().size() > 0) { + NEO::Device *activeSubDevice = activeDevice->getSubDevice(0u); + (void)activeSubDevice; + auto &subDeviceEngineGroups = activeSubDevice->getRegularEngineGroups(); + (void)subDeviceEngineGroups; + + for (uint32_t i = 0; i < subDeviceEngineGroups.size(); i++) { + if (subDeviceEngineGroups[i].engineGroupType == NEO::EngineGroupType::Copy || + subDeviceEngineGroups[i].engineGroupType == NEO::EngineGroupType::LinkedCopy) { + subDeviceNumEngineGroups += 1; + } + } + } +} + +void SingleRootMultiSubDeviceFixtureWithImplicitScalingImpl::TearDown() { + context->destroy(); +} void GetMemHandlePtrTestFixture::SetUp() { NEO::MockCompilerEnableGuard mock(true); diff --git a/level_zero/core/test/unit_tests/fixtures/device_fixture.h b/level_zero/core/test/unit_tests/fixtures/device_fixture.h index bb5466c65a..df4d57151b 100644 --- a/level_zero/core/test/unit_tests/fixtures/device_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/device_fixture.h @@ -30,13 +30,6 @@ struct ContextImp; namespace ult { class MockBuiltins; -struct ContextShareableMock : public L0::ContextImp { - ContextShareableMock(L0::DriverHandleImp *driverHandle) : L0::ContextImp(driverHandle) {} - bool isShareableMemory(const void *pNext, bool exportableMemory, NEO::Device *neoDevice) override { - return true; - } -}; - struct DeviceFixture { NEO::MockCompilerEnableGuard compilerMock = NEO::MockCompilerEnableGuard(true); void SetUp(); // NOLINT(readability-identifier-naming) @@ -149,8 +142,9 @@ struct MultipleDevicesWithCustomHwInfo { const uint32_t numSubDevices = 2u; }; -template -struct SingleRootMultiSubDeviceFixtureWithImplicitScaling : public MultiDeviceFixture { +struct SingleRootMultiSubDeviceFixtureWithImplicitScalingImpl : public MultiDeviceFixture { + + SingleRootMultiSubDeviceFixtureWithImplicitScalingImpl(uint32_t copyEngineCount, uint32_t implicitScaling) : implicitScaling(implicitScaling), expectedCopyEngineCount(copyEngineCount){}; NEO::MockCompilerEnableGuard compilerMock = NEO::MockCompilerEnableGuard(true); DebugManagerStateRestore restorer; @@ -164,77 +158,20 @@ struct SingleRootMultiSubDeviceFixtureWithImplicitScaling : public MultiDeviceFi NEO::Device *neoDevice = nullptr; L0::DeviceImp *deviceImp = nullptr; - NEO::HardwareInfo hwInfo; - uint32_t expectedCopyEngineCount = copyEngineCount; + NEO::HardwareInfo hwInfo{}; + const uint32_t implicitScaling; + const uint32_t expectedCopyEngineCount; uint32_t expectedComputeEngineCount = 0; uint32_t numEngineGroups = 0; uint32_t subDeviceNumEngineGroups = 0; - void SetUp() { - DebugManagerStateRestore restorer; - DebugManager.flags.EnableImplicitScaling.set(implicitScaling); - DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices); - DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices); - - NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); - hwInfo.featureTable.flags.ftrRcsNode = false; - hwInfo.featureTable.flags.ftrCCSNode = true; - // hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; - if (expectedCopyEngineCount != 0) { - hwInfo.capabilityTable.blitterOperationsSupported = true; - hwInfo.featureTable.ftrBcsInfo = maxNBitValue(expectedCopyEngineCount); - } else { - hwInfo.capabilityTable.blitterOperationsSupported = false; - } - - if (implicitScaling) { - expectedComputeEngineCount = 1u; - } else { - expectedComputeEngineCount = hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; - } - - MockDevice *mockDevice = MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0); - - NEO::DeviceVector devices; - devices.push_back(std::unique_ptr(mockDevice)); - - driverHandle = std::make_unique>(); - ze_result_t res = driverHandle->initialize(std::move(devices)); - EXPECT_EQ(ZE_RESULT_SUCCESS, res); - - ze_context_handle_t hContext; - ze_context_desc_t desc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, nullptr, 0}; - res = driverHandle->createContext(&desc, 0u, nullptr, &hContext); - EXPECT_EQ(ZE_RESULT_SUCCESS, res); - context = static_cast(Context::fromHandle(hContext)); - - device = driverHandle->devices[0]; - neoDevice = device->getNEODevice(); - deviceImp = static_cast(device); - - NEO::Device *activeDevice = deviceImp->getActiveDevice(); - auto &engineGroups = activeDevice->getRegularEngineGroups(); - numEngineGroups = static_cast(engineGroups.size()); - - if (activeDevice->getSubDevices().size() > 0) { - NEO::Device *activeSubDevice = activeDevice->getSubDevice(0u); - (void)activeSubDevice; - auto &subDeviceEngineGroups = activeSubDevice->getRegularEngineGroups(); - (void)subDeviceEngineGroups; - - for (uint32_t i = 0; i < subDeviceEngineGroups.size(); i++) { - if (subDeviceEngineGroups[i].engineGroupType == NEO::EngineGroupType::Copy || - subDeviceEngineGroups[i].engineGroupType == NEO::EngineGroupType::LinkedCopy) { - subDeviceNumEngineGroups += 1; - } - } - } - } - - void TearDown() { - context->destroy(); - } + void SetUp(); + void TearDown(); +}; +template +struct SingleRootMultiSubDeviceFixtureWithImplicitScaling : public SingleRootMultiSubDeviceFixtureWithImplicitScalingImpl { + SingleRootMultiSubDeviceFixtureWithImplicitScaling() : SingleRootMultiSubDeviceFixtureWithImplicitScalingImpl(copyEngineCount, implicitScalingArg){}; }; } // namespace ult diff --git a/level_zero/core/test/unit_tests/mocks/mock_context.h b/level_zero/core/test/unit_tests/mocks/mock_context.h index ff782086b2..8f082ec602 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_context.h +++ b/level_zero/core/test/unit_tests/mocks/mock_context.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -9,7 +9,7 @@ #include "shared/test/common/test_macros/mock_method_macros.h" -#include "level_zero/core/source/context/context.h" +#include "level_zero/core/source/context/context_imp.h" #include "level_zero/core/test/unit_tests/mock.h" #include "level_zero/core/test/unit_tests/white_box.h" @@ -62,5 +62,11 @@ struct Mock : public Context { ADDMETHOD_NOBASE(createImage, ze_result_t, ZE_RESULT_SUCCESS, (ze_device_handle_t hDevice, const ze_image_desc_t *desc, ze_image_handle_t *phImage)); }; +struct ContextShareableMock : public L0::ContextImp { + ContextShareableMock(L0::DriverHandle *driverHandle) : L0::ContextImp(driverHandle) {} + bool isShareableMemory(const void *pNext, bool exportableMemory, NEO::Device *neoDevice) override { + return true; + } +}; } // namespace ult } // namespace L0 diff --git a/level_zero/core/test/unit_tests/sources/device/test_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_device.cpp index c23babb5a5..70d59992ef 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_device.cpp @@ -36,6 +36,7 @@ #include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h" #include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" #include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h" +#include "level_zero/core/test/unit_tests/mocks/mock_context.h" #include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h" #include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h" diff --git a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp index 200f5a97a5..2a3a544a15 100644 --- a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp +++ b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp @@ -32,6 +32,7 @@ #include "level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h" #include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h" #include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" +#include "level_zero/core/test/unit_tests/mocks/mock_context.h" #include "level_zero/core/test/unit_tests/mocks/mock_kernel.h" namespace L0 { diff --git a/level_zero/tools/test/unit_tests/sources/sysman/fabric_port/linux/mock_fabric_device.h b/level_zero/tools/test/unit_tests/sources/sysman/fabric_port/linux/mock_fabric_device.h index 395c195066..35d1492607 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/fabric_port/linux/mock_fabric_device.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/fabric_port/linux/mock_fabric_device.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,6 +8,7 @@ #pragma once #include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" +#include "gmock/gmock.h" #include "sysman/fabric_port/fabric_port.h" namespace L0 {