From 9eda8a1ffce1b0835c1e48ebdfde0a4de3c6c63d Mon Sep 17 00:00:00 2001 From: foreman Date: Fri, 8 Nov 2019 13:54:34 -0500 Subject: [PATCH] P4 to Git Change 2027470 by axie@axie-hip-rocm on 2019/11/08 13:48:51 SWDEV-198863 - Options for hip-clang-vdi path to provide the chicken bits, or functional equivalents to HCC_DB (phase 3) Use ClPrint to implement other log functions. Move some funtion to use new log functions. This is the final change of the JIRA. Tests: 1. Linux HIP ROCM platform. VEGA10. Driver is release build. 1.1 export LOG_LEVEL=3 ./hipModule There are many logs. 1.2 export GPU_LOG_MASK=0 ./hipModule There is no log 2. Windows HIP PAL platform. VEGA10, Driver is release build. 2.1 set LOG_LEVEL=3 run test hipPrintfKernel There are many logs 2.2 set GPU_LOG_MASK=0 run test hipPrintfKernel There is no log 3. http://ocltc.amd.com:8111/viewModification.html?modId=128588&personal=true&tab=vcsModificationBuilds ReviewBoard: http://ocltc.amd.com/reviews/r/18259/ Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#177 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#157 edit ... //depot/stg/opencl/drivers/opencl/runtime/utils/debug.cpp#6 edit ... //depot/stg/opencl/drivers/opencl/runtime/utils/debug.hpp#14 edit [ROCm/clr commit: 1f0d5016ed15808e6ac846914163ef94ee7582a1] --- .../rocclr/runtime/device/pal/paldevice.cpp | 2 +- .../rocclr/runtime/device/pal/palvirtual.cpp | 12 ++++----- projects/clr/rocclr/runtime/utils/debug.cpp | 4 +-- projects/clr/rocclr/runtime/utils/debug.hpp | 27 +++++++++++-------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp index 21ce72d743..22f9a3656d 100644 --- a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp +++ b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp @@ -1022,7 +1022,7 @@ bool Device::create(Pal::IDevice* device) { } message << std::endl; - LogInfo(message.str().c_str()); + ClPrint(amd::LOG_INFO, amd::LOG_INIT, message.str().c_str()); #endif // DEBUG for (uint i = 0; i < Pal::GpuHeap::GpuHeapCount; ++i) { diff --git a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp index da8a617cb1..c77a38b55d 100644 --- a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp +++ b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp @@ -2392,7 +2392,7 @@ bool VirtualGPU::submitKernelInternal(const amd::NDRangeContainer& sizes, const } size_t ldsSize; - LogPrintfInfo("!\tShaderName : %s\n", hsaKernel.name().c_str()); + ClPrint(amd::LOG_INFO, amd::LOG_KERN, "!\tShaderName : %s\n", hsaKernel.name().c_str()); // Check memory dependency and SVM objects if (!processMemObjectsHSA(kernel, parameters, nativeMem, ldsSize)) { @@ -3381,11 +3381,11 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p addVmMemory(gpuMem); const void* globalAddress = *reinterpret_cast(params + desc.offset_); - LogPrintfInfo("!\targ%d: %s %s = ptr:%p obj:[%p-%p] threadId : %zx\n", index, - desc.typeName_.c_str(), desc.name_.c_str(), globalAddress, - reinterpret_cast(gpuMem->vmAddress()), - reinterpret_cast(gpuMem->vmAddress() + gpuMem->size()), - std::this_thread::get_id()); + ClPrint(amd::LOG_INFO, amd::LOG_KERN, "!\targ%d: %s %s = ptr:%p obj:[%p-%p] threadId : %zx\n", index, + desc.typeName_.c_str(), desc.name_.c_str(), globalAddress, + reinterpret_cast(gpuMem->vmAddress()), + reinterpret_cast(gpuMem->vmAddress() + gpuMem->size()), + std::this_thread::get_id()); //! Check if compiler expects read/write. //! Note: SVM with subbuffers has an issue with tracking. diff --git a/projects/clr/rocclr/runtime/utils/debug.cpp b/projects/clr/rocclr/runtime/utils/debug.cpp index 4dd502070f..3d6b70540e 100644 --- a/projects/clr/rocclr/runtime/utils/debug.cpp +++ b/projects/clr/rocclr/runtime/utils/debug.cpp @@ -68,8 +68,8 @@ void log_printf(LogLevel level, const char* file, int line, const char* format, va_list ap; va_start(ap, format); - char message[1024]; - vsprintf(message, format, ap); + char message[4096]; + vsnprintf(message, sizeof(message), format, ap); va_end(ap); fprintf(stderr, ":%d:%s:%d: %s\n", level, file, line, message); diff --git a/projects/clr/rocclr/runtime/utils/debug.hpp b/projects/clr/rocclr/runtime/utils/debug.hpp index d025bdb983..cd7d5db5cd 100644 --- a/projects/clr/rocclr/runtime/utils/debug.hpp +++ b/projects/clr/rocclr/runtime/utils/debug.hpp @@ -142,21 +142,18 @@ inline void warning(const char* msg) { amd::report_warning(msg); } } \ } while (false) -#define LogInfo(msg) Log(amd::LOG_INFO, msg) -#define LogError(msg) Log(amd::LOG_ERROR, msg) -#define LogWarning(msg) Log(amd::LOG_WARNING, msg) #define LogTSInfo(msg) LogTS(amd::LOG_INFO, msg) #define LogTSError(msg) LogTS(amd::LOG_ERROR, msg) #define LogTSWarning(msg) LogTS(amd::LOG_WARNING, msg) -#define LogPrintfDebug(format, ...) Logf(amd::LOG_DEBUG, format, __VA_ARGS__) -#define LogPrintfError(format, ...) Logf(amd::LOG_ERROR, format, __VA_ARGS__) -#define LogPrintfWarning(format, ...) Logf(amd::LOG_WARNING, format, __VA_ARGS__) -#define LogPrintfInfo(format, ...) Logf(amd::LOG_INFO, format, __VA_ARGS__) - #define DebugInfoGuarantee(cond) LogGuarantee(cond, amd::LOG_INFO, "Warning") +/* backend and compiler use LOG_LEVEL macro from makefile. Define GPU_LOG_MASK for them. */ +#if defined(LOG_LEVEL) +#define GPU_LOG_MASK 0x7FFFFFFF +#endif + // You may define CL_LOG to enable following log functions even for release build #define CL_LOG @@ -179,12 +176,20 @@ inline void warning(const char* msg) { amd::report_warning(msg); } } \ } while (false) -#define ClTrace(level, mask) ClPrint(level, mask, "%s", __func__) - #else /*CL_LOG*/ #define ClPrint(level, mask, format, ...) (void)(0) #define ClCondPrint(level, mask, condition, format, ...) (void)(0) -#define ClTrace(level, mask) (void)(0) #endif /*CL_LOG*/ +#define ClTrace(level, mask) ClPrint(level, mask, "%s", __func__) + +#define LogInfo(msg) ClPrint(amd::LOG_INFO, amd::LOG_ALWAYS, msg) +#define LogError(msg) ClPrint(amd::LOG_ERROR, amd::LOG_ALWAYS, msg) +#define LogWarning(msg) ClPrint(amd::LOG_WARNING, amd::LOG_ALWAYS, msg) + +#define LogPrintfDebug(format, ...) ClPrint(amd::LOG_DEBUG, amd::LOG_ALWAYS, format, __VA_ARGS__) +#define LogPrintfError(format, ...) ClPrint(amd::LOG_ERROR, amd::LOG_ALWAYS, format, __VA_ARGS__) +#define LogPrintfWarning(format, ...) ClPrint(amd::LOG_WARNING, amd::LOG_ALWAYS, format, __VA_ARGS__) +#define LogPrintfInfo(format, ...) ClPrint(amd::LOG_INFO, amd::LOG_ALWAYS, format, __VA_ARGS__) + #endif /*DEBUG_HPP_*/