rocprofiler-sdk/rccl/api_args.h Source File

rocprofiler-sdk/rccl/api_args.h Source File#

ROCprofiler-SDK developer API: rocprofiler-sdk/rccl/api_args.h Source File
ROCprofiler-SDK developer API 1.0.0
ROCm Profiling API and tools
api_args.h
1// MIT License
2//
3// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21// THE SOFTWARE.
22
23#pragma once
24
25#include <rocprofiler-sdk/defines.h>
26
27#if !defined(ROCPROFILER_SDK_USE_SYSTEM_RCCL)
28# if defined __has_include
29# if __has_include(<rccl/rccl.h>)
30# define ROCPROFILER_SDK_USE_SYSTEM_RCCL 1
31# else
32# define ROCPROFILER_SDK_USE_SYSTEM_RCCL 0
33# endif
34# else
35# define ROCPROFILER_SDK_USE_SYSTEM_RCCL 0
36# endif
37#endif
38
39#if ROCPROFILER_SDK_USE_SYSTEM_RCCL > 0
40# include <rccl/rccl.h>
41#else
42# include <rocprofiler-sdk/rccl/details/rccl.h>
43#endif
44
45#include <stdint.h>
46
47ROCPROFILER_EXTERN_C_INIT
48
49// Empty struct has a size of 0 in C but size of 1 in C++.
50// This struct is added to the union members which represent
51// functions with no arguments to ensure ABI compatibility
52typedef struct rocprofiler_rccl_api_no_args
53{
54 char empty;
55} rocprofiler_rccl_api_no_args;
56
57typedef union rocprofiler_rccl_api_retval_t
58{
59 int32_t ncclResult_t_retval;
60 const char* const_charp_retval;
61} rocprofiler_rccl_api_retval_t;
62
63typedef union rocprofiler_rccl_api_args_t
64{
65 struct
66 {
67 const void* sendbuff;
68 void* recvbuff;
69 size_t sendcount;
70 ncclDataType_t datatype;
71 ncclComm_t comm;
72 hipStream_t stream;
73 } ncclAllGather;
74 struct
75 {
76 const void* sendbuff;
77 void* recvbuff;
78 size_t count;
79 ncclDataType_t datatype;
80 ncclRedOp_t op;
81 struct ncclComm* comm;
82 hipStream_t stream;
83 } ncclAllReduce;
84 struct
85 {
86 const void* sendbuff;
87 void* recvbuff;
88 size_t count;
89 ncclDataType_t datatype;
90 ncclComm_t comm;
91 hipStream_t stream;
92 } ncclAllToAll;
93 struct
94 {
95 const void* sendbuff;
96 const size_t* sendcounts;
97 const size_t* sdispls;
98 void* recvbuff;
99 const size_t* recvcounts;
100 const size_t* rdispls;
101 ncclDataType_t datatype;
102 ncclComm_t comm;
103 hipStream_t stream;
104 } ncclAllToAllv;
105 struct
106 {
107 const void* sendbuff;
108 void* recvbuff;
109 size_t count;
110 ncclDataType_t datatype;
111 int root;
112 ncclComm_t comm;
113 hipStream_t stream;
114 } ncclBroadcast;
115 struct
116 {
117 const void* sendbuff;
118 void* recvbuff;
119 size_t sendcount;
120 ncclDataType_t datatype;
121 int root;
122 ncclComm_t comm;
123 hipStream_t stream;
124 } ncclGather;
125 struct
126 {
127 const void* sendbuff;
128 void* recvbuff;
129 size_t count;
130 ncclDataType_t datatype;
131 ncclRedOp_t op;
132 int root;
133 ncclComm_t comm;
134 hipStream_t stream;
135 } ncclReduce;
136 struct
137 {
138 const void* sendbuff;
139 void* recvbuff;
140 size_t recvcount;
141 ncclDataType_t datatype;
142 ncclRedOp_t op;
143 struct ncclComm* comm;
144 hipStream_t stream;
145 } ncclReduceScatter;
146 struct
147 {
148 const void* sendbuff;
149 void* recvbuff;
150 size_t recvcount;
151 ncclDataType_t datatype;
152 int root;
153 ncclComm_t comm;
154 hipStream_t stream;
155 } ncclScatter;
156 struct
157 {
158 const void* sendbuff;
159 size_t count;
160 ncclDataType_t datatype;
161 int peer;
162 ncclComm_t comm;
163 hipStream_t stream;
164 } ncclSend;
165 struct
166 {
167 void* recvbuff;
168 size_t count;
169 ncclDataType_t datatype;
170 int peer;
171 ncclComm_t comm;
172 hipStream_t stream;
173 } ncclRecv;
174 struct
175 {
176 ncclRedOp_t* op;
177 void* scalar;
178 ncclDataType_t datatype;
179 ncclScalarResidence_t residence;
180 ncclComm_t comm;
181 } ncclRedOpCreatePreMulSum;
182 struct
183 {
184 ncclRedOp_t op;
185 ncclComm_t comm;
186 } ncclRedOpDestroy;
187 struct
188 {
189 rocprofiler_rccl_api_no_args no_args;
190 } ncclGroupStart;
191 struct
192 {
193 rocprofiler_rccl_api_no_args no_args;
194 } ncclGroupEnd;
195 struct
196 {
197 int* version;
198 } ncclGetVersion;
199 struct
200 {
201 ncclUniqueId* out;
202 } ncclGetUniqueId;
203 struct
204 {
205 ncclComm_t* newcomm;
206 int nranks;
207 ncclUniqueId commId;
208 int myrank;
209 } ncclCommInitRank;
210 struct
211 {
212 ncclComm_t* comms;
213 int ndev;
214 const int* devlist;
215 } ncclCommInitAll;
216 struct
217 {
218 ncclComm_t* comm;
219 int nranks;
220 ncclUniqueId commId;
221 int myrank;
222 ncclConfig_t* config;
223 } ncclCommInitRankConfig;
224 struct
225 {
226 ncclComm_t comm;
227 } ncclCommFinalize;
228 struct
229 {
230 ncclComm_t comm;
231 } ncclCommDestroy;
232 struct
233 {
234 ncclComm_t comm;
235 } ncclCommAbort;
236 struct
237 {
238 ncclComm_t comm;
239 int color;
240 int key;
241 ncclComm_t* newcomm;
242 ncclConfig_t* config;
243 } ncclCommSplit;
244 struct
245 {
246 ncclResult_t code;
247 } ncclGetErrorString;
248 struct
249 {
250 ncclComm_t comm;
251 } ncclGetLastError;
252 struct
253 {
254 ncclComm_t comm;
255 ncclResult_t* asyncError;
256 } ncclCommGetAsyncError;
257 struct
258 {
259 ncclComm_t comm;
260 int* count;
261 } ncclCommCount;
262 struct
263 {
264 ncclComm_t comm;
265 int* devid;
266 } ncclCommCuDevice;
267 struct
268 {
269 ncclComm_t comm;
270 int* rank;
271 } ncclCommUserRank;
272 struct
273 {
274 void** ptr;
275 size_t size;
276 } ncclMemAlloc;
277 struct
278 {
279 void* ptr;
280 } ncclMemFree;
281 struct
282 {
283 const char* mscclAlgoFilePath;
284 mscclAlgoHandle_t* mscclAlgoHandle;
285 int rank;
286 } mscclLoadAlgo;
287 struct
288 {
289 const void* sendBuff;
290 const size_t* sendCounts;
291 const size_t* sDisPls;
292 void* recvBuff;
293 const size_t* recvCounts;
294 const size_t* rDisPls;
295 size_t count;
296 ncclDataType_t dataType;
297 int root;
298 int peer;
299 ncclRedOp_t op;
300 mscclAlgoHandle_t mscclAlgoHandle;
301 ncclComm_t comm;
302 hipStream_t stream;
303 } mscclRunAlgo;
304 struct
305 {
306 mscclAlgoHandle_t mscclAlgoHandle;
307 } mscclUnloadAlgo;
308 struct
309 {
310 ncclComm_t comm;
311 void* buff;
312 size_t size;
313 void** handle;
314 } ncclCommRegister;
315 struct
316 {
317 ncclComm_t comm;
318 void* handle;
319 } ncclCommDeregister;
320#if RCCL_API_TRACE_VERSION_PATCH >= 1
321 struct
322 {
323 const void* sendbuff;
324 void* recvbuff;
325 size_t count;
326 ncclDataType_t datatype;
327 ncclRedOp_t op;
328 struct ncclComm* comm;
329 hipStream_t stream;
330 const void* acc;
331 } ncclAllReduceWithBias;
332#endif
333#if RCCL_API_TRACE_VERSION_PATCH >= 2
334 struct
335 {
336 ncclComm_t comm;
337 int* excludeRanksList;
338 int excludeRanksCount;
339 ncclComm_t* newcomm;
340 ncclConfig_t* config;
341 int shrinkFlags;
342 } ncclCommShrink;
343 struct
344 {
345 ncclComm_t comm;
346 void* buff;
347 size_t size;
348 ncclWindow_t* win;
349 int winFlags;
350 } ncclCommWindowRegister;
351 struct
352 {
353 ncclComm_t comm;
354 ncclWindow_t win;
355 } ncclCommWindowDeregister;
356#endif
357} rocprofiler_rccl_api_args_t;
358
359ROCPROFILER_EXTERN_C_FINI