diff --git a/level_zero/core/source/printf_handler/printf_handler.cpp b/level_zero/core/source/printf_handler/printf_handler.cpp index a37183f705..67fbf9ea37 100644 --- a/level_zero/core/source/printf_handler/printf_handler.cpp +++ b/level_zero/core/source/printf_handler/printf_handler.cpp @@ -17,9 +17,9 @@ namespace L0 { NEO::GraphicsAllocation *PrintfHandler::createPrintfBuffer(Device *device) { NEO::AllocationProperties properties( - device->getRootDeviceIndex(), PrintfHandler::printfBufferSize, NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); + device->getRootDeviceIndex(), PrintfHandler::printfBufferSize, NEO::GraphicsAllocation::AllocationType::PRINTF_SURFACE); properties.alignment = MemoryConstants::pageSize64k; - auto allocation = device->getDriverHandle()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); + auto allocation = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); *reinterpret_cast(allocation->getUnderlyingBuffer()) = PrintfHandler::printfSurfaceInitialDataSize; diff --git a/level_zero/core/test/unit_tests/sources/printf_handler/CMakeLists.txt b/level_zero/core/test/unit_tests/sources/printf_handler/CMakeLists.txt new file mode 100644 index 0000000000..b08b1363f3 --- /dev/null +++ b/level_zero/core/test/unit_tests/sources/printf_handler/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_printf_handler.cpp +) \ No newline at end of file diff --git a/level_zero/core/test/unit_tests/sources/printf_handler/test_printf_handler.cpp b/level_zero/core/test/unit_tests/sources/printf_handler/test_printf_handler.cpp new file mode 100644 index 0000000000..5159b8e0b2 --- /dev/null +++ b/level_zero/core/test/unit_tests/sources/printf_handler/test_printf_handler.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/unit_test/mocks/mock_device.h" + +#include "test.h" + +#include "level_zero/core/source/printf_handler/printf_handler.h" +#include "level_zero/core/test/unit_tests/mocks/mock_device.h" + +namespace L0 { +namespace ult { + +TEST(PrintfHandler, whenPrintfBufferIscreatedThenCorrectAllocationTypeIsUsed) { + NEO::Device *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment(NEO::defaultHwInfo.get(), 0)); + Mock l0Device(neoDevice, neoDevice->getExecutionEnvironment()); + + auto allocation = PrintfHandler::createPrintfBuffer(&l0Device); + EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::PRINTF_SURFACE, allocation->getAllocationType()); + neoDevice->getMemoryManager()->freeGraphicsMemory(allocation); +} + +} // namespace ult +} // namespace L0 diff --git a/shared/test/unit_test/mocks/mock_dispatch_kernel_encoder_interface.cpp b/shared/test/unit_test/mocks/mock_dispatch_kernel_encoder_interface.cpp index 62ae5ef731..5f32a745f7 100644 --- a/shared/test/unit_test/mocks/mock_dispatch_kernel_encoder_interface.cpp +++ b/shared/test/unit_test/mocks/mock_dispatch_kernel_encoder_interface.cpp @@ -41,4 +41,5 @@ void MockDispatchKernelEncoder::expectAnyMockFunctionCall() { EXPECT_CALL(*this, hasGroupCounts()).Times(::testing::AnyNumber()); EXPECT_CALL(*this, getSurfaceStateHeap()).Times(::testing::AnyNumber()); EXPECT_CALL(*this, getDynamicStateHeap()).Times(::testing::AnyNumber()); + EXPECT_CALL(*this, isInlineDataRequired()).Times(::testing::AnyNumber()); } \ No newline at end of file