| 1 |
/* |
| 2 |
* Copyright (C) 2021-2023 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "shared/source/command_stream/csr_definitions.h" |
| 9 |
#include "shared/source/command_stream/linear_stream.h" |
| 10 |
#include "shared/source/gen12lp/hw_cmds_adlp.h" |
| 11 |
#include "shared/source/gen12lp/hw_info_adlp.h" |
| 12 |
#include "shared/source/helpers/pipeline_select_helper.h" |
| 13 |
#include "shared/source/helpers/preamble.h" |
| 14 |
#include "shared/test/common/cmd_parse/hw_parse.h" |
| 15 |
#include "shared/test/common/helpers/dispatch_flags_helper.h" |
| 16 |
#include "shared/test/common/mocks/mock_execution_environment.h" |
| 17 |
#include "shared/test/common/test_macros/header/per_product_test_definitions.h" |
| 18 |
#include "shared/test/common/test_macros/test.h" |
| 19 |
|
| 20 |
using namespace NEO; |
| 21 |
|
| 22 |
using PreambleHelperTestsAdlp = ::testing::Test; |
| 23 |
|
| 24 |
ADLPTEST_F(PreambleHelperTestsAdlp, givenSystolicPipelineSelectModeDisabledWhenProgrammingPipelineSelectThenDisableSystolicMode) { |
| 25 |
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; |
| 26 |
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT; |
| 27 |
|
| 28 |
constexpr static auto bufferSize = sizeof(PIPE_CONTROL) + sizeof(PIPE_CONTROL); |
| 29 |
|
| 30 |
char streamBuffer[bufferSize]; |
| 31 |
LinearStream stream(streamBuffer, bufferSize); |
| 32 |
|
| 33 |
MockExecutionEnvironment mockExecutionEnvironment{}; |
| 34 |
auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; |
| 35 |
|
| 36 |
DispatchFlags flags = DispatchFlagsHelper::createDefaultDispatchFlags(); |
| 37 |
flags.pipelineSelectArgs.systolicPipelineSelectMode = false; |
| 38 |
flags.pipelineSelectArgs.systolicPipelineSelectSupport = PreambleHelper<FamilyType>::isSystolicModeConfigurable(rootDeviceEnvironment); |
| 39 |
|
| 40 |
PreambleHelper<FamilyType>::programPipelineSelect(&stream, flags.pipelineSelectArgs, rootDeviceEnvironment); |
| 41 |
HardwareParse hwParser; |
| 42 |
hwParser.parseCommands<FamilyType>(stream, 0); |
| 43 |
|
| 44 |
GenCmdList pipeControlList = hwParser.getCommandsList<PIPE_CONTROL>(); |
| 45 |
auto itorPipeControl = find<PIPE_CONTROL *>(pipeControlList.begin(), pipeControlList.end()); |
| 46 |
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPipeControl); |
| 47 |
EXPECT_TRUE(pc.getCommandStreamerStallEnable()); |
| 48 |
|
| 49 |
GenCmdList pipelineSelectList = hwParser.getCommandsList<PIPELINE_SELECT>(); |
| 50 |
auto itorPipelineSelect = find<PIPELINE_SELECT *>(pipelineSelectList.begin(), pipelineSelectList.end()); |
| 51 |
const auto &ps = *reinterpret_cast<PIPELINE_SELECT *>(*itorPipelineSelect); |
| 52 |
|
| 53 |
const auto expectedMask = pipelineSelectEnablePipelineSelectMaskBits | pipelineSelectMediaSamplerDopClockGateMaskBits | pipelineSelectSystolicModeEnableMaskBits; |
| 54 |
EXPECT_FALSE(ps.getSpecialModeEnable()); |
| 55 |
EXPECT_EQ(expectedMask, ps.getMaskBits()); |
| 56 |
EXPECT_EQ(PIPELINE_SELECT::PIPELINE_SELECTION_GPGPU, ps.getPipelineSelection()); |
| 57 |
} |
| 58 |
|
| 59 |
ADLPTEST_F(PreambleHelperTestsAdlp, givenSystolicPipelineSelectModeEnabledWhenProgrammingPipelineSelectThenEnableSystolicMode) { |
| 60 |
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; |
| 61 |
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT; |
| 62 |
|
| 63 |
constexpr static auto bufferSize = sizeof(PIPE_CONTROL) + sizeof(PIPE_CONTROL); |
| 64 |
|
| 65 |
char streamBuffer[bufferSize]; |
| 66 |
LinearStream stream(streamBuffer, bufferSize); |
| 67 |
MockExecutionEnvironment mockExecutionEnvironment{}; |
| 68 |
auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; |
| 69 |
|
| 70 |
DispatchFlags flags = DispatchFlagsHelper::createDefaultDispatchFlags(); |
| 71 |
flags.pipelineSelectArgs.systolicPipelineSelectMode = true; |
| 72 |
flags.pipelineSelectArgs.systolicPipelineSelectSupport = PreambleHelper<FamilyType>::isSystolicModeConfigurable(rootDeviceEnvironment); |
| 73 |
|
| 74 |
PreambleHelper<FamilyType>::programPipelineSelect(&stream, flags.pipelineSelectArgs, rootDeviceEnvironment); |
| 75 |
HardwareParse hwParser; |
| 76 |
hwParser.parseCommands<FamilyType>(stream, 0); |
| 77 |
|
| 78 |
GenCmdList pipeControlList = hwParser.getCommandsList<PIPE_CONTROL>(); |
| 79 |
auto itorPipeControl = find<PIPE_CONTROL *>(pipeControlList.begin(), pipeControlList.end()); |
| 80 |
const auto &pc = *reinterpret_cast<PIPE_CONTROL *>(*itorPipeControl); |
| 81 |
EXPECT_TRUE(pc.getCommandStreamerStallEnable()); |
| 82 |
|
| 83 |
GenCmdList pipelineSelectList = hwParser.getCommandsList<PIPELINE_SELECT>(); |
| 84 |
auto itorPipelineSelect = find<PIPELINE_SELECT *>(pipelineSelectList.begin(), pipelineSelectList.end()); |
| 85 |
const auto &ps = *reinterpret_cast<PIPELINE_SELECT *>(*itorPipelineSelect); |
| 86 |
|
| 87 |
const auto expectedMask = pipelineSelectEnablePipelineSelectMaskBits | pipelineSelectMediaSamplerDopClockGateMaskBits | pipelineSelectSystolicModeEnableMaskBits; |
| 88 |
EXPECT_TRUE(ps.getSpecialModeEnable()); |
| 89 |
EXPECT_EQ(expectedMask, ps.getMaskBits()); |
| 90 |
EXPECT_EQ(PIPELINE_SELECT::PIPELINE_SELECTION_GPGPU, ps.getPipelineSelection()); |
| 91 |
} |