Skip to content

Commit 45c39ab

Browse files
authored
Move Nvidia related code from flagcx/core to flagcx/adaptor/tuner (#271)
1 parent 3d64ba1 commit 45c39ab

5 files changed

Lines changed: 34 additions & 12 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ INCLUDEDIR := \
238238
$(abspath flagcx/core) \
239239
$(abspath flagcx/adaptor) \
240240
$(abspath flagcx/adaptor/include) \
241+
$(abspath flagcx/adaptor/tuner) \
241242
$(abspath flagcx/service)
242243

243244
LIBSRCFILES:= \
@@ -247,6 +248,7 @@ LIBSRCFILES:= \
247248
$(wildcard flagcx/adaptor/device/*.cc) \
248249
$(wildcard flagcx/adaptor/ccl/*.cc) \
249250
$(wildcard flagcx/adaptor/net/*.cc) \
251+
$(wildcard flagcx/adaptor/tuner/tuner_util.cc) \
250252
$(wildcard flagcx/service/*.cc)
251253

252254
LIBOBJ := $(LIBSRCFILES:%.cc=$(OBJDIR)/%.o)

flagcx/adaptor/tuner/nccl_param.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ static void ncclLoadParam(char const* env, int64_t deftVal, int64_t* value) {
2828
return value; \
2929
}
3030

31-
// In order to intercept a NCCL environment getter function, add an additional line of NCCL_PRARM here.
31+
// In order to intercept a NCCL environment getter function, add an additional line of NCCL_PARAM here.
3232
// Below is an example of intercepting NCCL_P2P_NVL_CHUNKSIZE env.
3333
NCCL_PARAM(P2pNvlChunkSize, "P2P_NVL_CHUNKSIZE", (1 << 19)); /* 512 kB */

flagcx/adaptor/tuner/tuner_util.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "tuner/tuner_util.h"
2+
3+
#ifdef USE_NVIDIA_ADAPTOR
4+
static struct flagcxEnvConfig config1 = {
5+
"defaultConfig1",
6+
1,
7+
{FLAGCX_ENV_TYPE_CREATION, "NCCL_P2P_NVL_CHUNKSIZE", "1024", "524288"}};
8+
static struct flagcxEnvConfig config2 = {
9+
"defaultConfig2",
10+
1,
11+
{FLAGCX_ENV_TYPE_CREATION, "NCCL_P2P_NVL_CHUNKSIZE", "524288", "524288"}};
12+
13+
// demo
14+
flagcxResult_t loadConfigList(std::vector<struct flagcxEnvConfig> &cfgList) {
15+
cfgList.push_back(config1);
16+
cfgList.push_back(config2);
17+
return flagcxSuccess;
18+
}
19+
#endif

flagcx/adaptor/tuner/tuner_util.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef FLAGCX_TUNER_UTIL_H_
2+
#define FLAGCX_TUNER_UTIL_H_
3+
4+
#include "tuner.h" // struct flagcxEnvConfig
5+
#include <vector>
6+
7+
// This is a demonstration function that provide a way to load all config list for a specific GPU.
8+
flagcxResult_t loadConfigList(std::vector<struct flagcxEnvConfig> &cfgList);
9+
10+
#endif // end include guard

flagcx/core/flagcx_tuner.cc

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "check.h"
33
#include "param.h"
44
#include "timer.h"
5+
#include "tuner/tuner_util.h"
56
#include <cfloat>
67
#include <map>
78
#include <sstream>
@@ -113,15 +114,6 @@ struct flagcxTunerContext {
113114
flagcxTimer<TunerProfileKey> timer;
114115
};
115116

116-
static struct flagcxEnvConfig config1 = {
117-
"defaultConfig1",
118-
1,
119-
{FLAGCX_ENV_TYPE_CREATION, "NCCL_P2P_NVL_CHUNKSIZE", "1024", "524288"}};
120-
static struct flagcxEnvConfig config2 = {
121-
"defaultConfig2",
122-
1,
123-
{FLAGCX_ENV_TYPE_CREATION, "NCCL_P2P_NVL_CHUNKSIZE", "524288", "524288"}};
124-
125117
bool operator<(const struct flagcxCommTag &lhs,
126118
const struct flagcxCommTag &rhs) {
127119
return strcmp(lhs.tag, rhs.tag) < 0;
@@ -150,8 +142,7 @@ flagcxResult_t flagcxTunerInit(size_t nRanks, size_t nNodes,
150142
flagcxDebugLogger_t logFunction,
151143
void **context) {
152144
struct flagcxTunerContext *ctx = new struct flagcxTunerContext;
153-
ctx->configList.push_back(config1);
154-
ctx->configList.push_back(config2);
145+
FLAGCXCHECK(loadConfigList(ctx->configList));
155146
ctx->logger = logFunction;
156147
*context = ctx;
157148

0 commit comments

Comments
 (0)