2018-09-24 16:06:59 -07:00
|
|
|
/*************************************************************************
|
2022-01-07 06:39:55 -08:00
|
|
|
* Copyright (c) 2015-2022, NVIDIA CORPORATION. All rights reserved.
|
2018-09-24 16:06:59 -07:00
|
|
|
*
|
|
|
|
|
* See LICENSE.txt for license information
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef NCCL_DEBUG_H_
|
|
|
|
|
#define NCCL_DEBUG_H_
|
|
|
|
|
|
2021-09-08 13:56:25 -07:00
|
|
|
#include "nccl_net.h"
|
2018-09-24 16:06:59 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <chrono>
|
2022-05-24 02:02:31 -07:00
|
|
|
#include <type_traits>
|
2018-09-24 16:06:59 -07:00
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
#include <string.h>
|
2021-09-08 13:56:25 -07:00
|
|
|
#include <pthread.h>
|
2018-09-24 16:06:59 -07:00
|
|
|
|
2022-01-07 06:39:55 -08:00
|
|
|
// Conform to pthread and NVTX standard
|
|
|
|
|
#define NCCL_THREAD_NAMELEN 16
|
|
|
|
|
|
2018-11-13 10:37:20 -08:00
|
|
|
extern int ncclDebugLevel;
|
2018-09-24 16:06:59 -07:00
|
|
|
extern uint64_t ncclDebugMask;
|
2022-05-24 02:02:31 -07:00
|
|
|
extern pthread_mutex_t ncclDebugLock;
|
2018-09-24 16:06:59 -07:00
|
|
|
extern FILE *ncclDebugFile;
|
2019-03-14 19:39:20 -07:00
|
|
|
extern ncclResult_t getHostName(char* hostname, int maxlen, const char delim);
|
2018-09-24 16:06:59 -07:00
|
|
|
|
2021-02-09 15:34:08 -08:00
|
|
|
void ncclDebugLog(ncclDebugLogLevel level, unsigned long flags, const char *filefunc, int line, const char *fmt, ...) __attribute__ ((format (printf, 5, 6)));
|
2019-11-19 14:57:39 -08:00
|
|
|
|
|
|
|
|
// Let code temporarily downgrade WARN into INFO
|
|
|
|
|
extern thread_local int ncclDebugNoWarn;
|
2022-05-24 02:02:31 -07:00
|
|
|
extern char ncclLastError[];
|
2018-09-24 16:06:59 -07:00
|
|
|
|
2018-11-13 10:37:20 -08:00
|
|
|
#define WARN(...) ncclDebugLog(NCCL_LOG_WARN, NCCL_ALL, __FILE__, __LINE__, __VA_ARGS__)
|
|
|
|
|
#define INFO(FLAGS, ...) ncclDebugLog(NCCL_LOG_INFO, (FLAGS), __func__, __LINE__, __VA_ARGS__)
|
2022-05-24 02:02:31 -07:00
|
|
|
#define TRACE_CALL(...) ncclDebugLog(NCCL_LOG_TRACE, NCCL_CALL, __func__, __LINE__, __VA_ARGS__)
|
2018-09-24 16:06:59 -07:00
|
|
|
|
|
|
|
|
#ifdef ENABLE_TRACE
|
2018-11-13 10:37:20 -08:00
|
|
|
#define TRACE(FLAGS, ...) ncclDebugLog(NCCL_LOG_TRACE, (FLAGS), __func__, __LINE__, __VA_ARGS__)
|
2022-05-24 02:02:31 -07:00
|
|
|
extern std::chrono::steady_clock::time_point ncclEpoch;
|
2018-09-24 16:06:59 -07:00
|
|
|
#else
|
|
|
|
|
#define TRACE(...)
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-07 06:39:55 -08:00
|
|
|
void ncclSetThreadName(pthread_t thread, const char *fmt, ...);
|
|
|
|
|
|
2018-09-24 16:06:59 -07:00
|
|
|
#endif
|