Manage runtime environments (#452)

* Add `Env` class that manages all runtime environments.
* Changed `NPKIT_DUMP_DIR` to `MSCCLPP_NPKIT_DUMP_DIR`.
This commit is contained in:
Changho Hwang
2025-01-15 09:44:52 -08:00
committed by GitHub
parent 8ac50dc85d
commit 869cdba00c
19 changed files with 229 additions and 51 deletions

View File

@@ -9,6 +9,7 @@
#include <sys/syscall.h>
#include <unistd.h>
#include <mscclpp/env.hpp>
#include <mscclpp/gpu_utils.hpp>
#include <mscclpp/utils.hpp>
#include <string>
@@ -34,7 +35,7 @@ void mscclppDebugInit() {
pthread_mutex_unlock(&mscclppDebugLock);
return;
}
const char* mscclpp_debug = getenv("MSCCLPP_DEBUG");
const char* mscclpp_debug = mscclpp::env()->debug.c_str();
int tempNcclDebugLevel = -1;
if (mscclpp_debug == NULL) {
tempNcclDebugLevel = MSCCLPP_LOG_NONE;
@@ -54,8 +55,9 @@ void mscclppDebugInit() {
* This can be a comma separated list such as INIT,COLL
* or ^INIT,COLL etc
*/
char* mscclppDebugSubsysEnv = getenv("MSCCLPP_DEBUG_SUBSYS");
if (mscclppDebugSubsysEnv != NULL) {
std::string mscclppDebugSubsysStr = mscclpp::env()->debugSubsys;
const char* mscclppDebugSubsysEnv = mscclppDebugSubsysStr.c_str();
if (mscclppDebugSubsysStr != "") {
int invert = 0;
if (mscclppDebugSubsysEnv[0] == '^') {
invert = 1;
@@ -108,7 +110,7 @@ void mscclppDebugInit() {
* then create the debug file. But don't bother unless the
* MSCCLPP_DEBUG level is > VERSION
*/
const char* mscclppDebugFileEnv = getenv("MSCCLPP_DEBUG_FILE");
const char* mscclppDebugFileEnv = mscclpp::env()->debugFile.c_str();
if (tempNcclDebugLevel > MSCCLPP_LOG_VERSION && mscclppDebugFileEnv != NULL) {
int c = 0;
char debugFn[PATH_MAX + 1] = "";