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

159 строки
4.6 KiB
C
Исходник Обычный вид История

2019-03-14 19:39:20 -07:00
/*************************************************************************
2022-01-07 06:39:55 -08:00
* Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved.
* Modifications Copyright (c) 2019-2022 Advanced Micro Devices, Inc. All rights reserved.
2019-03-14 19:39:20 -07:00
*
* See LICENSE.txt for license information
************************************************************************/
#ifndef NCCL_INFO_H_
#define NCCL_INFO_H_
#include "nccl.h"
2023-09-26 05:47:28 -07:00
#include "device.h"
2021-09-08 13:56:25 -07:00
#include "collectives.h"
2022-05-24 02:02:31 -07:00
#include "core.h"
#include "utils.h"
#include "strongstream.h"
2024-02-05 05:06:02 -08:00
#define NCCL_MAX_LOCAL_RANKS 64
2019-03-14 19:39:20 -07:00
2022-01-07 06:39:55 -08:00
typedef enum : uint8_t {
2019-03-14 19:39:20 -07:00
ncclPatternRing,
ncclPatternRingTwice,
ncclPatternPipelineFrom,
ncclPatternPipelineTo,
ncclPatternTreeUp,
ncclPatternTreeDown,
2020-01-16 16:02:42 -08:00
ncclPatternTreeUpDown,
2022-08-18 02:53:17 -07:00
ncclPatternCollnetChain,
ncclPatternCollnetDirect,
2023-02-27 02:48:21 -08:00
ncclPatternNvls,
2023-04-03 05:32:07 -07:00
ncclPatternNvlsTree,
2022-01-07 06:39:55 -08:00
ncclPatternSend,
ncclPatternRecv
2019-03-14 19:39:20 -07:00
} ncclPattern_t;
// Used to pass NCCL call information between functions
struct ncclInfo {
2019-11-19 14:57:39 -08:00
ncclFunc_t coll;
2019-03-14 19:39:20 -07:00
const char* opName;
// NCCL Coll Args
const void* sendbuff;
void* recvbuff;
size_t count;
ncclDataType_t datatype;
ncclRedOp_t op;
2022-01-07 06:39:55 -08:00
int root; // peer for p2p operations
2019-03-14 19:39:20 -07:00
ncclComm_t comm;
2022-11-07 14:09:26 -08:00
cudaStream_t stream;
2019-03-14 19:39:20 -07:00
// Algorithm details
int chunkSteps;
int sliceSteps;
// Computed later
2021-09-08 13:56:25 -07:00
ncclDevRedOpFull opFull;
2019-03-14 19:39:20 -07:00
ncclPattern_t pattern;
size_t nBytes;
2024-02-05 05:06:02 -08:00
size_t aggnBytes;
size_t workBytes;
2023-09-26 05:47:28 -07:00
size_t sendbuffSize;
size_t recvbuffSize;
2024-02-05 05:06:02 -08:00
int stepSize;
int chunkCount;
2022-01-07 06:39:55 -08:00
int chunkSize;
2020-05-12 14:40:18 -07:00
int channelId;
2024-02-05 05:06:02 -08:00
int workFuncIndex;
ncclRegBufferType regBufType;
void* regBufSend[NCCL_MAX_LOCAL_RANKS];
void* regBufRecv[NCCL_MAX_LOCAL_RANKS];
2024-03-26 06:08:55 -07:00
// collnet buffer reg handles
void* sendMhandle;
void* recvMhandle;
2024-02-05 05:06:02 -08:00
// Need to initialize
int nThreads;
int nChannels;
int algorithm;
int protocol;
bool userTuned;
struct ncclInfo *next;
2019-03-14 19:39:20 -07:00
};
2022-05-24 02:02:31 -07:00
inline ncclResult_t ncclInfoSetDerived(struct ncclInfo* info, int nRanks) {
2024-02-05 05:06:02 -08:00
info->nBytes = info->workBytes = info->count * ncclTypeSize(info->datatype);
if (info->coll == ncclFuncAllGather || info->coll == ncclFuncBroadcast || info->coll == ncclFuncAllToAllPivot) {
2024-02-05 05:06:02 -08:00
info->count = info->workBytes;
2022-05-24 02:02:31 -07:00
info->datatype = ncclInt8;
}
if (info->coll == ncclFuncAllGather || info->coll == ncclFuncReduceScatter) info->nBytes *= nRanks; // count is per rank
2023-09-26 05:47:28 -07:00
/* compute buffer size for NVLS buffer registration */
if (info->coll == ncclFuncAllGather) {
2024-02-05 05:06:02 -08:00
info->sendbuffSize = info->workBytes;
2023-09-26 05:47:28 -07:00
info->recvbuffSize = info->sendbuffSize * nRanks;
} else if (info->coll == ncclFuncReduceScatter) {
2024-02-05 05:06:02 -08:00
info->recvbuffSize = info->workBytes;
2023-09-26 05:47:28 -07:00
info->sendbuffSize = info->recvbuffSize * nRanks;
} else {
2024-02-05 05:06:02 -08:00
info->sendbuffSize = info->recvbuffSize = info->workBytes;
2023-09-26 05:47:28 -07:00
}
2022-05-24 02:02:31 -07:00
return ncclSuccess;
}
struct ncclTaskColl {
struct ncclTaskColl* next;
ncclFunc_t func;
void const* sendbuff;
void* recvbuff;
size_t count;
int root;
ncclDataType_t datatype;
ncclDevRedOpFull op;
int chunkSteps, sliceSteps;
2024-02-05 05:06:02 -08:00
struct ncclInfo info;
2022-05-24 02:02:31 -07:00
};
struct ncclTaskP2p {
ncclTaskP2p *next;
void *buff;
size_t bytes;
// Stateful chunk index. If a p2p gets "cut" over two plans this keeps track
// of where it left off.
int chunk;
};
struct ncclCudaStreamList {
struct ncclCudaStreamList *next;
2022-11-07 14:09:26 -08:00
cudaStream_t stream;
2022-05-24 02:02:31 -07:00
};
struct ncclTasks {
struct Peer {
bool sendSeen, recvSeen;
struct ncclIntruQueue<struct ncclTaskP2p, &ncclTaskP2p::next> sendQueue;
struct ncclIntruQueue<struct ncclTaskP2p, &ncclTaskP2p::next> recvQueue;
};
2024-02-05 05:06:02 -08:00
struct ncclIntruQueue<struct ncclInfo, &ncclInfo::next> collQueue;
// Queue for user-tuned executed collectives
struct ncclIntruQueue<struct ncclInfo, &ncclInfo::next> collTunedQueue;
// Queue for continuous bytes distribution (CBD) collectives
struct ncclIntruQueue<struct ncclInfo, &ncclInfo::next> collCBDQueue;
// Queue for collnet
struct ncclIntruQueue<struct ncclInfo, &ncclInfo::next> collnetQueue;
size_t workBytesTotal;
int usableChannels;
bool sorted;
2022-05-24 02:02:31 -07:00
struct Peer* peers/*[nRanks]*/;
2023-04-03 05:32:07 -07:00
int *p2pSendOrder, *p2pRecvOrder;
int p2pOrderSteps;
2022-05-24 02:02:31 -07:00
int nTasksColl, nTasksP2p;
// The list of user streams aggregated over all tasks present.
struct ncclCudaStreamList* streams;
// Keep track of the number of user streams
int numStreams;
2022-05-24 02:02:31 -07:00
// The most recent user stream. Ignored if streams==nullptr
2022-11-07 14:09:26 -08:00
cudaStream_t streamRecent;
2022-05-24 02:02:31 -07:00
// The graph capturing all user streams or invalid if none. Thus we restrict the
// user that all streams must be captured in the same graph or not captured
// at all. Technically we could probably relax this, but that would mean
// collecting a different `ncclTasks` per graph and one for non-graph.
struct ncclCudaGraph capturingGraph;
2019-03-14 19:39:20 -07:00
};
#endif