From 5b50575c23fd87b03e2a0c3a4662960e8cc2b091 Mon Sep 17 00:00:00 2001 From: Jaime Arteaga Date: Wed, 12 Aug 2020 15:01:06 -0700 Subject: [PATCH] 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 --- .../core/source/cmdlist/cmdlist_imp.cpp | 7 ++++- .../sources/cmdlist/test_cmdlist_1.cpp | 28 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_imp.cpp b/level_zero/core/source/cmdlist/cmdlist_imp.cpp index 525a7904a5..e8045ac25b 100644 --- a/level_zero/core/source/cmdlist/cmdlist_imp.cpp +++ b/level_zero/core/source/cmdlist/cmdlist_imp.cpp @@ -69,7 +69,12 @@ CommandList *CommandList::createImmediate(uint32_t productFamily, Device *device bool internalUsage, bool isCopyOnly) { NEO::CommandStreamReceiver *csr = nullptr; - device->getCsrForOrdinalAndIndex(&csr, desc->ordinal, desc->index); + auto deviceImp = static_cast(device); + if (internalUsage) { + csr = deviceImp->neoDevice->getInternalEngine().commandStreamReceiver; + } else { + device->getCsrForOrdinalAndIndex(&csr, desc->ordinal, desc->index); + } auto commandQueue = CommandQueue::create(productFamily, device, csr, desc, isCopyOnly); if (!commandQueue) { diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp index a455b9b5c1..f09f58038e 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp @@ -14,6 +14,7 @@ #include "test.h" #include "level_zero/core/source/builtin/builtin_functions_lib_impl.h" +#include "level_zero/core/source/cmdqueue/cmdqueue_imp.h" #include "level_zero/core/source/context/context.h" #include "level_zero/core/source/driver/driver_handle_imp.h" #include "level_zero/core/source/image/image_hw.h" @@ -159,6 +160,33 @@ TEST_F(CommandListCreate, givenValidPtrThenAppendMemoryPrefetchReturnsSuccess) { ASSERT_EQ(res, ZE_RESULT_SUCCESS); } +TEST_F(CommandListCreate, givenImmediateCommandListThenInternalEngineIsUsedIfRequested) { + const ze_command_queue_desc_t desc = {}; + bool internalEngine = true; + + std::unique_ptr commandList0(CommandList::createImmediate(productFamily, + device, + &desc, + internalEngine, + false)); + ASSERT_NE(nullptr, commandList0); + + CommandQueueImp *cmdQueue = reinterpret_cast(commandList0->cmdQImmediate); + EXPECT_EQ(cmdQueue->getCsr(), neoDevice->getInternalEngine().commandStreamReceiver); + + internalEngine = false; + + std::unique_ptr commandList1(CommandList::createImmediate(productFamily, + device, + &desc, + internalEngine, + false)); + ASSERT_NE(nullptr, commandList1); + + cmdQueue = reinterpret_cast(commandList1->cmdQImmediate); + EXPECT_NE(cmdQueue->getCsr(), neoDevice->getInternalEngine().commandStreamReceiver); +} + TEST_F(CommandListCreate, givenImmediateCommandListThenCustomNumIddPerBlockUsed) { const ze_command_queue_desc_t desc = {};