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
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
2023-09-26 05:47:28 -07:00
|
|
|
#ifndef NCCL_INT_DEBUG_H_
|
|
|
|
|
#define NCCL_INT_DEBUG_H_
|
2018-09-24 16:06:59 -07:00
|
|
|
|
2023-09-26 05:47:28 -07:00
|
|
|
#include "nccl.h"
|
|
|
|
|
#include "nccl_common.h"
|
2018-09-24 16:06:59 -07:00
|
|
|
#include <stdio.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 FILE *ncclDebugFile;
|
|
|
|
|
|
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
|
|
|
|
2025-10-30 14:14:20 -07:00
|
|
|
#define ERROR(...) ncclDebugLog(NCCL_LOG_ERROR, NCCL_ALL, __FILE__, __LINE__, __VA_ARGS__)
|
2024-06-11 01:28:01 -07:00
|
|
|
#define VERSION(...) ncclDebugLog(NCCL_LOG_VERSION, NCCL_ALL, __FILE__, __LINE__, __VA_ARGS__)
|
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__)
|
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, ...);
|
|
|
|
|
|
2024-12-18 08:26:06 -08:00
|
|
|
void ncclResetDebugInit();
|
|
|
|
|
|
2025-10-30 14:14:20 -07:00
|
|
|
// RCCL custom error message handling.
|
|
|
|
|
static inline ncclResult_t rcclCudaErrorHandler(cudaError_t err) {
|
|
|
|
|
|
|
|
|
|
// Print the cuda error
|
|
|
|
|
ERROR("HIP failure: '%s'", cudaGetErrorString(err));
|
|
|
|
|
|
|
|
|
|
// Special error message here:
|
|
|
|
|
switch (err) {
|
|
|
|
|
case cudaErrorStreamCaptureInvalidated:
|
|
|
|
|
ERROR("Application is trying to use an invalidated stream to launch RCCL kernel. "
|
|
|
|
|
"This operation is invalid. RCCL is exiting.");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return ncclUnhandledCudaError;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-24 16:06:59 -07:00
|
|
|
#endif
|