Skip to content

Commit 527ff85

Browse files
author
chenqing
committed
Move EnvVar ro source file and change nccl_param Makefile to adapt different hardware
1 parent 49e59b3 commit 527ff85

3 files changed

Lines changed: 80 additions & 37 deletions

File tree

flagcx/adaptor/tuner/Makefile

100644100755
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,44 @@ CXX = g++
33
CXXFLAGS = -fPIC -Wall -Wextra -O2 -std=c++11
44
LDFLAGS = -shared -pthread
55

6+
# set to 0 if not provided
7+
USE_NVIDIA ?= 0
8+
USE_ASCEND ?= 0
9+
USE_ILUVATAR_COREX ?= 0
10+
USE_CAMBRICON ?= 0
11+
USE_GLOO ?= 0
12+
USE_BOOTSTRAP ?= 0
13+
USE_METAX ?= 0
14+
USE_MUSA ?= 0
15+
USE_KUNLUNXIN ?=0
16+
USE_AMD ?= 0
17+
USE_DU ?= 0
18+
USE_MPI ?= 0
19+
USE_UCX ?= 0
20+
USE_IBUC ?= 0
21+
22+
ifeq ($(USE_NVIDIA), 1)
23+
CXXFLAGS += -DUSE_NVIDIA_ADAPTOR
24+
else ifeq ($(USE_ASCEND), 1)
25+
CXXFLAGS += -DUSE_ASCEND_ADAPTOR
26+
else ifeq ($(USE_ILUVATAR_COREX), 1)
27+
CXXFLAGS = -DUSE_ILUVATAR_COREX_ADAPTOR
28+
else ifeq ($(USE_CAMBRICON), 1)
29+
CXXFLAGS = -DUSE_CAMBRICON_ADAPTOR
30+
else ifeq ($(USE_METAX), 1)
31+
CXXFLAGS = -DUSE_METAX_ADAPTOR
32+
else ifeq ($(USE_MUSA), 1)
33+
CXXFLAGS = -DUSE_MUSA_ADAPTOR
34+
else ifeq ($(USE_KUNLUNXIN), 1)
35+
CXXFLAGS = -DUSE_KUNLUNXIN_ADAPTOR
36+
else ifeq ($(USE_DU), 1)
37+
CXXFLAGS = -DUSE_DU_ADAPTOR
38+
else ifeq ($(USE_AMD), 1)
39+
CXXFLAGS = -DUSE_AMD_ADAPTOR -D__HIP_PLATFORM_AMD__
40+
else
41+
CXXFLAGS = -DUSE_NVIDIA_ADAPTOR
42+
endif
43+
644
# Target shared library name
745
TARGET = libnccl_param.so
846

flagcx/adaptor/tuner/tuner_util.cc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,47 @@
11
#include "tuner/tuner_util.h"
22

33

4+
//Environment variables for different hardware
5+
#ifdef USE_NVIDIA_ADAPTOR
6+
7+
static EnvVar algo(
8+
"NCCL_ALGO",
9+
{"ring", "tree"},
10+
"ring"
11+
);
12+
13+
static EnvVar proto(
14+
"NCCL_PROTO",
15+
{"LL", "LL128", "Simple"},
16+
"Simple"
17+
);
18+
19+
static EnvVar thread(
20+
"NCCL_NTHREADS",
21+
{"128", "256"},
22+
"256"
23+
);
24+
25+
static EnvVar minChannel(
26+
"NCCL_MIN_NCHANNELS",
27+
{"16", "32"},
28+
"16"
29+
);
30+
31+
static EnvVar chunkSize(
32+
"NCCL_P2P_NVL_CHUNKSIZE",
33+
{"1024", "2048"},
34+
"1024"
35+
);
36+
37+
std::vector<EnvVar> vars = {algo, proto, thread, minChannel, chunkSize};
38+
39+
#else
40+
41+
std::vector<EnvVar> vars = {};
42+
43+
#endif
44+
445
// Safely copy std::string to char buffer, ensuring NUL termination and truncation
546
static void safeStrCopy(char *dst, size_t dstSize, const std::string &src) {
647
if (dstSize == 0) return;

flagcx/adaptor/tuner/tuner_util.h

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,6 @@ struct EnvVar {
1919
flagcxResult_t generateCandidate(std::vector<struct flagcxEnvConfig> &cfgList);
2020
static void safeStrCopy(char *dst, size_t dstSize, const std::string &src);
2121

22-
#ifdef USE_NVIDIA_ADAPTOR
23-
24-
static EnvVar algo(
25-
"NCCL_ALGO",
26-
{"ring", "tree"},
27-
"ring"
28-
);
29-
30-
static EnvVar proto(
31-
"NCCL_PROTO",
32-
{"LL", "LL128", "Simple"},
33-
"Simple"
34-
);
35-
36-
static EnvVar thread(
37-
"NCCL_NTHREADS",
38-
{"128", "256"},
39-
"256"
40-
);
41-
42-
static EnvVar minChannel(
43-
"NCCL_MIN_NCHANNELS",
44-
{"16", "32"},
45-
"16"
46-
);
47-
48-
static EnvVar chunkSize(
49-
"NCCL_P2P_NVL_CHUNKSIZE",
50-
{"1024", "2048"},
51-
"1024"
52-
);
53-
static std::vector<EnvVar> vars = {algo, proto, thread, minChannel, chunkSize};
54-
55-
#else
56-
static std::vector<EnvVar> vars = {};
57-
58-
#endif
22+
extern std::vector<EnvVar> vars;
5923

6024
#endif // end include guard

0 commit comments

Comments
 (0)