diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/CMakeLists.txt b/level_zero/core/test/unit_tests/xe_hpc_core/CMakeLists.txt index 049e270f67..178324b9e7 100644 --- a/level_zero/core/test/unit_tests/xe_hpc_core/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/xe_hpc_core/CMakeLists.txt @@ -13,6 +13,8 @@ if(TESTS_XE_HPC_CORE) ${CMAKE_CURRENT_SOURCE_DIR}/test_device_xe_hpc_core.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_l0_hw_helper_xe_hpc_core.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_module_xe_hpc_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xe_hpc_core_test_l0_fixtures.h + ${CMAKE_CURRENT_SOURCE_DIR}/xe_hpc_core_test_l0_fixtures.cpp ) add_subdirectories() endif() diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/pvc/CMakeLists.txt b/level_zero/core/test/unit_tests/xe_hpc_core/pvc/CMakeLists.txt new file mode 100644 index 0000000000..e60eabb1ae --- /dev/null +++ b/level_zero/core/test/unit_tests/xe_hpc_core/pvc/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright (C) 2022 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_PVC) + target_sources(${TARGET_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/test_device_pvc.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_pvc.cpp + ) +endif() diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/pvc/test_cmdlist_pvc.cpp b/level_zero/core/test/unit_tests/xe_hpc_core/pvc/test_cmdlist_pvc.cpp new file mode 100644 index 0000000000..3ccad5d104 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe_hpc_core/pvc/test_cmdlist_pvc.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/test_macros/test.h" + +#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" +#include "level_zero/core/test/unit_tests/xe_hpc_core/xe_hpc_core_test_l0_fixtures.h" + +namespace L0 { +namespace ult { + +using CommandListStatePrefetchPvcXt = Test; + +PVCTEST_F(CommandListStatePrefetchPvcXt, givenCommandBufferIsExhaustedWhenPrefetchApiCalledAndIsPvcXtNotBaseDieA0ThenProgramStatePrefetch) { + auto hwInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo(); + const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo->platform.eProductFamily); + hwInfo->platform.usDeviceID = PVC_XT_IDS.front(); + hwInfo->platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, *hwInfo); // not BD A0 + checkIfCommandBufferIsExhaustedWhenPrefetchApiCalledThenStatePrefetchProgrammed(hwInfo); +} + +PVCTEST_F(CommandListStatePrefetchPvcXt, givenDebugFlagSetWhenPrefetchApiCalledAndIsPvcXtNotBaseDieA0ThenProgramStatePrefetch) { + auto hwInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo(); + const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo->platform.eProductFamily); + hwInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo(); + hwInfo->platform.usDeviceID = PVC_XT_IDS.front(); + hwInfo->platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, *hwInfo); // not BD A0 + checkIfDebugFlagSetWhenPrefetchApiCalledAThenStatePrefetchProgrammed(hwInfo); +} + +using CommandListEventFenceTestsPvc = Test; + +PVCTEST_F(CommandListEventFenceTestsPvc, givenCommandListWithProfilingEventAfterCommandOnPvcRev00ThenMiFenceIsNotAdded) { + using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + auto commandList = std::make_unique>>(); + commandList->initialize(device, NEO::EngineGroupType::Compute, 0u); + ze_event_pool_desc_t eventPoolDesc = {}; + eventPoolDesc.count = 1; + eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP; + + auto hwInfo = commandList->commandContainer.getDevice()->getExecutionEnvironment()->rootDeviceEnvironments[0]->getMutableHardwareInfo(); + hwInfo->platform.usRevId = 0x00; + + ze_event_desc_t eventDesc = {}; + eventDesc.index = 0; + eventDesc.signal = 0; + eventDesc.wait = 0; + ze_result_t result = ZE_RESULT_SUCCESS; + auto eventPool = std::unique_ptr(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, result)); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + auto event = std::unique_ptr(L0::Event::create(eventPool.get(), &eventDesc, device)); + commandList->appendEventForProfiling(event->toHandle(), false, false); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), commandList->commandContainer.getCommandStream()->getUsed())); + + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_EQ(cmdList.end(), itor); +} + +using CommandListAppendBarrierXeHpcCore = Test; + +PVCTEST_F(CommandListAppendBarrierXeHpcCore, givenCommandListWhenAppendingBarrierThenPipeControlIsProgrammedAndHdcAndUnTypedFlushesAreSet) { + using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; + using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; + auto commandList = std::make_unique>>(); + commandList->initialize(device, NEO::EngineGroupType::RenderCompute, 0u); + ze_result_t returnValue = commandList->appendBarrier(nullptr, 0, nullptr); + EXPECT_EQ(returnValue, ZE_RESULT_SUCCESS); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), commandList->commandContainer.getCommandStream()->getUsed())); + + // PC for STATE_BASE_ADDRESS from list initialization + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + itor++; + + // PC for appendBarrier + itor = find(itor, cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + + auto pipeControlCmd = reinterpret_cast(*itor); + EXPECT_TRUE(pipeControlCmd->getHdcPipelineFlush()); + EXPECT_TRUE(pipeControlCmd->getUnTypedDataPortCacheFlush()); +} + +} // namespace ult +} // namespace L0 \ No newline at end of file diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/pvc/test_device_pvc.cpp b/level_zero/core/test/unit_tests/xe_hpc_core/pvc/test_device_pvc.cpp new file mode 100644 index 0000000000..e666ec68b3 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe_hpc_core/pvc/test_device_pvc.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/implicit_scaling.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/cmdlist/cmdlist_imp.h" +#include "level_zero/core/source/hw_helpers/l0_hw_helper.h" +#include "level_zero/core/test/unit_tests/xe_hpc_core/xe_hpc_core_test_l0_fixtures.h" + +namespace L0 { +namespace ult { + +using DeviceTestPvcXt = Test; + +PVCTEST_F(DeviceTestPvcXt, whenCallingGetMemoryPropertiesWithNonNullPtrAndRevisionIsNotBaseDieA0OnPvcXtThenMaxClockRateReturnedIsZero) { + auto &device = driverHandle->devices[0]; + auto hwInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo(); + const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo->platform.eProductFamily); + hwInfo->platform.usDeviceID = PVC_XT_IDS.front(); + hwInfo->platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, *hwInfo); // not BD A0 + + checkIfCallingGetMemoryPropertiesWithNonNullPtrThenMaxClockRateReturnZero(hwInfo); +} + +using DeviceTestPvc = Test; +PVCTEST_F(DeviceTestPvc, givenPvcAStepWhenCreatingMultiTileDeviceThenExpectImplicitScalingDisabled) { + auto hwInfo = *NEO::defaultHwInfo; + const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); + hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A0, hwInfo); + + 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 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; +} + +PVCTEST_F(DeviceTestPvc, whenCallingGetMemoryPropertiesWithNonNullPtrThenPropertiesAreReturned) { + uint32_t count = 0; + ze_result_t res = device->getMemoryProperties(&count, nullptr); + EXPECT_EQ(res, ZE_RESULT_SUCCESS); + EXPECT_EQ(1u, count); + + ze_device_memory_properties_t memProperties = {}; + res = device->getMemoryProperties(&count, &memProperties); + EXPECT_EQ(res, ZE_RESULT_SUCCESS); + EXPECT_EQ(1u, count); + + EXPECT_EQ(memProperties.maxClockRate, 3200u); + EXPECT_EQ(memProperties.maxBusWidth, this->neoDevice->getDeviceInfo().addressBits); + EXPECT_EQ(memProperties.totalSize, this->neoDevice->getDeviceInfo().globalMemSize); +} + +PVCTEST_F(DeviceTestPvc, GivenPvcWhenGettingPhysicalEuSimdWidthThenReturn16) { + ze_device_properties_t properties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; + device->getProperties(&properties); + EXPECT_EQ(16u, properties.physicalEUSimdWidth); +} + +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/test_cmdlist_xe_hpc_core.cpp b/level_zero/core/test/unit_tests/xe_hpc_core/test_cmdlist_xe_hpc_core.cpp index d04976ce42..edcdeb9f69 100644 --- a/level_zero/core/test/unit_tests/xe_hpc_core/test_cmdlist_xe_hpc_core.cpp +++ b/level_zero/core/test/unit_tests/xe_hpc_core/test_cmdlist_xe_hpc_core.cpp @@ -55,57 +55,6 @@ HWTEST2_F(CommandListAppendLaunchKernelXeHpcCore, givenKernelUsingSyncBufferWhen using CommandListStatePrefetchXeHpcCore = Test; -HWTEST2_F(CommandListStatePrefetchXeHpcCore, givenDebugFlagSetWhenPrefetchApiCalledAndIsNotBaseDieA0ThenProgramStatePrefetch, IsXeHpcCore) { - using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; - DebugManagerStateRestore restore; - - auto pCommandList = std::make_unique>>(); - auto result = pCommandList->initialize(device, NEO::EngineGroupType::Compute, 0u); - ASSERT_EQ(ZE_RESULT_SUCCESS, result); - - constexpr size_t size = MemoryConstants::cacheLineSize * 2; - constexpr size_t alignment = MemoryConstants::pageSize64k; - constexpr size_t offset = MemoryConstants::cacheLineSize; - constexpr uint32_t mocsIndexForL3 = (2 << 1); - void *ptr = nullptr; - - ze_device_mem_alloc_desc_t deviceDesc = {}; - context->allocDeviceMem(device->toHandle(), &deviceDesc, size + offset, alignment, &ptr); - EXPECT_NE(nullptr, ptr); - - auto hwInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo(); - hwInfo->platform.usRevId = 0x8; // not BD A0 - - auto cmdListBaseOffset = pCommandList->commandContainer.getCommandStream()->getUsed(); - - { - auto ret = pCommandList->appendMemoryPrefetch(ptrOffset(ptr, offset), size); - EXPECT_EQ(ZE_RESULT_SUCCESS, ret); - - EXPECT_EQ(cmdListBaseOffset, pCommandList->commandContainer.getCommandStream()->getUsed()); - } - - { - DebugManager.flags.AddStatePrefetchCmdToMemoryPrefetchAPI.set(1); - - auto ret = pCommandList->appendMemoryPrefetch(ptrOffset(ptr, offset), size); - EXPECT_EQ(ZE_RESULT_SUCCESS, ret); - - EXPECT_EQ(cmdListBaseOffset + sizeof(STATE_PREFETCH), pCommandList->commandContainer.getCommandStream()->getUsed()); - - auto statePrefetchCmd = reinterpret_cast(ptrOffset(pCommandList->commandContainer.getCommandStream()->getCpuBase(), cmdListBaseOffset)); - - EXPECT_EQ(statePrefetchCmd->getAddress(), reinterpret_cast(ptrOffset(ptr, offset))); - EXPECT_FALSE(statePrefetchCmd->getKernelInstructionPrefetch()); - EXPECT_EQ(mocsIndexForL3, statePrefetchCmd->getMemoryObjectControlState()); - EXPECT_EQ(1u, statePrefetchCmd->getPrefetchSize()); - - EXPECT_EQ(reinterpret_cast(ptr), pCommandList->commandContainer.getResidencyContainer().back()->getGpuAddress()); - } - - context->freeMem(ptr); -} - HWTEST2_F(CommandListStatePrefetchXeHpcCore, givenUnifiedSharedMemoryWhenPrefetchApiCalledThenDontSetMemPrefetch, IsXeHpcCore) { auto pCommandList = std::make_unique>>(); auto result = pCommandList->initialize(device, NEO::EngineGroupType::Compute, 0u); @@ -271,92 +220,6 @@ HWTEST2_F(CommandListStatePrefetchXeHpcCore, givenAppendMemoryPrefetchForKmdMigr context->freeMem(ptr); } -HWTEST2_F(CommandListStatePrefetchXeHpcCore, givenCommandBufferIsExhaustedWhenPrefetchApiCalledAndIsNotBaseDieA0ThenProgramStatePrefetch, IsXeHpcCore) { - using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; - using MI_BATCH_BUFFER_END = typename FamilyType::MI_BATCH_BUFFER_END; - - DebugManagerStateRestore restore; - - auto pCommandList = std::make_unique>>(); - auto result = pCommandList->initialize(device, NEO::EngineGroupType::Compute, 0u); - ASSERT_EQ(ZE_RESULT_SUCCESS, result); - - constexpr size_t size = MemoryConstants::cacheLineSize * 2; - constexpr size_t alignment = MemoryConstants::pageSize64k; - constexpr size_t offset = MemoryConstants::cacheLineSize; - constexpr uint32_t mocsIndexForL3 = (2 << 1); - void *ptr = nullptr; - - ze_device_mem_alloc_desc_t deviceDesc = {}; - context->allocDeviceMem(device->toHandle(), &deviceDesc, size + offset, alignment, &ptr); - EXPECT_NE(nullptr, ptr); - - auto hwInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo(); - hwInfo->platform.usRevId = 0x8; // not BD A0 - - auto firstBatchBufferAllocation = pCommandList->commandContainer.getCommandStream()->getGraphicsAllocation(); - - auto useSize = pCommandList->commandContainer.getCommandStream()->getAvailableSpace(); - useSize -= sizeof(MI_BATCH_BUFFER_END); - pCommandList->commandContainer.getCommandStream()->getSpace(useSize); - - DebugManager.flags.AddStatePrefetchCmdToMemoryPrefetchAPI.set(1); - - auto ret = pCommandList->appendMemoryPrefetch(ptrOffset(ptr, offset), size); - EXPECT_EQ(ZE_RESULT_SUCCESS, ret); - auto secondBatchBufferAllocation = pCommandList->commandContainer.getCommandStream()->getGraphicsAllocation(); - - EXPECT_NE(firstBatchBufferAllocation, secondBatchBufferAllocation); - - auto statePrefetchCmd = reinterpret_cast(pCommandList->commandContainer.getCommandStream()->getCpuBase()); - - EXPECT_EQ(statePrefetchCmd->getAddress(), reinterpret_cast(ptrOffset(ptr, offset))); - EXPECT_FALSE(statePrefetchCmd->getKernelInstructionPrefetch()); - EXPECT_EQ(mocsIndexForL3, statePrefetchCmd->getMemoryObjectControlState()); - EXPECT_EQ(1u, statePrefetchCmd->getPrefetchSize()); - - NEO::ResidencyContainer::iterator it = pCommandList->commandContainer.getResidencyContainer().end(); - it--; - EXPECT_EQ(secondBatchBufferAllocation->getGpuAddress(), (*it)->getGpuAddress()); - it--; - EXPECT_EQ(reinterpret_cast(ptr), (*it)->getGpuAddress()); - - context->freeMem(ptr); -} - -using CommandListEventFenceTestsPvc = Test; - -HWTEST2_F(CommandListEventFenceTestsPvc, givenCommandListWithProfilingEventAfterCommandOnPvcRev00ThenMiFenceIsNotAdded, IsPVC) { - using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; - using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; - - auto commandList = std::make_unique>>(); - commandList->initialize(device, NEO::EngineGroupType::Compute, 0u); - ze_event_pool_desc_t eventPoolDesc = {}; - eventPoolDesc.count = 1; - eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP; - - auto hwInfo = commandList->commandContainer.getDevice()->getExecutionEnvironment()->rootDeviceEnvironments[0]->getMutableHardwareInfo(); - hwInfo->platform.usRevId = 0x00; - - ze_event_desc_t eventDesc = {}; - eventDesc.index = 0; - eventDesc.signal = 0; - eventDesc.wait = 0; - ze_result_t result = ZE_RESULT_SUCCESS; - auto eventPool = std::unique_ptr(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, result)); - EXPECT_EQ(ZE_RESULT_SUCCESS, result); - auto event = std::unique_ptr(L0::Event::create(eventPool.get(), &eventDesc, device)); - commandList->appendEventForProfiling(event->toHandle(), false, false); - - GenCmdList cmdList; - ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( - cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), commandList->commandContainer.getCommandStream()->getUsed())); - - auto itor = find(cmdList.begin(), cmdList.end()); - EXPECT_EQ(cmdList.end(), itor); -} - using CommandListEventFenceTestsXeHpcCore = Test; HWTEST2_F(CommandListEventFenceTestsXeHpcCore, givenCommandListWithProfilingEventAfterCommandWhenRevId03ThenMiFenceIsAdded, IsXeHpcCore) { @@ -448,33 +311,5 @@ HWTEST2_F(CommandListAppendRangesBarrierXeHpcCore, givenCallToAppendRangesBarrie EXPECT_TRUE(pipeControlCmd->getHdcPipelineFlush()); EXPECT_TRUE(pipeControlCmd->getUnTypedDataPortCacheFlush()); } - -using CommandListAppendBarrierXeHpcCore = Test; - -HWTEST2_F(CommandListAppendBarrierXeHpcCore, givenCommandListWhenAppendingBarrierThenPipeControlIsProgrammedAndHdcAndUnTypedFlushesAreSet, IsPVC) { - using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; - using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; - auto commandList = std::make_unique>>(); - commandList->initialize(device, NEO::EngineGroupType::RenderCompute, 0u); - ze_result_t returnValue = commandList->appendBarrier(nullptr, 0, nullptr); - EXPECT_EQ(returnValue, ZE_RESULT_SUCCESS); - GenCmdList cmdList; - ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( - cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), commandList->commandContainer.getCommandStream()->getUsed())); - - // PC for STATE_BASE_ADDRESS from list initialization - auto itor = find(cmdList.begin(), cmdList.end()); - EXPECT_NE(cmdList.end(), itor); - itor++; - - // PC for appendBarrier - itor = find(itor, cmdList.end()); - EXPECT_NE(cmdList.end(), itor); - - auto pipeControlCmd = reinterpret_cast(*itor); - EXPECT_TRUE(pipeControlCmd->getHdcPipelineFlush()); - EXPECT_TRUE(pipeControlCmd->getUnTypedDataPortCacheFlush()); -} - } // namespace ult } // namespace L0 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 f796b1cfa3..fee7b3c865 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 @@ -6,7 +6,6 @@ */ #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" @@ -22,24 +21,6 @@ HWTEST_EXCLUDE_PRODUCT(AppendMemoryCopy, givenCopyOnlyCommandListAndHostPointers using DeviceTestXeHpc = Test; -HWTEST2_F(DeviceTestXeHpc, whenCallingGetMemoryPropertiesWithNonNullPtrAndBdRevisionIsNotA0ThenmaxClockRateReturnedIsZero, IsXeHpcCore) { - uint32_t count = 0; - auto device = driverHandle->devices[0]; - auto hwInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo(); - hwInfo->platform.usRevId = 0x8; // not BD A0 - - ze_result_t res = device->getMemoryProperties(&count, nullptr); - EXPECT_EQ(res, ZE_RESULT_SUCCESS); - EXPECT_EQ(1u, count); - - ze_device_memory_properties_t memProperties = {}; - res = device->getMemoryProperties(&count, &memProperties); - EXPECT_EQ(res, ZE_RESULT_SUCCESS); - EXPECT_EQ(1u, count); - - EXPECT_EQ(memProperties.maxClockRate, 0u); -} - HWTEST2_F(DeviceTestXeHpc, givenXeHpcAStepAndDebugFlagOverridesWhenCreatingMultiTileDeviceThenExpectImplicitScalingEnabled, IsXeHpcCore) { DebugManagerStateRestore restorer; DebugManager.flags.CreateMultipleSubDevices.set(2); @@ -49,7 +30,8 @@ HWTEST2_F(DeviceTestXeHpc, givenXeHpcAStepAndDebugFlagOverridesWhenCreatingMulti ze_result_t returnValue = ZE_RESULT_SUCCESS; std::unique_ptr driverHandle(new DriverHandleImp); auto hwInfo = *NEO::defaultHwInfo; - hwInfo.platform.usRevId = 0x3; + const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); + hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_A0, hwInfo); auto neoDevice = std::unique_ptr(NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); auto device = Device::create(driverHandle.get(), neoDevice.release(), false, &returnValue); @@ -69,7 +51,8 @@ HWTEST2_F(DeviceTestXeHpc, givenXeHpcBStepWhenCreatingMultiTileDeviceThenExpectI ze_result_t returnValue = ZE_RESULT_SUCCESS; std::unique_ptr driverHandle(new DriverHandleImp); auto hwInfo = *NEO::defaultHwInfo; - hwInfo.platform.usRevId = 0x6; + const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); + hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); auto neoDevice = std::unique_ptr(NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); auto device = Device::create(driverHandle.get(), neoDevice.release(), false, &returnValue); @@ -81,44 +64,6 @@ HWTEST2_F(DeviceTestXeHpc, givenXeHpcBStepWhenCreatingMultiTileDeviceThenExpectI delete device; } -using DeviceTestPvc = Test; - -HWTEST2_F(DeviceTestPvc, givenPvcAStepWhenCreatingMultiTileDeviceThenExpectImplicitScalingDisabled, IsPVC) { - 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, whenCallingGetMemoryPropertiesWithNonNullPtrThenPropertiesAreReturned, IsPVC) { - uint32_t count = 0; - ze_result_t res = device->getMemoryProperties(&count, nullptr); - EXPECT_EQ(res, ZE_RESULT_SUCCESS); - EXPECT_EQ(1u, count); - - ze_device_memory_properties_t memProperties = {}; - res = device->getMemoryProperties(&count, &memProperties); - EXPECT_EQ(res, ZE_RESULT_SUCCESS); - EXPECT_EQ(1u, count); - - EXPECT_EQ(memProperties.maxClockRate, 3200u); - EXPECT_EQ(memProperties.maxBusWidth, this->neoDevice->getDeviceInfo().addressBits); - EXPECT_EQ(memProperties.totalSize, this->neoDevice->getDeviceInfo().globalMemSize); -} - using MultiDeviceCommandQueueGroupWithNineCopyEnginesTest = Test>; HWTEST2_F(MultiDeviceCommandQueueGroupWithNineCopyEnginesTest, givenMainAndLinkCopyEngineSupportAndCCSAndImplicitScalingThenExpectedQueueGroupsAreReturned, IsXeHpcCore) { @@ -397,22 +342,20 @@ HWTEST2_F(CommandQueueGroupTest, givenBlitterDisabledAndAllBcsSetThenTwoQueueGro EXPECT_EQ(count, 2u); } -class DeviceCopyQueueGroupFixture : public DeviceFixture { +class DeviceCopyQueueGroupXeHpcFixture : public DeviceFixture { public: void SetUp() { DebugManager.flags.EnableBlitterOperationsSupport.set(0); DeviceFixture::SetUp(); } - void TearDown() { DeviceFixture::TearDown(); } DebugManagerStateRestore restorer; }; +using DeviceCopyQueueGroupXeHpcTest = Test; -using DeviceCopyQueueGroupTest = Test; - -HWTEST2_F(DeviceCopyQueueGroupTest, +HWTEST2_F(DeviceCopyQueueGroupXeHpcTest, givenBlitterSupportAndEnableBlitterOperationsSupportSetToZeroThenNoCopyEngineIsReturned, IsXeHpcCore) { const uint32_t rootDeviceIndex = 0u; NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); @@ -446,11 +389,5 @@ HWTEST2_F(DeviceTestXeHpc, givenReturnedDevicePropertiesThenExpectedPropertyFlag EXPECT_EQ(0u, deviceProps.flags & ZE_DEVICE_PROPERTY_FLAG_INTEGRATED); } -HWTEST2_F(DeviceTestXeHpc, GivenPvcWhenGettingPhysicalEuSimdWidthThenReturn16, IsPVC) { - ze_device_properties_t properties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; - device->getProperties(&properties); - EXPECT_EQ(16u, properties.physicalEUSimdWidth); -} - } // namespace ult } // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/xe_hpc_core_test_l0_fixtures.cpp b/level_zero/core/test/unit_tests/xe_hpc_core/xe_hpc_core_test_l0_fixtures.cpp new file mode 100644 index 0000000000..dabb5e5e7e --- /dev/null +++ b/level_zero/core/test/unit_tests/xe_hpc_core/xe_hpc_core_test_l0_fixtures.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/core/test/unit_tests/xe_hpc_core/xe_hpc_core_test_l0_fixtures.h" + +#include "shared/test/common/test_macros/test.h" + +#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" + +using namespace L0; +using namespace ult; + +void DeviceFixtureXeHpcTests::checkIfCallingGetMemoryPropertiesWithNonNullPtrThenMaxClockRateReturnZero(HardwareInfo *hwInfo) { + uint32_t count = 0; + ze_result_t res = device->getMemoryProperties(&count, nullptr); + EXPECT_EQ(res, ZE_RESULT_SUCCESS); + EXPECT_EQ(1u, count); + + ze_device_memory_properties_t memProperties = {}; + res = device->getMemoryProperties(&count, &memProperties); + EXPECT_EQ(res, ZE_RESULT_SUCCESS); + EXPECT_EQ(1u, count); + + EXPECT_EQ(memProperties.maxClockRate, 0u); +} + +void CommandListStatePrefetchXeHpcCore::checkIfDebugFlagSetWhenPrefetchApiCalledAThenStatePrefetchProgrammed(HardwareInfo *hwInfo) { + using STATE_PREFETCH = typename XE_HPC_COREFamily::STATE_PREFETCH; + DebugManagerStateRestore restore; + auto pCommandList = std::make_unique>>(); + auto result = pCommandList->initialize(device, NEO::EngineGroupType::Compute, 0u); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + constexpr size_t size = MemoryConstants::cacheLineSize * 2; + constexpr size_t alignment = MemoryConstants::pageSize64k; + constexpr size_t offset = MemoryConstants::cacheLineSize; + constexpr uint32_t mocsIndexForL3 = (2 << 1); + void *ptr = nullptr; + + ze_device_mem_alloc_desc_t deviceDesc = {}; + context->allocDeviceMem(device->toHandle(), &deviceDesc, size + offset, alignment, &ptr); + EXPECT_NE(nullptr, ptr); + + auto cmdListBaseOffset = pCommandList->commandContainer.getCommandStream()->getUsed(); + + { + auto ret = pCommandList->appendMemoryPrefetch(ptrOffset(ptr, offset), size); + EXPECT_EQ(ZE_RESULT_SUCCESS, ret); + + EXPECT_EQ(cmdListBaseOffset, pCommandList->commandContainer.getCommandStream()->getUsed()); + } + + { + DebugManager.flags.AddStatePrefetchCmdToMemoryPrefetchAPI.set(1); + + auto ret = pCommandList->appendMemoryPrefetch(ptrOffset(ptr, offset), size); + EXPECT_EQ(ZE_RESULT_SUCCESS, ret); + + EXPECT_EQ(cmdListBaseOffset + sizeof(STATE_PREFETCH), pCommandList->commandContainer.getCommandStream()->getUsed()); + + auto statePrefetchCmd = reinterpret_cast(ptrOffset(pCommandList->commandContainer.getCommandStream()->getCpuBase(), cmdListBaseOffset)); + + EXPECT_EQ(statePrefetchCmd->getAddress(), reinterpret_cast(ptrOffset(ptr, offset))); + EXPECT_FALSE(statePrefetchCmd->getKernelInstructionPrefetch()); + EXPECT_EQ(mocsIndexForL3, statePrefetchCmd->getMemoryObjectControlState()); + EXPECT_EQ(1u, statePrefetchCmd->getPrefetchSize()); + + EXPECT_EQ(reinterpret_cast(ptr), pCommandList->commandContainer.getResidencyContainer().back()->getGpuAddress()); + } + + context->freeMem(ptr); +} + +void CommandListStatePrefetchXeHpcCore::checkIfCommandBufferIsExhaustedWhenPrefetchApiCalledThenStatePrefetchProgrammed(HardwareInfo *hwInfo) { + using STATE_PREFETCH = typename XE_HPC_COREFamily::STATE_PREFETCH; + using MI_BATCH_BUFFER_END = typename XE_HPC_COREFamily::MI_BATCH_BUFFER_END; + + DebugManagerStateRestore restore; + + auto pCommandList = std::make_unique>>(); + auto result = pCommandList->initialize(device, NEO::EngineGroupType::Compute, 0u); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + constexpr size_t size = MemoryConstants::cacheLineSize * 2; + constexpr size_t alignment = MemoryConstants::pageSize64k; + constexpr size_t offset = MemoryConstants::cacheLineSize; + constexpr uint32_t mocsIndexForL3 = (2 << 1); + void *ptr = nullptr; + + ze_device_mem_alloc_desc_t deviceDesc = {}; + context->allocDeviceMem(device->toHandle(), &deviceDesc, size + offset, alignment, &ptr); + EXPECT_NE(nullptr, ptr); + + auto firstBatchBufferAllocation = pCommandList->commandContainer.getCommandStream()->getGraphicsAllocation(); + + auto useSize = pCommandList->commandContainer.getCommandStream()->getAvailableSpace(); + useSize -= sizeof(MI_BATCH_BUFFER_END); + pCommandList->commandContainer.getCommandStream()->getSpace(useSize); + + DebugManager.flags.AddStatePrefetchCmdToMemoryPrefetchAPI.set(1); + + auto ret = pCommandList->appendMemoryPrefetch(ptrOffset(ptr, offset), size); + EXPECT_EQ(ZE_RESULT_SUCCESS, ret); + auto secondBatchBufferAllocation = pCommandList->commandContainer.getCommandStream()->getGraphicsAllocation(); + + EXPECT_NE(firstBatchBufferAllocation, secondBatchBufferAllocation); + + auto statePrefetchCmd = reinterpret_cast(pCommandList->commandContainer.getCommandStream()->getCpuBase()); + + EXPECT_EQ(statePrefetchCmd->getAddress(), reinterpret_cast(ptrOffset(ptr, offset))); + EXPECT_FALSE(statePrefetchCmd->getKernelInstructionPrefetch()); + EXPECT_EQ(mocsIndexForL3, statePrefetchCmd->getMemoryObjectControlState()); + EXPECT_EQ(1u, statePrefetchCmd->getPrefetchSize()); + + NEO::ResidencyContainer::iterator it = pCommandList->commandContainer.getResidencyContainer().end(); + it--; + EXPECT_EQ(secondBatchBufferAllocation->getGpuAddress(), (*it)->getGpuAddress()); + it--; + EXPECT_EQ(reinterpret_cast(ptr), (*it)->getGpuAddress()); + + context->freeMem(ptr); +} diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/xe_hpc_core_test_l0_fixtures.h b/level_zero/core/test/unit_tests/xe_hpc_core/xe_hpc_core_test_l0_fixtures.h new file mode 100644 index 0000000000..106133c484 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe_hpc_core/xe_hpc_core_test_l0_fixtures.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/helpers/debug_manager_state_restore.h" + +#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" +#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h" + +namespace L0 { +namespace ult { +struct DeviceFixtureXeHpcTests : public DeviceFixture { + void checkIfCallingGetMemoryPropertiesWithNonNullPtrThenMaxClockRateReturnZero(HardwareInfo *hwInfo); + DebugManagerStateRestore restorer; +}; + +struct CommandListStatePrefetchXeHpcCore : public ModuleFixture { + void checkIfDebugFlagSetWhenPrefetchApiCalledAThenStatePrefetchProgrammed(HardwareInfo *hwInfo); + void checkIfCommandBufferIsExhaustedWhenPrefetchApiCalledThenStatePrefetchProgrammed(HardwareInfo *hwInfo); +}; +} // namespace ult +} // namespace L0 \ No newline at end of file diff --git a/opencl/test/unit_test/xe_hpc_core/CMakeLists.txt b/opencl/test/unit_test/xe_hpc_core/CMakeLists.txt index f49539f7c6..fb9ec9b2e4 100644 --- a/opencl/test/unit_test/xe_hpc_core/CMakeLists.txt +++ b/opencl/test/unit_test/xe_hpc_core/CMakeLists.txt @@ -22,6 +22,8 @@ if(TESTS_XE_HPC_CORE) ${CMAKE_CURRENT_SOURCE_DIR}/test_device_caps_xe_hpc_core.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_platform_caps_xe_hpc_core.cpp ${CMAKE_CURRENT_SOURCE_DIR}/api_tests_xe_hpc_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xe_hpc_core_test_ocl_fixtures.h + ${CMAKE_CURRENT_SOURCE_DIR}/xe_hpc_core_test_ocl_fixtures.cpp ) get_property(NEO_CORE_TESTS_XE_HPC_CORE GLOBAL PROPERTY NEO_CORE_TESTS_XE_HPC_CORE) diff --git a/opencl/test/unit_test/xe_hpc_core/hw_helper_tests_xe_hpc_core.cpp b/opencl/test/unit_test/xe_hpc_core/hw_helper_tests_xe_hpc_core.cpp index f8493dd254..d7c1b316f7 100644 --- a/opencl/test/unit_test/xe_hpc_core/hw_helper_tests_xe_hpc_core.cpp +++ b/opencl/test/unit_test/xe_hpc_core/hw_helper_tests_xe_hpc_core.cpp @@ -43,72 +43,6 @@ XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenCommandBufferAllocationTypeWhenGe EXPECT_FALSE(allocData.flags.useSystemMemory); } -XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenSingleTileCsrWhenAllocatingCsrSpecificAllocationsAndIsNotBaseDieA0ThenStoreThemInProperMemoryPool) { - const uint32_t numDevices = 4u; - const uint32_t tileIndex = 2u; - const DeviceBitfield singleTileMask{static_cast(1u << tileIndex)}; - DebugManagerStateRestore restore; - VariableBackup backup{&ultHwConfig}; - - ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; - DebugManager.flags.CreateMultipleSubDevices.set(numDevices); - DebugManager.flags.EnableLocalMemory.set(true); - initPlatform(); - - auto clDevice = platform()->getClDevice(0); - auto hwInfo = clDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->getMutableHardwareInfo(); - hwInfo->platform.usRevId = 0x8; // not BD A0 - - auto commandStreamReceiver = clDevice->getSubDevice(tileIndex)->getDefaultEngine().commandStreamReceiver; - auto &heap = commandStreamReceiver->getIndirectHeap(IndirectHeap::Type::INDIRECT_OBJECT, MemoryConstants::pageSize64k); - auto heapAllocation = heap.getGraphicsAllocation(); - if (commandStreamReceiver->canUse4GbHeaps) { - EXPECT_EQ(AllocationType::INTERNAL_HEAP, heapAllocation->getAllocationType()); - } else { - EXPECT_EQ(AllocationType::LINEAR_STREAM, heapAllocation->getAllocationType()); - } - EXPECT_EQ(singleTileMask, heapAllocation->storageInfo.memoryBanks); - - commandStreamReceiver->ensureCommandBufferAllocation(heap, heap.getAvailableSpace() + 1, 0u); - auto commandBufferAllocation = heap.getGraphicsAllocation(); - EXPECT_EQ(AllocationType::COMMAND_BUFFER, commandBufferAllocation->getAllocationType()); - EXPECT_NE(heapAllocation, commandBufferAllocation); - EXPECT_EQ(commandBufferAllocation->getMemoryPool(), MemoryPool::LocalMemory); -} - -XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenMultiTileCsrWhenAllocatingCsrSpecificAllocationsAndIsNotBaseDieA0ThenStoreThemInLocalMemoryPool) { - const uint32_t numDevices = 4u; - const DeviceBitfield tile0Mask{0x1}; - DebugManagerStateRestore restore; - VariableBackup backup{&ultHwConfig}; - - ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; - DebugManager.flags.CreateMultipleSubDevices.set(numDevices); - DebugManager.flags.EnableLocalMemory.set(true); - DebugManager.flags.OverrideLeastOccupiedBank.set(0u); - initPlatform(); - - auto clDevice = platform()->getClDevice(0); - auto hwInfo = clDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->getMutableHardwareInfo(); - hwInfo->platform.usRevId = 0x8; // not BD A0 - - auto commandStreamReceiver = clDevice->getDefaultEngine().commandStreamReceiver; - auto &heap = commandStreamReceiver->getIndirectHeap(IndirectHeap::Type::INDIRECT_OBJECT, MemoryConstants::pageSize64k); - auto heapAllocation = heap.getGraphicsAllocation(); - if (commandStreamReceiver->canUse4GbHeaps) { - EXPECT_EQ(AllocationType::INTERNAL_HEAP, heapAllocation->getAllocationType()); - } else { - EXPECT_EQ(AllocationType::LINEAR_STREAM, heapAllocation->getAllocationType()); - } - EXPECT_EQ(tile0Mask, heapAllocation->storageInfo.memoryBanks); - - commandStreamReceiver->ensureCommandBufferAllocation(heap, heap.getAvailableSpace() + 1, 0u); - auto commandBufferAllocation = heap.getGraphicsAllocation(); - EXPECT_EQ(AllocationType::COMMAND_BUFFER, commandBufferAllocation->getAllocationType()); - EXPECT_NE(heapAllocation, commandBufferAllocation); - EXPECT_EQ(commandBufferAllocation->getMemoryPool(), MemoryPool::LocalMemory); -} - XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenSingleTileBdA0CsrWhenAllocatingCsrSpecificAllocationsThenStoreThemInProperMemoryPool) { const uint32_t numDevices = 4u; const uint32_t tileIndex = 2u; @@ -168,46 +102,6 @@ XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, GivenBarrierEncodingWhenCallingGetBarr EXPECT_EQ(32u, hwHelper.getBarriersCountFromHasBarriers(7u)); } -HWTEST2_F(HwHelperTestsXeHpcCore, givenRevisionEnumAndPlatformFamilyTypeThenProperValueForIsWorkaroundRequiredIsReturned, IsPVC) { - uint32_t steppings[] = { - REVISION_A0, - REVISION_B, - REVISION_C, - REVISION_D, - CommonConstants::invalidStepping, - }; - - const auto &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); - const auto &hwInfoConfig = *HwInfoConfig::get(hardwareInfo.platform.eProductFamily); - - for (auto stepping : steppings) { - hardwareInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(stepping, hardwareInfo); - - if (stepping == REVISION_A0) { - EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hardwareInfo)); - EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_C, hardwareInfo)); - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_C, hardwareInfo)); - } else if (stepping == REVISION_B) { - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hardwareInfo)); - EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_C, hardwareInfo)); - EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_C, hardwareInfo)); - } else { - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hardwareInfo)); - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_C, hardwareInfo)); - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_C, hardwareInfo)); - } - - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_A0, hardwareInfo)); - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_C, REVISION_A0, hardwareInfo)); - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_C, REVISION_B, hardwareInfo)); - - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_D, hardwareInfo)); - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_D, REVISION_A0, hardwareInfo)); - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_A1, hardwareInfo)); - EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A1, REVISION_A0, hardwareInfo)); - } -} - XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenCccsDisabledButDebugVariableSetWhenIsCooperativeEngineSupportedEnabledAndGetGpgpuEnginesCalledThenSetCccsProperly) { HardwareInfo hwInfo = *defaultHwInfo; const auto &hwInfoConfig = *HwInfoConfig::get(hardwareInfo.platform.eProductFamily); @@ -720,20 +614,6 @@ XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenHwHelperWhenAskedIfFenceAllocatio EXPECT_TRUE(helper.isFenceAllocationRequired(hwInfo)); } -HWTEST2_F(HwHelperTestsXeHpcCore, givenDefaultMemorySynchronizationCommandsWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned, IsPVC) { - using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; - - EXPECT_EQ(sizeof(MI_SEMAPHORE_WAIT), MemorySynchronizationCommands::getSizeForAdditonalSynchronization(*defaultHwInfo)); -} - -HWTEST2_F(HwHelperTestsXeHpcCore, givenDebugMemorySynchronizationCommandsWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned, IsPVC) { - DebugManagerStateRestore restorer; - DebugManager.flags.DisablePipeControlPrecedingPostSyncCommand.set(1); - using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; - - EXPECT_EQ(2 * sizeof(MI_SEMAPHORE_WAIT), MemorySynchronizationCommands::getSizeForAdditonalSynchronization(*defaultHwInfo)); -} - XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenDontProgramGlobalFenceAsMiMemFenceCommandInCommandStreamWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) { DebugManagerStateRestore debugRestorer; DebugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); @@ -1005,28 +885,3 @@ XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenHwHelperWhenAskingForPatIndexWaTh EXPECT_TRUE(hwHelper.isPatIndexFallbackWaRequired()); } - -HWTEST2_F(HwHelperTestsXeHpcCore, GivenRevisionIdWhenGetComputeUnitsUsedForScratchThenReturnValidValue, IsPVC) { - auto &helper = HwHelper::get(renderCoreFamily); - auto hwInfo = *defaultHwInfo; - hwInfo.gtSystemInfo.EUCount *= 2; - - uint32_t expectedValue = hwInfo.gtSystemInfo.MaxSubSlicesSupported * hwInfo.gtSystemInfo.MaxEuPerSubSlice; - - struct { - unsigned short revId; - uint32_t expectedRatio; - } testInputs[] = { - {0x0, 8}, - {0x1, 8}, - {0x3, 16}, - {0x5, 16}, - {0x6, 16}, - {0x7, 16}, - }; - - for (auto &testInput : testInputs) { - hwInfo.platform.usRevId = testInput.revId; - EXPECT_EQ(expectedValue * testInput.expectedRatio, helper.getComputeUnitsUsedForScratch(&hwInfo)); - } -} diff --git a/opencl/test/unit_test/xe_hpc_core/pvc/CMakeLists.txt b/opencl/test/unit_test/xe_hpc_core/pvc/CMakeLists.txt index 8dabfdf57f..6ceaddb2f7 100644 --- a/opencl/test/unit_test/xe_hpc_core/pvc/CMakeLists.txt +++ b/opencl/test/unit_test/xe_hpc_core/pvc/CMakeLists.txt @@ -13,6 +13,7 @@ if(TESTS_PVC) ${CMAKE_CURRENT_SOURCE_DIR}/sampler_tests_pvc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_device_caps_pvc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_pvc.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_pvc.cpp ) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_xe_hpc_core_pvc}) add_subdirectories() diff --git a/opencl/test/unit_test/xe_hpc_core/pvc/hw_helper_tests_pvc.cpp b/opencl/test/unit_test/xe_hpc_core/pvc/hw_helper_tests_pvc.cpp new file mode 100644 index 0000000000..53c86a3c29 --- /dev/null +++ b/opencl/test/unit_test/xe_hpc_core/pvc/hw_helper_tests_pvc.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/helpers/ult_hw_config.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/test/unit_test/mocks/mock_platform.h" +#include "opencl/test/unit_test/xe_hpc_core/xe_hpc_core_test_ocl_fixtures.h" +namespace NEO { + +using HwHelperTestsPvcXt = Test; +PVCTEST_F(HwHelperTestsPvcXt, givenSingleTileCsrOnPvcXtWhenAllocatingCsrSpecificAllocationsAndIsNotBaseDieA0ThenStoredInProperMemoryPool) { + auto hwInfo = *defaultHwInfo; + const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); + hwInfo.platform.usDeviceID = PVC_XT_IDS.front(); + hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); // not BD A0 + checkIfSingleTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInProperMemoryPool(&hwInfo); +} + +PVCTEST_F(HwHelperTestsPvcXt, givenMultiTileCsrOnPvcWhenAllocatingCsrSpecificAllocationsAndIsNotBaseDieA0ThenStoredInLocalMemoryPool) { + auto hwInfo = *defaultHwInfo; + const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); + hwInfo.platform.usDeviceID = PVC_XT_IDS.front(); + hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); // not BD A0 + checkIfMultiTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInLocalMemoryPool(&hwInfo); +} + +using HwHelperTestsPvc = Test; +PVCTEST_F(HwHelperTestsPvc, givenRevisionEnumAndPlatformFamilyTypeThenProperValueForIsWorkaroundRequiredIsReturned) { + uint32_t steppings[] = { + REVISION_A0, + REVISION_B, + REVISION_C, + REVISION_D, + CommonConstants::invalidStepping, + }; + + const auto &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); + const auto &hwInfoConfig = *HwInfoConfig::get(hardwareInfo.platform.eProductFamily); + + for (auto stepping : steppings) { + hardwareInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(stepping, hardwareInfo); + + if (stepping == REVISION_A0) { + EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hardwareInfo)); + EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_C, hardwareInfo)); + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_C, hardwareInfo)); + } else if (stepping == REVISION_B) { + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hardwareInfo)); + EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_C, hardwareInfo)); + EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_C, hardwareInfo)); + } else { + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hardwareInfo)); + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_C, hardwareInfo)); + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_C, hardwareInfo)); + } + + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_A0, hardwareInfo)); + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_C, REVISION_A0, hardwareInfo)); + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_C, REVISION_B, hardwareInfo)); + + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_D, hardwareInfo)); + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_D, REVISION_A0, hardwareInfo)); + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_A1, hardwareInfo)); + EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A1, REVISION_A0, hardwareInfo)); + } +} + +PVCTEST_F(HwHelperTestsPvc, givenDefaultMemorySynchronizationCommandsWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) { + using MI_SEMAPHORE_WAIT = typename XE_HPC_COREFamily::MI_SEMAPHORE_WAIT; + + EXPECT_EQ(sizeof(MI_SEMAPHORE_WAIT), MemorySynchronizationCommands::getSizeForAdditonalSynchronization(*defaultHwInfo)); +} + +PVCTEST_F(HwHelperTestsPvc, givenDebugMemorySynchronizationCommandsWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) { + DebugManagerStateRestore restorer; + DebugManager.flags.DisablePipeControlPrecedingPostSyncCommand.set(1); + using MI_SEMAPHORE_WAIT = typename XE_HPC_COREFamily::MI_SEMAPHORE_WAIT; + + EXPECT_EQ(2 * sizeof(MI_SEMAPHORE_WAIT), MemorySynchronizationCommands::getSizeForAdditonalSynchronization(*defaultHwInfo)); +} + +PVCTEST_F(HwHelperTestsPvc, givenRevisionIdWhenGetComputeUnitsUsedForScratchThenReturnValidValue) { + auto &helper = HwHelper::get(IGFX_XE_HPC_CORE); + auto hwInfo = *defaultHwInfo; + hwInfo.gtSystemInfo.EUCount *= 2; + + uint32_t expectedValue = hwInfo.gtSystemInfo.MaxSubSlicesSupported * hwInfo.gtSystemInfo.MaxEuPerSubSlice; + + struct { + unsigned short revId; + uint32_t expectedRatio; + } testInputs[] = { + {0x0, 8}, + {0x1, 8}, + {0x3, 16}, + {0x5, 16}, + {0x6, 16}, + {0x7, 16}, + }; + + for (auto &testInput : testInputs) { + hwInfo.platform.usRevId = testInput.revId; + EXPECT_EQ(expectedValue * testInput.expectedRatio, helper.getComputeUnitsUsedForScratch(&hwInfo)); + } +} +} // namespace NEO \ No newline at end of file diff --git a/opencl/test/unit_test/xe_hpc_core/xe_hpc_core_test_ocl_fixtures.cpp b/opencl/test/unit_test/xe_hpc_core/xe_hpc_core_test_ocl_fixtures.cpp new file mode 100644 index 0000000000..f7c857933f --- /dev/null +++ b/opencl/test/unit_test/xe_hpc_core/xe_hpc_core_test_ocl_fixtures.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "opencl/test/unit_test/xe_hpc_core/xe_hpc_core_test_ocl_fixtures.h" + +#include "shared/test/common/helpers/debug_manager_state_restore.h" + +#include "opencl/test/unit_test/mocks/mock_platform.h" + +namespace NEO { + +void HwHelperTestsXeHpcCore::setupDeviceIdAndRevision(HardwareInfo *hwInfo, ClDevice &clDevice) { + auto deviceHwInfo = clDevice.getExecutionEnvironment()->rootDeviceEnvironments[0]->getMutableHardwareInfo(); + deviceHwInfo->platform.usDeviceID = hwInfo->platform.usDeviceID; + deviceHwInfo->platform.usRevId = hwInfo->platform.usRevId; +} +void HwHelperTestsXeHpcCore::checkIfSingleTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInProperMemoryPool(HardwareInfo *hwInfo) { + const uint32_t numDevices = 4u; + const uint32_t tileIndex = 2u; + const DeviceBitfield singleTileMask{static_cast(1u << tileIndex)}; + ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; + DebugManager.flags.CreateMultipleSubDevices.set(numDevices); + DebugManager.flags.EnableLocalMemory.set(true); + initPlatform(); + auto clDevice = platform()->getClDevice(0); + setupDeviceIdAndRevision(hwInfo, *clDevice); + + auto commandStreamReceiver = clDevice->getSubDevice(tileIndex)->getDefaultEngine().commandStreamReceiver; + auto &heap = commandStreamReceiver->getIndirectHeap(IndirectHeap::Type::INDIRECT_OBJECT, MemoryConstants::pageSize64k); + auto heapAllocation = heap.getGraphicsAllocation(); + if (commandStreamReceiver->canUse4GbHeaps) { + EXPECT_EQ(AllocationType::INTERNAL_HEAP, heapAllocation->getAllocationType()); + } else { + EXPECT_EQ(AllocationType::LINEAR_STREAM, heapAllocation->getAllocationType()); + } + EXPECT_EQ(singleTileMask, heapAllocation->storageInfo.memoryBanks); + + commandStreamReceiver->ensureCommandBufferAllocation(heap, heap.getAvailableSpace() + 1, 0u); + auto commandBufferAllocation = heap.getGraphicsAllocation(); + EXPECT_EQ(AllocationType::COMMAND_BUFFER, commandBufferAllocation->getAllocationType()); + EXPECT_NE(heapAllocation, commandBufferAllocation); + EXPECT_EQ(commandBufferAllocation->getMemoryPool(), MemoryPool::LocalMemory); +} + +void HwHelperTestsXeHpcCore::checkIfMultiTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInLocalMemoryPool(HardwareInfo *hwInfo) { + const uint32_t numDevices = 4u; + const DeviceBitfield tile0Mask{0x1}; + ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false; + DebugManager.flags.CreateMultipleSubDevices.set(numDevices); + DebugManager.flags.EnableLocalMemory.set(true); + DebugManager.flags.OverrideLeastOccupiedBank.set(0u); + initPlatform(); + + auto clDevice = platform()->getClDevice(0); + setupDeviceIdAndRevision(hwInfo, *clDevice); + + auto commandStreamReceiver = clDevice->getDefaultEngine().commandStreamReceiver; + auto &heap = commandStreamReceiver->getIndirectHeap(IndirectHeap::Type::INDIRECT_OBJECT, MemoryConstants::pageSize64k); + auto heapAllocation = heap.getGraphicsAllocation(); + if (commandStreamReceiver->canUse4GbHeaps) { + EXPECT_EQ(AllocationType::INTERNAL_HEAP, heapAllocation->getAllocationType()); + } else { + EXPECT_EQ(AllocationType::LINEAR_STREAM, heapAllocation->getAllocationType()); + } + EXPECT_EQ(tile0Mask, heapAllocation->storageInfo.memoryBanks); + + commandStreamReceiver->ensureCommandBufferAllocation(heap, heap.getAvailableSpace() + 1, 0u); + auto commandBufferAllocation = heap.getGraphicsAllocation(); + EXPECT_EQ(AllocationType::COMMAND_BUFFER, commandBufferAllocation->getAllocationType()); + EXPECT_NE(heapAllocation, commandBufferAllocation); + EXPECT_EQ(commandBufferAllocation->getMemoryPool(), MemoryPool::LocalMemory); +} +} // namespace NEO \ No newline at end of file diff --git a/opencl/test/unit_test/xe_hpc_core/xe_hpc_core_test_ocl_fixtures.h b/opencl/test/unit_test/xe_hpc_core/xe_hpc_core_test_ocl_fixtures.h new file mode 100644 index 0000000000..30d493929b --- /dev/null +++ b/opencl/test/unit_test/xe_hpc_core/xe_hpc_core_test_ocl_fixtures.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/ult_hw_config.h" + +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" + +namespace NEO { +struct HwHelperTestsXeHpcCore : public ClDeviceFixture { + void checkIfSingleTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInProperMemoryPool(HardwareInfo *hwInfo); + void checkIfMultiTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInLocalMemoryPool(HardwareInfo *hwInfo); + void setupDeviceIdAndRevision(HardwareInfo *hwInfo, ClDevice &clDevice); + DebugManagerStateRestore restore; + VariableBackup backup{&ultHwConfig}; +}; +} // namespace NEO \ No newline at end of file