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

131 lines
6.4 KiB
C
Raw Normal View History

2018-09-24 16:06:59 -07:00
/*************************************************************************
2022-01-07 06:39:55 -08:00
* Copyright (c) 2016-2022, NVIDIA CORPORATION. All rights reserved.
* Modifications Copyright (c) 2019-2022 Advanced Micro Devices, Inc. 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_
2023-09-26 05:47:28 -07:00
#include "device.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
2022-01-07 06:39:55 -08:00
#define NTRANSPORTS 4
2024-06-11 01:28:01 -07:00
#define TRANSPORT_UNDEFINED -1
2019-11-19 14:57:39 -08:00
#define TRANSPORT_P2P 0
#define TRANSPORT_SHM 1
#define TRANSPORT_NET 2
2022-01-07 06:39:55 -08:00
#define TRANSPORT_COLLNET 3
#include "proxy.h"
2024-06-11 01:28:01 -07:00
#include "comm.h"
2018-09-24 16:06:59 -07:00
2022-05-24 02:02:31 -07:00
extern struct ncclTransport p2pTransport;
extern struct ncclTransport shmTransport;
extern struct ncclTransport netTransport;
extern struct ncclTransport collNetTransport;
extern struct ncclTransport* ncclTransports[];
2018-09-24 16:06:59 -07:00
// Forward declarations
struct ncclRing;
struct ncclConnector;
struct ncclComm;
2025-01-03 08:41:41 -05:00
#define CHANNEL_MASK_OFFSET(nranks, connIndex) (nranks * (connIndex == NCCL_CONN_IDX_P2P_NET ? NCCL_CONN_IDX_P2P_NET : 0))
2018-09-24 16:06:59 -07:00
#define CONNECT_SIZE 128
struct ncclConnect {
char data[CONNECT_SIZE];
};
2023-04-03 05:32:07 -07:00
#if CUDART_VERSION >= 12010
#define NVLS_HANDLE_SIZE 64
struct ncclNvlsSharedRes {
int refCount;
2024-06-11 01:28:01 -07:00
bool inited;
CUmulticastObjectProp bufProp;
CUmulticastObjectProp signalProp;
2023-04-03 05:32:07 -07:00
CUmemAccessDesc accessDesc;
int dev;
2024-06-11 01:28:01 -07:00
size_t buffSize;
size_t creditSize;
CUmemGenericAllocationHandle mcBuffHandle; // Multicast handle for NVLS buffer
CUmemGenericAllocationHandle mcCreditHandle; // Multicast handle for NVLS credit buffer
2023-04-03 05:32:07 -07:00
char* mcBuff; // Multicast NVLS buffer address
2024-06-11 01:28:01 -07:00
char* mcCredit; // Multicast NVLS credit address
CUmemGenericAllocationHandle ucBuffHandle; // Unicast Handle for NVLS buffer
CUmemGenericAllocationHandle ucCreditHandle; // Unicast Handle for NVLS credit buffer
2023-04-03 05:32:07 -07:00
char* ucBuff; // Unicast NVLS buffer address
2024-06-11 01:28:01 -07:00
char* ucCredit; // Unicast NVLS credit address
2023-04-03 05:32:07 -07:00
int nChannels;
2023-11-13 10:26:55 -08:00
struct ncclShmemCollBuff nvlsShmem;
void *nvlsShmemHandle;
2023-04-03 05:32:07 -07:00
};
#endif /* CUDART_VERSION >= 12010 */
struct ncclCollNetSharedRes {
int refCount;
int size;
char* cudaBuff;
char* hostBuff;
struct ncclProxyArgs* proxyAppend[2*NCCL_MAX_NETDEVS];
void* resources;
int nChannels;
size_t buffSize;
2024-06-11 01:28:01 -07:00
int intraHighestTransportType;
2023-04-03 05:32:07 -07:00
};
2018-09-24 16:06:59 -07:00
struct ncclTransportComm {
2021-04-12 16:00:11 -07:00
ncclResult_t (*setup)(struct ncclComm* comm, struct ncclTopoGraph* graph, struct ncclPeerInfo*, struct ncclPeerInfo*, struct ncclConnect*, struct ncclConnector*, int channelId, int connIndex);
2020-09-04 14:35:05 -07:00
ncclResult_t (*connect)(struct ncclComm* comm, struct ncclConnect*, int nranks, int rank, struct ncclConnector*);
2022-01-07 06:39:55 -08:00
ncclResult_t (*free)(struct ncclConnector*);
2023-04-03 05:32:07 -07:00
ncclResult_t (*proxySharedInit)(struct ncclProxyConnection* connection, struct ncclProxyState* proxyState, int nChannels);
ncclResult_t (*proxySetup)(struct ncclProxyConnection* connection, struct ncclProxyState* proxyState, void* reqBuff, int reqSize, void* respBuff, int respSize, int* done);
ncclResult_t (*proxyConnect)(struct ncclProxyConnection* connection, struct ncclProxyState* proxyState, void* reqBuff, int reqSize, void* respBuff, int respSize, int* done);
ncclResult_t (*proxyFree)(struct ncclProxyConnection* connection, struct ncclProxyState* proxyState);
ncclResult_t (*proxyProgress)(struct ncclProxyState* proxyState, struct ncclProxyArgs*);
2024-03-26 06:08:55 -07:00
ncclResult_t (*proxyRegister)(struct ncclProxyConnection* connection, struct ncclProxyState* proxyState, void* reqBuff, int reqSize, void* respBuff, int respSize, int* done);
ncclResult_t (*proxyDeregister)(struct ncclProxyConnection* connection, struct ncclProxyState* proxyState, void* reqBuff, int reqSize, int* done);
2018-09-24 16:06:59 -07:00
};
struct ncclTransport {
2023-02-27 02:48:21 -08:00
const char name[8];
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;
};
2022-05-24 02:02:31 -07:00
ncclResult_t ncclTransportP2pConnect(struct ncclComm* comm, int channelId, int nrecv, int* peerRecv, int nsend, int* peerSend, int connIndex);
2023-09-12 06:30:04 +08:00
ncclResult_t ncclTransportP2pSetup(struct ncclComm* comm, struct ncclTopoGraph* graph, int connIndex, int* highestTransportType=NULL, bool* needsProxy=NULL);
2018-09-24 16:06:59 -07:00
2023-04-03 05:32:07 -07:00
ncclResult_t ncclNvlsInit(struct ncclComm* comm);
ncclResult_t ncclNvlsSetup(struct ncclComm* comm, struct ncclComm* parent);
2024-06-11 01:28:01 -07:00
ncclResult_t ncclNvlsBufferSetup(struct ncclComm* comm);
ncclResult_t ncclNvlsTreeConnect(struct ncclComm* comm);
ncclResult_t ncclNvlsGraphRegisterBuffer(struct ncclComm *comm, const void *sendbuff, void *recvbuff, size_t sendbuffSize, size_t recvbuffSize, bool *outRegBufUsed, void **outRegBufSend, void **outRegBufRecv, struct ncclIntruQueue<struct ncclCommCallback, &ncclCommCallback::next>* cleanupQueue, int* nCleanupQueueElts);
2023-09-26 05:47:28 -07:00
ncclResult_t ncclNvlsLocalRegisterBuffer(struct ncclComm *comm, const void *sendbuff, void *recvbuff, size_t sendbuffSize, size_t recvbuffSize, bool *outRegBufUsed, void **outRegBufSend, void **outRegBufRecv);
ncclResult_t ncclNvlsDeregBuffer(CUmemGenericAllocationHandle *mcHandler, CUdeviceptr ptr, int dev, size_t size);
2023-02-27 02:48:21 -08:00
ncclResult_t ncclNvlsFree(struct ncclComm* comm);
2021-04-12 16:00:11 -07:00
enum { collNetRecv=0, collNetSend=1 };
2024-03-26 06:08:55 -07:00
int ncclTransportCollNetSetup(struct ncclComm* comm, struct ncclTopoGraph* collNetGraph, struct ncclChannel* channel, int masterRank, int masterPeer, int collNetGraphChannelId, int type, ncclConnect* connect);
2021-04-12 16:00:11 -07:00
ncclResult_t ncclTransportCollNetCheck(struct ncclComm* comm, int collNetSetupFail);
2021-05-11 18:16:30 -07:00
ncclResult_t ncclTransportCollNetFree(struct ncclComm* comm);
2024-03-26 06:08:55 -07:00
ncclResult_t ncclCollnetLocalRegisterBuffer(struct ncclComm* comm, const void* userbuff, size_t buffSize, int type, int* outRegBufUsed, void** outHandle);
2024-06-11 01:28:01 -07:00
ncclResult_t ncclCollnetGraphRegisterBuffer(struct ncclComm* comm, const void* userbuff, size_t buffSize, int type, int* outRegBufFlag, void** outHandle, struct ncclIntruQueue<struct ncclCommCallback, &ncclCommCallback::next>* cleanupQueue, int* nCleanupQueueElts);
2024-03-26 06:08:55 -07:00
ncclResult_t ncclCollnetDeregBuffer(struct ncclComm* comm, struct ncclProxyConnector* proxyconn, void* handle);
2024-06-11 01:28:01 -07:00
ncclResult_t ncclTransportRingConnect(struct ncclComm* comm);
ncclResult_t ncclTransportTreeConnect(struct ncclComm* comm);
ncclResult_t ncclCollNetSetup(ncclComm_t comm, ncclComm_t parent, struct ncclTopoGraph* graphs[]);
ncclResult_t ncclCollNetChainBufferSetup(ncclComm_t comm);
ncclResult_t ncclCollNetDirectBufferSetup(ncclComm_t comm);
2018-09-24 16:06:59 -07:00
#endif