13
13
#include " shared/test/common/helpers/unit_test_helper.h"
14
14
#include " shared/test/common/test_macros/hw_test.h"
15
15
#include " shared/test/common/test_macros/mock_method_macros.h"
16
+ #include " shared/test/common/test_macros/test.h"
16
17
17
18
#include " opencl/source/command_queue/command_queue.h"
18
19
#include " opencl/source/program/program.h"
19
20
#include " opencl/test/unit_test/fixtures/enqueue_handler_fixture.h"
20
21
#include " opencl/test/unit_test/mocks/mock_buffer.h"
21
22
#include " opencl/test/unit_test/mocks/mock_command_queue.h"
23
+ #include " opencl/test/unit_test/mocks/mock_debug_program.h"
22
24
#include " opencl/test/unit_test/mocks/mock_kernel.h"
23
25
#include " opencl/test/unit_test/program/program_from_binary.h"
24
26
25
27
using namespace NEO ;
26
- using namespace ::testing;
27
28
28
29
typedef EnqueueHandlerTest EnqueueDebugKernelSimpleTest;
29
30
30
- class EnqueueDebugKernelTest : public ProgramSimpleFixture ,
31
- public ::testing::Test {
31
+ class EnqueueDebugKernelFixture {
32
32
public:
33
- void SetUp () override {
34
- ProgramSimpleFixture::setUp ();
35
- device = pClDevice;
36
- pDevice->executionEnvironment ->rootDeviceEnvironments [pDevice->getRootDeviceIndex ()]->debugger .reset (new SourceLevelDebugger (nullptr ));
37
-
38
- auto sipType = SipKernel::getSipKernelType (*pDevice);
39
- SipKernel::initSipKernel (sipType, *pDevice);
40
-
41
- if (pDevice->getHardwareInfo ().platform .eRenderCoreFamily >= IGFX_GEN9_CORE) {
42
- pDevice->deviceInfo .debuggerActive = true ;
43
- std::string filename;
44
- std::string kernelOption (CompilerOptions::debugKernelEnable);
45
- KernelFilenameHelper::getKernelFilenameFromInternalOption (kernelOption, filename);
46
-
47
- kbHelper = new KernelBinaryHelper (filename, false );
48
- createProgramWithSource (
49
- pContext,
50
- " copybuffer.cl" );
51
- pProgram->enableKernelDebug ();
52
-
53
- cl_int retVal = pProgram->build (pProgram->getDevices (), nullptr , false );
33
+ void setUp () {
34
+ clDevice = context.getDevice (0 );
35
+ device = &clDevice->getDevice ();
36
+
37
+ device->getExecutionEnvironment ()->rootDeviceEnvironments [device->getRootDeviceIndex ()]->debugger .reset (new SourceLevelDebugger (nullptr ));
38
+
39
+ auto sipType = SipKernel::getSipKernelType (*device);
40
+ SipKernel::initSipKernel (sipType, *device);
41
+
42
+ if (device->getHardwareInfo ().platform .eRenderCoreFamily >= IGFX_GEN9_CORE) {
43
+ const_cast <DeviceInfo &>(device->getDeviceInfo ()).debuggerActive = true ;
44
+
45
+ program = std::make_unique<MockDebugProgram>(context.getDevices ());
46
+ cl_int retVal = program->build (program->getDevices (), nullptr , false );
54
47
ASSERT_EQ (CL_SUCCESS, retVal);
55
48
56
- // create a kernel
57
- pMultiDeviceKernel = MultiDeviceKernel::create (
58
- pProgram,
59
- pProgram->getKernelInfosForKernel (" CopyBuffer" ),
49
+ multiDeviceKernel = MultiDeviceKernel::create (
50
+ static_cast <NEO::Program *>(program.get ()),
51
+ MockKernel::toKernelInfoContainer (*program->getKernelInfo (" kernel" , 0 ), device->getRootDeviceIndex ()),
60
52
&retVal);
61
- debugKernel = pMultiDeviceKernel ->getKernel (rootDeviceIndex );
53
+ debugKernel = multiDeviceKernel ->getKernel (device-> getRootDeviceIndex () );
62
54
63
55
ASSERT_EQ (CL_SUCCESS, retVal);
64
56
ASSERT_NE (nullptr , debugKernel);
65
-
66
- cl_mem src = &bufferSrc;
67
- cl_mem dst = &bufferDst;
68
- retVal = debugKernel->setArg (
69
- 0 ,
70
- sizeof (cl_mem),
71
- &src);
72
- retVal = debugKernel->setArg (
73
- 1 ,
74
- sizeof (cl_mem),
75
- &dst);
76
57
}
77
58
}
78
59
79
- void TearDown () override {
80
- if (pDevice->getHardwareInfo ().platform .eRenderCoreFamily >= IGFX_GEN9_CORE) {
81
- delete kbHelper;
82
- pMultiDeviceKernel->release ();
60
+ void tearDown () {
61
+ if (multiDeviceKernel != nullptr ) {
62
+ multiDeviceKernel->release ();
83
63
}
84
- ProgramSimpleFixture::tearDown ();
85
64
}
86
- cl_device_id device;
65
+
66
+ std::unique_ptr<char []> ssh = nullptr ;
67
+ std::unique_ptr<MockDebugProgram> program = nullptr ;
68
+ NEO::ClDevice *clDevice = nullptr ;
69
+ NEO::Device *device = nullptr ;
87
70
Kernel *debugKernel = nullptr ;
88
- MultiDeviceKernel *pMultiDeviceKernel = nullptr ;
89
- KernelBinaryHelper *kbHelper = nullptr ;
71
+ MultiDeviceKernel *multiDeviceKernel = nullptr ;
90
72
MockContext context;
91
73
MockBuffer bufferSrc;
92
74
MockBuffer bufferDst;
93
75
};
94
76
77
+ using EnqueueDebugKernelTest = Test<EnqueueDebugKernelFixture>;
78
+
95
79
HWTEST_F (EnqueueDebugKernelTest, givenDebugKernelWhenEnqueuedThenSSHAndBtiAreCorrectlySet) {
96
- if (pDevice ->isDebuggerActive ()) {
80
+ if (device ->isDebuggerActive ()) {
97
81
using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE;
98
82
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
99
- std::unique_ptr<MockCommandQueueHw<FamilyType>> mockCmdQ (new MockCommandQueueHw<FamilyType>(&context, pClDevice , 0 ));
83
+ std::unique_ptr<MockCommandQueueHw<FamilyType>> mockCmdQ (new MockCommandQueueHw<FamilyType>(&context, clDevice , 0 ));
100
84
101
85
size_t gws[] = {1 , 1 , 1 };
102
86
auto &ssh = mockCmdQ->getIndirectHeap (IndirectHeap::Type::SURFACE_STATE, 4096u );
@@ -118,10 +102,10 @@ HWTEST_F(EnqueueDebugKernelTest, givenDebugKernelWhenEnqueuedThenSSHAndBtiAreCor
118
102
}
119
103
120
104
HWTEST_F (EnqueueDebugKernelTest, givenDebugKernelWhenEnqueuedThenSurfaceStateForDebugSurfaceIsSetAtBindlessOffsetZero) {
121
- if (pDevice ->isDebuggerActive ()) {
105
+ if (device ->isDebuggerActive ()) {
122
106
using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE;
123
107
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
124
- std::unique_ptr<MockCommandQueueHw<FamilyType>> mockCmdQ (new MockCommandQueueHw<FamilyType>(&context, pClDevice , 0 ));
108
+ std::unique_ptr<MockCommandQueueHw<FamilyType>> mockCmdQ (new MockCommandQueueHw<FamilyType>(&context, clDevice , 0 ));
125
109
126
110
size_t gws[] = {1 , 1 , 1 };
127
111
auto &ssh = mockCmdQ->getIndirectHeap (IndirectHeap::Type::SURFACE_STATE, 4096u );
@@ -219,9 +203,9 @@ HWTEST_F(EnqueueDebugKernelSimpleTest, givenKernelFromProgramWithoutDebugEnabled
219
203
using ActiveDebuggerTest = EnqueueDebugKernelTest;
220
204
221
205
HWTEST_F (ActiveDebuggerTest, givenKernelFromProgramWithoutDebugEnabledAndActiveDebuggerWhenEnqueuedThenDebugSurfaceIsSetup) {
222
- MockProgram program (&context, false , toClDeviceVector (*pClDevice ));
223
- std::unique_ptr<MockDebugKernel> kernel (MockKernel::create<MockDebugKernel>(*pDevice , &program));
224
- std::unique_ptr<CommandQueueHw<FamilyType>> cmdQ (new CommandQueueHw<FamilyType>(&context, pClDevice , nullptr , false ));
206
+ MockProgram program (&context, false , toClDeviceVector (*clDevice ));
207
+ std::unique_ptr<MockDebugKernel> kernel (MockKernel::create<MockDebugKernel>(*device , &program));
208
+ std::unique_ptr<CommandQueueHw<FamilyType>> cmdQ (new CommandQueueHw<FamilyType>(&context, clDevice , nullptr , false ));
225
209
226
210
size_t gws[] = {1 , 1 , 1 };
227
211
cmdQ->enqueueKernel (kernel.get (), 1 , nullptr , gws, nullptr , 0 , nullptr , nullptr );
0 commit comments