fix: add AllocationType::printfSurface to is2MBPageAllocationType

printfSurface is always allocated with size 4 MB it doesn't
need aligning.
Adding it to is2MBPageAllocationType for clarity and certainty.

Related-To: NEO-12287
Signed-off-by: Fabian Zwoliński <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwoliński
2025-11-25 08:40:07 +00:00
committed by Compute-Runtime-Automation
parent 7b13028ac4
commit d7b6c7b69e
4 changed files with 31 additions and 4 deletions

View File

@@ -24,6 +24,10 @@ NEO::GraphicsAllocation *PrintfHandler::createPrintfBuffer(Device *device) {
NEO::AllocationProperties properties(
device->getRootDeviceIndex(), PrintfHandler::printfBufferSize, NEO::AllocationType::printfSurface, device->getNEODevice()->getDeviceBitfield());
properties.alignment = MemoryConstants::pageSize64k;
DEBUG_BREAK_IF(device->getNEODevice()->getProductHelper().is2MBLocalMemAlignmentEnabled() &&
!isAligned(properties.size, MemoryConstants::pageSize2M));
auto allocation = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
*reinterpret_cast<uint32_t *>(allocation->getUnderlyingBuffer()) =

View File

@@ -44,13 +44,17 @@ void PrintfHandler::prepareDispatch(const MultiDispatchInfo &multiDispatchInfo)
if (printfSurfaceSize == 0) {
return;
}
auto rootDeviceIndex = device.getRootDeviceIndex();
kernel = multiDispatchInfo.peekMainKernel();
printfSurface = device.getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, printfSurfaceSize, AllocationType::printfSurface, device.getDeviceBitfield()});
auto &rootDeviceEnvironment = device.getRootDeviceEnvironment();
const auto &productHelper = device.getProductHelper();
DEBUG_BREAK_IF(productHelper.is2MBLocalMemAlignmentEnabled() &&
!isAligned(printfSurfaceSize, MemoryConstants::pageSize2M));
auto rootDeviceIndex = device.getRootDeviceIndex();
kernel = multiDispatchInfo.peekMainKernel();
printfSurface = device.getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, printfSurfaceSize, AllocationType::printfSurface, device.getDeviceBitfield()});
MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *printfSurface),
device, printfSurface, 0, printfSurfaceInitialDataSizePtr.get(),
sizeof(*printfSurfaceInitialDataSizePtr.get()));

View File

@@ -261,7 +261,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation>, NEO::NonCopyableAn
static bool is2MBPageAllocationType(AllocationType type) {
return type == AllocationType::timestampPacketTagBuffer ||
type == AllocationType::gpuTimestampDeviceBuffer ||
type == AllocationType::profilingTagBuffer;
type == AllocationType::profilingTagBuffer ||
type == AllocationType::printfSurface;
}
static bool isAccessedFromCommandStreamer(AllocationType allocationType) {

View File

@@ -215,6 +215,24 @@ TEST(GraphicsAllocationTest, whenAllocationTypeIsImageThenAllocationIsNotLockabl
EXPECT_FALSE(GraphicsAllocation::isLockable(AllocationType::image));
}
TEST(GraphicsAllocationTest, givenAllocationTypeWhenCheckingIs2MBPageAllocationTypeThenReturnTrue) {
for (uint32_t i = 0; i < static_cast<uint32_t>(AllocationType::count); i++) {
auto allocType = static_cast<AllocationType>(i);
switch (allocType) {
case AllocationType::timestampPacketTagBuffer:
case AllocationType::gpuTimestampDeviceBuffer:
case AllocationType::profilingTagBuffer:
case AllocationType::printfSurface:
EXPECT_TRUE(GraphicsAllocation::is2MBPageAllocationType(allocType));
break;
default:
EXPECT_FALSE(GraphicsAllocation::is2MBPageAllocationType(allocType));
break;
}
}
}
TEST(GraphicsAllocationTest, givenNumMemoryBanksWhenGettingNumHandlesForKmdSharedAllocationThenReturnCorrectValue) {
DebugManagerStateRestore restore;