Debian Codegraph @

shared/test/unit_test/direct_submission/dispatchers/blitter_dispatcher_tests.cpp

raw
1 /*
2 * Copyright (C) 2020-2023 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "shared/source/direct_submission/dispatchers/blitter_dispatcher.h"
9 #include "shared/source/helpers/definitions/command_encoder_args.h"
10 #include "shared/test/common/cmd_parse/hw_parse.h"
11 #include "shared/test/common/mocks/mock_command_encoder.h"
12 #include "shared/test/common/mocks/mock_device.h"
13 #include "shared/test/common/test_macros/hw_test.h"
14 #include "shared/test/unit_test/direct_submission/dispatchers/dispatcher_fixture.h"
15
16 using namespace NEO;
17
18 using BlitterDispatcheTest = Test<DispatcherFixture>;
19
20 HWTEST_F(BlitterDispatcheTest, givenBlitterWhenAskingForPreemptionCmdSizeThenReturnZero) {
21 EXPECT_EQ(0u, BlitterDispatcher<FamilyType>::getSizePreemption());
22 }
23
24 HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingPreemptionCmdThenDispatchNothing) {
25 BlitterDispatcher<FamilyType>::dispatchPreemption(cmdBuffer);
26
27 EXPECT_EQ(0u, cmdBuffer.getUsed());
28 }
29
30 HWTEST_F(BlitterDispatcheTest, givenBlitterWhenAskingForMonitorFenceCmdSizeThenReturnExpectedNumberOfMiFlush) {
31 EncodeDummyBlitWaArgs waArgs{false, &(pDevice->getRootDeviceEnvironmentRef())};
32 size_t expectedSize = EncodeMiFlushDW<FamilyType>::getCommandSizeWithWa(waArgs);
33 EXPECT_EQ(expectedSize, BlitterDispatcher<FamilyType>::getSizeMonitorFence(pDevice->getRootDeviceEnvironment()));
34 }
35
36 HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingMonitorFenceCmdThenDispatchMiFlushWithPostSync) {
37 using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
38 EncodeDummyBlitWaArgs waArgs{false, &(pDevice->getRootDeviceEnvironmentRef())};
39
40 size_t expectedSize = EncodeMiFlushDW<FamilyType>::getCommandSizeWithWa(waArgs);
41
42 uint64_t expectedGpuAddress = 0x5100ull;
43 uint64_t expectedValue = 0x1234ull;
44 BlitterDispatcher<FamilyType>::dispatchMonitorFence(cmdBuffer, expectedGpuAddress, expectedValue, pDevice->getRootDeviceEnvironment(), false, false, false);
45
46 EXPECT_EQ(expectedSize, cmdBuffer.getUsed());
47
48 HardwareParse hwParse;
49 hwParse.parseCommands<FamilyType>(cmdBuffer);
50 auto commandsList = hwParse.getCommandsList<MI_FLUSH_DW>();
51
52 bool foundPostSync = false;
53 for (auto &cmd : commandsList) {
54 MI_FLUSH_DW *miFlush = static_cast<MI_FLUSH_DW *>(cmd);
55 if (miFlush->getDestinationAddress() == expectedGpuAddress &&
56 miFlush->getImmediateData() == expectedValue) {
57 foundPostSync = true;
58 }
59 }
60 EXPECT_TRUE(foundPostSync);
61 }
62 HWTEST_F(BlitterDispatcheTest, givenBlitterWhenAskingForCacheFlushCmdSizeThenReturnExpetedSize) {
63 EncodeDummyBlitWaArgs waArgs{false, &(pDevice->getRootDeviceEnvironmentRef())};
64 size_t expectedSize = EncodeMiFlushDW<FamilyType>::getCommandSizeWithWa(waArgs);
65 EXPECT_EQ(expectedSize, BlitterDispatcher<FamilyType>::getSizeCacheFlush(pDevice->getRootDeviceEnvironment()));
66 }
67
68 HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingCacheFlushCmdThenDispatchMiFlushCommand) {
69 using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
70 EncodeDummyBlitWaArgs waArgs{false, &(pDevice->getRootDeviceEnvironmentRef())};
71 size_t expectedSize = EncodeMiFlushDW<FamilyType>::getCommandSizeWithWa(waArgs);
72
73 BlitterDispatcher<FamilyType>::dispatchCacheFlush(cmdBuffer, pDevice->getRootDeviceEnvironment(), 0ull);
74
75 EXPECT_EQ(expectedSize, cmdBuffer.getUsed());
76
77 HardwareParse hwParse;
78 hwParse.parseCommands<FamilyType>(cmdBuffer);
79 auto commandsList = hwParse.getCommandsList<MI_FLUSH_DW>();
80 EXPECT_LE(1u, commandsList.size());
81 }
82
83 HWTEST_F(BlitterDispatcheTest, givenBlitterWhenDispatchingTlbFlushThenDispatchMiFlushCommandWithproperBits) {
84 using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
85 EncodeDummyBlitWaArgs waArgs{false, &(pDevice->getRootDeviceEnvironmentRef())};
86 size_t expectedSize = EncodeMiFlushDW<FamilyType>::getCommandSizeWithWa(waArgs);
87
88 BlitterDispatcher<FamilyType>::dispatchTlbFlush(cmdBuffer, 0ull, pDevice->getRootDeviceEnvironment());
89
90 EXPECT_EQ(expectedSize, cmdBuffer.getUsed());
91
92 HardwareParse hwParse;
93 hwParse.parseCommands<FamilyType>(cmdBuffer, MockEncodeMiFlushDW<FamilyType>::getWaSize(waArgs));
94 auto miFlushDw = hwParse.getCommand<MI_FLUSH_DW>();
95
96 EXPECT_TRUE(miFlushDw->getTlbInvalidate());
97 EXPECT_EQ(miFlushDw->getPostSyncOperation(), MI_FLUSH_DW::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA_QWORD);
98 EXPECT_EQ(BlitterDispatcher<FamilyType>::getSizeTlbFlush(pDevice->getRootDeviceEnvironment()), EncodeMiFlushDW<FamilyType>::getCommandSizeWithWa(waArgs));
99 }
100
101 HWTEST_F(BlitterDispatcheTest, givenBlitterWhenCheckingForMultiTileSynchronizationSupportThenExpectFalse) {
102 EXPECT_FALSE(BlitterDispatcher<FamilyType>::isMultiTileSynchronizationSupported());
103 }