Files
rocm-systems/src/include/graph.h
T

105 lines
4.1 KiB
C
Raw Normal View History

2019-11-19 14:57:39 -08:00
/*************************************************************************
2021-04-12 16:00:11 -07:00
* Copyright (c) 2016-2021, NVIDIA CORPORATION. All rights reserved.
2019-11-19 14:57:39 -08:00
*
* See LICENSE.txt for license information
************************************************************************/
#ifndef NCCL_GRAPH_H_
#define NCCL_GRAPH_H_
#include "nccl.h"
#include "devcomm.h"
#include <limits.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
ncclResult_t ncclTopoCudaPath(int cudaDev, char** path);
struct ncclTopoSystem;
// Build the topology
ncclResult_t ncclTopoGetSystem(struct ncclComm* comm, struct ncclTopoSystem** system);
ncclResult_t ncclTopoSortSystem(struct ncclTopoSystem* system);
ncclResult_t ncclTopoPrint(struct ncclTopoSystem* system);
ncclResult_t ncclTopoComputePaths(struct ncclTopoSystem* system, struct ncclPeerInfo* info);
void ncclTopoFree(struct ncclTopoSystem* system);
ncclResult_t ncclTopoTrimSystem(struct ncclTopoSystem* system, struct ncclComm* comm);
2020-05-12 14:40:18 -07:00
ncclResult_t ncclTopoComputeP2pChannels(struct ncclComm* comm);
2019-11-19 14:57:39 -08:00
// Query topology
2021-04-12 16:00:11 -07:00
ncclResult_t ncclTopoGetNetDev(struct ncclTopoSystem* system, int rank, struct ncclTopoGraph* graph, int channelId, int rr, int* net);
2020-09-04 14:35:05 -07:00
ncclResult_t ncclTopoCheckP2p(struct ncclTopoSystem* system, int64_t id1, int64_t id2, int* p2p, int *read, int* intermediateRank);
2020-01-16 16:02:42 -08:00
ncclResult_t ncclTopoCheckGdr(struct ncclTopoSystem* topo, int64_t busId, int netDev, int read, int* useGdr);
// Set CPU affinity
ncclResult_t ncclTopoSetAffinity(struct ncclTopoSystem* system, int rank);
#define NCCL_TOPO_CPU_ARCH_X86 1
#define NCCL_TOPO_CPU_ARCH_POWER 2
#define NCCL_TOPO_CPU_ARCH_ARM 3
#define NCCL_TOPO_CPU_VENDOR_INTEL 1
#define NCCL_TOPO_CPU_VENDOR_AMD 2
#define NCCL_TOPO_CPU_VENDOR_ZHAOXIN 3
2020-01-16 16:02:42 -08:00
#define NCCL_TOPO_CPU_TYPE_BDW 1
#define NCCL_TOPO_CPU_TYPE_SKL 2
#define NCCL_TOPO_CPU_TYPE_YONGFENG 1
2020-01-16 16:02:42 -08:00
ncclResult_t ncclTopoCpuType(struct ncclTopoSystem* system, int* arch, int* vendor, int* model);
2020-09-04 14:35:05 -07:00
ncclResult_t ncclTopoGetNetCount(struct ncclTopoSystem* system, int* count);
2019-11-19 14:57:39 -08:00
#define NCCL_TOPO_MAX_NODES 256
2020-01-16 16:02:42 -08:00
// Init search. Needs to be done before calling ncclTopoCompute
ncclResult_t ncclTopoSearchInit(struct ncclTopoSystem* system);
2020-09-04 14:35:05 -07:00
#define NCCL_TOPO_PATTERN_BALANCED_TREE 1 // Spread NIC traffic between two GPUs (Tree parent + one child on first GPU, second child on second GPU)
#define NCCL_TOPO_PATTERN_SPLIT_TREE 2 // Spread NIC traffic between two GPUs (Tree parent on first GPU, tree children on the second GPU)
#define NCCL_TOPO_PATTERN_TREE 3 // All NIC traffic going to/from the same GPU
2019-11-19 14:57:39 -08:00
#define NCCL_TOPO_PATTERN_RING 4 // Ring
struct ncclTopoGraph {
// Input / output
2020-01-16 16:02:42 -08:00
int id; // ring : 0, tree : 1, collnet : 2
2019-11-19 14:57:39 -08:00
int pattern;
int crossNic;
2020-01-16 16:02:42 -08:00
int collNet;
int minChannels;
int maxChannels;
2019-11-19 14:57:39 -08:00
// Output
int nChannels;
2020-01-16 16:02:42 -08:00
float speedIntra;
float speedInter;
int typeIntra;
int typeInter;
2019-11-19 14:57:39 -08:00
int sameChannels;
int nHops;
int intra[MAXCHANNELS*NCCL_TOPO_MAX_NODES];
int inter[MAXCHANNELS*2];
};
ncclResult_t ncclTopoCompute(struct ncclTopoSystem* system, struct ncclTopoGraph* graph);
ncclResult_t ncclTopoPrintGraph(struct ncclTopoSystem* system, struct ncclTopoGraph* graph);
2020-01-16 16:02:42 -08:00
ncclResult_t ncclTopoDumpGraphs(struct ncclTopoSystem* system, int ngraphs, struct ncclTopoGraph** graphs);
2019-11-19 14:57:39 -08:00
struct ncclTopoRanks {
int ringRecv[MAXCHANNELS];
int ringSend[MAXCHANNELS];
int ringPrev[MAXCHANNELS];
int ringNext[MAXCHANNELS];
2020-09-04 14:35:05 -07:00
int treeToParent[MAXCHANNELS];
int treeToChild0[MAXCHANNELS];
int treeToChild1[MAXCHANNELS];
2019-11-19 14:57:39 -08:00
};
ncclResult_t ncclTopoPreset(struct ncclComm* comm,
2021-04-12 16:00:11 -07:00
struct ncclTopoGraph* treeGraph, struct ncclTopoGraph* ringGraph,
2019-11-19 14:57:39 -08:00
struct ncclTopoRanks* topoRanks);
2020-09-04 14:35:05 -07:00
ncclResult_t ncclTopoPostset(struct ncclComm* comm, int* firstRanks, int* treePatterns,
2021-04-12 16:00:11 -07:00
struct ncclTopoRanks** allTopoRanks, int* rings, struct ncclTopoGraph* collNetGraph);
2020-01-16 16:02:42 -08:00
2020-05-12 14:40:18 -07:00
ncclResult_t ncclTopoTuneModel(struct ncclComm* comm, int minCompCap, int maxCompCap, struct ncclTopoGraph* treeGraph, struct ncclTopoGraph* ringGraph, struct ncclTopoGraph* collNetGraph);
2020-01-16 16:02:42 -08:00
#include "info.h"
ncclResult_t ncclTopoGetAlgoTime(struct ncclInfo* info, int algorithm, int protocol, float* time);
2019-11-19 14:57:39 -08:00
#endif