1 /*
2 * Copyright (C) 2021 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "shared/source/helpers/engine_control.h"
9 #include "shared/test/common/helpers/debug_manager_state_restore.h"
10 #include "shared/test/common/helpers/engine_descriptor_helper.h"
11 #include "shared/test/common/mocks/mock_os_context.h"
12 #include "shared/test/common/mocks/mock_tbx_csr.h"
13 #include "shared/test/common/test_macros/test.h"
14
15 #include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
16 #include "opencl/test/unit_test/mocks/mock_command_queue.h"
17 #include "opencl/test/unit_test/mocks/mock_context.h"
18
19 using namespace NEO;
20
21 using ClTbxCommandStreamTests = Test<ClDeviceFixture>;
HWTEST_F(ClTbxCommandStreamTests,givenTbxCsrWhenDispatchBlitEnqueueThenProcessCorrectly)22 HWTEST_F(ClTbxCommandStreamTests, givenTbxCsrWhenDispatchBlitEnqueueThenProcessCorrectly) {
23 DebugManagerStateRestore dbgRestore;
24 DebugManager.flags.EnableBlitterOperationsSupport.set(1);
25 DebugManager.flags.EnableBlitterForEnqueueOperations.set(1);
26
27 MockContext context(pClDevice);
28
29 MockTbxCsr<FamilyType> tbxCsr0{*pDevice->executionEnvironment, pDevice->getDeviceBitfield()};
30 tbxCsr0.initializeTagAllocation();
31 MockTbxCsr<FamilyType> tbxCsr1{*pDevice->executionEnvironment, pDevice->getDeviceBitfield()};
32 tbxCsr1.initializeTagAllocation();
33
34 MockOsContext osContext0(0, EngineDescriptorHelper::getDefaultDescriptor(pDevice->getDeviceBitfield()));
35 tbxCsr0.setupContext(osContext0);
36 EngineControl engineControl0{&tbxCsr0, &osContext0};
37
38 MockOsContext osContext1(1, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::Regular}, pDevice->getDeviceBitfield()));
39 tbxCsr1.setupContext(osContext0);
40 EngineControl engineControl1{&tbxCsr1, &osContext1};
41
42 MockCommandQueueHw<FamilyType> cmdQ(&context, pClDevice, nullptr);
43 cmdQ.gpgpuEngine = &engineControl0;
44 cmdQ.clearBcsEngines();
45 cmdQ.bcsEngines[0] = &engineControl1;
46
47 cl_int error = CL_SUCCESS;
48 std::unique_ptr<Buffer> buffer(Buffer::create(&context, 0, 1, nullptr, error));
49
50 uint32_t hostPtr = 0;
51 error = cmdQ.enqueueWriteBuffer(buffer.get(), CL_TRUE, 0, 1, &hostPtr, nullptr, 0, nullptr, nullptr);
52 EXPECT_EQ(CL_SUCCESS, error);
53 }
54