1 // SPDX-License-Identifier: MIT 2 // 3 // Copyright 2024 Advanced Micro Devices, Inc. 4 5 #ifndef __DML2_DEBUG_H__ 6 #define __DML2_DEBUG_H__ 7 8 #ifndef DML2_ASSERT 9 #define DML2_ASSERT(condition) ((void)0) 10 #endif 11 12 /* 13 * DML_LOG_FATAL - fatal errors for unrecoverable DML states until a restart. 14 * DML_LOG_ERROR - unexpected but recoverable failures inside DML 15 * DML_LOG_WARN - unexpected inputs or events to DML 16 * DML_LOG_INFO - high level tracing of DML interfaces 17 * DML_LOG_DEBUG - detailed tracing of DML internal components 18 * DML_LOG_VERBOSE - detailed tracing of DML calculation procedure 19 */ 20 #if !defined(DML_LOG_LEVEL) 21 #if defined(_DEBUG) && defined(_DEBUG_PRINTS) 22 /* for backward compatibility with old macros */ 23 #define DML_LOG_LEVEL 5 24 #else 25 #define DML_LOG_LEVEL 0 26 #endif 27 #endif 28 29 #define DML_LOG_FATAL(fmt, ...) dml2_log_internal(fmt, ## __VA_ARGS__) 30 #if DML_LOG_LEVEL >= 1 31 #define DML_LOG_ERROR(fmt, ...) dml2_log_internal(fmt, ## __VA_ARGS__) 32 #else 33 #define DML_LOG_ERROR(fmt, ...) ((void)0) 34 #endif 35 #if DML_LOG_LEVEL >= 2 36 #define DML_LOG_WARN(fmt, ...) dml2_log_internal(fmt, ## __VA_ARGS__) 37 #else 38 #define DML_LOG_WARN(fmt, ...) ((void)0) 39 #endif 40 #if DML_LOG_LEVEL >= 3 41 #define DML_LOG_INFO(fmt, ...) dml2_log_internal(fmt, ## __VA_ARGS__) 42 #else 43 #define DML_LOG_INFO(fmt, ...) ((void)0) 44 #endif 45 #if DML_LOG_LEVEL >= 4 46 #define DML_LOG_DEBUG(fmt, ...) dml2_log_internal(fmt, ## __VA_ARGS__) 47 #else 48 #define DML_LOG_DEBUG(fmt, ...) ((void)0) 49 #endif 50 #if DML_LOG_LEVEL >= 5 51 #define DML_LOG_VERBOSE(fmt, ...) dml2_log_internal(fmt, ## __VA_ARGS__) 52 #else 53 #define DML_LOG_VERBOSE(fmt, ...) ((void)0) 54 #endif 55 56 int dml2_log_internal(const char *format, ...); 57 int dml2_printf(const char *format, ...); 58 59 #endif 60