From 55bd5444024a7a001a3ffbe6ed311ad3a38df397 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Fri, 25 Sep 2020 11:24:15 +0200 Subject: [PATCH] Lazy evaluate arguments of printDebugStrings(...) function Change-Id: Ie44e109fd9235c5df32fb90b9e6fc6058e558a99 Signed-off-by: Bartosz Dunajski --- .../core/source/debugger/debugger_l0.cpp | 14 ++++++------ .../core/source/debugger/debugger_l0.inl | 12 +++++----- level_zero/core/source/module/module_imp.cpp | 8 +++---- level_zero/tools/source/metrics/metric.cpp | 4 ++-- .../source/metrics/metric_enumeration_imp.cpp | 2 +- .../tools/source/metrics/metric_query_imp.cpp | 2 +- level_zero/tools/source/pin/pin.cpp | 6 ++--- opencl/source/cl_device/cl_device_caps.cpp | 14 ++++++------ opencl/source/command_queue/enqueue_common.h | 2 +- opencl/source/helpers/dispatch_info_builder.h | 22 +++++++++---------- opencl/source/mem_obj/buffer.cpp | 6 ++--- .../source/program/process_device_binary.cpp | 4 ++-- opencl/source/program/program.cpp | 4 ++-- opencl/source/scheduler/scheduler_kernel.cpp | 2 +- .../utilities/debug_settings_reader_tests.cpp | 4 ++-- .../command_stream_receiver_hw_base.inl | 10 ++++----- .../experimental_command_buffer.cpp | 2 +- shared/source/command_stream/preemption.cpp | 4 ++-- .../debug_settings/debug_settings_manager.cpp | 2 +- .../debug_settings/debug_settings_manager.h | 4 ++++ .../patchtokens_decoder.cpp | 4 ++-- .../os_interface/linux/drm_buffer_object.cpp | 12 +++++----- .../os_interface/linux/drm_memory_manager.cpp | 4 ++-- shared/source/os_interface/linux/drm_neo.cpp | 12 +++++----- .../os_interface/linux/hw_info_config.cpp | 6 ++--- .../source/os_interface/windows/wddm/wddm.cpp | 6 ++--- 26 files changed, 88 insertions(+), 84 deletions(-) diff --git a/level_zero/core/source/debugger/debugger_l0.cpp b/level_zero/core/source/debugger/debugger_l0.cpp index 51d106cab4..de6703e2cb 100644 --- a/level_zero/core/source/debugger/debugger_l0.cpp +++ b/level_zero/core/source/debugger/debugger_l0.cpp @@ -52,12 +52,12 @@ void DebuggerL0::printTrackedAddresses(uint32_t contextId) { auto memory = perContextSbaAllocations[contextId]->getUnderlyingBuffer(); auto sba = reinterpret_cast(memory); - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stdout, - "Debugger: SBA ssh = %" SCNx64 - " gsba = %" SCNx64 - " bsurfsba = %" SCNx64 "\n", - sba->SurfaceStateBaseAddress, sba->GeneralStateBaseAddress, - sba->BindlessSurfaceStateBaseAddress); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stdout, + "Debugger: SBA ssh = %" SCNx64 + " gsba = %" SCNx64 + " bsurfsba = %" SCNx64 "\n", + sba->SurfaceStateBaseAddress, sba->GeneralStateBaseAddress, + sba->BindlessSurfaceStateBaseAddress); } DebuggerL0 ::~DebuggerL0() { @@ -77,4 +77,4 @@ void DebuggerL0::captureStateBaseAddress(NEO::CommandContainer &container, SbaAd } } -} // namespace L0 \ No newline at end of file +} // namespace L0 diff --git a/level_zero/core/source/debugger/debugger_l0.inl b/level_zero/core/source/debugger/debugger_l0.inl index 00c0d81491..b9d2cc1cac 100644 --- a/level_zero/core/source/debugger/debugger_l0.inl +++ b/level_zero/core/source/debugger/debugger_l0.inl @@ -25,12 +25,12 @@ void DebuggerL0Hw::programSbaTrackingCommands(NEO::LinearStream &cmdS using MI_STORE_DATA_IMM = typename GfxFamily::MI_STORE_DATA_IMM; auto gpuAddress = NEO::GmmHelper::decanonize(sbaTrackingGpuVa.address); - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stdout, - "Debugger: SBA stored ssh = %" SCNx64 - " gsba = %" SCNx64 - " bsurfsba = %" SCNx64 "\n", - sba.SurfaceStateBaseAddress, sba.GeneralStateBaseAddress, - sba.BindlessSurfaceStateBaseAddress); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stdout, + "Debugger: SBA stored ssh = %" SCNx64 + " gsba = %" SCNx64 + " bsurfsba = %" SCNx64 "\n", + sba.SurfaceStateBaseAddress, sba.GeneralStateBaseAddress, + sba.BindlessSurfaceStateBaseAddress); if (sba.GeneralStateBaseAddress) { MI_STORE_DATA_IMM storeDataImmediate = GfxFamily::cmdInitStoreDataImm; diff --git a/level_zero/core/source/module/module_imp.cpp b/level_zero/core/source/module/module_imp.cpp index 52955feb18..5d722e8c3c 100644 --- a/level_zero/core/source/module/module_imp.cpp +++ b/level_zero/core/source/module/module_imp.cpp @@ -127,11 +127,11 @@ bool ModuleTranslationUnit::createFromNativeBinary(const char *input, size_t inp auto singleDeviceBinary = unpackSingleDeviceBinary(archive, NEO::ConstStringRef(productAbbreviation, strlen(productAbbreviation)), targetDevice, decodeErrors, decodeWarnings); if (decodeWarnings.empty() == false) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeWarnings.c_str()); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeWarnings.c_str()); } if (singleDeviceBinary.intermediateRepresentation.empty() && singleDeviceBinary.deviceBinary.empty()) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeErrors.c_str()); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeErrors.c_str()); return false; } else { this->irBinary = makeCopy(reinterpret_cast(singleDeviceBinary.intermediateRepresentation.begin()), singleDeviceBinary.intermediateRepresentation.size()); @@ -172,11 +172,11 @@ bool ModuleTranslationUnit::processUnpackedBinary() { NEO::DeviceBinaryFormat singleDeviceBinaryFormat; std::tie(decodeError, singleDeviceBinaryFormat) = NEO::decodeSingleDeviceBinary(programInfo, binary, decodeErrors, decodeWarnings); if (decodeWarnings.empty() == false) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeWarnings.c_str()); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeWarnings.c_str()); } if (NEO::DecodeError::Success != decodeError) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeErrors.c_str()); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeErrors.c_str()); return false; } diff --git a/level_zero/tools/source/metrics/metric.cpp b/level_zero/tools/source/metrics/metric.cpp index 566ec130a6..10320efd73 100644 --- a/level_zero/tools/source/metrics/metric.cpp +++ b/level_zero/tools/source/metrics/metric.cpp @@ -210,14 +210,14 @@ bool MetricContext::isMetricApiAvailable() { // Check Metrics Discovery availability. library.reset(NEO::OsLibrary::load(MetricEnumeration::getMetricsDiscoveryFilename())); if (library == nullptr) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find metrics discovery %s\n", MetricEnumeration::getMetricsDiscoveryFilename()); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find metrics discovery %s\n", MetricEnumeration::getMetricsDiscoveryFilename()); return false; } // Check Metrics Library availability. library.reset(NEO::OsLibrary::load(MetricsLibrary::getFilename())); if (library == nullptr) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find metrics library %s\n", MetricsLibrary::getFilename()); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find metrics library %s\n", MetricsLibrary::getFilename()); return false; } diff --git a/level_zero/tools/source/metrics/metric_enumeration_imp.cpp b/level_zero/tools/source/metrics/metric_enumeration_imp.cpp index e34ca72ef3..2899056170 100644 --- a/level_zero/tools/source/metrics/metric_enumeration_imp.cpp +++ b/level_zero/tools/source/metrics/metric_enumeration_imp.cpp @@ -91,7 +91,7 @@ ze_result_t MetricEnumeration::loadMetricsDiscovery() { if (openMetricsDevice == nullptr || closeMetricsDevice == nullptr || openMetricsDeviceFromFile == nullptr) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "cannot load %s exported functions\n", MetricEnumeration::getMetricsDiscoveryFilename()); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "cannot load %s exported functions\n", MetricEnumeration::getMetricsDiscoveryFilename()); cleanupMetricsDiscovery(); return ZE_RESULT_ERROR_UNKNOWN; } diff --git a/level_zero/tools/source/metrics/metric_query_imp.cpp b/level_zero/tools/source/metrics/metric_query_imp.cpp index 4a2bf490fc..9033267b76 100644 --- a/level_zero/tools/source/metrics/metric_query_imp.cpp +++ b/level_zero/tools/source/metrics/metric_query_imp.cpp @@ -192,7 +192,7 @@ bool MetricsLibrary::load() { } if (contextCreateFunction == nullptr || contextDeleteFunction == nullptr) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "cannot load %s exported functions\n", MetricsLibrary::getFilename()); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "cannot load %s exported functions\n", MetricsLibrary::getFilename()); return false; } diff --git a/level_zero/tools/source/pin/pin.cpp b/level_zero/tools/source/pin/pin.cpp index b0b9e74e08..5620997bb5 100644 --- a/level_zero/tools/source/pin/pin.cpp +++ b/level_zero/tools/source/pin/pin.cpp @@ -23,21 +23,21 @@ ze_result_t PinContext::init() { hGtPinLibrary.reset(NEO::OsLibrary::load(gtPinLibraryFilename.c_str())); if (hGtPinLibrary.get() == nullptr) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find gtpin library %s\n", gtPinLibraryFilename.c_str()); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find gtpin library %s\n", gtPinLibraryFilename.c_str()); return ZE_RESULT_ERROR_UNKNOWN; } OpenGTPin_fn openGTPin = reinterpret_cast(hGtPinLibrary.get()->getProcAddress(gtPinOpenFunctionName.c_str())); if (openGTPin == nullptr) { hGtPinLibrary.reset(nullptr); - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find gtpin library open function symbol %s\n", gtPinOpenFunctionName.c_str()); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find gtpin library open function symbol %s\n", gtPinOpenFunctionName.c_str()); return ZE_RESULT_ERROR_UNKNOWN; } uint32_t openResult = openGTPin(nullptr); if (openResult != 0) { hGtPinLibrary.reset(nullptr); - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "gtpin library open %s failed with status %u\n", gtPinOpenFunctionName.c_str(), openResult); + PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "gtpin library open %s failed with status %u\n", gtPinOpenFunctionName.c_str(), openResult); return ZE_RESULT_ERROR_UNKNOWN; } diff --git a/opencl/source/cl_device/cl_device_caps.cpp b/opencl/source/cl_device/cl_device_caps.cpp index 04df497425..1680aba245 100644 --- a/opencl/source/cl_device/cl_device_caps.cpp +++ b/opencl/source/cl_device/cl_device_caps.cpp @@ -302,14 +302,14 @@ void ClDevice::initializeCaps() { deviceInfo.halfFpConfig = defaultFpFlags; - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "computeUnitsUsedForScratch: %d\n", sharedDeviceInfo.computeUnitsUsedForScratch); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "computeUnitsUsedForScratch: %d\n", sharedDeviceInfo.computeUnitsUsedForScratch); - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "hwInfo: {%d, %d}: (%d, %d, %d)\n", - systemInfo.EUCount, - systemInfo.ThreadCount, - systemInfo.MaxEuPerSubSlice, - systemInfo.MaxSlicesSupported, - systemInfo.MaxSubSlicesSupported); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "hwInfo: {%d, %d}: (%d, %d, %d)\n", + systemInfo.EUCount, + systemInfo.ThreadCount, + systemInfo.MaxEuPerSubSlice, + systemInfo.MaxSlicesSupported, + systemInfo.MaxSubSlicesSupported); deviceInfo.localMemType = CL_LOCAL; diff --git a/opencl/source/command_queue/enqueue_common.h b/opencl/source/command_queue/enqueue_common.h index 5fd85d976b..9cd1ca3695 100644 --- a/opencl/source/command_queue/enqueue_common.h +++ b/opencl/source/command_queue/enqueue_common.h @@ -783,7 +783,7 @@ CompletionStamp CommandQueueHw::enqueueNonBlocked( dispatchFlags.implicitFlush = true; } - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stdout, "preemption = %d.\n", static_cast(dispatchFlags.preemptionMode)); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stdout, "preemption = %d.\n", static_cast(dispatchFlags.preemptionMode)); CompletionStamp completionStamp = getGpgpuCommandStreamReceiver().flushTask( commandStream, commandStreamStart, diff --git a/opencl/source/helpers/dispatch_info_builder.h b/opencl/source/helpers/dispatch_info_builder.h index c24ef3a0a7..bb9e3c2498 100644 --- a/opencl/source/helpers/dispatch_info_builder.h +++ b/opencl/source/helpers/dispatch_info_builder.h @@ -268,17 +268,17 @@ class DispatchInfoBuilder { pushSplit(dispatchInfo, target); } else { target.push(dispatchInfo); - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stdout, - "DIM:%u\tGWS:(%zu, %zu, %zu)\tELWS:(%zu, %zu, %zu)\tOffset:(%zu, %zu, %zu)\tAGWS:(%zu, %zu, %zu)\tLWS:(%zu, %zu, %zu)\tTWGS:(%zu, %zu, %zu)\tNWGS:(%zu, %zu, %zu)\tSWGS:(%zu, %zu, %zu)\n", - dispatchInfo.getDim(), - dispatchInfo.getGWS().x, dispatchInfo.getGWS().y, dispatchInfo.getGWS().z, - dispatchInfo.getEnqueuedWorkgroupSize().x, dispatchInfo.getEnqueuedWorkgroupSize().y, dispatchInfo.getEnqueuedWorkgroupSize().z, - dispatchInfo.getOffset().x, dispatchInfo.getOffset().y, dispatchInfo.getOffset().z, - dispatchInfo.getActualWorkgroupSize().x, dispatchInfo.getActualWorkgroupSize().y, dispatchInfo.getActualWorkgroupSize().z, - dispatchInfo.getLocalWorkgroupSize().x, dispatchInfo.getLocalWorkgroupSize().y, dispatchInfo.getLocalWorkgroupSize().z, - dispatchInfo.getTotalNumberOfWorkgroups().x, dispatchInfo.getTotalNumberOfWorkgroups().y, dispatchInfo.getTotalNumberOfWorkgroups().z, - dispatchInfo.getNumberOfWorkgroups().x, dispatchInfo.getNumberOfWorkgroups().y, dispatchInfo.getNumberOfWorkgroups().z, - dispatchInfo.getStartOfWorkgroups().x, dispatchInfo.getStartOfWorkgroups().y, dispatchInfo.getStartOfWorkgroups().z); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stdout, + "DIM:%u\tGWS:(%zu, %zu, %zu)\tELWS:(%zu, %zu, %zu)\tOffset:(%zu, %zu, %zu)\tAGWS:(%zu, %zu, %zu)\tLWS:(%zu, %zu, %zu)\tTWGS:(%zu, %zu, %zu)\tNWGS:(%zu, %zu, %zu)\tSWGS:(%zu, %zu, %zu)\n", + dispatchInfo.getDim(), + dispatchInfo.getGWS().x, dispatchInfo.getGWS().y, dispatchInfo.getGWS().z, + dispatchInfo.getEnqueuedWorkgroupSize().x, dispatchInfo.getEnqueuedWorkgroupSize().y, dispatchInfo.getEnqueuedWorkgroupSize().z, + dispatchInfo.getOffset().x, dispatchInfo.getOffset().y, dispatchInfo.getOffset().z, + dispatchInfo.getActualWorkgroupSize().x, dispatchInfo.getActualWorkgroupSize().y, dispatchInfo.getActualWorkgroupSize().z, + dispatchInfo.getLocalWorkgroupSize().x, dispatchInfo.getLocalWorkgroupSize().y, dispatchInfo.getLocalWorkgroupSize().z, + dispatchInfo.getTotalNumberOfWorkgroups().x, dispatchInfo.getTotalNumberOfWorkgroups().y, dispatchInfo.getTotalNumberOfWorkgroups().z, + dispatchInfo.getNumberOfWorkgroups().x, dispatchInfo.getNumberOfWorkgroups().y, dispatchInfo.getNumberOfWorkgroups().z, + dispatchInfo.getStartOfWorkgroups().x, dispatchInfo.getStartOfWorkgroups().y, dispatchInfo.getStartOfWorkgroups().z); } } } diff --git a/opencl/source/mem_obj/buffer.cpp b/opencl/source/mem_obj/buffer.cpp index 3e87c5cd6e..e843ba73fa 100644 --- a/opencl/source/mem_obj/buffer.cpp +++ b/opencl/source/mem_obj/buffer.cpp @@ -316,9 +316,9 @@ Buffer *Buffer::create(Context *context, return nullptr; } - printDebugString(DebugManager.flags.LogMemoryObject.get(), stdout, - "\nCreated Buffer: Handle %p, hostPtr %p, size %llu, memoryStorage %p, GPU address %#llx, memoryPool:%du\n", - pBuffer, hostPtr, size, memory->getUnderlyingBuffer(), memory->getGpuAddress(), memory->getMemoryPool()); + PRINT_DEBUG_STRING(DebugManager.flags.LogMemoryObject.get(), stdout, + "\nCreated Buffer: Handle %p, hostPtr %p, size %llu, memoryStorage %p, GPU address %#llx, memoryPool:%du\n", + pBuffer, hostPtr, size, memory->getUnderlyingBuffer(), memory->getGpuAddress(), memory->getMemoryPool()); if (memoryProperties.flags.useHostPtr) { if (!zeroCopyAllowed && !isHostPtrSVM) { diff --git a/opencl/source/program/process_device_binary.cpp b/opencl/source/program/process_device_binary.cpp index 4cf2157d47..ebf77a6536 100644 --- a/opencl/source/program/process_device_binary.cpp +++ b/opencl/source/program/process_device_binary.cpp @@ -146,11 +146,11 @@ cl_int Program::processGenBinary() { DeviceBinaryFormat singleDeviceBinaryFormat; std::tie(decodeError, singleDeviceBinaryFormat) = NEO::decodeSingleDeviceBinary(programInfo, binary, decodeErrors, decodeWarnings); if (decodeWarnings.empty() == false) { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeWarnings.c_str()); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeWarnings.c_str()); } if (DecodeError::Success != decodeError) { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeErrors.c_str()); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeErrors.c_str()); return CL_INVALID_BINARY; } diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index a28a27b0ff..58f9baa0b4 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -177,12 +177,12 @@ cl_int Program::createProgramFromBinary( auto singleDeviceBinary = unpackSingleDeviceBinary(archive, ConstStringRef(productAbbreviation, strlen(productAbbreviation)), targetDevice, decodeErrors, decodeWarnings); if (decodeWarnings.empty() == false) { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeWarnings.c_str()); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeWarnings.c_str()); } if (singleDeviceBinary.intermediateRepresentation.empty() && singleDeviceBinary.deviceBinary.empty()) { retVal = CL_INVALID_BINARY; - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeErrors.c_str()); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s\n", decodeErrors.c_str()); } else { retVal = CL_SUCCESS; this->irBinary = makeCopy(reinterpret_cast(singleDeviceBinary.intermediateRepresentation.begin()), singleDeviceBinary.intermediateRepresentation.size()); diff --git a/opencl/source/scheduler/scheduler_kernel.cpp b/opencl/source/scheduler/scheduler_kernel.cpp index ea0b63921a..b0f4ff5bf8 100644 --- a/opencl/source/scheduler/scheduler_kernel.cpp +++ b/opencl/source/scheduler/scheduler_kernel.cpp @@ -62,7 +62,7 @@ void SchedulerKernel::computeGws() { } DBG_LOG(PrintEMDebugInformation, "Scheduler GWS: ", gws); - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "Scheduler GWS: %" PRIu64, static_cast(gws)); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "Scheduler GWS: %" PRIu64, static_cast(gws)); } BuiltinCode SchedulerKernel::loadSchedulerKernel(Device *device) { std::string schedulerResourceName = getFamilyNameWithType(device->getHardwareInfo()) + "_0_scheduler.builtin_kernel.bin"; diff --git a/opencl/test/unit_test/utilities/debug_settings_reader_tests.cpp b/opencl/test/unit_test/utilities/debug_settings_reader_tests.cpp index bdc60c37e4..185ac2fe7b 100644 --- a/opencl/test/unit_test/utilities/debug_settings_reader_tests.cpp +++ b/opencl/test/unit_test/utilities/debug_settings_reader_tests.cpp @@ -89,7 +89,7 @@ TEST(SettingsReader, GivenRegKeyWhenCreatingOsReaderThenReaderIsCreated) { TEST(SettingsReader, GivenTrueWhenPrintingDebugStringThenPrintsToOutput) { int i = 4; testing::internal::CaptureStdout(); - printDebugString(true, stdout, "testing error %d", i); + PRINT_DEBUG_STRING(true, stdout, "testing error %d", i); std::string output = testing::internal::GetCapturedStdout(); EXPECT_STRNE(output.c_str(), ""); } @@ -97,7 +97,7 @@ TEST(SettingsReader, GivenTrueWhenPrintingDebugStringThenPrintsToOutput) { TEST(SettingsReader, GivenFalseWhenPrintingDebugStringThenNoOutput) { int i = 4; testing::internal::CaptureStdout(); - printDebugString(false, stderr, "Error String %d", i); + PRINT_DEBUG_STRING(false, stderr, "Error String %d", i); std::string output = testing::internal::GetCapturedStdout(); EXPECT_STREQ(output.c_str(), ""); } diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index 1f6fe28dc2..95b4a5cb99 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -808,9 +808,9 @@ inline void CommandStreamReceiverHw::waitForTaskCountWithKmdNotifyFal int64_t waitTimeout = 0; bool enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode); - printDebugString(DebugManager.flags.LogWaitingForCompletion.get(), stdout, - "\nWaiting for task count %u at location %p. Current value: %u\n", - taskCountToWait, getTagAddress(), *getTagAddress()); + PRINT_DEBUG_STRING(DebugManager.flags.LogWaitingForCompletion.get(), stdout, + "\nWaiting for task count %u at location %p. Current value: %u\n", + taskCountToWait, getTagAddress(), *getTagAddress()); auto status = waitForCompletionWithTimeout(enableTimeout, waitTimeout, taskCountToWait); if (!status) { @@ -824,8 +824,8 @@ inline void CommandStreamReceiverHw::waitForTaskCountWithKmdNotifyFal kmdNotifyHelper->updateLastWaitForCompletionTimestamp(); } - printDebugString(DebugManager.flags.LogWaitingForCompletion.get(), stdout, - "\nWaiting completed. Current value: %u\n", *getTagAddress()); + PRINT_DEBUG_STRING(DebugManager.flags.LogWaitingForCompletion.get(), stdout, + "\nWaiting completed. Current value: %u\n", *getTagAddress()); } template diff --git a/shared/source/command_stream/experimental_command_buffer.cpp b/shared/source/command_stream/experimental_command_buffer.cpp index 27e9e8e1bd..33b3fd755e 100644 --- a/shared/source/command_stream/experimental_command_buffer.cpp +++ b/shared/source/command_stream/experimental_command_buffer.cpp @@ -38,7 +38,7 @@ ExperimentalCommandBuffer::~ExperimentalCommandBuffer() { auto stop = static_cast(*(timestamp + 1) * timerResolution); auto start = static_cast(*timestamp * timerResolution); auto delta = stop - start; - printDebugString(defaultPrint, stdout, "#%u: delta %llu start %llu stop %llu\n", i, delta, start, stop); + PRINT_DEBUG_STRING(defaultPrint, stdout, "#%u: delta %llu start %llu stop %llu\n", i, delta, start, stop); timestamp += 2; } MemoryManager *memoryManager = commandStreamReceiver->getMemoryManager(); diff --git a/shared/source/command_stream/preemption.cpp b/shared/source/command_stream/preemption.cpp index b719281a9f..f0db6a1859 100644 --- a/shared/source/command_stream/preemption.cpp +++ b/shared/source/command_stream/preemption.cpp @@ -87,8 +87,8 @@ PreemptionMode PreemptionHelper::taskPreemptionMode(Device &device, const MultiD if (devMode > taskMode) { devMode = taskMode; } - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stdout, "devMode = %d, taskMode = %d.\n", - static_cast(device.getPreemptionMode()), static_cast(taskMode)); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stdout, "devMode = %d, taskMode = %d.\n", + static_cast(device.getPreemptionMode()), static_cast(taskMode)); } return devMode; } diff --git a/shared/source/debug_settings/debug_settings_manager.cpp b/shared/source/debug_settings/debug_settings_manager.cpp index 9656ec5c58..583af40417 100644 --- a/shared/source/debug_settings/debug_settings_manager.cpp +++ b/shared/source/debug_settings/debug_settings_manager.cpp @@ -58,7 +58,7 @@ template void DebugSettingsManager::dumpNonDefaultFlag(const char *variableName, const DataType &variableValue, const DataType &defaultValue) { if (variableValue != defaultValue) { const auto variableStringValue = std::to_string(variableValue); - printDebugString(true, stdout, "Non-default value of debug variable: %s = %s\n", variableName, variableStringValue.c_str()); + PRINT_DEBUG_STRING(true, stdout, "Non-default value of debug variable: %s = %s\n", variableName, variableStringValue.c_str()); } } diff --git a/shared/source/debug_settings/debug_settings_manager.h b/shared/source/debug_settings/debug_settings_manager.h index fcdb32a0ca..132030ed4c 100644 --- a/shared/source/debug_settings/debug_settings_manager.h +++ b/shared/source/debug_settings/debug_settings_manager.h @@ -28,6 +28,10 @@ constexpr DebugFunctionalityLevel globalDebugFunctionalityLevel = DebugFunctiona constexpr DebugFunctionalityLevel globalDebugFunctionalityLevel = DebugFunctionalityLevel::None; #endif +#define PRINT_DEBUG_STRING(flag, ...) \ + if (flag) \ + NEO::printDebugString(flag, __VA_ARGS__); + namespace NEO { template void printDebugString(bool showDebugLogs, Args &&... args) { diff --git a/shared/source/device_binary_format/patchtokens_decoder.cpp b/shared/source/device_binary_format/patchtokens_decoder.cpp index 6d977461b4..7bae539499 100644 --- a/shared/source/device_binary_format/patchtokens_decoder.cpp +++ b/shared/source/device_binary_format/patchtokens_decoder.cpp @@ -316,7 +316,7 @@ inline void decodeKernelDataParameterToken(const SPatchDataParameterBuffer *toke inline bool decodeToken(const SPatchItemHeader *token, KernelFromPatchtokens &out) { switch (token->Token) { default: { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "Unknown kernel-scope Patch Token: %d\n", token->Token); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "Unknown kernel-scope Patch Token: %d\n", token->Token); DEBUG_BREAK_IF(true); out.unhandledTokens.push_back(token); break; @@ -432,7 +432,7 @@ inline bool decodeToken(const SPatchItemHeader *token, ProgramFromPatchtokens &o auto &progTok = out.programScopeTokens; switch (token->Token) { default: { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "Unknown program-scope Patch Token: %d\n", token->Token); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "Unknown program-scope Patch Token: %d\n", token->Token); DEBUG_BREAK_IF(true); out.unhandledTokens.push_back(token); break; diff --git a/shared/source/os_interface/linux/drm_buffer_object.cpp b/shared/source/os_interface/linux/drm_buffer_object.cpp index 7eb5cc9fdc..309aea9a5c 100644 --- a/shared/source/os_interface/linux/drm_buffer_object.cpp +++ b/shared/source/os_interface/linux/drm_buffer_object.cpp @@ -55,12 +55,12 @@ bool BufferObject::close() { drm_gem_close close = {}; close.handle = this->handle; - printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Calling gem close on handle: BO-%d\n", this->handle); + PRINT_DEBUG_STRING(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Calling gem close on handle: BO-%d\n", this->handle); int ret = this->drm->ioctl(DRM_IOCTL_GEM_CLOSE, &close); if (ret != 0) { int err = errno; - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(GEM_CLOSE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err)); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(GEM_CLOSE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err)); DEBUG_BREAK_IF(true); return false; } @@ -78,7 +78,7 @@ int BufferObject::wait(int64_t timeoutNs) { int ret = this->drm->ioctl(DRM_IOCTL_I915_GEM_WAIT, &wait); if (ret != 0) { int err = errno; - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_WAIT) failed with %d. errno=%d(%s)\n", ret, err, strerror(err)); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_WAIT) failed with %d. errno=%d(%s)\n", ret, err, strerror(err)); } UNRECOVERABLE_IF(ret != 0); @@ -141,7 +141,7 @@ int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bo } int err = this->drm->getErrno(); - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_EXECBUFFER2) failed with %d. errno=%d(%s)\n", ret, err, strerror(err)); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_EXECBUFFER2) failed with %d. errno=%d(%s)\n", ret, err, strerror(err)); return err; } @@ -150,7 +150,7 @@ void BufferObject::bind(OsContext *osContext, uint32_t vmHandleId) { if (!this->bindInfo[contextId][vmHandleId]) { auto ret = this->drm->bindBufferObject(osContext, vmHandleId, this); auto err = this->drm->getErrno(); - printDebugString(DebugManager.flags.PrintBOBindingResult.get(), stderr, "bind BO-%d, range: %llx - %llx, size: %lld, result: %d, errno: %d(%s)\n", this->handle, this->gpuAddress, ptrOffset(this->gpuAddress, this->size), this->size, ret, err, strerror(err)); + PRINT_DEBUG_STRING(DebugManager.flags.PrintBOBindingResult.get(), stderr, "bind BO-%d, range: %llx - %llx, size: %lld, result: %d, errno: %d(%s)\n", this->handle, this->gpuAddress, ptrOffset(this->gpuAddress, this->size), this->size, ret, err, strerror(err)); UNRECOVERABLE_IF(ret != 0); this->bindInfo[contextId][vmHandleId] = true; } @@ -161,7 +161,7 @@ void BufferObject::unbind(OsContext *osContext, uint32_t vmHandleId) { if (this->bindInfo[contextId][vmHandleId]) { auto ret = this->drm->unbindBufferObject(osContext, vmHandleId, this); auto err = this->drm->getErrno(); - printDebugString(DebugManager.flags.PrintBOBindingResult.get(), stderr, "unbind BO-%d, range: %llx - %llx, size: %lld, result: %d, errno: %d(%s)\n", this->handle, this->gpuAddress, ptrOffset(this->gpuAddress, this->size), this->size, ret, err, strerror(err)); + PRINT_DEBUG_STRING(DebugManager.flags.PrintBOBindingResult.get(), stderr, "unbind BO-%d, range: %llx - %llx, size: %lld, result: %d, errno: %d(%s)\n", this->handle, this->gpuAddress, ptrOffset(this->gpuAddress, this->size), this->size, ret, err, strerror(err)); UNRECOVERABLE_IF(ret != 0); this->bindInfo[contextId][vmHandleId] = false; } diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 38b431c81a..b791fd8ca6 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -176,7 +176,7 @@ NEO::BufferObject *DrmMemoryManager::allocUserptr(uintptr_t address, size_t size return nullptr; } - printDebugString(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Created new BO with GEM_USERPTR, handle: BO-%d\n", userptr.handle); + PRINT_DEBUG_STRING(DebugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Created new BO with GEM_USERPTR, handle: BO-%d\n", userptr.handle); auto res = new (std::nothrow) BufferObject(&getDrm(rootDeviceIndex), userptr.handle, size, maxOsContextCount); if (!res) { @@ -550,7 +550,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o if (ret != 0) { int err = errno; - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(PRIME_FD_TO_HANDLE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err)); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(PRIME_FD_TO_HANDLE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err)); DEBUG_BREAK_IF(ret != 0); UNUSED_VARIABLE(ret); return nullptr; diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index fe53d86ed1..8bd3ce110b 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -83,9 +83,9 @@ int Drm::getParamIoctl(int param, int *dstValue) { int retVal = ioctl(DRM_IOCTL_I915_GETPARAM, &getParam); - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stdout, - "\nDRM_IOCTL_I915_GETPARAM: param: %s, output value: %d, retCode: %d\n", - IoctlHelper::getIoctlParamString(param), *getParam.value, retVal); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stdout, + "\nDRM_IOCTL_I915_GETPARAM: param: %s, output value: %d, retCode: %d\n", + IoctlHelper::getIoctlParamString(param), *getParam.value, retVal); return retVal; } @@ -287,19 +287,19 @@ int Drm::setupHardwareInfo(DeviceDescriptor *device, bool setupFeatureTableAndWo bool status = queryTopology(sliceTotal, subSliceTotal, euTotal); if (!status) { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n"); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n"); sliceTotal = hwInfo->gtSystemInfo.SliceCount; ret = getEuTotal(euTotal); if (ret != 0) { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n"); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n"); return ret; } ret = getSubsliceTotal(subSliceTotal); if (ret != 0) { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query subslice total parameter!\n"); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query subslice total parameter!\n"); return ret; } } diff --git a/shared/source/os_interface/linux/hw_info_config.cpp b/shared/source/os_interface/linux/hw_info_config.cpp index 9824f4d305..2b2788f260 100644 --- a/shared/source/os_interface/linux/hw_info_config.cpp +++ b/shared/source/os_interface/linux/hw_info_config.cpp @@ -97,20 +97,20 @@ int HwInfoConfig::configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *ou bool status = drm->queryTopology(sliceCount, subSliceCount, euCount); if (!status) { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n"); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n"); sliceCount = gtSystemInfo->SliceCount; ret = drm->getEuTotal(euCount); if (ret != 0) { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n"); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n"); *outHwInfo = {}; return ret; } ret = drm->getSubsliceTotal(subSliceCount); if (ret != 0) { - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query subslice total parameter!\n"); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query subslice total parameter!\n"); *outHwInfo = {}; return ret; } diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index e5f25ceeb3..54c449705d 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -780,9 +780,9 @@ bool Wddm::createContext(OsContextWin &osContext) { status = getGdi()->createContext(&CreateContext); osContext.setWddmContextHandle(CreateContext.hContext); - printDebugString(DebugManager.flags.PrintDebugMessages.get(), stdout, - "\nCreated Wddm context. Status: :%lu, engine: %u, contextId: %u, deviceBitfield: %lu \n", - status, osContext.getEngineType(), osContext.getContextId(), osContext.getDeviceBitfield().to_ulong()); + PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stdout, + "\nCreated Wddm context. Status: :%lu, engine: %u, contextId: %u, deviceBitfield: %lu \n", + status, osContext.getEngineType(), osContext.getContextId(), osContext.getDeviceBitfield().to_ulong()); return status == STATUS_SUCCESS; }