mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 05:24:02 +08:00
Fix osContext initialization for L0 immediate command lists
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9c5dee54dc
commit
f5b253207d
@@ -122,6 +122,8 @@ CommandQueue *CommandQueue::create(uint32_t productFamily, Device *device, NEO::
|
||||
commandQueue = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
csr->getOsContext().ensureContextInitialized();
|
||||
return commandQueue;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,6 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
|
||||
bool isCopyOnly = hwHelper.isCopyOnlyEngineType(static_cast<NEO::EngineGroupType>(engineGroupIndex));
|
||||
|
||||
*commandQueue = CommandQueue::create(platform.eProductFamily, this, csr, desc, isCopyOnly, false, returnValue);
|
||||
csr->getOsContext().ensureContextInitialized();
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -588,6 +588,48 @@ TEST_F(CommandListCreate, whenInvokingAppendMemoryCopyFromContextForImmediateCom
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
struct CommandListCreateWithDeferredOsContextInitialization : ContextCommandListCreate {
|
||||
void SetUp() override {
|
||||
DebugManager.flags.DeferOsContextInitialization.set(1);
|
||||
ContextCommandListCreate::SetUp();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
ContextCommandListCreate::TearDown();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
};
|
||||
TEST_F(ContextCommandListCreate, givenDeferredEngineCreationWhenImmediateCommandListIsCreatedThenEngineIsInitialized) {
|
||||
uint32_t groupsCount{};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, device->getCommandQueueGroupProperties(&groupsCount, nullptr));
|
||||
auto groups = std::vector<ze_command_queue_group_properties_t>(groupsCount);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, device->getCommandQueueGroupProperties(&groupsCount, groups.data()));
|
||||
|
||||
for (uint32_t groupIndex = 0u; groupIndex < groupsCount; groupIndex++) {
|
||||
const auto &group = groups[groupIndex];
|
||||
for (uint32_t queueIndex = 0; queueIndex < group.numQueues; queueIndex++) {
|
||||
CommandStreamReceiver *expectedCsr{};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, device->getCsrForOrdinalAndIndex(&expectedCsr, groupIndex, queueIndex));
|
||||
|
||||
ze_command_queue_desc_t desc = {};
|
||||
desc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
|
||||
desc.ordinal = groupIndex;
|
||||
desc.index = queueIndex;
|
||||
ze_command_list_handle_t cmdListHandle;
|
||||
ze_result_t result = context->createCommandListImmediate(device, &desc, &cmdListHandle);
|
||||
L0::CommandList *cmdList = L0::CommandList::fromHandle(cmdListHandle);
|
||||
|
||||
EXPECT_EQ(device, cmdList->device);
|
||||
EXPECT_EQ(CommandList::CommandListType::TYPE_IMMEDIATE, cmdList->cmdListType);
|
||||
EXPECT_NE(nullptr, cmdList);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_TRUE(expectedCsr->getOsContext().isInitialized());
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, cmdList->destroy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(CommandListCreate, whenInvokingAppendMemoryCopyFromContextForImmediateCommandListWithASyncModeThenSuccessIsReturned) {
|
||||
ze_command_queue_desc_t desc = {};
|
||||
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
|
||||
|
||||
@@ -38,6 +38,7 @@ using CommandQueueCreate = Test<DeviceFixture>;
|
||||
|
||||
TEST_F(CommandQueueCreate, whenCreatingCommandQueueThenItIsInitialized) {
|
||||
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
|
||||
csr->setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
const ze_command_queue_desc_t desc{};
|
||||
ze_result_t returnValue;
|
||||
auto commandQueue = whitebox_cast(CommandQueue::create(productFamily,
|
||||
@@ -130,6 +131,7 @@ TEST_F(CommandQueueCreate, whenCreatingCommandQueueWithInvalidProductFamilyThenF
|
||||
const ze_command_queue_desc_t desc = {};
|
||||
ze_result_t returnValue;
|
||||
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
|
||||
csr->setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
L0::CommandQueue *commandQueue = CommandQueue::create(PRODUCT_FAMILY::IGFX_MAX_PRODUCT,
|
||||
device,
|
||||
csr.get(),
|
||||
@@ -323,6 +325,7 @@ struct CommandQueueProgramSBATest : public ::testing::Test {
|
||||
HWTEST2_F(CommandQueueProgramSBATest, whenCreatingCommandQueueThenItIsInitialized, CommandQueueSBASupport) {
|
||||
ze_command_queue_desc_t desc = {};
|
||||
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
|
||||
csr->setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
auto commandQueue = new MockCommandQueueHw<gfxCoreFamily>(device, csr.get(), &desc);
|
||||
commandQueue->initialize(false, false);
|
||||
|
||||
@@ -372,6 +375,7 @@ HWTEST2_F(CommandQueueProgramSBATest,
|
||||
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
|
||||
ze_command_queue_desc_t desc = {};
|
||||
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
|
||||
csr->setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
auto commandQueue = new MockCommandQueueHw<gfxCoreFamily>(device, csr.get(), &desc);
|
||||
commandQueue->initialize(false, false);
|
||||
|
||||
@@ -404,6 +408,7 @@ HWTEST2_F(CommandQueueProgramSBATest,
|
||||
baseAllocation.setGpuBaseAddress(0x123000);
|
||||
ze_command_queue_desc_t desc = {};
|
||||
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
|
||||
csr->setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
auto commandQueue = new MockCommandQueueHw<gfxCoreFamily>(device, csr.get(), &desc);
|
||||
commandQueue->initialize(false, false);
|
||||
|
||||
@@ -442,6 +447,7 @@ HWTEST2_F(CommandQueueProgramSBATest,
|
||||
baseAllocation.setGpuBaseAddress(0x123000);
|
||||
ze_command_queue_desc_t desc = {};
|
||||
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
|
||||
csr->setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
auto commandQueue = new MockCommandQueueHw<gfxCoreFamily>(device, csr.get(), &desc);
|
||||
commandQueue->initialize(false, false);
|
||||
|
||||
@@ -469,6 +475,7 @@ TEST_F(CommandQueueCreate, givenCmdQueueWithBlitCopyWhenExecutingNonCopyBlitComm
|
||||
const ze_command_queue_desc_t desc = {};
|
||||
ze_result_t returnValue;
|
||||
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
|
||||
csr->setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
|
||||
device,
|
||||
csr.get(),
|
||||
@@ -1430,6 +1437,7 @@ struct CommandQueueCreateNegativeTest : public ::testing::Test {
|
||||
TEST_F(CommandQueueCreateNegativeTest, whenDeviceAllocationFailsDuringCommandQueueCreateThenAppropriateValueIsReturned) {
|
||||
const ze_command_queue_desc_t desc = {};
|
||||
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
|
||||
csr->setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
memoryManager->forceFailureInPrimaryAllocation = true;
|
||||
|
||||
ze_result_t returnValue;
|
||||
@@ -1491,6 +1499,7 @@ struct CommandQueueInitTests : public ::testing::Test {
|
||||
TEST_F(CommandQueueInitTests, givenMultipleSubDevicesWhenInitializingThenAllocateForAllSubDevices) {
|
||||
ze_command_queue_desc_t desc = {};
|
||||
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
|
||||
csr->setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
|
||||
ze_result_t returnValue;
|
||||
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily, device, csr.get(), &desc, false, false, returnValue);
|
||||
|
||||
Reference in New Issue
Block a user