mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Fix printf allocation access mode
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com> Use BCS if CPU access for local memory allocation is not allowed
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
03e617d14f
commit
c13889c31b
@ -86,15 +86,20 @@ void PrintfHandler::makeResident(CommandStreamReceiver &commandStreamReceiver) {
|
||||
}
|
||||
|
||||
void PrintfHandler::printEnqueueOutput() {
|
||||
auto &hwInfo = device.getHardwareInfo();
|
||||
|
||||
auto usesStringMap = kernel->getDescriptor().kernelAttributes.flags.usesStringMapForPrintf || nullptr != kernel->getImplicitArgs();
|
||||
const auto &hwInfoConfig = *HwInfoConfig::get(device.getHardwareInfo().platform.eProductFamily);
|
||||
const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
|
||||
auto printfOutputBuffer = reinterpret_cast<const uint8_t *>(printfSurface->getUnderlyingBuffer());
|
||||
auto printfOutputSize = static_cast<uint32_t>(printfSurface->getUnderlyingBufferSize());
|
||||
std::unique_ptr<uint8_t[]> printfOutputDecompressed;
|
||||
if (hwInfoConfig.allowStatelessCompression(device.getHardwareInfo())) {
|
||||
|
||||
auto &helper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
|
||||
if (hwInfoConfig.allowStatelessCompression(hwInfo) || helper.isBlitCopyRequiredForLocalMemory(hwInfo, *printfSurface)) {
|
||||
printfOutputDecompressed = std::make_unique<uint8_t[]>(printfOutputSize);
|
||||
printfOutputBuffer = printfOutputDecompressed.get();
|
||||
auto &bcsEngine = device.getEngine(EngineHelpers::getBcsEngineType(device.getHardwareInfo(), device.getDeviceBitfield(), device.getSelectorCopyEngine(), true), EngineUsage::Regular);
|
||||
auto &bcsEngine = device.getEngine(EngineHelpers::getBcsEngineType(hwInfo, device.getDeviceBitfield(), device.getSelectorCopyEngine(), true), EngineUsage::Regular);
|
||||
|
||||
BlitPropertiesContainer blitPropertiesContainer;
|
||||
blitPropertiesContainer.push_back(
|
||||
|
@ -160,6 +160,57 @@ HWTEST_F(PrintfHandlerTests, givenEnabledStatelessCompressionWhenPrintEnqueueOut
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(PrintfHandlerTests, givenDisallowedLocalMemoryCpuAccessWhenPrintEnqueueOutputIsCalledThenBCSEngineIsUsedToCopyPrintfOutput) {
|
||||
HardwareInfo hwInfo = *defaultHwInfo;
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = true;
|
||||
REQUIRE_BLITTER_OR_SKIP(&hwInfo);
|
||||
|
||||
class MockPrintfHandler : public PrintfHandler {
|
||||
public:
|
||||
using PrintfHandler::PrintfHandler;
|
||||
using PrintfHandler::printfSurface;
|
||||
|
||||
MockPrintfHandler(ClDevice &device) : PrintfHandler(device) {}
|
||||
};
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::CpuAccessDisallowed));
|
||||
DebugManager.flags.EnableLocalMemory.set(1);
|
||||
|
||||
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
|
||||
MockContext context(device.get());
|
||||
|
||||
auto kernelInfo = std::make_unique<MockKernelInfo>();
|
||||
kernelInfo->setPrintfSurface(sizeof(uintptr_t), 0);
|
||||
|
||||
auto program = std::make_unique<MockProgram>(&context, false, toClDeviceVector(*device));
|
||||
|
||||
uint64_t crossThread[10]{};
|
||||
auto kernel = std::make_unique<MockKernel>(program.get(), *kernelInfo, *device);
|
||||
kernel->setCrossThreadData(&crossThread, sizeof(uint64_t) * 8);
|
||||
|
||||
MockMultiDispatchInfo multiDispatchInfo(device.get(), kernel.get());
|
||||
auto printfHandler = std::make_unique<MockPrintfHandler>(*device);
|
||||
|
||||
printfHandler->prepareDispatch(multiDispatchInfo);
|
||||
EXPECT_NE(nullptr, printfHandler->getSurface());
|
||||
|
||||
device->getMemoryManager()->freeGraphicsMemory(printfHandler->printfSurface);
|
||||
|
||||
auto allocation = new MockGraphicsAllocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
allocation->memoryPool = MemoryPool::LocalMemory;
|
||||
|
||||
printfHandler->printfSurface = allocation;
|
||||
|
||||
printfHandler->printEnqueueOutput();
|
||||
|
||||
auto &bcsEngine = device->getEngine(EngineHelpers::getBcsEngineType(device->getHardwareInfo(), device->getDeviceBitfield(), device->getSelectorCopyEngine(), true), EngineUsage::Regular);
|
||||
auto bcsCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(bcsEngine.commandStreamReceiver);
|
||||
|
||||
EXPECT_TRUE(bcsCsr->blitBufferCalled >= 1);
|
||||
EXPECT_EQ(BlitterConstants::BlitDirection::BufferToHostPtr, bcsCsr->receivedBlitProperties[0].blitDirection);
|
||||
}
|
||||
|
||||
HWTEST_F(PrintfHandlerTests, givenPrintfHandlerWhenEnqueueIsBlockedThenDontUsePrintfObjectAfterMove) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.MakeEachEnqueueBlocking.set(true);
|
||||
|
Reference in New Issue
Block a user