Skip to content

Commit f4ef256

Browse files
Program hardware context in L0 command queue
Related-To: NEO-4577 Change-Id: I204a5e86ad3b23b71071bbbfd58c23a408f6865f Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent ca459b8 commit f4ef256

39 files changed

+195
-122
lines changed

level_zero/core/source/cmdqueue/cmdqueue_hw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace L0 {
2222
template <GFXCORE_FAMILY gfxCoreFamily>
2323
struct CommandQueueHw : public CommandQueueImp {
2424
using CommandQueueImp::CommandQueueImp;
25+
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
2526

2627
ze_result_t createFence(const ze_fence_desc_t *desc, ze_fence_handle_t *phFence) override;
2728
ze_result_t destroy() override;

level_zero/core/source/cmdqueue/cmdqueue_hw.inl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "shared/source/built_ins/built_ins.h"
1111
#include "shared/source/built_ins/sip.h"
1212
#include "shared/source/command_container/command_encoder.h"
13+
#include "shared/source/command_stream/command_stream_receiver_hw.h"
1314
#include "shared/source/command_stream/linear_stream.h"
1415
#include "shared/source/command_stream/preemption.h"
1516
#include "shared/source/command_stream/thread_arbitration_policy.h"
@@ -126,6 +127,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
126127
}
127128

128129
size_t linearStreamSizeEstimate = totalCmdBuffers * sizeof(MI_BATCH_BUFFER_START);
130+
linearStreamSizeEstimate += csr->getCmdsSizeForHardwareContext();
129131

130132
if (directSubmissionEnabled) {
131133
linearStreamSizeEstimate += sizeof(MI_BATCH_BUFFER_START);
@@ -175,6 +177,13 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
175177
reserveLinearStreamSize(alignedSize);
176178
NEO::LinearStream child(commandStream->getSpace(alignedSize), alignedSize);
177179

180+
const auto globalFenceAllocation = csr->getGlobalFenceAllocation();
181+
if (globalFenceAllocation) {
182+
residencyContainer.push_back(globalFenceAllocation);
183+
}
184+
185+
csr->programHardwareContext(child);
186+
178187
if (!isCopyOnlyCommandQueue) {
179188
if (!gpgpuEnabled) {
180189
programPipelineSelect(child);

level_zero/core/source/gen11/icllp/cmdqueue_icllp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "igfxfmid.h"
1616

1717
namespace L0 {
18-
18+
template struct CommandQueueHw<IGFX_GEN11_CORE>;
1919
static CommandQueuePopulateFactory<IGFX_ICELAKE_LP, CommandQueueHw<IGFX_GEN11_CORE>> populateICLLP;
2020

2121
} // namespace L0

level_zero/core/source/gen12lp/tgllp/cmdqueue_tgllp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "igfxfmid.h"
1616

1717
namespace L0 {
18-
18+
template struct CommandQueueHw<IGFX_GEN12LP_CORE>;
1919
static CommandQueuePopulateFactory<IGFX_TIGERLAKE_LP, CommandQueueHw<IGFX_GEN12LP_CORE>>
2020
populateTGLLP;
2121

level_zero/core/source/gen9/cfl/cmdqueue_cfl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "igfxfmid.h"
1616

1717
namespace L0 {
18-
18+
template struct CommandQueueHw<IGFX_GEN9_CORE>;
1919
static CommandQueuePopulateFactory<IGFX_COFFEELAKE, CommandQueueHw<IGFX_GEN9_CORE>> populateCFL;
2020

2121
} // namespace L0

level_zero/core/source/gen9/glk/cmdqueue_glk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "igfxfmid.h"
1616

1717
namespace L0 {
18-
18+
template struct CommandQueueHw<IGFX_GEN9_CORE>;
1919
static CommandQueuePopulateFactory<IGFX_GEMINILAKE, CommandQueueHw<IGFX_GEN9_CORE>> populateGLK;
2020

2121
} // namespace L0

level_zero/core/source/gen9/kbl/cmdqueue_kbl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "igfxfmid.h"
1616

1717
namespace L0 {
18-
18+
template struct CommandQueueHw<IGFX_GEN9_CORE>;
1919
static CommandQueuePopulateFactory<IGFX_KABYLAKE, CommandQueueHw<IGFX_GEN9_CORE>> populateKBL;
2020

2121
} // namespace L0

level_zero/core/source/gen9/skl/cmdqueue_skl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "igfxfmid.h"
1616

1717
namespace L0 {
18-
18+
template struct CommandQueueHw<IGFX_GEN9_CORE>;
1919
static CommandQueuePopulateFactory<IGFX_SKYLAKE, CommandQueueHw<IGFX_GEN9_CORE>> populateSKL;
2020

2121
} // namespace L0

level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include "shared/source/helpers/state_base_address.h"
99
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
1010
#include "shared/test/unit_test/helpers/default_hw_info.h"
11+
#include "shared/test/unit_test/mocks/mock_command_stream_receiver.h"
1112

12-
#include "opencl/test/unit_test/mocks/mock_graphics_allocation.h"
1313
#include "test.h"
1414

1515
#include "level_zero/core/source/driver/driver_handle_imp.h"
@@ -217,5 +217,45 @@ HWTEST2_F(CommandQueueDestroy, whenCommandQueueDestroyIsCalledPrintPrintfOutputI
217217
EXPECT_EQ(1u, kernel.printPrintfOutputCalledTimes);
218218
}
219219

220+
using CommandQueueCommands = Test<DeviceFixture>;
221+
HWTEST_F(CommandQueueCommands, givenCommandQueueWhenExecutingCommandListsThenHardwareContextIsProgrammedAndGlobalAllocationResident) {
222+
const ze_command_queue_desc_t desc = {
223+
ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT,
224+
ZE_COMMAND_QUEUE_FLAG_NONE,
225+
ZE_COMMAND_QUEUE_MODE_DEFAULT,
226+
ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
227+
0};
228+
229+
MockCsrHw2<FamilyType> csr(*neoDevice->getExecutionEnvironment(), 0);
230+
csr.initializeTagAllocation();
231+
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
232+
233+
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
234+
device,
235+
&csr,
236+
&desc,
237+
true);
238+
ASSERT_NE(nullptr, commandQueue);
239+
240+
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, true));
241+
auto commandListHandle = commandList->toHandle();
242+
auto status = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
243+
244+
auto globalFence = csr.getGlobalFenceAllocation();
245+
if (globalFence) {
246+
bool found = false;
247+
for (auto alloc : csr.copyOfAllocations) {
248+
if (alloc == globalFence) {
249+
found = true;
250+
break;
251+
}
252+
}
253+
EXPECT_TRUE(found);
254+
}
255+
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
256+
EXPECT_TRUE(csr.programHardwareContextCalled);
257+
commandQueue->destroy();
258+
}
259+
220260
} // namespace ult
221261
} // namespace L0

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
#include "shared/source/gmm_helper/gmm_helper.h"
99
#include "shared/source/os_interface/os_context.h"
1010
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
11+
#include "shared/test/unit_test/helpers/dispatch_flags_helper.h"
1112
#include "shared/test/unit_test/helpers/ult_hw_helper.h"
1213

1314
#include "opencl/source/command_queue/gpgpu_walker.h"
1415
#include "opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h"
15-
#include "opencl/test/unit_test/helpers/dispatch_flags_helper.h"
1616
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
1717
#include "opencl/test/unit_test/mocks/mock_buffer.h"
1818
#include "opencl/test/unit_test/mocks/mock_command_queue.h"

0 commit comments

Comments
 (0)