diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index e98d57740d..731ec41da4 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -798,17 +798,21 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool device->neoDevice = neoDevice; neoDevice->incRefInternal(); + auto &hwInfo = neoDevice->getHardwareInfo(); + auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily); + device->execEnvironment = (void *)neoDevice->getExecutionEnvironment(); device->allocationsForReuse = std::make_unique(); - device->implicitScalingCapable = NEO::ImplicitScalingHelper::isImplicitScalingEnabled(neoDevice->getDeviceBitfield(), true); + bool platformImplicitScaling = hwHelper.platformSupportsImplicitScaling(hwInfo); + device->implicitScalingCapable = NEO::ImplicitScalingHelper::isImplicitScalingEnabled(neoDevice->getDeviceBitfield(), platformImplicitScaling); device->metricContext = MetricContext::create(*device); device->builtins = BuiltinFunctionsLib::create( device, neoDevice->getBuiltIns()); device->cacheReservation = CacheReservation::create(*device); - device->maxNumHwThreads = NEO::HwHelper::getMaxThreadsForVfe(neoDevice->getHardwareInfo()); + device->maxNumHwThreads = NEO::HwHelper::getMaxThreadsForVfe(hwInfo); auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get(); - device->driverInfo.reset(NEO::DriverInfo::create(&neoDevice->getHardwareInfo(), osInterface)); + device->driverInfo.reset(NEO::DriverInfo::create(&hwInfo, osInterface)); auto debugSurfaceSize = NEO::SipKernel::maxDbgSurfaceSize; std::vector stateSaveAreaHeader; @@ -840,7 +844,6 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool if (debugSurface && stateSaveAreaHeader.size() > 0) { auto &hwInfo = neoDevice->getHardwareInfo(); - auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily); NEO::MemoryTransferHelper::transferMemoryToAllocation(hwHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *debugSurface), *neoDevice, debugSurface, 0, stateSaveAreaHeader.data(), stateSaveAreaHeader.size()); diff --git a/level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.h b/level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.h index b6fac703f3..7b68757e07 100644 --- a/level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -49,6 +49,7 @@ class CommandListFixture : public DeviceFixture { template struct MultiTileCommandListFixture : public SingleRootMultiSubDeviceFixture { void SetUp() { + DebugManager.flags.EnableImplicitScaling.set(1); osLocalMemoryBackup = std::make_unique>(&NEO::OSInterface::osEnableLocalMemory, true); apiSupportBackup = std::make_unique>(&NEO::ImplicitScaling::apiSupport, true); diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp index 09aeb15ddc..b8a0958589 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_2.cpp @@ -1139,8 +1139,10 @@ HWTEST2_F(CommandListAppendLaunchKernel, givenCooperativeAndNonCooperativeKernel EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); } -struct MultiTileCommandListAppendLaunchFunctionXeHpCoreFixture : MultiDeviceModuleFixture { +struct MultiTileCommandListAppendLaunchFunctionXeHpCoreFixture : public MultiDeviceModuleFixture { void SetUp() { + DebugManager.flags.EnableImplicitScaling.set(1); + MultiDeviceFixture::numRootDevices = 1u; MultiDeviceFixture::numSubDevices = 4u; 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 7931b21459..39a8b24a2b 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 @@ -8,6 +8,7 @@ #include "shared/source/command_container/implicit_scaling.h" #include "shared/source/device/root_device.h" #include "shared/source/helpers/bindless_heaps_helper.h" +#include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/preamble.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/os_interface/os_inc_base.h" @@ -2507,8 +2508,13 @@ struct MultiSubDeviceFixture : public DeviceFixture { using MultiSubDeviceTest = Test>; TEST_F(MultiSubDeviceTest, GivenApiSupportAndLocalMemoryEnabledWhenDeviceContainsSubDevicesThenItIsImplicitScalingCapable) { - EXPECT_TRUE(device->isImplicitScalingCapable()); - EXPECT_EQ(neoDevice, deviceImp->getActiveDevice()); + if (NEO::HwHelper::get(neoDevice->getHardwareInfo().platform.eRenderCoreFamily).platformSupportsImplicitScaling(neoDevice->getHardwareInfo())) { + EXPECT_TRUE(device->isImplicitScalingCapable()); + EXPECT_EQ(neoDevice, deviceImp->getActiveDevice()); + } else { + EXPECT_FALSE(device->isImplicitScalingCapable()); + EXPECT_EQ(subDevice, deviceImp->getActiveDevice()); + } } using MultiSubDeviceTestNoApi = Test>; diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/test_device_xe_hpc_core.cpp b/level_zero/core/test/unit_tests/xe_hpc_core/test_device_xe_hpc_core.cpp index a76d7c743f..6883b06be8 100644 --- a/level_zero/core/test/unit_tests/xe_hpc_core/test_device_xe_hpc_core.cpp +++ b/level_zero/core/test/unit_tests/xe_hpc_core/test_device_xe_hpc_core.cpp @@ -1,14 +1,17 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/command_container/implicit_scaling.h" #include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/mocks/ult_device_factory.h" #include "shared/test/common/test_macros/test.h" +#include "level_zero/core/source/hw_helpers/l0_hw_helper.h" #include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" namespace L0 { @@ -16,9 +19,9 @@ namespace ult { HWTEST_EXCLUDE_PRODUCT(AppendMemoryCopy, givenCopyOnlyCommandListAndHostPointersWhenMemoryCopyCalledThenPipeControlWithDcFlushAddedIsNotAddedAfterBlitCopy, IGFX_XE_HPC_CORE); -using DeviceFixturePVC = Test; +using DeviceTestPVC = Test; -HWTEST2_F(DeviceFixturePVC, whenCallingGetMemoryPropertiesWithNonNullPtrThenPropertiesAreReturned, IsXeHpcCore) { +HWTEST2_F(DeviceTestPVC, whenCallingGetMemoryPropertiesWithNonNullPtrThenPropertiesAreReturned, IsXeHpcCore) { uint32_t count = 0; ze_result_t res = device->getMemoryProperties(&count, nullptr); EXPECT_EQ(res, ZE_RESULT_SUCCESS); @@ -34,7 +37,7 @@ HWTEST2_F(DeviceFixturePVC, whenCallingGetMemoryPropertiesWithNonNullPtrThenProp EXPECT_EQ(memProperties.totalSize, this->neoDevice->getDeviceInfo().globalMemSize); } -HWTEST2_F(DeviceFixturePVC, whenCallingGetMemoryPropertiesWithNonNullPtrAndBdRevisionIsNotA0ThenmaxClockRateReturnedIsZero, IsXeHpcCore) { +HWTEST2_F(DeviceTestPVC, whenCallingGetMemoryPropertiesWithNonNullPtrAndBdRevisionIsNotA0ThenmaxClockRateReturnedIsZero, IsXeHpcCore) { uint32_t count = 0; auto device = driverHandle->devices[0]; auto hwInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo(); @@ -52,6 +55,67 @@ HWTEST2_F(DeviceFixturePVC, whenCallingGetMemoryPropertiesWithNonNullPtrAndBdRev EXPECT_EQ(memProperties.maxClockRate, 0u); } +HWTEST2_F(DeviceTestPVC, givenPvcAStepWhenCreatingMultiTileDeviceThenExpectImplicitScalingDisabled, IsXeHpcCore) { + DebugManagerStateRestore restorer; + DebugManager.flags.CreateMultipleSubDevices.set(2); + VariableBackup apiSupportBackup(&NEO::ImplicitScaling::apiSupport, true); + + ze_result_t returnValue = ZE_RESULT_SUCCESS; + std::unique_ptr driverHandle(new DriverHandleImp); + auto hwInfo = *NEO::defaultHwInfo; + hwInfo.platform.usRevId = 0x3; + + auto neoDevice = std::unique_ptr(NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto device = Device::create(driverHandle.get(), neoDevice.release(), false, &returnValue); + ASSERT_NE(nullptr, device); + + EXPECT_FALSE(device->isImplicitScalingCapable()); + + static_cast(device)->releaseResources(); + delete device; +} + +HWTEST2_F(DeviceTestPVC, givenPvcAStepAndDebugFlagOverridesWhenCreatingMultiTileDeviceThenExpectImplicitScalingEnabled, IsXeHpcCore) { + DebugManagerStateRestore restorer; + DebugManager.flags.CreateMultipleSubDevices.set(2); + DebugManager.flags.EnableImplicitScaling.set(1); + VariableBackup apiSupportBackup(&NEO::ImplicitScaling::apiSupport, true); + + ze_result_t returnValue = ZE_RESULT_SUCCESS; + std::unique_ptr driverHandle(new DriverHandleImp); + auto hwInfo = *NEO::defaultHwInfo; + hwInfo.platform.usRevId = 0x3; + + auto neoDevice = std::unique_ptr(NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto device = Device::create(driverHandle.get(), neoDevice.release(), false, &returnValue); + ASSERT_NE(nullptr, device); + + EXPECT_TRUE(device->isImplicitScalingCapable()); + + static_cast(device)->releaseResources(); + delete device; +} + +HWTEST2_F(DeviceTestPVC, givenPvcBStepWhenCreatingMultiTileDeviceThenExpectImplicitScalingEnabled, IsXeHpcCore) { + DebugManagerStateRestore restorer; + DebugManager.flags.CreateMultipleSubDevices.set(2); + VariableBackup apiSupportBackup(&NEO::ImplicitScaling::apiSupport, true); + + ze_result_t returnValue = ZE_RESULT_SUCCESS; + std::unique_ptr driverHandle(new DriverHandleImp); + auto hwInfo = *NEO::defaultHwInfo; + hwInfo.platform.usRevId = 0x6; + + auto neoDevice = std::unique_ptr(NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto device = Device::create(driverHandle.get(), neoDevice.release(), false, &returnValue); + ASSERT_NE(nullptr, device); + + EXPECT_TRUE(device->isImplicitScalingCapable()); + + static_cast(device)->releaseResources(); + delete device; +} + using DeviceQueueGroupTest = Test; HWTEST2_F(DeviceQueueGroupTest, givenNoBlitterSupportAndNoCCSThenOneQueueGroupIsReturned, IsXeHpcCore) { @@ -137,7 +201,7 @@ HWTEST2_F(DeviceCopyQueueGroupTest, } } -HWTEST2_F(DeviceFixturePVC, givenReturnedDevicePropertiesThenExpectedPropertyFlagsSet, IsPVC) { +HWTEST2_F(DeviceTestPVC, givenReturnedDevicePropertiesThenExpectedPropertyFlagsSet, IsPVC) { ze_device_properties_t deviceProps = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; device->getProperties(&deviceProps); diff --git a/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.cpp b/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.cpp index 18d9032fbe..539bde41b3 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -111,8 +111,7 @@ void MetricContextFixture::openMetricsAdapterGroup() { } void MetricMultiDeviceFixture::SetUp() { - - NEO::ImplicitScaling::apiSupport = true; + DebugManager.flags.EnableImplicitScaling.set(1); MultiDeviceFixture::SetUp(); @@ -183,8 +182,6 @@ void MetricMultiDeviceFixture::TearDown() { mockMetricEnumeration.reset(); MultiDeviceFixture::TearDown(); - - NEO::ImplicitScaling::apiSupport = false; } void MetricMultiDeviceFixture::openMetricsAdapter() { diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp index 157eaae7a3..cbf618c14e 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_4_tests.cpp @@ -635,6 +635,7 @@ HWTEST_F(CrossDeviceDependenciesTests, givenWaitListWithEventBlockedByUserEventW HWTEST_F(CommandStreamReceiverFlushTaskTests, givenStaticPartitioningEnabledWhenFlushingTaskThenWorkPartitionAllocationIsMadeResident) { DebugManagerStateRestore restore{}; DebugManager.flags.EnableStaticPartitioning.set(1); + DebugManager.flags.EnableImplicitScaling.set(1); DebugManager.flags.ForcePreemptionMode.set(PreemptionMode::Disabled); UltDeviceFactory deviceFactory{1, 2}; MockDevice *device = deviceFactory.rootDevices[0]; diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp index bdbca63ce2..3b6fa42ede 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp @@ -819,6 +819,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterTests, gi struct CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests : public CommandStreamReceiverFlushTaskXeHPAndLaterTests { void SetUp() override { DebugManager.flags.CreateMultipleSubDevices.set(2); + DebugManager.flags.EnableImplicitScaling.set(1); parsePipeControl = true; CommandStreamReceiverFlushTaskXeHPAndLaterTests::SetUp(); } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp index a090dabd8d..063c946774 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -826,6 +826,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverHwTestXeHPAndLater, givenPlatf HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverHwTestXeHPAndLater, whenCreatingWorkPartitionAllocationThenItsPropertiesAreCorrect) { DebugManagerStateRestore restore{}; DebugManager.flags.EnableStaticPartitioning.set(1); + DebugManager.flags.EnableImplicitScaling.set(1); DebugManager.flags.EnableLocalMemory.set(1); UltDeviceFactory deviceFactory{1, 2}; MockDevice &rootDevice = *deviceFactory.rootDevices[0]; diff --git a/opencl/test/unit_test/device/device_tests.cpp b/opencl/test/unit_test/device/device_tests.cpp index a5d53622c1..6a35bc14d6 100644 --- a/opencl/test/unit_test/device/device_tests.cpp +++ b/opencl/test/unit_test/device/device_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -446,6 +446,7 @@ HWTEST_F(DeviceTest, givenDeviceWhenAskingForDefaultEngineThenReturnValidValue) HWTEST_F(DeviceTest, givenDebugFlagWhenCreatingRootDeviceWithSubDevicesThenWorkPartitionAllocationIsCreatedForRootDevice) { DebugManagerStateRestore restore{}; + DebugManager.flags.EnableImplicitScaling.set(1); { UltDeviceFactory deviceFactory{1, 2}; EXPECT_NE(nullptr, deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation()); @@ -479,6 +480,7 @@ HWTEST_F(DeviceTest, givenDebugFlagWhenCreatingRootDeviceWithSubDevicesThenWorkP HWTEST_F(DeviceTest, givenDebugFlagWhenCreatingRootDeviceWithoutSubDevicesThenWorkPartitionAllocationIsNotCreated) { DebugManagerStateRestore restore{}; + DebugManager.flags.EnableImplicitScaling.set(1); { UltDeviceFactory deviceFactory{1, 1}; EXPECT_EQ(nullptr, deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation()); diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index 35672ad4c1..a18b9f6db8 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -1054,16 +1054,18 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenExportedFun // check getResidency as well std::vector residencySurfaces; pKernel->getResidency(residencySurfaces); - std::unique_ptr mockCsrExecEnv; + std::unique_ptr mockCsrExecEnv = std::make_unique(); + mockCsrExecEnv->prepareRootDeviceEnvironments(1); + mockCsrExecEnv->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); + mockCsrExecEnv->initializeMemoryManager(); { - CommandStreamReceiverMock csrMock; + CommandStreamReceiverMock csrMock(*mockCsrExecEnv.get(), 0, 1); csrMock.passResidencyCallToBaseClass = false; for (const auto &s : residencySurfaces) { s->makeResident(csrMock); delete s; } EXPECT_EQ(1U, csrMock.residency.count(exportedFunctionsSurface->getUnderlyingBuffer())); - mockCsrExecEnv = std::move(csrMock.mockExecutionEnvironment); } memoryManager->freeGraphicsMemory(pKernelInfo->kernelAllocation); @@ -1092,16 +1094,18 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenGlobalBuffe std::vector residencySurfaces; pKernel->getResidency(residencySurfaces); - std::unique_ptr mockCsrExecEnv; + std::unique_ptr mockCsrExecEnv = std::make_unique(); + mockCsrExecEnv->prepareRootDeviceEnvironments(1); + mockCsrExecEnv->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); + mockCsrExecEnv->initializeMemoryManager(); { - CommandStreamReceiverMock csrMock; + CommandStreamReceiverMock csrMock(*mockCsrExecEnv.get(), 0, 1); csrMock.passResidencyCallToBaseClass = false; for (const auto &s : residencySurfaces) { s->makeResident(csrMock); delete s; } EXPECT_EQ(1U, csrMock.residency.count(program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface->getUnderlyingBuffer())); - mockCsrExecEnv = std::move(csrMock.mockExecutionEnvironment); } memoryManager->freeGraphicsMemory(pKernelInfo->kernelAllocation); diff --git a/shared/source/command_container/implicit_scaling.cpp b/shared/source/command_container/implicit_scaling.cpp index 56498b290f..a0cc61e641 100644 --- a/shared/source/command_container/implicit_scaling.cpp +++ b/shared/source/command_container/implicit_scaling.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,8 +15,10 @@ namespace NEO { bool ImplicitScalingHelper::isImplicitScalingEnabled(const DeviceBitfield &devices, bool preCondition) { bool apiSupport = ImplicitScaling::apiSupport; - if (DebugManager.flags.EnableImplicitScaling.get() != -1) { - apiSupport = !!DebugManager.flags.EnableImplicitScaling.get(); + int32_t overrideEnableImplicitScaling = DebugManager.flags.EnableImplicitScaling.get(); + if (overrideEnableImplicitScaling != -1) { + apiSupport = !!overrideEnableImplicitScaling; + preCondition = apiSupport; } bool partitionWalker = (devices.count() > 1u) && diff --git a/shared/source/command_container/implicit_scaling.h b/shared/source/command_container/implicit_scaling.h index 2410a6bf5b..a9874e6029 100644 --- a/shared/source/command_container/implicit_scaling.h +++ b/shared/source/command_container/implicit_scaling.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -79,6 +79,8 @@ struct ImplicitScalingDispatch { static uint32_t getPostSyncOffset(); + static bool platformSupportsImplicitScaling(const HardwareInfo &hwInfo); + private: static bool pipeControlStallRequired; }; diff --git a/shared/source/command_container/implicit_scaling_xehp_and_later.inl b/shared/source/command_container/implicit_scaling_xehp_and_later.inl index 73438f0ce8..d42ea8acd3 100644 --- a/shared/source/command_container/implicit_scaling_xehp_and_later.inl +++ b/shared/source/command_container/implicit_scaling_xehp_and_later.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -212,4 +212,9 @@ inline uint32_t ImplicitScalingDispatch::getPostSyncOffset() { return static_cast(HwHelperHw::getSingleTimestampPacketSizeHw()); } +template +inline bool ImplicitScalingDispatch::platformSupportsImplicitScaling(const HardwareInfo &hwInfo) { + return false; +} + } // namespace NEO diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index fdb86ff232..9074d1a5c9 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -56,8 +56,10 @@ CommandStreamReceiver::CommandStreamReceiver(ExecutionEnvironment &executionEnvi } internalAllocationStorage = std::make_unique(*this); + const auto &hwInfo = peekHwInfo(); uint32_t subDeviceCount = static_cast(deviceBitfield.count()); - if (NEO::ImplicitScalingHelper::isImplicitScalingEnabled(deviceBitfield, true) && + bool platformImplicitScaling = HwHelper::get(hwInfo.platform.eRenderCoreFamily).platformSupportsImplicitScaling(hwInfo); + if (NEO::ImplicitScalingHelper::isImplicitScalingEnabled(deviceBitfield, platformImplicitScaling) && subDeviceCount > 1 && DebugManager.flags.EnableStaticPartitioning.get() != 0) { this->activePartitions = subDeviceCount; @@ -759,4 +761,8 @@ bool CommandStreamReceiver::testTaskCountReady(volatile uint32_t *pollAddress, u return true; } +const HardwareInfo &CommandStreamReceiver::peekHwInfo() const { + return *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo(); +} + } // namespace NEO diff --git a/shared/source/command_stream/command_stream_receiver.h b/shared/source/command_stream/command_stream_receiver.h index 762d303d45..a2078fc3f4 100644 --- a/shared/source/command_stream/command_stream_receiver.h +++ b/shared/source/command_stream/command_stream_receiver.h @@ -309,6 +309,8 @@ class CommandStreamReceiver { virtual void programComputeBarrierCommand(LinearStream &cmdStream) = 0; virtual size_t getCmdsSizeForComputeBarrierCommand() const = 0; + const HardwareInfo &peekHwInfo() const; + protected: void cleanupResources(); void printDeviceIndex(); diff --git a/shared/source/command_stream/command_stream_receiver_hw.h b/shared/source/command_stream/command_stream_receiver_hw.h index 70a7ea8462..fe1fe6f871 100644 --- a/shared/source/command_stream/command_stream_receiver_hw.h +++ b/shared/source/command_stream/command_stream_receiver_hw.h @@ -78,7 +78,6 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { void programComputeMode(LinearStream &csr, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo); void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) override; - const HardwareInfo &peekHwInfo() const; void collectStateBaseAddresPatchInfo( uint64_t commandBufferAddress, diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index 06ef8b89fa..67f8c1b19b 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -886,11 +886,6 @@ inline void CommandStreamReceiverHw::waitForTaskCountWithKmdNotifyFal "\nWaiting completed. Current value: %u\n", *getTagAddress()); } -template -inline const HardwareInfo &CommandStreamReceiverHw::peekHwInfo() const { - return *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo(); -} - template inline void CommandStreamReceiverHw::programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags) { PreemptionHelper::programCmdStream(csr, dispatchFlags.preemptionMode, this->lastPreemptionMode, preemptionAllocation); diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index 1e928e59eb..62376c640f 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -154,6 +154,7 @@ class HwHelper { virtual bool disableL3CacheForDebug(const HardwareInfo &hwInfo) const = 0; virtual bool isRevisionSpecificBinaryBuiltinRequired() const = 0; virtual bool forceNonGpuCoherencyWA(bool requiresCoherency) const = 0; + virtual bool platformSupportsImplicitScaling(const NEO::HardwareInfo &hwInfo) const = 0; protected: HwHelper() = default; @@ -390,6 +391,7 @@ class HwHelperHw : public HwHelper { bool disableL3CacheForDebug(const HardwareInfo &hwInfo) const override; bool isRevisionSpecificBinaryBuiltinRequired() const override; bool forceNonGpuCoherencyWA(bool requiresCoherency) const override; + bool platformSupportsImplicitScaling(const NEO::HardwareInfo &hwInfo) const override; protected: static const AuxTranslationMode defaultAuxTranslationMode; diff --git a/shared/source/helpers/hw_helper_bdw_and_later.inl b/shared/source/helpers/hw_helper_bdw_and_later.inl index 624933ef0e..783f3e4953 100644 --- a/shared/source/helpers/hw_helper_bdw_and_later.inl +++ b/shared/source/helpers/hw_helper_bdw_and_later.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -139,4 +139,10 @@ template bool HwHelperHw::isScratchSpaceSurfaceStateAccessible() const { return false; } + +template +inline bool HwHelperHw::platformSupportsImplicitScaling(const NEO::HardwareInfo &hwInfo) const { + return false; +} + } // namespace NEO diff --git a/shared/source/helpers/hw_helper_xehp_and_later.inl b/shared/source/helpers/hw_helper_xehp_and_later.inl index 6ddd3a1619..f943c03598 100644 --- a/shared/source/helpers/hw_helper_xehp_and_later.inl +++ b/shared/source/helpers/hw_helper_xehp_and_later.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,6 +7,7 @@ #include "shared/source/aub/aub_helper.h" #include "shared/source/command_container/command_encoder.h" +#include "shared/source/command_container/implicit_scaling.h" #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/helpers/heap_assigner.h" #include "shared/source/helpers/pipe_control_args.h" @@ -192,4 +193,10 @@ template bool HwHelperHw::isScratchSpaceSurfaceStateAccessible() const { return true; } + +template +inline bool HwHelperHw::platformSupportsImplicitScaling(const NEO::HardwareInfo &hwInfo) const { + return ImplicitScalingDispatch::platformSupportsImplicitScaling(hwInfo); +} + } // namespace NEO diff --git a/shared/source/xe_hp_core/implicit_scaling_xe_hp_core.cpp b/shared/source/xe_hp_core/implicit_scaling_xe_hp_core.cpp index eca12e87dc..b6bfb9d234 100644 --- a/shared/source/xe_hp_core/implicit_scaling_xe_hp_core.cpp +++ b/shared/source/xe_hp_core/implicit_scaling_xe_hp_core.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,6 +7,7 @@ #include "shared/source/command_container/implicit_scaling.h" #include "shared/source/command_container/implicit_scaling_xehp_and_later.inl" +#include "shared/source/helpers/api_specific_config.h" namespace NEO { @@ -15,5 +16,14 @@ using Family = XeHpFamily; template <> bool ImplicitScalingDispatch::pipeControlStallRequired = true; +template <> +bool ImplicitScalingDispatch::platformSupportsImplicitScaling(const HardwareInfo &hwInfo) { + if (ApiSpecificConfig::getApiType() == ApiSpecificConfig::ApiType::OCL) { + return true; + } else { + return false; + } +} + template struct ImplicitScalingDispatch; } // namespace NEO diff --git a/shared/source/xe_hpc_core/implicit_scaling_xe_hpc_core.cpp b/shared/source/xe_hpc_core/implicit_scaling_xe_hpc_core.cpp index 0352e6bc6f..238fbb40c8 100644 --- a/shared/source/xe_hpc_core/implicit_scaling_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/implicit_scaling_xe_hpc_core.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,6 +7,8 @@ #include "shared/source/command_container/implicit_scaling.h" #include "shared/source/command_container/implicit_scaling_xehp_and_later.inl" +#include "shared/source/helpers/api_specific_config.h" +#include "shared/source/os_interface/hw_info_config.h" namespace NEO { @@ -15,5 +17,14 @@ using Family = XE_HPC_COREFamily; template <> bool ImplicitScalingDispatch::pipeControlStallRequired = false; +template <> +bool ImplicitScalingDispatch::platformSupportsImplicitScaling(const HardwareInfo &hwInfo) { + if (ApiSpecificConfig::getApiType() == ApiSpecificConfig::ApiType::OCL) { + return true; + } else { + return HwInfoConfig::get(hwInfo.platform.eProductFamily)->getSteppingFromHwRevId(hwInfo) >= REVISION_B; + } +} + template struct ImplicitScalingDispatch; } // namespace NEO diff --git a/shared/test/common/test_macros/header/common_matchers.h b/shared/test/common/test_macros/header/common_matchers.h index 7e2f937299..28a8f4eda4 100644 --- a/shared/test/common/test_macros/header/common_matchers.h +++ b/shared/test/common/test_macros/header/common_matchers.h @@ -15,6 +15,7 @@ using IsGen12LP = IsGfxCore; using IsXeHpCore = IsGfxCore; using IsXeHpgCore = IsGfxCore; using IsXeHpcCore = IsGfxCore; +using IsNotXeHpcCore = IsNotGfxCore; using IsAtMostGen11 = IsAtMostGfxCore; diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index e76d04f641..078ac95ac1 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -1441,7 +1441,7 @@ HWTEST_F(CommandStreamReceiverTest, whenCreatingCommandStreamReceiverThenLastAdd HWTEST_F(CommandStreamReceiverTest, givenDebugFlagWhenCreatingCsrThenSetEnableStaticPartitioningAccordingly) { DebugManagerStateRestore restore{}; - VariableBackup backup(&ImplicitScaling::apiSupport, true); + DebugManager.flags.EnableImplicitScaling.set(1); { UltDeviceFactory deviceFactory{1, 2}; @@ -1636,7 +1636,7 @@ TEST_F(CommandStreamReceiverPageTableManagerTest, givenNonExisitingPageTableMana TEST(CreateWorkPartitionAllocationTest, givenDisabledBlitterWhenInitializingWorkPartitionAllocationThenFallbackToCpuCopy) { DebugManagerStateRestore restore{}; - VariableBackup backup(&ImplicitScaling::apiSupport, true); + DebugManager.flags.EnableImplicitScaling.set(1); UltDeviceFactory deviceFactory{1, 2}; MockDevice &device = *deviceFactory.rootDevices[0]; @@ -1662,7 +1662,7 @@ TEST(CreateWorkPartitionAllocationTest, givenDisabledBlitterWhenInitializingWork TEST(CreateWorkPartitionAllocationTest, givenEnabledBlitterWhenInitializingWorkPartitionAllocationThenDontCopyOnCpu) { DebugManagerStateRestore restore{}; - VariableBackup backup(&ImplicitScaling::apiSupport, true); + DebugManager.flags.EnableImplicitScaling.set(1); VariableBackup backupHwInfo(defaultHwInfo.get()); defaultHwInfo->capabilityTable.blitterOperationsSupported = true;