Skip to content

Commit 5b50575

Browse files
Jaime ArteagaCompute-Runtime-Automation
authored andcommitted
Use internal engine if selected for immediate list
This ensures internal for instance that the list used for the page-fault manager uses the internal engine, rather than one used by the application. Change-Id: I531d5c9d31c75ea9de14ac0439a4da01c688e91b Signed-off-by: Jaime Arteaga <[email protected]>
1 parent 49526b9 commit 5b50575

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

level_zero/core/source/cmdlist/cmdlist_imp.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ CommandList *CommandList::createImmediate(uint32_t productFamily, Device *device
6969
bool internalUsage, bool isCopyOnly) {
7070

7171
NEO::CommandStreamReceiver *csr = nullptr;
72-
device->getCsrForOrdinalAndIndex(&csr, desc->ordinal, desc->index);
72+
auto deviceImp = static_cast<DeviceImp *>(device);
73+
if (internalUsage) {
74+
csr = deviceImp->neoDevice->getInternalEngine().commandStreamReceiver;
75+
} else {
76+
device->getCsrForOrdinalAndIndex(&csr, desc->ordinal, desc->index);
77+
}
7378

7479
auto commandQueue = CommandQueue::create(productFamily, device, csr, desc, isCopyOnly);
7580
if (!commandQueue) {

level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "test.h"
1515

1616
#include "level_zero/core/source/builtin/builtin_functions_lib_impl.h"
17+
#include "level_zero/core/source/cmdqueue/cmdqueue_imp.h"
1718
#include "level_zero/core/source/context/context.h"
1819
#include "level_zero/core/source/driver/driver_handle_imp.h"
1920
#include "level_zero/core/source/image/image_hw.h"
@@ -159,6 +160,33 @@ TEST_F(CommandListCreate, givenValidPtrThenAppendMemoryPrefetchReturnsSuccess) {
159160
ASSERT_EQ(res, ZE_RESULT_SUCCESS);
160161
}
161162

163+
TEST_F(CommandListCreate, givenImmediateCommandListThenInternalEngineIsUsedIfRequested) {
164+
const ze_command_queue_desc_t desc = {};
165+
bool internalEngine = true;
166+
167+
std::unique_ptr<L0::CommandList> commandList0(CommandList::createImmediate(productFamily,
168+
device,
169+
&desc,
170+
internalEngine,
171+
false));
172+
ASSERT_NE(nullptr, commandList0);
173+
174+
CommandQueueImp *cmdQueue = reinterpret_cast<CommandQueueImp *>(commandList0->cmdQImmediate);
175+
EXPECT_EQ(cmdQueue->getCsr(), neoDevice->getInternalEngine().commandStreamReceiver);
176+
177+
internalEngine = false;
178+
179+
std::unique_ptr<L0::CommandList> commandList1(CommandList::createImmediate(productFamily,
180+
device,
181+
&desc,
182+
internalEngine,
183+
false));
184+
ASSERT_NE(nullptr, commandList1);
185+
186+
cmdQueue = reinterpret_cast<CommandQueueImp *>(commandList1->cmdQImmediate);
187+
EXPECT_NE(cmdQueue->getCsr(), neoDevice->getInternalEngine().commandStreamReceiver);
188+
}
189+
162190
TEST_F(CommandListCreate, givenImmediateCommandListThenCustomNumIddPerBlockUsed) {
163191
const ze_command_queue_desc_t desc = {};
164192

0 commit comments

Comments
 (0)