topo_expl: update to 2.6

This commit is contained in:
Wenkai Du
2020-03-03 11:42:40 -08:00
parent fa36fd9ef9
commit 6f54b23503
18 changed files with 940 additions and 544 deletions
+71 -354
View File
@@ -23,397 +23,114 @@ THE SOFTWARE.
#ifndef MODEL_H_
#define MODEL_H_
class CpuDevices {
private:
char *cpuName;
int interCpuWidth;
int cpuPciWidth;
int p2pPciWidth;
public:
CpuDevices(const char *cpuname, const int intercpuwidth, const int cpupciwidth, const int p2ppciwidth) :
cpuName((char *)cpuname), interCpuWidth(intercpuwidth), cpuPciWidth(cpupciwidth), p2pPciWidth(p2ppciwidth) {}
CpuDevices() : cpuName(0), interCpuWidth(0), cpuPciWidth(0), p2pPciWidth(0) {}
ncclResult_t getCpuWidths(char* name, int* interCpu, int* cpuPci, int* p2pPci) {
strcpy(name, cpuName);
*interCpu = interCpuWidth;
*cpuPci = cpuPciWidth;
*p2pPci = p2pPciWidth;
return ncclSuccess;
}
};
class GpuDevices {
private:
int nGpus;
uint64_t *busIds;
char **gpuPciPaths;
int *gpuNumaIds;
int *connMatrix;
public:
GpuDevices(const int ngpus, const uint64_t *busids, const char **gpupcipaths, const int *gpunumaids, const int *connmatrix) :
nGpus(ngpus), busIds((uint64_t *)busids), gpuPciPaths((char **)gpupcipaths), gpuNumaIds((int *)gpunumaids), connMatrix((int *)connmatrix) {}
GpuDevices () : nGpus(0), busIds(0), gpuPciPaths(0), gpuNumaIds(0), connMatrix(0) {}
int getnDevs() { return nGpus; }
uint64_t getBusId(int dev) { return busIds[dev]; }
ncclResult_t getPciPath(char* busId, char** path) {
char tempBusId[] = "0000:00:00.0";
*path = (char *)malloc(PATH_MAX);
int i;
for (i = 0; i < nGpus; i++) {
NCCLCHECK(int64ToBusId(busIds[i], tempBusId));
if (strcmp(busId, tempBusId) == 0)
break;
}
if (i < nGpus)
strcpy(*path, gpuPciPaths[i]);
else {
WARN("Could not find real path of %s", busId);
return ncclSystemError;
}
return ncclSuccess;
}
int p2pCanConnect(int device1, int device2) {
// connection matrix are 8 GPUs
int dist = connMatrix[device1*8+device2];
if (dist == 255)
return 0;
//if (dist%15 == 0 && dist/15 != 1) {
// return 0;
//}
return 1;
};
hipError_t getLinkTypeAndHopCount(int device1, int device2, uint32_t* linktype, uint32_t* hopcount) {
// connection matrix are 8 GPUs
int dist = connMatrix[device1*8+device2];
if (dist%15 == 0) {
*linktype = 4;
*hopcount = dist/15;
}
else if (dist%20 == 0) {
*linktype = 2;
*hopcount = dist/20;
}
else if (dist%36 == 0) {
*linktype = 1;
*hopcount = dist/36;
}
return hipSuccess;
}
virtual int getNumaId(char *path) {
int n;
// search for all GPUs
for (n = 0; n < nGpus; n++)
if (strcmp(path, gpuPciPaths[n]) == 0)
break;
if (n < nGpus)
return gpuNumaIds[n];
return -1;
}
};
class NetDevices {
private:
int nNetDevs;
char **netPciPaths;
uint64_t *netGuids; // IB ports on same card share the same GUID
int *netNumaIds;
public:
NetDevices(const int nnetdevs, const char **netpcipaths, const uint64_t *netguids, const int *netnumaids) :
nNetDevs(nnetdevs), netPciPaths((char **)netpcipaths), netGuids((uint64_t *)netguids), netNumaIds((int *)netnumaids) {}
NetDevices() : nNetDevs(0), netPciPaths(0), netGuids(0), netNumaIds(0) {}
int getnDevs() { return nNetDevs; }
ncclResult_t getPciPath(int dev, char** path) {
*path = (char *)malloc(PATH_MAX);
if (dev < nNetDevs)
strcpy(*path, netPciPaths[dev]);
else {
WARN("Could not find real path of %d", dev);
return ncclSystemError;
}
return ncclSuccess;
}
virtual int getNumaId(char *path) {
int n;
// search for all NICs
for (n = 0; n < nNetDevs; n++)
if (strcmp(path, netPciPaths[n]) == 0)
break;
if (n < nNetDevs)
return netNumaIds[n];
return -1;
}
uint64_t getIbGuid(char* path) {
int n;
for (n = 0; n < nNetDevs; n++)
if (strcmp(path, netPciPaths[n]) == 0)
break;
if (n < nNetDevs)
return netGuids[n];
WARN("Invalid IB path %s", path);
return 0;
}
};
#include <vector>
#include "topo.h"
#include "xml.h"
#include "utils.h"
class NodeModel {
private:
CpuDevices cpus;
GpuDevices gpus;
NetDevices netdevs;
public:
int nodeId;
int currRank;
int firstRank;
std::vector<struct ncclTopoSystem*> systems;
uint64_t hostHash; // auto-generated
uint64_t pidHash; // auto-generated
char description[256];
int nodeId;
int firstRank;
int currRank;
int rankToCudaDev(int rank) { return rank - firstRank; }
int getnGpus() { return gpus.getnDevs(); }
int getnNetDevs() { return netdevs.getnDevs(); }
ncclResult_t getGpuPciPath(char* busId, char** path) {
return gpus.getPciPath(busId, path);
NodeModel(const char *xml_file) {
char filename[PATH_MAX];
ssize_t count = readlink("/proc/self/exe", filename, PATH_MAX);
while (--count > 0) {
if (filename[count] == '/') {
filename[count+1] = 0;
break;
}
};
strcat(filename, "models/");
strcat(filename, xml_file);
struct ncclTopoSystem* system;
ncclTopoGetSystem(filename, &system);
systems.push_back(system);
for (int i=0; i<getNumGpus()-1; i++) {
ncclTopoGetSystem(filename, &system);
systems.push_back(system);
}
hostHash = ((uint64_t)rand() << 32) | rand();
pidHash = ((uint64_t)rand() << 32) | rand();
}
ncclResult_t getNetPciPath(int dev, char** path) {
struct ncclTopoSystem* getSystem(int rank) { return systems[rank-firstRank]; }
return netdevs.getPciPath(dev, path);
int getNumGpus() {
return systems[0]->nodes[GPU].count;
}
uint64_t getGpuBusId(int dev) {
return gpus.getBusId(dev);
int rankToCudaDev(int rank) {
for (int i=0; i<getNumGpus(); i++) {
if (rank == systems[0]->nodes[GPU].nodes[i].gpu.rank)
return systems[0]->nodes[GPU].nodes[i].gpu.dev;
}
return -1;
}
int p2pCanConnect(int device1, int device2) { return gpus.p2pCanConnect(device1, device2); }
hipError_t getLinkTypeAndHopCount(int device1, int device2, uint32_t* linktype, uint32_t* hopcount) {
return gpus.getLinkTypeAndHopCount(device1, device2, linktype, hopcount);
int64_t getGpuBusId(int rank) {
for (int i=0; i<getNumGpus(); i++) {
if (rank == systems[0]->nodes[GPU].nodes[i].gpu.rank)
return systems[0]->nodes[GPU].nodes[i].id;
}
return -1;
}
uint64_t getIbGuid(char* path) {
return netdevs.getIbGuid(path);
int busIdToCudaDev(int64_t busId) {
for (int i=0; i<getNumGpus(); i++)
if (systems[0]->nodes[GPU].nodes[i].id == busId)
return systems[0]->nodes[GPU].nodes[i].gpu.dev;
return -1;
}
void setRanks() {
for (int r=0; r<getNumGpus(); r++)
for (int i=0; i<getNumGpus(); i++)
systems[r]->nodes[GPU].nodes[i].gpu.rank += firstRank;
}
int p2pCanConnect(int device1, int device2) { return 1; }
int shmCanConnect(int device1, int device2) { return 1; }
int netCanConnect(int device1, int device2) { return 1; }
virtual int getNumaId(char *path) {
int numa = gpus.getNumaId(path);
if (numa != -1) return numa;
numa = netdevs.getNumaId(path);
if (numa != -1) return numa;
WARN("Invalid path %s for getNumaId", path);
return 0;
}
virtual ncclResult_t getCpuWidths(char* name, int* interCpu, int* cpuPci, int* p2pPci) {
return cpus.getCpuWidths(name, interCpu, cpuPci, p2pPci);
}
NodeModel(CpuDevices cpu, GpuDevices gpu, NetDevices net, const char *desc) :
cpus(cpu), gpus(gpu), netdevs(net) {
strncpy(description, desc, 256);
}
NodeModel() {}
~NodeModel() {}
};
class NetworkModel {
private:
int nNodes;
int nRanks;
NodeModel nodes[NCCL_TOPO_MAX_NODES];
std::vector<NodeModel*> nodes;
public:
void AddNode(NodeModel node) {
nodes[nNodes] = node;
nodes[nNodes].nodeId = nNodes;
nodes[nNodes].firstRank = nRanks;
nodes[nNodes].hostHash = ((uint64_t)rand() << 32) | rand();
nodes[nNodes].pidHash = ((uint64_t)rand() << 32) | rand();
nNodes++;
nRanks += node.getnGpus();
void AddNode(NodeModel* node) {
node->nodeId = nodes.size();
node->firstRank = nRanks;
node->setRanks();
nRanks += node->getNumGpus();
nodes.push_back(node);
}
int GetNNodes() { return nNodes; }
int GetNRanks() { return nRanks; }
NodeModel* GetNode(int rank) {
int node_id;
if(rank < 0 || rank >= nRanks)
return 0;
for(node_id = nNodes-1; node_id >= 0; node_id--)
if(rank >= nodes[node_id].firstRank) break;
if (node_id >= 0) {
nodes[node_id].currRank = rank;
return nodes+node_id;
for (auto & node : nodes) {
if (rank >= node->firstRank && rank < node->firstRank+node->getNumGpus()) {
node->currRank = rank;
return node;
}
}
else
return 0;
return NULL;
}
NetworkModel() : nNodes(0), nRanks(0) {}
};
int GetNNodes() { return nodes.size(); }
int GetNRanks() { return nRanks; }
const static uint64_t busIds_8[] = { 0x1d000, 0x20000, 0x23000, 0x26000, 0x3f000, 0x43000, 0x46000, 0x49000 };
const static char* gpuPciPaths_8[] = {
"/sys/devices/pci0000:17/0000:17:00.0/0000:18:00.0/0000:19:08.0/0000:1b:00.0/0000:1c:00.0/0000:1d:00.0",
"/sys/devices/pci0000:17/0000:17:00.0/0000:18:00.0/0000:19:0c.0/0000:1e:00.0/0000:1f:00.0/0000:20:00.0",
"/sys/devices/pci0000:17/0000:17:00.0/0000:18:00.0/0000:19:10.0/0000:21:00.0/0000:22:00.0/0000:23:00.0",
"/sys/devices/pci0000:17/0000:17:00.0/0000:18:00.0/0000:19:14.0/0000:24:00.0/0000:25:00.0/0000:26:00.0",
"/sys/devices/pci0000:3a/0000:3a:00.0/0000:3b:00.0/0000:3c:04.0/0000:3d:00.0/0000:3e:00.0/0000:3f:00.0",
"/sys/devices/pci0000:3a/0000:3a:00.0/0000:3b:00.0/0000:3c:0c.0/0000:41:00.0/0000:42:00.0/0000:43:00.0",
"/sys/devices/pci0000:3a/0000:3a:00.0/0000:3b:00.0/0000:3c:10.0/0000:44:00.0/0000:45:00.0/0000:46:00.0",
"/sys/devices/pci0000:3a/0000:3a:00.0/0000:3b:00.0/0000:3c:14.0/0000:47:00.0/0000:48:00.0/0000:49:00.0",
};
const static int gpuPciNumaIds_8[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
const static char* netPciPaths_1[] = {
"/sys/devices/pci0000:17/0000:17:00.0/0000:18:00.0/0000:19:04.0/0000:1a:00.0",
};
const static char* netPciPaths_1_1[] = {
"/sys/devices/pci0000:3a/0000:3a:00.0/0000:3b:00.0/0000:3c:08.0/0000:4c:00.0",
};
const static uint64_t netGuids_1[] = {
0xb8599f030007053aL,
};
const static int netPciNumaIds_1[] = { 0 };
const static char* netPciPaths_2[] = {
"/sys/devices/pci0000:17/0000:17:00.0/0000:18:00.0/0000:19:04.0/0000:1a:00.0",
"/sys/devices/pci0000:3a/0000:3a:00.0/0000:3b:00.0/0000:3c:08.0/0000:4c:00.0",
};
const static uint64_t netGuids_2[] = {
0xb8599f030007053aL,
0x506b4b030027bbf2L,
};
const static int netPciNumaIds_2[] = { 0, 0 };
const static uint64_t rome_busIds_8[] = { 0x63000, 0x23000, 0x26000, 0x03000, 0xe3000, 0xc3000, 0xc6000, 0xa3000 };
const static char* rome_gpuPciPaths_8[] = {
"/sys/devices/pci0000:60/0000:60:03.1/0000:61:00.0/0000:62:00.0/0000:63:00.0",
"/sys/devices/pci0000:20/0000:20:01.1/0000:21:00.0/0000:22:00.0/0000:23:00.0",
"/sys/devices/pci0000:20/0000:20:03.1/0000:24:00.0/0000:25:00.0/0000:26:00.0",
"/sys/devices/pci0000:00/0000:00:01.1/0000:01:00.0/0000:02:00.0/0000:03:00.0",
"/sys/devices/pci0000:e0/0000:e0:03.1/0000:e1:00.0/0000:e2:00.0/0000:e3:00.0",
"/sys/devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/0000:c2:00.0/0000:c3:00.0",
"/sys/devices/pci0000:c0/0000:c0:03.1/0000:c4:00.0/0000:c5:00.0/0000:c6:00.0",
"/sys/devices/pci0000:a0/0000:a0:03.1/0000:a1:00.0/0000:a2:00.0/0000:a3:00.0",
};
const static int rome_gpuPciNumaIds_8[] = { 0, 0, 0, 0, 4, 4, 4, 4 };
const static char* rome_netPciPaths_1[] = {
"/sys/devices/pci0000:40/0000:40:01.1/0000:41:00.0",
};
const static uint64_t rome_netGuids_1[] = {
0xb8599f030007053aL,
};
const static int rom_netPciNumaIds_1[] = { 0 };
const static char* rome_netPciPaths_2[] = {
"/sys/devices/pci0000:40/0000:40:01.1/0000:41:00.0",
"/sys/devices/pci0000:80/0000:80:01.1/0000:81:00.0",
};
const static uint64_t rome_netGuids_2[] = {
0xb8599f030007053aL,
0x506b4b030027bbf2L,
};
const static int rom_netPciNumaIds_2[] = { 0, 4 };
const int conn_mat_pcie[64] = {
0 , 40, 40, 40, 40, 40, 40, 40,
40, 0 , 40, 40, 40, 40, 40, 40,
40, 40, 0 , 40, 40, 40, 40, 40,
40, 40, 40, 0 , 40, 40, 40, 40,
40, 40, 40, 40, 0 , 40, 40, 40,
40, 40, 40, 40, 40, 0 , 40, 40,
40, 40, 40, 40, 40, 40, 0 , 40,
40, 40, 40, 40, 40, 40, 40, 0 ,
};
const int conn_mat_4p2h[64] = {
0 , 15, 15, 30, 40, 40, 40, 40,
15, 0 , 30, 15, 40, 40, 40, 40,
15, 30, 0 , 15, 40, 40, 40, 40,
30, 15, 15, 0 , 40, 40, 40, 40,
40, 40, 40, 40, 0 , 15, 15, 30,
40, 40, 40, 40, 15, 0 , 30, 15,
40, 40, 40, 40, 15, 30, 0 , 15,
40, 40, 40, 40, 30, 15, 15, 0 ,
};
const int conn_mat_8p6l[64] = {
0 , 15, 15, 15, 15, 30, 15, 15,
15, 0 , 15, 15, 30, 15, 15, 15,
15, 15, 0 , 15, 15, 15, 15, 30,
15, 15, 15, 0 , 15, 15, 30, 15,
15, 30, 15, 15, 0 , 15, 15, 15,
30, 15, 15, 15, 15, 0 , 15, 15,
15, 15, 15, 30, 15, 15, 0 , 15,
15, 15, 30, 15, 15, 15, 15, 0 ,
};
const int conn_mat_8p6l_1[64] = {
0 , 15, 15, 30, 15, 15, 15, 15,
15, 0 , 30, 15, 15, 15, 15, 15,
15, 30, 0 , 15, 15, 15, 15, 15,
30, 15, 15, 0 , 15, 15, 15, 15,
15, 15, 15, 15, 0 , 15, 15, 30,
15, 15, 15, 15, 15, 0 , 30, 15,
15, 15, 15, 15, 15, 30, 0 , 15,
15, 15, 15, 15, 30, 15, 15, 0 ,
};
const int conn_mat_rome[64] = {
0 , 40, 40, 40, 72, 72, 72, 72,
40, 0 , 40, 40, 72, 72, 72, 72,
40, 40, 0 , 40, 72, 72, 72, 72,
40, 40, 40, 0 , 72, 72, 72, 72,
72, 72, 72, 72, 0 , 40, 40, 40,
72, 72, 72, 72, 40, 0 , 40, 40,
72, 72, 72, 72, 40, 40, 0 , 40,
72, 72, 72, 72, 40, 40, 40, 0 ,
NetworkModel() : nRanks(0) {}
};
#endif
+3 -3
View File
@@ -12,11 +12,11 @@
#include <hip/hip_fp16.h>
#define NCCL_MAJOR 2
#define NCCL_MINOR 5
#define NCCL_PATCH 6
#define NCCL_MINOR 6
#define NCCL_PATCH 2
#define NCCL_SUFFIX ""
#define NCCL_VERSION_CODE 2506
#define NCCL_VERSION_CODE 2602
#define NCCL_VERSION(X,Y,Z) ((X) * 1000 + (Y) * 100 + (Z))
#define RCCL_BFLOAT16 1
+19 -17
View File
@@ -13,32 +13,34 @@ struct allGather1Data_t {
struct ncclComm* comm;
};
struct allGather3Data_t {
// AllGather3 - begin
struct ncclGraphInfo {
int sameChannels;
float speedIntra;
float speedInter;
int typeIntra;
};
struct allGather3Data_t{
int cudaCompCap;
int fullCudaCompCap;
int nvlink;
int nChannels;
struct {
int sameChannels;
int speedIntra;
int speedInter;
int nvlink;
} tree;
struct {
int sameChannels;
int speedIntra;
int speedInter;
int nvlink;
} ring;
struct ncclGraphInfo tree;
struct ncclGraphInfo ring;
struct ncclGraphInfo collNet;
struct ncclTopoRanks topoRanks;
};
ncclResult_t ncclTopoGetSystem(const char* xmlTopoFile, struct ncclTopoSystem** system);
ncclResult_t ncclTopoGetSystemFromXml(struct ncclXml* xml, struct ncclTopoSystem** topoSystem);
ncclResult_t bootstrapAllGather(struct ncclComm* comm, struct allGather1Data_t * allGather1Data);
ncclResult_t initTransportsRank_1(struct ncclComm* comm, struct allGather1Data_t *allGather1Data,
struct allGather3Data_t *allGather3Data, struct ncclTopoGraph& treeGraph, struct ncclTopoGraph& ringGraph);
ncclResult_t initTransportsRank_1(struct ncclComm* comm, struct allGather1Data_t *allGather1Data, struct allGather3Data_t *allGather3Data,
struct ncclTopoGraph& treeGraph, struct ncclTopoGraph& ringGraph, struct ncclTopoGraph& collNetGraph);
ncclResult_t initTransportsRank_3(struct ncclComm* comm, struct allGather3Data_t *allGather3Data,
struct ncclTopoGraph& treeGraph, struct ncclTopoGraph& ringGraph);
struct ncclTopoGraph& treeGraph, struct ncclTopoGraph& ringGraph, struct ncclTopoGraph& collNetGraph);
#endif