File: submit_blocked_parent_kernel_tests.cpp

package info (click to toggle)
intel-compute-runtime 20.44.18297-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 34,780 kB
  • sloc: cpp: 379,729; lisp: 4,931; python: 299; sh: 196; makefile: 8
file content (437 lines) | stat: -rw-r--r-- 21,380 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
/*
 * Copyright (C) 2017-2020 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "shared/source/utilities/tag_allocator.h"

#include "opencl/source/command_queue/gpgpu_walker.h"
#include "opencl/source/command_queue/hardware_interface.h"
#include "opencl/source/event/hw_timestamps.h"
#include "opencl/source/helpers/hardware_commands_helper.h"
#include "opencl/source/helpers/task_information.h"
#include "opencl/test/unit_test/fixtures/execution_model_fixture.h"
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
#include "opencl/test/unit_test/mocks/mock_device_queue.h"
#include "opencl/test/unit_test/test_macros/test_checks_ocl.h"

#include <memory>

using namespace NEO;

class SubmitBlockedParentKernelFixture : public ExecutionModelSchedulerTest,
                                         public testing::Test {
    void SetUp() override {
        ExecutionModelSchedulerTest::SetUp();
    }

    void TearDown() override {
        ExecutionModelSchedulerTest::TearDown();
    }
};

template <typename GfxFamily>
class MockDeviceQueueHwWithCriticalSectionRelease : public DeviceQueueHw<GfxFamily> {
    using BaseClass = DeviceQueueHw<GfxFamily>;

  public:
    MockDeviceQueueHwWithCriticalSectionRelease(Context *context,
                                                ClDevice *device,
                                                cl_queue_properties &properties) : BaseClass(context, device, properties) {}

    bool isEMCriticalSectionFree() override {
        auto igilCmdQueue = reinterpret_cast<IGIL_CommandQueue *>(DeviceQueue::queueBuffer->getUnderlyingBuffer());

        criticalSectioncheckCounter++;

        if (criticalSectioncheckCounter == maxCounter) {
            igilCmdQueue->m_controls.m_CriticalSection = DeviceQueueHw<GfxFamily>::ExecutionModelCriticalSection::Free;
            return true;
        }

        return igilCmdQueue->m_controls.m_CriticalSection == DeviceQueueHw<GfxFamily>::ExecutionModelCriticalSection::Free;
    }

    void setupIndirectState(IndirectHeap &surfaceStateHeap, IndirectHeap &dynamicStateHeap, Kernel *parentKernel, uint32_t parentIDCount, bool isCcsUsed) override {
        indirectStateSetup = true;
        return BaseClass::setupIndirectState(surfaceStateHeap, dynamicStateHeap, parentKernel, parentIDCount, isCcsUsed);
    }
    void addExecutionModelCleanUpSection(Kernel *parentKernel, TagNode<HwTimeStamps> *hwTimeStamp, uint64_t tagAddress, uint32_t taskCount) override {
        cleanupSectionAdded = true;
        timestampAddedInCleanupSection = hwTimeStamp ? hwTimeStamp->tagForCpuAccess : nullptr;
        return BaseClass::addExecutionModelCleanUpSection(parentKernel, hwTimeStamp, tagAddress, taskCount);
    }
    void dispatchScheduler(LinearStream &commandStream, SchedulerKernel &scheduler, PreemptionMode preemptionMode, IndirectHeap *ssh, IndirectHeap *dsh, bool isCcsUsed) override {
        schedulerDispatched = true;
        return BaseClass::dispatchScheduler(commandStream, scheduler, preemptionMode, ssh, dsh, isCcsUsed);
    }

    uint32_t criticalSectioncheckCounter = 0;
    const uint32_t maxCounter = 10;
    bool indirectStateSetup = false;
    bool cleanupSectionAdded = false;
    bool schedulerDispatched = false;
    HwTimeStamps *timestampAddedInCleanupSection = nullptr;
};

HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenLockedEMcritcalSectionWhenParentKernelCommandIsSubmittedThenItWaitsForcriticalSectionReleasement) {
    REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device);

    cl_queue_properties properties[3] = {0};
    MockParentKernel *parentKernel = MockParentKernel::create(*context);
    MockDeviceQueueHwWithCriticalSectionRelease<FamilyType> mockDevQueue(context, device, properties[0]);
    parentKernel->createReflectionSurface();
    context->setDefaultDeviceQueue(&mockDevQueue);

    mockDevQueue.acquireEMCriticalSection();

    size_t heapSize = 20;
    size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();

    IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
    pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
    pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
    pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);

    dsh->getSpace(mockDevQueue.getDshOffset());

    size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);

    auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER, device->getDeviceBitfield()});
    auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
                                                                *pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
    blockedCommandData->setHeaps(dsh, ioh, ssh);

    blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
    PreemptionMode preemptionMode = device->getPreemptionMode();
    std::vector<Surface *> surfaces;
    auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);

    cmdComputeKernel->submit(0, false);

    EXPECT_EQ(mockDevQueue.maxCounter, mockDevQueue.criticalSectioncheckCounter);
    delete cmdComputeKernel;
    delete parentKernel;
}

HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenParentKernelWhenCommandIsSubmittedThenPassedDshIsUsed) {
    REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device);

    cl_queue_properties properties[3] = {0};
    MockParentKernel *parentKernel = MockParentKernel::create(*context);
    MockDeviceQueueHwWithCriticalSectionRelease<FamilyType> mockDevQueue(context, device, properties[0]);
    parentKernel->createReflectionSurface();
    context->setDefaultDeviceQueue(&mockDevQueue);

    auto *dshOfDevQueue = mockDevQueue.getIndirectHeap(IndirectHeap::DYNAMIC_STATE);

    size_t heapSize = 20;
    size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();

    IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
    pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
    pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
    pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);

    // add initial offset of colorCalState
    dsh->getSpace(DeviceQueue::colorCalcStateSize);

    uint64_t ValueToFillDsh = 5;
    uint64_t *dshVal = (uint64_t *)dsh->getSpace(sizeof(uint64_t));

    // Fill Interface Descriptor Data
    *dshVal = ValueToFillDsh;

    // Move to parent DSH Offset
    size_t alignToOffsetDshSize = mockDevQueue.getDshOffset() - DeviceQueue::colorCalcStateSize - sizeof(uint64_t);
    dsh->getSpace(alignToOffsetDshSize);

    // Fill with pattern
    dshVal = (uint64_t *)dsh->getSpace(sizeof(uint64_t));
    *dshVal = ValueToFillDsh;

    size_t usedDSHBeforeSubmit = dshOfDevQueue->getUsed();

    uint32_t colorCalcSizeDevQueue = DeviceQueue::colorCalcStateSize;
    EXPECT_EQ(colorCalcSizeDevQueue, usedDSHBeforeSubmit);

    auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER, device->getDeviceBitfield()});
    auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
                                                                *pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
    blockedCommandData->setHeaps(dsh, ioh, ssh);

    size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);

    blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
    PreemptionMode preemptionMode = device->getPreemptionMode();
    std::vector<Surface *> surfaces;
    auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);

    cmdComputeKernel->submit(0, false);

    //device queue dsh is not changed
    size_t usedDSHAfterSubmit = dshOfDevQueue->getUsed();
    EXPECT_EQ(usedDSHAfterSubmit, usedDSHAfterSubmit);

    delete cmdComputeKernel;
    delete parentKernel;
}

HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenParentKernelWhenCommandIsSubmittedThenIndirectStateAndEMCleanupSectionIsSetup) {
    REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device);

    cl_queue_properties properties[3] = {0};
    MockParentKernel *parentKernel = MockParentKernel::create(*context);
    MockDeviceQueueHwWithCriticalSectionRelease<FamilyType> mockDevQueue(context, device, properties[0]);
    parentKernel->createReflectionSurface();
    context->setDefaultDeviceQueue(&mockDevQueue);

    size_t heapSize = 20;
    size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();

    IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
    pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
    pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
    pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);

    dsh->getSpace(mockDevQueue.getDshOffset());

    auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER, device->getDeviceBitfield()});
    auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
                                                                *pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
    blockedCommandData->setHeaps(dsh, ioh, ssh);

    size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);

    blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
    PreemptionMode preemptionMode = device->getPreemptionMode();
    std::vector<Surface *> surfaces;
    auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);

    cmdComputeKernel->submit(0, false);

    EXPECT_TRUE(mockDevQueue.indirectStateSetup);
    EXPECT_TRUE(mockDevQueue.cleanupSectionAdded);

    delete cmdComputeKernel;
    delete parentKernel;
}

HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenBlockedParentKernelWithProfilingWhenCommandIsSubmittedThenEMCleanupSectionsSetsCompleteTimestamp) {
    REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device);

    cl_queue_properties properties[3] = {0};
    MockParentKernel *parentKernel = MockParentKernel::create(*context);
    MockDeviceQueueHwWithCriticalSectionRelease<FamilyType> mockDevQueue(context, device, properties[0]);
    parentKernel->createReflectionSurface();
    context->setDefaultDeviceQueue(&mockDevQueue);

    size_t heapSize = 20;
    size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();
    IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
    pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
    pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
    pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);
    dsh->getSpace(mockDevQueue.getDshOffset());

    auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER, device->getDeviceBitfield()});
    auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
                                                                *pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
    blockedCommandData->setHeaps(dsh, ioh, ssh);

    size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);

    blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
    PreemptionMode preemptionMode = device->getPreemptionMode();
    std::vector<Surface *> surfaces;
    auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);

    auto timestamp = pCmdQ->getGpgpuCommandStreamReceiver().getEventTsAllocator()->getTag();
    cmdComputeKernel->timestamp = timestamp;
    cmdComputeKernel->submit(0, false);

    EXPECT_TRUE(mockDevQueue.cleanupSectionAdded);
    EXPECT_EQ(mockDevQueue.timestampAddedInCleanupSection, timestamp->tagForCpuAccess);

    delete cmdComputeKernel;
    delete parentKernel;
}

HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenParentKernelWhenCommandIsSubmittedThenSchedulerIsDispatched) {
    REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device);

    cl_queue_properties properties[3] = {0};
    MockParentKernel *parentKernel = MockParentKernel::create(*context);
    MockDeviceQueueHwWithCriticalSectionRelease<FamilyType> mockDevQueue(context, device, properties[0]);
    parentKernel->createReflectionSurface();
    context->setDefaultDeviceQueue(&mockDevQueue);

    size_t heapSize = 20;
    size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();

    IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
    pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
    pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
    pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);
    dsh->getSpace(mockDevQueue.getDshOffset());

    auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER, device->getDeviceBitfield()});
    auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
                                                                *pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
    blockedCommandData->setHeaps(dsh, ioh, ssh);

    size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);

    blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
    PreemptionMode preemptionMode = device->getPreemptionMode();
    std::vector<Surface *> surfaces;
    auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);

    cmdComputeKernel->submit(0, false);

    EXPECT_TRUE(mockDevQueue.schedulerDispatched);

    delete cmdComputeKernel;
    delete parentKernel;
}

HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenUsedCommandQueueHeapsWhenParentKernelIsSubmittedThenQueueHeapsAreNotUsed) {
    REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device);

    cl_queue_properties properties[3] = {0};
    MockParentKernel *parentKernel = MockParentKernel::create(*context);
    MockDeviceQueueHw<FamilyType> mockDevQueue(context, device, properties[0]);
    parentKernel->createReflectionSurface();
    context->setDefaultDeviceQueue(&mockDevQueue);

    MockCommandQueue cmdQ(context, device, properties);

    size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);

    size_t heapSize = 20;

    size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();
    IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
    pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
    pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
    pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, heapSize, ssh);

    dsh->getSpace(mockDevQueue.getDshOffset());

    auto &queueSsh = cmdQ.getIndirectHeap(IndirectHeap::SURFACE_STATE, 100);
    auto &queueDsh = cmdQ.getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 100);
    auto &queueIoh = cmdQ.getIndirectHeap(IndirectHeap::INDIRECT_OBJECT, 100);

    size_t usedSize = 4u;

    queueSsh.getSpace(usedSize);
    queueDsh.getSpace(usedSize);
    queueIoh.getSpace(usedSize);

    auto intialSshUsed = queueSsh.getUsed();

    auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER, device->getDeviceBitfield()});
    auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
                                                                *pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
    blockedCommandData->setHeaps(dsh, ioh, ssh);

    blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
    PreemptionMode preemptionMode = device->getPreemptionMode();
    std::vector<Surface *> surfaces;
    auto *cmdComputeKernel = new CommandComputeKernel(cmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);

    cmdComputeKernel->submit(0, false);

    EXPECT_FALSE(cmdQ.releaseIndirectHeapCalled);
    EXPECT_EQ(usedSize, queueDsh.getUsed());
    EXPECT_EQ(usedSize, queueIoh.getUsed());
    EXPECT_EQ(intialSshUsed, queueSsh.getUsed());

    delete cmdComputeKernel;
    delete parentKernel;
}

HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenNotUsedSSHWhenParentKernelIsSubmittedThenExistingSSHIsUsed) {
    REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device);

    cl_queue_properties properties[3] = {0};
    MockParentKernel *parentKernel = MockParentKernel::create(*context);
    MockDeviceQueueHw<FamilyType> mockDevQueue(context, device, properties[0]);
    parentKernel->createReflectionSurface();
    context->setDefaultDeviceQueue(&mockDevQueue);

    size_t minSizeSSHForEM = HardwareCommandsHelper<FamilyType>::getSshSizeForExecutionModel(*parentKernel);

    size_t heapSize = 20;

    size_t dshSize = mockDevQueue.getDshBuffer()->getUnderlyingBufferSize();
    size_t sshSize = 1000;
    IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
    pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, dshSize, dsh);
    pCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, heapSize, ioh);
    pCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, sshSize, ssh);
    dsh->getSpace(mockDevQueue.getDshOffset());

    pCmdQ->getIndirectHeap(IndirectHeap::SURFACE_STATE, sshSize);

    void *sshBuffer = pCmdQ->getIndirectHeap(IndirectHeap::SURFACE_STATE, 0u).getCpuBase();

    auto cmdStreamAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER, device->getDeviceBitfield()});
    auto blockedCommandData = std::make_unique<KernelOperation>(new LinearStream(cmdStreamAllocation),
                                                                *pCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
    blockedCommandData->setHeaps(dsh, ioh, ssh);

    blockedCommandData->surfaceStateHeapSizeEM = minSizeSSHForEM;
    PreemptionMode preemptionMode = device->getPreemptionMode();
    std::vector<Surface *> surfaces;
    auto *cmdComputeKernel = new CommandComputeKernel(*pCmdQ, blockedCommandData, surfaces, false, false, false, nullptr, preemptionMode, parentKernel, 1);

    cmdComputeKernel->submit(0, false);

    void *newSshBuffer = pCmdQ->getIndirectHeap(IndirectHeap::SURFACE_STATE, 0u).getCpuBase();

    EXPECT_EQ(sshBuffer, newSshBuffer);

    delete cmdComputeKernel;
    delete parentKernel;
}

HWCMDTEST_F(IGFX_GEN8_CORE, ParentKernelCommandQueueFixture, givenBlockedCommandQueueWhenDispatchWalkerIsCalledThenHeapsHaveProperSizes) {
    REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device);

    cl_queue_properties properties[3] = {0};
    std::unique_ptr<MockParentKernel> parentKernel(MockParentKernel::create(*context));

    MockDeviceQueueHw<FamilyType> mockDevQueue(context, device, properties[0]);
    parentKernel->createReflectionSurface();
    context->setDefaultDeviceQueue(&mockDevQueue);

    auto blockedCommandsData = createBlockedCommandsData(*pCmdQ);
    const size_t globalOffsets[3] = {0, 0, 0};
    const size_t workItems[3] = {1, 1, 1};

    DispatchInfo dispatchInfo(parentKernel.get(), 1, workItems, nullptr, globalOffsets);
    MultiDispatchInfo multiDispatchInfo(parentKernel.get());
    multiDispatchInfo.push(dispatchInfo);
    HardwareInterface<FamilyType>::dispatchWalker(
        *pCmdQ,
        multiDispatchInfo,
        CsrDependencies(),
        blockedCommandsData.get(),
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        CL_COMMAND_NDRANGE_KERNEL);

    EXPECT_NE(nullptr, blockedCommandsData);
    EXPECT_EQ(blockedCommandsData->dsh->getMaxAvailableSpace(), mockDevQueue.getDshBuffer()->getUnderlyingBufferSize());
    EXPECT_EQ(blockedCommandsData->dsh, blockedCommandsData->ioh);

    EXPECT_NE(nullptr, blockedCommandsData->dsh->getGraphicsAllocation());
    EXPECT_NE(nullptr, blockedCommandsData->ioh->getGraphicsAllocation());
    EXPECT_NE(nullptr, blockedCommandsData->ssh->getGraphicsAllocation());
    EXPECT_EQ(blockedCommandsData->dsh->getGraphicsAllocation(), blockedCommandsData->ioh->getGraphicsAllocation());
}