Use PRINTF_SURFACE for printf buffer allocation

BUFFER_HOST_MEMORY is incorrect type

Change-Id: I4c03b35cda2f5097ee6cd155e4f4812ce3796289
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-04-07 15:51:49 +02:00
parent 23dd6b95ec
commit a77965adf7
4 changed files with 41 additions and 2 deletions

View File

@ -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<uint32_t *>(allocation->getUnderlyingBuffer()) =
PrintfHandler::printfSurfaceInitialDataSize;

View File

@ -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
)

View File

@ -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::MockDevice>(NEO::defaultHwInfo.get(), 0));
Mock<L0::DeviceImp> 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

View File

@ -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());
}