diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl index fafa526eba..be4aae63b7 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl @@ -418,12 +418,15 @@ template void CommandQueueHw::programFrontEnd(uint64_t scratchAddress, uint32_t perThreadScratchSpaceSize, NEO::LinearStream &commandStream) { using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; UNRECOVERABLE_IF(csr == nullptr); + auto &hwInfo = device->getHwInfo(); + auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily); + auto engineGroupType = hwHelper.getEngineGroupType(csr->getOsContext().getEngineType(), hwInfo); NEO::PreambleHelper::programVFEState(&commandStream, - device->getHwInfo(), + hwInfo, perThreadScratchSpaceSize, scratchAddress, device->getMaxNumHwThreads(), - csr->getOsContext().getEngineType(), + engineGroupType, NEO::AdditionalKernelExecInfo::NotApplicable, NEO::KernelExecutionType::NotApplicable); csr->setMediaVFEStateDirty(false); diff --git a/opencl/source/device_queue/device_queue_hw_bdw_plus.inl b/opencl/source/device_queue/device_queue_hw_bdw_plus.inl index d4e96162d2..33a6277b20 100644 --- a/opencl/source/device_queue/device_queue_hw_bdw_plus.inl +++ b/opencl/source/device_queue/device_queue_hw_bdw_plus.inl @@ -131,7 +131,7 @@ void DeviceQueueHw::addMediaStateClearCmds() { addDcFlushToPipeControlWa(pipeControl); PreambleHelper::programVFEState(&slbCS, device->getHardwareInfo(), 0u, 0, device->getSharedDeviceInfo().maxFrontEndThreads, - aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable, + EngineGroupType::RenderCompute, AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable); } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp index c26a121a77..95331ea24e 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp @@ -270,7 +270,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskGmockTests, givenPatch bool stateBaseAddressDirty; bool vfeStateDirty; - MockOsContext osContext(0, 8, EngineTypeUsage{aub_stream::ENGINE_BCS, EngineUsage::Regular}, PreemptionMode::Disabled, false); + MockOsContext osContext(0, 8, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false); mockCsr->setupContext(osContext); mockCsr->getScratchSpaceController()->setRequiredScratchSpace(nullptr, 0u, 10u, 0u, 1u, *pDevice->getDefaultEngine().osContext, stateBaseAddressDirty, vfeStateDirty); @@ -291,7 +291,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskGmockTests, givenPatch bool stateBaseAddressDirty; bool vfeStateDirty; - MockOsContext osContext(0, 8, EngineTypeUsage{aub_stream::ENGINE_BCS, EngineUsage::Regular}, PreemptionMode::Disabled, false); + MockOsContext osContext(0, 8, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false); mockCsr->setupContext(osContext); mockCsr->getScratchSpaceController()->setRequiredScratchSpace(nullptr, 0u, 10u, 0u, 1u, *pDevice->getDefaultEngine().osContext, stateBaseAddressDirty, vfeStateDirty); @@ -314,7 +314,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskGmockTests, givenPatch DispatchFlags flags = DispatchFlagsHelper::createDefaultDispatchFlags(); mockCsr->requiredScratchSize = 0x200000; - MockOsContext osContext(0, 8, EngineTypeUsage{aub_stream::ENGINE_BCS, EngineUsage::Regular}, PreemptionMode::Disabled, false); + MockOsContext osContext(0, 8, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false); mockCsr->setupContext(osContext); mockCsr->programVFEState(commandStream, flags, 10); diff --git a/opencl/test/unit_test/helpers/timestamp_packet_tests.cpp b/opencl/test/unit_test/helpers/timestamp_packet_tests.cpp index cd69ed5805..a25cde9072 100644 --- a/opencl/test/unit_test/helpers/timestamp_packet_tests.cpp +++ b/opencl/test/unit_test/helpers/timestamp_packet_tests.cpp @@ -920,8 +920,8 @@ HWTEST_F(TimestampPacketTests, givenMultipleDevicesOnCsrWhenIncrementingCpuDepen UltClDeviceFactory factory{2, 4}; - auto osContext0 = std::unique_ptr(OsContext::create(nullptr, 0, osContext0DeviceBitfiled, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false)); - auto osContext1 = std::unique_ptr(OsContext::create(nullptr, 1, osContext1DeviceBitfiled, EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::Disabled, false)); + auto osContext0 = std::unique_ptr(OsContext::create(nullptr, 0, osContext0DeviceBitfiled, EngineTypeUsage{getChosenEngineType(*defaultHwInfo), EngineUsage::Regular}, PreemptionMode::Disabled, false)); + auto osContext1 = std::unique_ptr(OsContext::create(nullptr, 1, osContext1DeviceBitfiled, EngineTypeUsage{getChosenEngineType(*defaultHwInfo), EngineUsage::Regular}, PreemptionMode::Disabled, false)); EXPECT_EQ(2u, osContext0->getNumSupportedDevices()); EXPECT_EQ(3u, osContext1->getNumSupportedDevices()); diff --git a/shared/source/command_stream/CMakeLists.txt b/shared/source/command_stream/CMakeLists.txt index 347132379c..e7389a9d6e 100644 --- a/shared/source/command_stream/CMakeLists.txt +++ b/shared/source/command_stream/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2020 Intel Corporation +# Copyright (C) 2019-2021 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -17,16 +17,17 @@ set(NEO_CORE_COMMAND_STREAM ${CMAKE_CURRENT_SOURCE_DIR}/csr_deps.cpp ${CMAKE_CURRENT_SOURCE_DIR}/csr_deps.h ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/command_stream_receiver_hw_ext.inl + ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/csr_properties_flags.h ${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream.h ${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.h ${CMAKE_CURRENT_SOURCE_DIR}/experimental_command_buffer.inl ${CMAKE_CURRENT_SOURCE_DIR}/linear_stream.cpp ${CMAKE_CURRENT_SOURCE_DIR}/linear_stream.h - ${CMAKE_CURRENT_SOURCE_DIR}/preemption_mode.h ${CMAKE_CURRENT_SOURCE_DIR}/preemption.cpp ${CMAKE_CURRENT_SOURCE_DIR}/preemption.h ${CMAKE_CURRENT_SOURCE_DIR}/preemption.inl + ${CMAKE_CURRENT_SOURCE_DIR}/preemption_mode.h ${CMAKE_CURRENT_SOURCE_DIR}/scratch_space_controller.cpp ${CMAKE_CURRENT_SOURCE_DIR}/scratch_space_controller.h ${CMAKE_CURRENT_SOURCE_DIR}/scratch_space_controller_base.cpp @@ -34,7 +35,6 @@ set(NEO_CORE_COMMAND_STREAM ${CMAKE_CURRENT_SOURCE_DIR}/submissions_aggregator.cpp ${CMAKE_CURRENT_SOURCE_DIR}/submissions_aggregator.h ${CMAKE_CURRENT_SOURCE_DIR}/thread_arbitration_policy.h - ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/csr_properties_flags.h ) set_property(GLOBAL PROPERTY NEO_CORE_COMMAND_STREAM ${NEO_CORE_COMMAND_STREAM}) 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 66eb5d2d8a..c06132e02b 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -919,7 +919,14 @@ inline void CommandStreamReceiverHw::programVFEState(LinearStream &cs if (dispatchFlags.kernelExecutionType != KernelExecutionType::NotApplicable) { lastKernelExecutionType = dispatchFlags.kernelExecutionType; } - auto commandOffset = PreambleHelper::programVFEState(&csr, peekHwInfo(), requiredScratchSize, getScratchPatchAddress(), maxFrontEndThreads, getOsContext().getEngineType(), lastAdditionalKernelExecInfo, lastKernelExecutionType); + auto &hwInfo = peekHwInfo(); + auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily); + auto engineGroupType = hwHelper.getEngineGroupType(getOsContext().getEngineType(), hwInfo); + auto pVfeState = PreambleHelper::programVFEState( + &csr, hwInfo, requiredScratchSize, getScratchPatchAddress(), + maxFrontEndThreads, engineGroupType, lastAdditionalKernelExecInfo, lastKernelExecutionType); + auto commandOffset = PreambleHelper::getScratchSpaceAddressOffsetForVfeState(&csr, pVfeState); + if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) { flatBatchBufferHelper->collectScratchSpacePatchInfo(getScratchPatchAddress(), commandOffset, csr); } diff --git a/shared/source/gen11/preamble_gen11.cpp b/shared/source/gen11/preamble_gen11.cpp index ce2af53a7a..915c71f7b4 100644 --- a/shared/source/gen11/preamble_gen11.cpp +++ b/shared/source/gen11/preamble_gen11.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2020 Intel Corporation + * Copyright (C) 2018-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -50,7 +50,7 @@ void PreambleHelper::programPipelineSelect(LinearStream *pCommandStre } template <> -void PreambleHelper::addPipeControlBeforeVfeCmd(LinearStream *pCommandStream, const HardwareInfo *hwInfo, aub_stream::EngineType engineType) { +void PreambleHelper::addPipeControlBeforeVfeCmd(LinearStream *pCommandStream, const HardwareInfo *hwInfo, EngineGroupType engineGroupType) { auto pipeControl = pCommandStream->getSpaceForCmd(); PIPE_CONTROL cmd = ICLFamily::cmdInitPipeControl; cmd.setCommandStreamerStallEnable(true); diff --git a/shared/source/gen12lp/preamble_gen12lp.cpp b/shared/source/gen12lp/preamble_gen12lp.cpp index 292fe47089..c613df49c8 100644 --- a/shared/source/gen12lp/preamble_gen12lp.cpp +++ b/shared/source/gen12lp/preamble_gen12lp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -58,12 +58,12 @@ void PreambleHelper::programPipelineSelect(LinearStream *pCommandSt } template <> -void PreambleHelper::addPipeControlBeforeVfeCmd(LinearStream *pCommandStream, const HardwareInfo *hwInfo, aub_stream::EngineType engineType) { +void PreambleHelper::addPipeControlBeforeVfeCmd(LinearStream *pCommandStream, const HardwareInfo *hwInfo, EngineGroupType engineGroupType) { auto pipeControl = pCommandStream->getSpaceForCmd(); PIPE_CONTROL cmd = TGLLPFamily::cmdInitPipeControl; cmd.setCommandStreamerStallEnable(true); if (hwInfo->workaroundTable.waSendMIFLUSHBeforeVFE) { - if (!EngineHelpers::isCcs(engineType)) { + if (engineGroupType != EngineGroupType::Compute) { cmd.setRenderTargetCacheFlushEnable(true); cmd.setDepthCacheFlushEnable(true); cmd.setDepthStallEnable(true); diff --git a/shared/source/gen8/preamble_gen8.cpp b/shared/source/gen8/preamble_gen8.cpp index 42f2afcf41..13236facc8 100644 --- a/shared/source/gen8/preamble_gen8.cpp +++ b/shared/source/gen8/preamble_gen8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2020 Intel Corporation + * Copyright (C) 2018-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -10,7 +10,7 @@ namespace NEO { template <> -void PreambleHelper::addPipeControlBeforeVfeCmd(LinearStream *pCommandStream, const HardwareInfo *hwInfo, aub_stream::EngineType engineType) { +void PreambleHelper::addPipeControlBeforeVfeCmd(LinearStream *pCommandStream, const HardwareInfo *hwInfo, EngineGroupType engineGroupType) { auto pipeControl = pCommandStream->getSpaceForCmd(); PIPE_CONTROL cmd = BDWFamily::cmdInitPipeControl; cmd.setCommandStreamerStallEnable(true); diff --git a/shared/source/gen9/preamble_gen9.cpp b/shared/source/gen9/preamble_gen9.cpp index fa4a7d55ce..0a1da69381 100644 --- a/shared/source/gen9/preamble_gen9.cpp +++ b/shared/source/gen9/preamble_gen9.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2020 Intel Corporation + * Copyright (C) 2017-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -51,7 +51,7 @@ void PreambleHelper::programPipelineSelect(LinearStream *pCommandStre } template <> -void PreambleHelper::addPipeControlBeforeVfeCmd(LinearStream *pCommandStream, const HardwareInfo *hwInfo, aub_stream::EngineType engineType) { +void PreambleHelper::addPipeControlBeforeVfeCmd(LinearStream *pCommandStream, const HardwareInfo *hwInfo, EngineGroupType engineGroupType) { auto pipeControl = pCommandStream->getSpaceForCmd(); PIPE_CONTROL cmd = SKLFamily::cmdInitPipeControl; cmd.setCommandStreamerStallEnable(true); diff --git a/shared/source/helpers/preamble.h b/shared/source/helpers/preamble.h index 277eca1e19..fa6d4705e5 100644 --- a/shared/source/helpers/preamble.h +++ b/shared/source/helpers/preamble.h @@ -10,6 +10,7 @@ #include "opencl/source/kernel/kernel_execution_type.h" +#include "engine_group_types.h" #include "engine_node.h" #include "igfxfmid.h" @@ -37,16 +38,17 @@ struct PreambleHelper { const HardwareInfo &hwInfo); static void programThreadArbitration(LinearStream *pCommandStream, uint32_t requiredThreadArbitrationPolicy); static void programPreemption(LinearStream *pCommandStream, Device &device, GraphicsAllocation *preemptionCsr); - static void addPipeControlBeforeVfeCmd(LinearStream *pCommandStream, const HardwareInfo *hwInfo, aub_stream::EngineType engineType); + static void addPipeControlBeforeVfeCmd(LinearStream *pCommandStream, const HardwareInfo *hwInfo, EngineGroupType engineGroupType); static void appendProgramVFEState(const HardwareInfo &hwInfo, KernelExecutionType kernelExecutionType, uint32_t additionalKernelExecInfo, void *cmd); - static uint64_t programVFEState(LinearStream *pCommandStream, - const HardwareInfo &hwInfo, - uint32_t scratchSize, - uint64_t scratchAddress, - uint32_t maxFrontEndThreads, - aub_stream::EngineType engineType, - uint32_t additionalKernelExecInfo, - KernelExecutionType kernelExecutionType); + static void *programVFEState(LinearStream *pCommandStream, + const HardwareInfo &hwInfo, + uint32_t scratchSize, + uint64_t scratchAddress, + uint32_t maxFrontEndThreads, + EngineGroupType engineGroupType, + uint32_t additionalKernelExecInfo, + KernelExecutionType kernelExecutionType); + static uint64_t getScratchSpaceAddressOffsetForVfeState(LinearStream *pCommandStream, void *pVfeState); static void programAdditionalFieldsInVfeState(VFE_STATE_TYPE *mediaVfeState, const HardwareInfo &hwInfo); static void programPreamble(LinearStream *pCommandStream, Device &device, uint32_t l3Config, uint32_t requiredThreadArbitrationPolicy, GraphicsAllocation *preemptionCsr); diff --git a/shared/source/helpers/preamble_bdw_plus.inl b/shared/source/helpers/preamble_bdw_plus.inl index 3e942d4afd..2566941d8a 100644 --- a/shared/source/helpers/preamble_bdw_plus.inl +++ b/shared/source/helpers/preamble_bdw_plus.inl @@ -27,19 +27,18 @@ uint32_t PreambleHelper::getUrbEntryAllocationSize() { } template -uint64_t PreambleHelper::programVFEState(LinearStream *pCommandStream, - const HardwareInfo &hwInfo, - uint32_t scratchSize, - uint64_t scratchAddress, - uint32_t maxFrontEndThreads, - aub_stream::EngineType engineType, - uint32_t additionalExecInfo, - KernelExecutionType kernelExecutionType) { +void *PreambleHelper::programVFEState(LinearStream *pCommandStream, + const HardwareInfo &hwInfo, + uint32_t scratchSize, + uint64_t scratchAddress, + uint32_t maxFrontEndThreads, + EngineGroupType engineGroupType, + uint32_t additionalExecInfo, + KernelExecutionType kernelExecutionType) { using MEDIA_VFE_STATE = typename GfxFamily::MEDIA_VFE_STATE; - addPipeControlBeforeVfeCmd(pCommandStream, &hwInfo, engineType); + addPipeControlBeforeVfeCmd(pCommandStream, &hwInfo, engineGroupType); - auto scratchSpaceAddressOffset = static_cast(pCommandStream->getUsed() + MEDIA_VFE_STATE::PATCH_CONSTANTS::SCRATCHSPACEBASEPOINTER_BYTEOFFSET); auto pMediaVfeState = pCommandStream->getSpaceForCmd(); MEDIA_VFE_STATE cmd = GfxFamily::cmdInitMediaVfeState; cmd.setMaximumNumberOfThreads(maxFrontEndThreads); @@ -56,7 +55,15 @@ uint64_t PreambleHelper::programVFEState(LinearStream *pCommandStream appendProgramVFEState(hwInfo, kernelExecutionType, additionalExecInfo, &cmd); *pMediaVfeState = cmd; - return scratchSpaceAddressOffset; + return pMediaVfeState; +} + +template +uint64_t PreambleHelper::getScratchSpaceAddressOffsetForVfeState(LinearStream *pCommandStream, void *pVfeState) { + using MEDIA_VFE_STATE = typename GfxFamily::MEDIA_VFE_STATE; + return static_cast(reinterpret_cast(pVfeState) - + reinterpret_cast(pCommandStream->getCpuBase()) + + MEDIA_VFE_STATE::PATCH_CONSTANTS::SCRATCHSPACEBASEPOINTER_BYTEOFFSET); } template diff --git a/shared/test/common/gen11/test_preamble_gen11.cpp b/shared/test/common/gen11/test_preamble_gen11.cpp index 8691eb9f9b..014ac35947 100644 --- a/shared/test/common/gen11/test_preamble_gen11.cpp +++ b/shared/test/common/gen11/test_preamble_gen11.cpp @@ -59,7 +59,7 @@ GEN11TEST_F(Gen11PreambleVfeState, GivenWaOffWhenProgrammingVfeStateThenProgramm testWaTable->waSendMIFLUSHBeforeVFE = 0; LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 168u, - aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable, + EngineGroupType::RenderCompute, AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable); parseCommands(cs); @@ -79,7 +79,7 @@ GEN11TEST_F(Gen11PreambleVfeState, GivenWaOnWhenProgrammingVfeStateThenProgrammi testWaTable->waSendMIFLUSHBeforeVFE = 1; LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 168u, - aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable, + EngineGroupType::RenderCompute, AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable); parseCommands(cs); diff --git a/shared/test/common/gen12lp/test_preamble_gen12lp.cpp b/shared/test/common/gen12lp/test_preamble_gen12lp.cpp index 25202792a2..5f0e4f6b42 100644 --- a/shared/test/common/gen12lp/test_preamble_gen12lp.cpp +++ b/shared/test/common/gen12lp/test_preamble_gen12lp.cpp @@ -63,7 +63,7 @@ HWTEST2_F(Gen12LpPreambleVfeState, GivenWaOffWhenProgrammingVfeStateThenProgramm testWaTable->waSendMIFLUSHBeforeVFE = 0; LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 672u, - aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable, + EngineGroupType::RenderCompute, AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable); parseCommands(cs); @@ -85,7 +85,7 @@ HWTEST2_F(Gen12LpPreambleVfeState, givenCcsEngineWhenWaIsSetThenAppropriatePipeC LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 672u, - aub_stream::EngineType::ENGINE_CCS, AdditionalKernelExecInfo::NotApplicable, + EngineGroupType::Compute, AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable); parseCommands(cs); @@ -106,7 +106,7 @@ HWTEST2_F(Gen12LpPreambleVfeState, givenRcsEngineWhenWaIsSetThenAppropriatePipeC LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 672u, - aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable, + EngineGroupType::RenderCompute, AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable); parseCommands(cs); diff --git a/shared/test/common/gen8/test_preamble_gen8.cpp b/shared/test/common/gen8/test_preamble_gen8.cpp index 35ffb223e4..7cfe8230a2 100644 --- a/shared/test/common/gen8/test_preamble_gen8.cpp +++ b/shared/test/common/gen8/test_preamble_gen8.cpp @@ -95,7 +95,7 @@ BDWTEST_F(PreambleVfeState, WhenProgrammingVfeStateThenProgrammingIsCorrect) { typedef BDWFamily::PIPE_CONTROL PIPE_CONTROL; LinearStream &cs = linearStream; - PreambleHelper::programVFEState(&linearStream, *defaultHwInfo, 0u, 0, 168u, aub_stream::EngineType::ENGINE_RCS, + PreambleHelper::programVFEState(&linearStream, *defaultHwInfo, 0u, 0, 168u, EngineGroupType::RenderCompute, AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable); parseCommands(cs); diff --git a/shared/test/common/gen9/skl/test_preamble_skl.cpp b/shared/test/common/gen9/skl/test_preamble_skl.cpp index 4fc784e907..397cdc0f99 100644 --- a/shared/test/common/gen9/skl/test_preamble_skl.cpp +++ b/shared/test/common/gen9/skl/test_preamble_skl.cpp @@ -108,7 +108,7 @@ GEN9TEST_F(PreambleVfeState, GivenWaOffWhenProgrammingVfeStateThenProgrammingIsC testWaTable->waSendMIFLUSHBeforeVFE = 0; LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 168u, - aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable, + EngineGroupType::RenderCompute, AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable); parseCommands(cs); @@ -128,7 +128,7 @@ GEN9TEST_F(PreambleVfeState, GivenWaOnWhenProgrammingVfeStateThenProgrammingIsCo testWaTable->waSendMIFLUSHBeforeVFE = 1; LinearStream &cs = linearStream; PreambleHelper::programVFEState(&linearStream, pPlatform->getClDevice(0)->getHardwareInfo(), 0u, 0, 168u, - aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable, + EngineGroupType::RenderCompute, AdditionalKernelExecInfo::NotApplicable, KernelExecutionType::NotApplicable); parseCommands(cs); diff --git a/shared/test/unit_test/preamble/CMakeLists.txt b/shared/test/unit_test/preamble/CMakeLists.txt index dd80805c8c..88b8951bad 100644 --- a/shared/test/unit_test/preamble/CMakeLists.txt +++ b/shared/test/unit_test/preamble/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2020 Intel Corporation +# Copyright (C) 2019-2021 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -10,3 +10,4 @@ set(NEO_CORE_PREAMBLE_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/preamble_tests.cpp ) set_property(GLOBAL PROPERTY NEO_CORE_PREAMBLE_TESTS ${NEO_CORE_PREAMBLE_TESTS}) +add_subdirectories() diff --git a/shared/test/unit_test/preamble/preamble_tests.cpp b/shared/test/unit_test/preamble/preamble_tests.cpp index 33786401f0..bbdcee21d4 100644 --- a/shared/test/unit_test/preamble/preamble_tests.cpp +++ b/shared/test/unit_test/preamble/preamble_tests.cpp @@ -214,7 +214,31 @@ HWTEST_F(PreambleTest, givenMinHwThreadsUnoccupiedDebugVariableWhenGetThreadsMax EXPECT_EQ(expected, value); } -HWCMDTEST_F(IGFX_GEN8_CORE, PreambleTest, givenPreambleHelperWhenMediaVfeStateIsProgrammedThenOffsetToCommandIsReturned) { +HWCMDTEST_F(IGFX_GEN8_CORE, PreambleTest, WhenProgramVFEStateIsCalledThenCorrectVfeStateAddressIsReturned) { + using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE; + + char buffer[64]; + MockGraphicsAllocation graphicsAllocation(buffer, sizeof(buffer)); + LinearStream preambleStream(&graphicsAllocation, graphicsAllocation.getUnderlyingBuffer(), graphicsAllocation.getUnderlyingBufferSize()); + uint64_t addressToPatch = 0xC0DEC0DE; + uint64_t expectedAddress = 0xC0DEC000; + + auto pVfeCmd = PreambleHelper::programVFEState(&preambleStream, *defaultHwInfo, 1024u, addressToPatch, + 10u, EngineGroupType::RenderCompute, AdditionalKernelExecInfo::NotApplicable, + KernelExecutionType::NotApplicable); + EXPECT_GE(reinterpret_cast(pVfeCmd), reinterpret_cast(preambleStream.getCpuBase())); + EXPECT_LT(reinterpret_cast(pVfeCmd), reinterpret_cast(preambleStream.getCpuBase()) + preambleStream.getUsed()); + + auto &vfeCmd = *reinterpret_cast(pVfeCmd); + EXPECT_EQ(10u, vfeCmd.getMaximumNumberOfThreads()); + EXPECT_EQ(1u, vfeCmd.getNumberOfUrbEntries()); + EXPECT_EQ(expectedAddress, vfeCmd.getScratchSpaceBasePointer()); + EXPECT_EQ(0u, vfeCmd.getScratchSpaceBasePointerHigh()); +} + +HWCMDTEST_F(IGFX_GEN8_CORE, PreambleTest, WhenGetScratchSpaceAddressOffsetForVfeStateIsCalledThenCorrectOffsetIsReturned) { + using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE; + char buffer[64]; MockGraphicsAllocation graphicsAllocation(buffer, sizeof(buffer)); LinearStream preambleStream(&graphicsAllocation, graphicsAllocation.getUnderlyingBuffer(), graphicsAllocation.getUnderlyingBufferSize()); @@ -222,10 +246,14 @@ HWCMDTEST_F(IGFX_GEN8_CORE, PreambleTest, givenPreambleHelperWhenMediaVfeStateIs FlatBatchBufferHelperHw helper(*mockDevice->getExecutionEnvironment()); uint64_t addressToPatch = 0xC0DEC0DE; - auto offset = PreambleHelper::programVFEState(&preambleStream, mockDevice->getHardwareInfo(), 1024u, addressToPatch, - 10u, aub_stream::EngineType::ENGINE_RCS, AdditionalKernelExecInfo::NotApplicable, - KernelExecutionType::NotApplicable); + auto pVfeCmd = PreambleHelper::programVFEState(&preambleStream, mockDevice->getHardwareInfo(), 1024u, addressToPatch, + 10u, EngineGroupType::RenderCompute, AdditionalKernelExecInfo::NotApplicable, + KernelExecutionType::NotApplicable); + + auto offset = PreambleHelper::getScratchSpaceAddressOffsetForVfeState(&preambleStream, pVfeCmd); EXPECT_NE(0u, offset); + EXPECT_EQ(MEDIA_VFE_STATE::PATCH_CONSTANTS::SCRATCHSPACEBASEPOINTER_BYTEOFFSET + reinterpret_cast(pVfeCmd), + offset + reinterpret_cast(preambleStream.getCpuBase())); } HWTEST_F(PreambleTest, givenSetForceSemaphoreDelayBetweenWaitsWhenProgramSemaphoreDelayThenSemaWaitPollRegisterIsProgrammed) {