From 6dc5810c7fa14ceafb45dd06a2e86b565c7dcb40 Mon Sep 17 00:00:00 2001 From: Mateusz Hoppe Date: Fri, 27 Mar 2020 10:05:00 +0100 Subject: [PATCH] Add more cmdlist tests Related-To: NEO-4515 Change-Id: Idc0e0cdab97cb1a2437c212cbe8ae2bcf673125f Signed-off-by: Mateusz Hoppe --- level_zero/core/source/cmdqueue/cmdqueue.cpp | 4 +-- .../core/source/cmdqueue/cmdqueue_hw.inl | 2 +- .../sources/cmdlist/test_cmdlist.cpp | 35 +++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/level_zero/core/source/cmdqueue/cmdqueue.cpp b/level_zero/core/source/cmdqueue/cmdqueue.cpp index d838b25345..8061cca277 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue.cpp +++ b/level_zero/core/source/cmdqueue/cmdqueue.cpp @@ -118,12 +118,12 @@ void CommandQueueImp::CommandBufferManager::initialize(Device *device, size_t si false, NEO::SubDevice::unspecifiedSubDeviceIndex}; - buffers[BUFFER_ALLOCATION::FIRST] = device->getDriverHandle()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); + buffers[BUFFER_ALLOCATION::FIRST] = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); UNRECOVERABLE_IF(nullptr == buffers[BUFFER_ALLOCATION::FIRST]); memset(buffers[BUFFER_ALLOCATION::FIRST]->getUnderlyingBuffer(), 0, buffers[BUFFER_ALLOCATION::FIRST]->getUnderlyingBufferSize()); - buffers[BUFFER_ALLOCATION::SECOND] = device->getDriverHandle()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); + buffers[BUFFER_ALLOCATION::SECOND] = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); UNRECOVERABLE_IF(nullptr == buffers[BUFFER_ALLOCATION::SECOND]); memset(buffers[BUFFER_ALLOCATION::SECOND]->getUnderlyingBuffer(), 0, buffers[BUFFER_ALLOCATION::SECOND]->getUnderlyingBufferSize()); diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl index 0fff6372bf..9e2b1353d7 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl @@ -43,7 +43,7 @@ ze_result_t CommandQueueHw::createFence(const ze_fence_desc_t *de template ze_result_t CommandQueueHw::destroy() { delete commandStream; - buffers.destroy(this->getDevice()->getDriverHandle()->getMemoryManager()); + buffers.destroy(this->getDevice()->getNEODevice()->getMemoryManager()); delete this; return ZE_RESULT_SUCCESS; } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist.cpp index d589a76875..bf0cb2047a 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist.cpp @@ -62,5 +62,40 @@ TEST_F(CommandListCreate, givenRegularCommandListThenDefaultNumIddPerBlockIsUsed const uint32_t defaultNumIdds = CommandList::defaultNumIddsPerBlock; EXPECT_EQ(defaultNumIdds, commandList->commandContainer.getNumIddPerBlock()); } + +TEST_F(CommandListCreate, givenImmediateCommandListThenCustomNumIddPerBlockUsed) { + const ze_command_queue_desc_t desc = { + ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT, + ZE_COMMAND_QUEUE_FLAG_NONE, + ZE_COMMAND_QUEUE_MODE_DEFAULT, + ZE_COMMAND_QUEUE_PRIORITY_NORMAL, + 0}; + std::unique_ptr commandList(CommandList::createImmediate(productFamily, device.get(), &desc, false)); + ASSERT_NE(nullptr, commandList); + + const uint32_t cmdListImmediateIdds = CommandList::commandListimmediateIddsPerBlock; + EXPECT_EQ(cmdListImmediateIdds, commandList->commandContainer.getNumIddPerBlock()); +} + +TEST_F(CommandListCreate, whenCreatingImmediateCommandListThenItHasImmediateCommandQueueCreated) { + const ze_command_queue_desc_t desc = { + ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT, + ZE_COMMAND_QUEUE_FLAG_NONE, + ZE_COMMAND_QUEUE_MODE_DEFAULT, + ZE_COMMAND_QUEUE_PRIORITY_NORMAL, + 0}; + std::unique_ptr commandList(CommandList::createImmediate(productFamily, device.get(), &desc, false)); + ASSERT_NE(nullptr, commandList); + + EXPECT_EQ(device.get(), commandList->device); + EXPECT_EQ(1u, commandList->cmdListType); + EXPECT_NE(nullptr, commandList->cmdQImmediate); +} + +TEST_F(CommandListCreate, givenInvalidProductFamilyThenReturnsNullPointer) { + std::unique_ptr commandList(CommandList::create(IGFX_UNKNOWN, device.get())); + EXPECT_EQ(nullptr, commandList); +} + } // namespace ult } // namespace L0 \ No newline at end of file