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

42
include/mscclpp/env.hpp Normal file
View File

@@ -0,0 +1,42 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#ifndef MSCCLPP_ENV_HPP_
#define MSCCLPP_ENV_HPP_
#include <memory>
#include <string>
namespace mscclpp {
class Env;
/// Get the MSCCL++ environment.
/// @return A reference to the global environment object.
std::shared_ptr<Env> env();
/// The MSCCL++ environment. The constructor reads environment variables and sets the corresponding fields.
/// Use the @ref env() function to get the environment object.
class Env {
public:
const std::string debug;
const std::string debugSubsys;
const std::string debugFile;
const std::string hcaDevices;
const std::string hostid;
const std::string socketFamily;
const std::string socketIfname;
const std::string commId;
const std::string executionPlanDir;
const std::string npkitDumpDir;
const bool cudaIpcUseDefaultStream;
private:
Env();
friend std::shared_ptr<Env> env();
};
} // namespace mscclpp
#endif // MSCCLPP_ENV_HPP_