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

122 γραμμές
3.0 KiB
C++

2018-09-24 16:06:59 -07:00
/*************************************************************************
2018-12-13 15:56:12 -08:00
* Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved.
2018-09-24 16:06:59 -07:00
*
* See LICENSE.txt for license information
************************************************************************/
#ifndef NCCL_TRANSPORT_H_
#define NCCL_TRANSPORT_H_
2019-03-14 19:39:20 -07:00
#include "devcomm.h"
2019-11-19 14:57:39 -08:00
#include "graph.h"
2018-12-13 15:56:12 -08:00
#include "nvmlwrap.h"
2019-11-19 14:57:39 -08:00
#include "core.h"
2018-09-24 16:06:59 -07:00
#define NTRANSPORTS 3
2019-11-19 14:57:39 -08:00
#define TRANSPORT_P2P 0
#define TRANSPORT_SHM 1
#define TRANSPORT_NET 2
2018-09-24 16:06:59 -07:00
extern struct ncclTransport ncclTransports[];
// Forward declarations
struct ncclRing;
struct ncclConnector;
struct ncclComm;
2018-12-13 15:56:12 -08:00
struct ncclPeerInfo {
int rank;
int cudaDev;
2019-11-19 14:57:39 -08:00
int gdrSupport;
2018-12-13 15:56:12 -08:00
uint64_t hostHash;
uint64_t pidHash;
2019-11-19 14:57:39 -08:00
dev_t shmDev;
int64_t busId;
2018-09-24 16:06:59 -07:00
};
#define CONNECT_SIZE 128
struct ncclConnect {
char data[CONNECT_SIZE];
};
2019-03-14 19:39:20 -07:00
enum ncclProxyOpState { ncclProxyOpNone, ncclProxyOpReady, ncclProxyOpProgress };
2018-12-13 15:56:12 -08:00
struct ncclProxyArgs;
typedef ncclResult_t (*proxyProgressFunc_t)(struct ncclProxyArgs*);
2018-09-24 16:06:59 -07:00
struct ncclProxyArgs {
2018-12-13 15:56:12 -08:00
proxyProgressFunc_t progress;
struct ncclChannel* channel;
struct ncclConnector* connector;
int sliceSteps;
int chunkSteps;
2018-09-24 16:06:59 -07:00
int nsteps;
uint64_t opCount;
2019-11-19 14:57:39 -08:00
int protocol;
2018-12-13 15:56:12 -08:00
int state; // add component before this line -- it is left out during initialization
// Internal state
uint64_t head;
uint64_t tail;
uint64_t end;
void* requests[NCCL_STEPS];
int idle;
// Element linking
pthread_mutex_t mutex;
struct ncclProxyArgs* next;
struct ncclProxyArgs* nextPeer;
};
struct ncclProxyPool;
struct ncclProxyState {
pthread_cond_t cond;
pthread_mutex_t mutex;
bool stop;
struct ncclProxyArgs* ops;
struct ncclProxyArgs* pool;
struct ncclProxyPool* pools;
2018-09-24 16:06:59 -07:00
};
struct ncclTransportComm {
2019-11-19 14:57:39 -08:00
ncclResult_t (*setup)(struct ncclTopoSystem* topo, struct ncclTopoGraph* graph, struct ncclPeerInfo*, struct ncclPeerInfo*, struct ncclConnect*, struct ncclConnector*, int buffSize, int channelId);
2018-09-24 16:06:59 -07:00
ncclResult_t (*connect)(struct ncclConnect*, struct ncclConnector*);
ncclResult_t (*free)(void*);
ncclResult_t (*proxy)(struct ncclProxyArgs*);
};
struct ncclTransport {
const char name[4];
2019-11-19 14:57:39 -08:00
ncclResult_t (*canConnect)(int*, struct ncclTopoSystem* topo, struct ncclTopoGraph* graph, struct ncclPeerInfo*, struct ncclPeerInfo*);
2018-09-24 16:06:59 -07:00
struct ncclTransportComm send;
struct ncclTransportComm recv;
};
#include <pthread.h>
typedef ncclResult_t (*threadFunc_t)(struct ncclProxyArgs*);
enum proxyMode {
proxyRing = 0,
proxyFrom = 1,
proxyTo = 2
};
2018-12-13 15:56:12 -08:00
ncclResult_t transportAllocateProxyArgs(struct ncclComm* comm, struct ncclProxyArgs** argsptr);
ncclResult_t transportSaveProxies(struct ncclProxyArgs* args, int pattern, int root, int nranks);
ncclResult_t transportStartProxy(struct ncclComm* comm);
ncclResult_t transportCreateProxy(struct ncclComm* comm);
ncclResult_t transportDestroyProxy(struct ncclComm* comm);
2018-09-24 16:06:59 -07:00
#include <unistd.h>
// Spin wait until func evaluates to true
template<typename FUNC>
inline void transportProxyWait(const FUNC& func) {
while (!func()) {
sched_yield();
}
}
#endif