diff --git a/level_zero/core/source/cmdlist/cmdlist.cpp b/level_zero/core/source/cmdlist/cmdlist.cpp index 638d400f93..9484101fcb 100644 --- a/level_zero/core/source/cmdlist/cmdlist.cpp +++ b/level_zero/core/source/cmdlist/cmdlist.cpp @@ -30,7 +30,7 @@ void CommandList::storePrintfFunction(Kernel *function) { } void CommandList::removeHostPtrAllocations() { - auto memoryManager = device ? device->getDriverHandle()->getMemoryManager() : nullptr; + auto memoryManager = device ? device->getNEODevice()->getMemoryManager() : nullptr; for (auto &allocation : hostPtrMap) { UNRECOVERABLE_IF(memoryManager == nullptr); memoryManager->freeGraphicsMemory(allocation.second); @@ -39,7 +39,7 @@ void CommandList::removeHostPtrAllocations() { } void CommandList::removeDeallocationContainerData() { - auto memoryManager = device ? device->getDriverHandle()->getMemoryManager() : nullptr; + auto memoryManager = device ? device->getNEODevice()->getMemoryManager() : nullptr; auto container = commandContainer.getDeallocationContainer(); for (auto deallocation : container) { diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index ebf520830f..a29deb5d03 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -573,11 +573,6 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice) { device->neoDevice->getHardwareInfo().platform.eProductFamily, device, &cmdQueueDesc, true); } - if (neoDevice->getDeviceInfo().debuggerActive) { - auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get(); - device->getSourceLevelDebugger()->notifyNewDevice(osInterface ? osInterface->getDeviceHandle() : 0); - } - if (neoDevice->getDeviceInfo().debuggerActive) { auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get(); diff --git a/level_zero/core/test/unit_tests/mocks/mock_device.h b/level_zero/core/test/unit_tests/mocks/mock_device.h index 05efc9ee6b..25771e0cd4 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_device.h +++ b/level_zero/core/test/unit_tests/mocks/mock_device.h @@ -12,6 +12,7 @@ #include "shared/source/device/device_info.h" #include "level_zero/core/source/device/device.h" +#include "level_zero/core/source/device/device_imp.h" #include "level_zero/core/source/driver/driver_handle.h" #include "level_zero/core/test/unit_tests/mock.h" #include "level_zero/core/test/unit_tests/white_box.h" @@ -110,6 +111,17 @@ struct Mock : public Device { MOCK_CONST_METHOD0(getDebugSurface, NEO::GraphicsAllocation *()); }; +template <> +struct Mock : public L0::DeviceImp { + using Base = L0::DeviceImp; + + explicit Mock(NEO::Device *device, NEO::ExecutionEnvironment *execEnv) { + device->incRefInternal(); + Base::execEnvironment = execEnv; + Base::neoDevice = device; + } +}; + } // namespace ult } // namespace L0 diff --git a/level_zero/core/test/unit_tests/sources/CMakeLists.txt b/level_zero/core/test/unit_tests/sources/CMakeLists.txt index a5326dcaaa..a21d32fb41 100644 --- a/level_zero/core/test/unit_tests/sources/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/sources/CMakeLists.txt @@ -9,4 +9,4 @@ target_sources(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deferred_deleter_test.cpp ) -add_subdirectories() \ No newline at end of file +add_subdirectories() diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/CMakeLists.txt b/level_zero/core/test/unit_tests/sources/cmdlist/CMakeLists.txt new file mode 100644 index 0000000000..704445c0dc --- /dev/null +++ b/level_zero/core/test/unit_tests/sources/cmdlist/CMakeLists.txt @@ -0,0 +1,10 @@ +# +# Copyright (C) 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +target_sources(${TARGET_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist.cpp +) \ No newline at end of file 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 new file mode 100644 index 0000000000..d589a76875 --- /dev/null +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/unit_test/helpers/default_hw_info.h" + +#include "opencl/test/unit_test/mocks/mock_device.h" +#include "test.h" + +#include "level_zero/core/test/unit_tests/mocks/mock_device.h" + +namespace L0 { +namespace ult { + +struct L0DeviceFixture { + void SetUp() { + neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment(NEO::defaultHwInfo.get()); + device = std::make_unique>(neoDevice, neoDevice->getExecutionEnvironment()); + } + + void TearDown() { + } + + NEO::MockDevice *neoDevice = nullptr; + std::unique_ptr> device = nullptr; +}; + +using CommandListCreate = Test; + +TEST_F(CommandListCreate, whenCommandListIsCreatedThenItIsInitialized) { + std::unique_ptr commandList(CommandList::create(productFamily, device.get())); + ASSERT_NE(nullptr, commandList); + + EXPECT_EQ(device.get(), commandList->device); + ASSERT_GT(commandList->commandContainer.getCmdBufferAllocations().size(), 0u); + + auto numAllocations = 0u; + auto allocation = whitebox_cast(commandList->commandContainer.getCmdBufferAllocations()[0]); + ASSERT_NE(allocation, nullptr); + + ++numAllocations; + + ASSERT_NE(nullptr, commandList->commandContainer.getCommandStream()); + for (uint32_t i = 0; i < NEO::HeapType::NUM_TYPES; i++) { + ASSERT_NE(commandList->commandContainer.getIndirectHeap(static_cast(i)), nullptr); + ++numAllocations; + ASSERT_NE(commandList->commandContainer.getIndirectHeapAllocation(static_cast(i)), nullptr); + } + + EXPECT_LT(0u, commandList->commandContainer.getCommandStream()->getAvailableSpace()); + ASSERT_EQ(commandList->commandContainer.getResidencyContainer().size(), numAllocations); + EXPECT_EQ(commandList->commandContainer.getResidencyContainer().front(), allocation); +} + +TEST_F(CommandListCreate, givenRegularCommandListThenDefaultNumIddPerBlockIsUsed) { + std::unique_ptr commandList(CommandList::create(productFamily, device.get())); + ASSERT_NE(nullptr, commandList); + + const uint32_t defaultNumIdds = CommandList::defaultNumIddsPerBlock; + EXPECT_EQ(defaultNumIdds, commandList->commandContainer.getNumIddPerBlock()); +} +} // namespace ult +} // namespace L0 \ No newline at end of file