Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : /*
12 : * 该特性代码不涉及开源
13 : */
14 :
15 : #include "interface_hccl.h"
16 : #include "typical_param_check.h"
17 : #include "hccl_common.h"
18 : #include "externalinput.h"
19 : #include "rdma_resource_manager.h"
20 : #include "typical_mr_manager.h"
21 : #include "typical_sync_mem.h"
22 : #include "typical_window_mem.h"
23 : #include "typical_qp_manager.h"
24 : #include "send_recv_executor.h"
25 : #include "adapter_rts.h"
26 :
27 : using namespace hccl;
28 : constexpr u32 DEVISOR_VALUE_FOUR = 4;
29 : constexpr u32 MAX_WQE_PER_DOORBELL = 300;
30 : constexpr u32 QP_QUEUE_DEPTH_MAX = 32768;
31 : constexpr u32 QP_QUEUE_DEPTH_MIN = 128;
32 : #define HCCN_RESV_MEM_TYPE_PDCCL (0)
33 :
34 0 : struct MrInfoT AscendMrInfo2MrInfo(AscendMrInfo* ascendMrInfo)
35 : {
36 0 : struct MrInfoT innerMrInfo = {};
37 0 : innerMrInfo.addr = reinterpret_cast<void*>(ascendMrInfo->addr);
38 0 : innerMrInfo.size = ascendMrInfo->size;
39 0 : innerMrInfo.lkey = ascendMrInfo->key;
40 0 : return innerMrInfo;
41 : }
42 :
43 30 : HcclResult hcclCreateAscendQP(AscendQPInfo* ascendQPInfo)
44 : {
45 30 : s32 deviceLogicId = 0;
46 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
47 30 : CHK_PTR_NULL(ascendQPInfo);
48 30 : struct TypicalQp qpInfo = {};
49 30 : CHK_RET(TypicalQpManager::GetInstance().CreateQp(qpInfo));
50 30 : ascendQPInfo->qpn = qpInfo.qpn;
51 30 : ascendQPInfo->gidIdx = qpInfo.gidIdx;
52 510 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
53 480 : ascendQPInfo->gid[i] = qpInfo.gid[i];
54 : }
55 30 : ascendQPInfo->psn = qpInfo.psn;
56 30 : HCCL_INFO(
57 : "hcclCreateAscendQP success! qpn %u, gid index %u, psn %u", ascendQPInfo->qpn, ascendQPInfo->gidIdx,
58 : ascendQPInfo->psn);
59 :
60 30 : return HCCL_SUCCESS;
61 : }
62 :
63 76 : HcclResult CheckDepth(uint32_t depth)
64 : {
65 76 : if (depth >= QP_QUEUE_DEPTH_MIN && ((depth & (depth - 1)) == 0) && depth <= QP_QUEUE_DEPTH_MAX) {
66 61 : return HCCL_SUCCESS;
67 : }
68 15 : HCCL_ERROR(
69 : "[CheckDepth]depth[%u] is invalid, depth should be power of 2 and in [%u, %u]", depth, QP_QUEUE_DEPTH_MIN,
70 : QP_QUEUE_DEPTH_MAX);
71 15 : return HCCL_E_PARA;
72 : }
73 :
74 22 : HcclResult hcclCreateAscendQPWithAttr(AscendQPInfo* ascendQPInfo)
75 : {
76 22 : s32 deviceLogicId = 0;
77 22 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
78 22 : CHK_PTR_NULL(ascendQPInfo);
79 22 : CHK_RET(CheckDepth(ascendQPInfo->sq_depth));
80 19 : CHK_RET(CheckDepth(ascendQPInfo->scq_depth));
81 16 : CHK_RET(CheckDepth(ascendQPInfo->rq_depth));
82 13 : CHK_RET(CheckDepth(ascendQPInfo->rcq_depth));
83 : struct TypicalQp qpInfo;
84 10 : QpConfigInfo qpConfigInfo{
85 10 : ascendQPInfo->sq_depth, ascendQPInfo->rq_depth, ascendQPInfo->scq_depth, ascendQPInfo->rcq_depth, 0, 0};
86 : u32 poolId;
87 10 : if (HCCL_SUCCESS == RdmaResourceManager::GetInstance().GetResvMemPoolIdByType(HCCN_RESV_MEM_TYPE_PDCCL, poolId)) {
88 0 : qpConfigInfo.use_resv_mem = 1;
89 0 : qpConfigInfo.resv_mem_pool_id = poolId;
90 : }
91 10 : CHK_RET(TypicalQpManager::GetInstance().CreateQp(qpInfo, qpConfigInfo));
92 9 : ascendQPInfo->qpn = qpInfo.qpn;
93 9 : ascendQPInfo->gidIdx = qpInfo.gidIdx;
94 153 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
95 144 : ascendQPInfo->gid[i] = qpInfo.gid[i];
96 : }
97 9 : ascendQPInfo->psn = qpInfo.psn;
98 9 : HCCL_INFO(
99 : "hcclCreateAscendQP success! qpn[%u], gid index[%u], psn[%u], sq_depth[%u], rq_depth[%u], scq_depth[%u], "
100 : "rcq_depth[%u] ",
101 : ascendQPInfo->qpn, ascendQPInfo->gidIdx, ascendQPInfo->psn, ascendQPInfo->sq_depth, ascendQPInfo->rq_depth,
102 : ascendQPInfo->scq_depth, ascendQPInfo->rcq_depth);
103 :
104 9 : return HCCL_SUCCESS;
105 : }
106 :
107 5 : HcclResult hcclCreateAscendCQWithAttr(AscendCQInfo* ascendCQInfo)
108 : {
109 5 : CHK_PTR_NULL(ascendCQInfo);
110 4 : if (ascendCQInfo->cqDepth == 0) {
111 0 : ascendCQInfo->cqDepth = HOST_SQ_CQ_DEPTH;
112 : }
113 4 : CHK_RET(CheckDepth(ascendCQInfo->cqDepth));
114 :
115 1 : s32 deviceLogicId = 0;
116 1 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
117 1 : CHK_RET(TypicalQpManager::GetInstance().CreateCq(*ascendCQInfo));
118 1 : HCCL_INFO("hcclCreateAscendCQWithAttr success! cqn[%u], cqDepth[%u]", ascendCQInfo->cqn, ascendCQInfo->cqDepth);
119 1 : return HCCL_SUCCESS;
120 : }
121 :
122 3 : HcclResult hcclDestroyAscendCQ(AscendCQInfo* ascendCQInfo)
123 : {
124 3 : CHK_PTR_NULL(ascendCQInfo);
125 2 : s32 deviceLogicId = 0;
126 2 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
127 2 : CHK_RET(TypicalQpManager::GetInstance().DestroyCq(ascendCQInfo->cqn));
128 1 : HCCL_INFO("hcclDestroyAscendCQ success! cqn[%u]", ascendCQInfo->cqn);
129 1 : return HCCL_SUCCESS;
130 : }
131 :
132 5 : HcclResult hcclPollAscendCQ(AscendCQInfo* cqInfo, uint32_t num, uint32_t* polledNum, struct AscendWc* wc)
133 : {
134 5 : CHK_PTR_NULL(cqInfo);
135 4 : CHK_PTR_NULL(polledNum);
136 3 : CHK_PTR_NULL(wc);
137 :
138 2 : s32 deviceLogicId = 0;
139 2 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
140 2 : void* cqHandle = nullptr;
141 2 : CHK_RET(TypicalQpManager::GetInstance().GetCqHandle(cqInfo->cqn, cqHandle));
142 :
143 2 : s32 ret = HrtRaPollTypicalCq(cqHandle, num, (void*)wc);
144 2 : if (ret < 0) {
145 1 : HCCL_ERROR("[hcclPollAscendCQ] Poll typical cq failed, cqn[%u], ret[%d]", cqInfo->cqn, ret);
146 1 : return HCCL_E_INTERNAL;
147 : }
148 1 : *polledNum = (uint32_t)ret;
149 1 : return HCCL_SUCCESS;
150 : }
151 :
152 6 : HcclResult hcclCreateAscendQPWithCQWithAttr(
153 : AscendCQInfo* ascendSendCQInfo, AscendCQInfo* ascendRecvCQInfo, AscendVerbsQPInfo* ascendQPInfo)
154 : {
155 6 : s32 deviceLogicId = 0;
156 6 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
157 6 : CHK_PTR_NULL(ascendSendCQInfo);
158 5 : CHK_PTR_NULL(ascendRecvCQInfo);
159 4 : CHK_PTR_NULL(ascendQPInfo);
160 :
161 3 : CHK_RET(TypicalQpManager::GetInstance().ValidateCq(ascendSendCQInfo->cqn));
162 2 : CHK_RET(TypicalQpManager::GetInstance().ValidateCq(ascendRecvCQInfo->cqn));
163 :
164 2 : struct TypicalQp qpInfo {
165 : 0
166 : };
167 2 : QpConfigWithCQInfo qpConfigInfo{0};
168 2 : qpConfigInfo.sendCqn = ascendSendCQInfo->cqn;
169 2 : qpConfigInfo.recvCqn = ascendRecvCQInfo->cqn;
170 :
171 2 : if (ascendQPInfo->cap.maxSendWr == 0) {
172 1 : qpConfigInfo.sq_depth = DEFAULT_OPBASE_MAX_SEND_WR;
173 : } else {
174 1 : CHK_RET(CheckDepth(ascendQPInfo->cap.maxSendWr));
175 1 : qpConfigInfo.sq_depth = ascendQPInfo->cap.maxSendWr;
176 : }
177 2 : if (ascendQPInfo->cap.maxRecvWr == 0) {
178 1 : qpConfigInfo.rq_depth = DEFAULT_MAX_RECV_WR;
179 : } else {
180 1 : CHK_RET(CheckDepth(ascendQPInfo->cap.maxRecvWr));
181 1 : qpConfigInfo.rq_depth = ascendQPInfo->cap.maxRecvWr;
182 : }
183 :
184 2 : CHK_RET(TypicalQpManager::GetInstance().GetCqDepth(ascendSendCQInfo->cqn, qpConfigInfo.scq_depth));
185 2 : CHK_RET(TypicalQpManager::GetInstance().GetCqDepth(ascendRecvCQInfo->cqn, qpConfigInfo.rcq_depth));
186 :
187 2 : if (ascendQPInfo->qp_type == 0) {
188 1 : ascendQPInfo->qp_type = ASCEND_QPT_RC;
189 : }
190 :
191 2 : qpConfigInfo.sq_sig_all = ascendQPInfo->sqSigAll;
192 :
193 2 : if (ascendQPInfo->cap.maxSendSge == 0) {
194 1 : qpConfigInfo.max_send_sge = DEFAULT_MAX_SEND_SGE;
195 : } else {
196 1 : qpConfigInfo.max_send_sge = ascendQPInfo->cap.maxSendSge;
197 : }
198 2 : if (ascendQPInfo->cap.maxRecvSge == 0) {
199 1 : qpConfigInfo.max_recv_sge = DEFAULT_MAX_RECV_SGE;
200 : } else {
201 1 : qpConfigInfo.max_recv_sge = ascendQPInfo->cap.maxRecvSge;
202 : }
203 2 : if (ascendQPInfo->cap.maxInlineData == 0) {
204 1 : qpConfigInfo.max_inline_data = DEFAULT_MAX_INLINE_DATA;
205 : } else {
206 1 : qpConfigInfo.max_inline_data = ascendQPInfo->cap.maxInlineData;
207 : }
208 :
209 : u32 poolId;
210 2 : if (HCCL_SUCCESS == RdmaResourceManager::GetInstance().GetResvMemPoolIdByType(HCCN_RESV_MEM_TYPE_PDCCL, poolId)) {
211 0 : qpConfigInfo.use_resv_mem = 1;
212 0 : qpConfigInfo.resv_mem_pool_id = poolId;
213 : }
214 2 : CHK_RET(TypicalQpManager::GetInstance().CreateQpWithCQ(qpInfo, qpConfigInfo));
215 2 : ascendQPInfo->qpn = qpInfo.qpn;
216 2 : ascendQPInfo->gidIdx = qpInfo.gidIdx;
217 34 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
218 32 : ascendQPInfo->gid[i] = qpInfo.gid[i];
219 : }
220 2 : ascendQPInfo->psn = qpInfo.psn;
221 2 : HCCL_INFO(
222 : "hcclCreateAscendQPWithCQWithAttr success! qpn[%u], gid index[%u], psn[%u], sendCqn[%u], recvCqn[%u]",
223 : ascendQPInfo->qpn, ascendQPInfo->gidIdx, ascendQPInfo->psn, ascendSendCQInfo->cqn, ascendRecvCQInfo->cqn);
224 :
225 2 : return HCCL_SUCCESS;
226 : }
227 :
228 3 : HcclResult hcclDestroyAscendVerbsQP(AscendVerbsQPInfo* ascendQPVerbsInfo)
229 : {
230 3 : s32 deviceLogicId = 0;
231 3 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
232 3 : CHK_PTR_NULL(ascendQPVerbsInfo);
233 : struct TypicalQp qpInfo;
234 2 : qpInfo.qpn = ascendQPVerbsInfo->qpn;
235 2 : qpInfo.gidIdx = ascendQPVerbsInfo->gidIdx;
236 34 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
237 32 : qpInfo.gid[i] = ascendQPVerbsInfo->gid[i];
238 : }
239 2 : qpInfo.psn = ascendQPVerbsInfo->psn;
240 2 : CHK_RET(TypicalQpManager::GetInstance().DestroyQpWithoutCQ(qpInfo));
241 1 : HCCL_INFO("hcclDestroyAscendVerbsQP success! qpn[%u]", ascendQPVerbsInfo->qpn);
242 1 : return HCCL_SUCCESS;
243 : }
244 :
245 0 : HcclResult hcclModifyAscendQP(AscendQPInfo* localQPInfo, AscendQPInfo* remoteQPInfo)
246 : {
247 0 : s32 deviceLogicId = 0;
248 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
249 : AscendQPQos qpQos;
250 0 : qpQos.sl = GetExternalInputRdmaServerLevel();
251 0 : qpQos.tc = GetExternalInputRdmaTrafficClass();
252 0 : CHK_RET(hcclModifyAscendQPEx(localQPInfo, remoteQPInfo, &qpQos));
253 0 : return HCCL_SUCCESS;
254 : }
255 :
256 30 : HcclResult hcclModifyAscendQPEx(AscendQPInfo* localQPInfo, AscendQPInfo* remoteQPInfo, AscendQPQos* qpQos)
257 : {
258 30 : s32 deviceLogicId = 0;
259 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
260 30 : CHK_PTR_NULL(localQPInfo);
261 30 : CHK_PTR_NULL(remoteQPInfo);
262 30 : CHK_PTR_NULL(qpQos);
263 30 : CHK_PRT_RET(
264 : (qpQos->sl > HCCL_RDMA_SL_MAX),
265 : HCCL_ERROR(
266 : "[hcclModifyAscendQPEx]The value of sl[%u] is invalid. except: [%u, %u].", qpQos->sl, HCCL_RDMA_SL_MIN,
267 : HCCL_RDMA_SL_MAX),
268 : HCCL_E_PARA);
269 30 : CHK_PRT_RET(
270 : (qpQos->tc > HCCL_RDMA_TC_MAX),
271 : HCCL_ERROR(
272 : "[hcclModifyAscendQPEx]The value of tc[%u] is invalid. except: [%u, %u].", qpQos->tc, HCCL_RDMA_TC_MIN,
273 : HCCL_RDMA_TC_MAX),
274 : HCCL_E_PARA);
275 :
276 : // 设置的RDMATrafficClass需要是4的整数倍, 否则报错
277 30 : CHK_PRT_RET(
278 : qpQos->tc % DEVISOR_VALUE_FOUR != 0,
279 : HCCL_ERROR("[hcclModifyAscendQPEx]The value of tc[%u] is not a multiple of 4.", qpQos->tc), HCCL_E_PARA);
280 :
281 : struct TypicalQp localQp;
282 30 : localQp.qpn = localQPInfo->qpn;
283 30 : localQp.gidIdx = localQPInfo->gidIdx;
284 510 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
285 480 : localQp.gid[i] = localQPInfo->gid[i];
286 : }
287 30 : localQp.psn = localQPInfo->psn;
288 30 : localQp.sl = qpQos->sl;
289 30 : localQp.tc = qpQos->tc;
290 :
291 30 : struct TypicalQp remoteQp = {};
292 30 : remoteQp.qpn = remoteQPInfo->qpn;
293 30 : remoteQp.gidIdx = remoteQPInfo->gidIdx;
294 510 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
295 480 : remoteQp.gid[i] = remoteQPInfo->gid[i];
296 : }
297 30 : remoteQp.psn = remoteQPInfo->psn;
298 30 : CHK_RET(TypicalQpManager::GetInstance().ModifyQp(localQp, remoteQp));
299 30 : return HCCL_SUCCESS;
300 : }
301 :
302 2 : HcclResult hcclModifyAscendVerbsQP(AscendVerbsQPInfo* localQPInfo, AscendVerbsQPInfo* remoteQPInfo)
303 : {
304 2 : s32 deviceLogicId = 0;
305 2 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
306 : AscendQPQos qpQos;
307 1 : qpQos.sl = GetExternalInputRdmaServerLevel();
308 1 : qpQos.tc = GetExternalInputRdmaTrafficClass();
309 1 : CHK_RET(hcclModifyAscendVerbsQPEx(localQPInfo, remoteQPInfo, &qpQos));
310 1 : return HCCL_SUCCESS;
311 : }
312 :
313 : HcclResult
314 9 : hcclModifyAscendVerbsQPEx(AscendVerbsQPInfo* localQPVerbsInfo, AscendVerbsQPInfo* remoteQPVerbsInfo, AscendQPQos* qpQos)
315 : {
316 9 : s32 deviceLogicId = 0;
317 9 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
318 9 : CHK_PTR_NULL(localQPVerbsInfo);
319 8 : CHK_PTR_NULL(remoteQPVerbsInfo);
320 7 : CHK_PTR_NULL(qpQos);
321 6 : CHK_PRT_RET(
322 : (qpQos->sl > HCCL_RDMA_SL_MAX),
323 : HCCL_ERROR(
324 : "[hcclModifyAscendVerbsQPEx]The value of sl[%u] is invalid. except: [%u, %u].", qpQos->sl, HCCL_RDMA_SL_MIN,
325 : HCCL_RDMA_SL_MAX),
326 : HCCL_E_PARA);
327 5 : CHK_PRT_RET(
328 : (qpQos->tc > HCCL_RDMA_TC_MAX),
329 : HCCL_ERROR(
330 : "[hcclModifyAscendVerbsQPEx]The value of tc[%u] is invalid. except: [%u, %u].", qpQos->tc, HCCL_RDMA_TC_MIN,
331 : HCCL_RDMA_TC_MAX),
332 : HCCL_E_PARA);
333 :
334 4 : CHK_PRT_RET(
335 : qpQos->tc % DEVISOR_VALUE_FOUR != 0,
336 : HCCL_ERROR("[hcclModifyAscendVerbsQPEx]The value of tc[%u] is not a multiple of 4.", qpQos->tc), HCCL_E_PARA);
337 :
338 : struct TypicalQp localQp;
339 3 : localQp.qpn = localQPVerbsInfo->qpn;
340 3 : localQp.gidIdx = localQPVerbsInfo->gidIdx;
341 51 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
342 48 : localQp.gid[i] = localQPVerbsInfo->gid[i];
343 : }
344 3 : localQp.psn = localQPVerbsInfo->psn;
345 3 : localQp.sl = qpQos->sl;
346 3 : localQp.tc = qpQos->tc;
347 :
348 3 : struct TypicalQp remoteQp = {};
349 3 : remoteQp.qpn = remoteQPVerbsInfo->qpn;
350 3 : remoteQp.gidIdx = remoteQPVerbsInfo->gidIdx;
351 51 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
352 48 : remoteQp.gid[i] = remoteQPVerbsInfo->gid[i];
353 : }
354 3 : remoteQp.psn = remoteQPVerbsInfo->psn;
355 3 : CHK_RET(TypicalQpManager::GetInstance().ModifyVerbsQp(localQp, remoteQp));
356 2 : return HCCL_SUCCESS;
357 : }
358 :
359 30 : HcclResult hcclDestroyAscendQP(AscendQPInfo* ascendQPInfo)
360 : {
361 30 : s32 deviceLogicId = 0;
362 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
363 30 : CHK_PTR_NULL(ascendQPInfo);
364 : struct TypicalQp qpInfo;
365 30 : qpInfo.qpn = ascendQPInfo->qpn;
366 30 : qpInfo.gidIdx = ascendQPInfo->gidIdx;
367 510 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
368 480 : qpInfo.gid[i] = ascendQPInfo->gid[i];
369 : }
370 30 : qpInfo.psn = ascendQPInfo->psn;
371 30 : CHK_RET(TypicalQpManager::GetInstance().DestroyQp(qpInfo));
372 30 : return HCCL_SUCCESS;
373 : }
374 :
375 30 : HcclResult hcclAllocWindowMem(void** ptr, size_t len)
376 : {
377 30 : s32 deviceLogicId = 0;
378 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
379 30 : return TypicalWindowMem::GetInstance().AllocWindowMem(ptr, len);
380 : }
381 :
382 30 : HcclResult hcclFreeWindowMem(void* ptr)
383 : {
384 30 : s32 deviceLogicId = 0;
385 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
386 30 : return TypicalWindowMem::GetInstance().FreeWindowMem(ptr);
387 : }
388 :
389 90 : HcclResult hcclAllocSyncMem(int32_t** ptr)
390 : {
391 90 : s32 deviceLogicId = 0;
392 90 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
393 90 : return TypicalSyncMem::GetInstance().AllocSyncMem(ptr);
394 : }
395 :
396 90 : HcclResult hcclFreeSyncMem(int32_t* ptr)
397 : {
398 90 : s32 deviceLogicId = 0;
399 90 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
400 90 : return TypicalSyncMem::GetInstance().FreeSyncMem(ptr);
401 : }
402 :
403 30 : HcclResult hcclRegisterMem(AscendMrInfo* memInfo)
404 : {
405 30 : s32 deviceLogicId = 0;
406 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
407 30 : CHK_PTR_NULL(memInfo);
408 30 : MrInfoT mrInfo = {};
409 30 : mrInfo.addr = reinterpret_cast<void*>(static_cast<uintptr_t>(memInfo->addr));
410 30 : mrInfo.size = memInfo->size;
411 30 : mrInfo.access = RA_ACCESS_REMOTE_WRITE | RA_ACCESS_LOCAL_WRITE | RA_ACCESS_REMOTE_READ;
412 30 : CHK_RET(TypicalMrManager::GetInstance().RegisterMem(mrInfo));
413 30 : memInfo->key = mrInfo.lkey;
414 30 : HCCL_RUN_INFO(
415 : "[hcclRegisterMem] Register WindowMem addr[%p], size[%llu], key[%u].", mrInfo.addr, mrInfo.size, mrInfo.lkey);
416 30 : return HCCL_SUCCESS;
417 : }
418 :
419 30 : HcclResult hcclDeRegisterMem(AscendMrInfo* memInfo)
420 : {
421 30 : s32 deviceLogicId = 0;
422 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
423 30 : CHK_PTR_NULL(memInfo);
424 30 : MrInfoT mrInfo = {};
425 30 : mrInfo.addr = reinterpret_cast<void*>(static_cast<uintptr_t>(memInfo->addr));
426 30 : mrInfo.size = memInfo->size;
427 30 : mrInfo.access = RA_ACCESS_REMOTE_WRITE | RA_ACCESS_LOCAL_WRITE | RA_ACCESS_REMOTE_READ;
428 30 : mrInfo.lkey = memInfo->key;
429 30 : CHK_RET(TypicalMrManager::GetInstance().DeRegisterMem(mrInfo));
430 30 : HCCL_RUN_INFO(
431 : "[hcclDeRegisterMem] DeRegister WindowMem addr[%p], size[%llu], key[%u].", mrInfo.addr, mrInfo.size,
432 : mrInfo.lkey);
433 30 : return HCCL_SUCCESS;
434 : }
435 :
436 3 : HcclResult hcclRdmaMemRegister(AscendMrAttr* memInfo)
437 : {
438 3 : s32 deviceLogicId = 0;
439 3 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
440 3 : CHK_PTR_NULL(memInfo);
441 2 : MrInfoT mrInfo = {};
442 2 : mrInfo.addr = reinterpret_cast<void*>(static_cast<uintptr_t>(memInfo->addr));
443 2 : mrInfo.size = memInfo->size;
444 2 : mrInfo.access = RA_ACCESS_REMOTE_WRITE | RA_ACCESS_LOCAL_WRITE | RA_ACCESS_REMOTE_READ;
445 2 : CHK_RET(TypicalMrManager::GetInstance().RegisterMem(mrInfo));
446 1 : memInfo->lkey = mrInfo.lkey;
447 1 : memInfo->rkey = mrInfo.rkey;
448 1 : HCCL_RUN_INFO(
449 : "[hcclRdmaMemRegister] Register MR addr[%p], size[%llu], lkey[%u], rkey[%u].", mrInfo.addr, mrInfo.size,
450 : mrInfo.lkey, mrInfo.rkey);
451 1 : return HCCL_SUCCESS;
452 : }
453 :
454 3 : HcclResult hcclRdmaMemDeRegister(AscendMrAttr* memInfo)
455 : {
456 3 : s32 deviceLogicId = 0;
457 3 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
458 3 : CHK_PTR_NULL(memInfo);
459 2 : MrInfoT mrInfo = {};
460 2 : mrInfo.addr = reinterpret_cast<void*>(static_cast<uintptr_t>(memInfo->addr));
461 2 : mrInfo.size = memInfo->size;
462 2 : mrInfo.access = RA_ACCESS_REMOTE_WRITE | RA_ACCESS_LOCAL_WRITE | RA_ACCESS_REMOTE_READ;
463 2 : mrInfo.lkey = memInfo->lkey;
464 2 : CHK_RET(TypicalMrManager::GetInstance().DeRegisterMem(mrInfo));
465 1 : HCCL_RUN_INFO(
466 : "[hcclRdmaMemDeRegister] DeRegister MR addr[%p], size[%llu], lkey[%u].", mrInfo.addr, mrInfo.size, mrInfo.lkey);
467 1 : return HCCL_SUCCESS;
468 : }
469 :
470 8 : HcclResult hcclAscendPostSend(
471 : AscendVerbsQPInfo* qpInfo, struct AscendSendWr* sendWr, aclrtStream stream, struct AscendSendWr** badWr)
472 : {
473 8 : s32 deviceLogicId = 0;
474 8 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
475 8 : CHK_PTR_NULL(qpInfo);
476 7 : CHK_PTR_NULL(sendWr);
477 6 : CHK_PTR_NULL(badWr);
478 5 : CHK_PTR_NULL(stream);
479 :
480 : QpHandle qpHandle;
481 4 : CHK_RET(TypicalQpManager::GetInstance().GetVerbsQpHandleByQpn(qpInfo->qpn, qpHandle));
482 :
483 4 : constexpr u32 MAX_SGLIST_VERBS = 16;
484 4 : struct AscendSendWr* curWr = sendWr;
485 8 : while (curWr != nullptr) {
486 7 : CHK_PRT_RET(
487 : static_cast<u32>(curWr->numSge) > MAX_SGLIST_VERBS,
488 : HCCL_ERROR("[hcclAscendPostSend] numSge[%d] exceeds MAX_SGLIST_VERBS[%u]", curWr->numSge, MAX_SGLIST_VERBS),
489 : HCCL_E_PARA);
490 5 : CHK_PTR_NULL(curWr->sgList);
491 :
492 : struct SgList sgeList[MAX_SGLIST_VERBS];
493 8 : for (int i = 0; i < curWr->numSge; i++) {
494 4 : sgeList[i].addr = curWr->sgList[i].addr;
495 4 : sgeList[i].len = curWr->sgList[i].len;
496 4 : sgeList[i].lkey = curWr->sgList[i].lkey;
497 : }
498 :
499 4 : struct SendWrVerbs wr = {};
500 4 : struct SendWrRsp opRsp = {};
501 4 : wr.wrId = curWr->wrId;
502 4 : wr.sgList = sgeList;
503 4 : wr.numSge = curWr->numSge;
504 4 : wr.remoteAddr = curWr->wr.rdma.remoteAddr;
505 4 : wr.rkey = curWr->wr.rdma.rkey;
506 4 : wr.opcode = static_cast<uint32_t>(curWr->opcode);
507 4 : wr.sendFlags = static_cast<int>(curWr->sendFlags);
508 4 : wr.immData = curWr->immData;
509 :
510 4 : CHK_RET(HrtRaSendWrVerbs(qpHandle, &wr, &opRsp));
511 :
512 4 : if (curWr->next == nullptr) {
513 2 : CHK_RET(hrtRDMADBSend(opRsp.db.dbIndex, opRsp.db.dbInfo, stream));
514 : }
515 :
516 4 : curWr = curWr->next;
517 : }
518 :
519 2 : *badWr = nullptr;
520 2 : return HCCL_SUCCESS;
521 : }
522 :
523 8 : HcclResult hcclAscendPostRecv(
524 : AscendVerbsQPInfo* qpInfo, struct AscendRecvWr* recvWr, aclrtStream stream, struct AscendRecvWr** badWr)
525 : {
526 8 : s32 deviceLogicId = 0;
527 8 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
528 8 : CHK_PTR_NULL(qpInfo);
529 7 : CHK_PTR_NULL(recvWr);
530 6 : CHK_PTR_NULL(badWr);
531 5 : CHK_PTR_NULL(stream);
532 :
533 : QpHandle qpHandle;
534 4 : CHK_RET(TypicalQpManager::GetInstance().GetVerbsQpHandleByQpn(qpInfo->qpn, qpHandle));
535 :
536 4 : constexpr u32 MAX_SGLIST_RECV = 16;
537 4 : struct AscendRecvWr* curWr = recvWr;
538 8 : while (curWr != nullptr) {
539 7 : CHK_PRT_RET(
540 : static_cast<u32>(curWr->numSge) > MAX_SGLIST_RECV,
541 : HCCL_ERROR("[hcclAscendPostRecv] numSge[%d] exceeds MAX_SGLIST_RECV[%u]", curWr->numSge, MAX_SGLIST_RECV),
542 : HCCL_E_PARA);
543 5 : CHK_PTR_NULL(curWr->sgList);
544 :
545 : struct SgList sgeList[MAX_SGLIST_RECV];
546 8 : for (int i = 0; i < curWr->numSge; i++) {
547 4 : sgeList[i].addr = curWr->sgList[i].addr;
548 4 : sgeList[i].len = curWr->sgList[i].len;
549 4 : sgeList[i].lkey = curWr->sgList[i].lkey;
550 : }
551 :
552 4 : struct RecvWrVerbs wr = {};
553 4 : wr.wrId = curWr->wrId;
554 4 : wr.sgList = sgeList;
555 4 : wr.numSge = curWr->numSge;
556 :
557 4 : CHK_RET(HrtRaRecvWrVerbs(qpHandle, &wr));
558 :
559 4 : curWr = curWr->next;
560 : }
561 :
562 2 : *badWr = nullptr;
563 2 : return HCCL_SUCCESS;
564 : }
565 :
566 0 : HcclResult HcclSendByAscendQP(
567 : void* sendBuf, uint64_t count, HcclDataType dataType, AscendSendRecvInfo* sendRecvInfo, aclrtStream stream)
568 : {
569 0 : s32 deviceLogicId = 0;
570 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
571 0 : CHK_RET(CheckParam(sendBuf, count, dataType, stream));
572 0 : CHK_RET(CheckSendRecvInfo(sendRecvInfo));
573 : QpHandle qpHandle;
574 0 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvInfo->localQPinfo->qpn, qpHandle));
575 : SendRecvExecutor executor(
576 0 : stream, qpHandle, AscendMrInfo2MrInfo(sendRecvInfo->localWindowMem),
577 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteWindowMem), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemPrepare),
578 0 : AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemDone), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemAck),
579 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemPrepare), AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemDone),
580 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemAck), sendRecvInfo->immData);
581 0 : CHK_RET(executor.Init());
582 0 : CHK_RET(executor.Send(sendBuf, count, dataType));
583 0 : return HCCL_SUCCESS;
584 0 : }
585 :
586 0 : HcclResult HcclRecvByAscendQP(
587 : void* recvBuf, uint64_t count, HcclDataType dataType, AscendSendRecvInfo* sendRecvInfo, aclrtStream stream)
588 : {
589 0 : s32 deviceLogicId = 0;
590 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
591 0 : CHK_RET(CheckParam(recvBuf, count, dataType, stream));
592 0 : CHK_RET(CheckSendRecvInfo(sendRecvInfo));
593 : QpHandle qpHandle;
594 0 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvInfo->localQPinfo->qpn, qpHandle));
595 : SendRecvExecutor executor(
596 0 : stream, qpHandle, AscendMrInfo2MrInfo(sendRecvInfo->localWindowMem),
597 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteWindowMem), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemPrepare),
598 0 : AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemDone), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemAck),
599 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemPrepare), AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemDone),
600 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemAck), sendRecvInfo->immData);
601 0 : CHK_RET(executor.Init());
602 0 : CHK_RET(executor.Receive(recvBuf, count, dataType));
603 0 : return HCCL_SUCCESS;
604 0 : }
605 :
606 32 : HcclResult hcclAscendRdmaInit()
607 : {
608 32 : s32 deviceLogicId = 0;
609 32 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
610 32 : CHK_RET(RdmaResourceManager::GetInstance().Init());
611 32 : return HCCL_SUCCESS;
612 : }
613 3 : HcclResult hcclAscendRdmaInitV2()
614 : {
615 3 : s32 deviceLogicId = 0;
616 3 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
617 2 : RdmaResourceManager::GetInstance().SetDisableLiteThread(true);
618 2 : CHK_RET(RdmaResourceManager::GetInstance().Init());
619 1 : return HCCL_SUCCESS;
620 : }
621 32 : HcclResult hcclAscendRdmaDeInit()
622 : {
623 32 : s32 deviceLogicId = 0;
624 32 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
625 32 : CHK_RET(RdmaResourceManager::GetInstance().DeInit());
626 32 : return HCCL_SUCCESS;
627 : }
628 :
629 0 : HcclResult HcclGetCqeErrInfoList(struct HcclErrCqeInfo* infoList, uint32_t* num)
630 : {
631 0 : s32 deviceLogicId = 0;
632 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
633 0 : CHK_PTR_NULL(infoList);
634 0 : CHK_PTR_NULL(num);
635 0 : u32 arrLen = *num;
636 0 : struct CqeErrInfo errCqeList[arrLen];
637 0 : CHK_RET(RdmaResourceManager::GetInstance().GetCqeErrInfo(errCqeList, num));
638 :
639 0 : CHK_PRT_RET(
640 : *num > arrLen,
641 : HCCL_ERROR(
642 : "[HcclGetCqeErrInfoList] GetCqeErrInfo num[%u] is larger than "
643 : "infoList user given[%u].",
644 : num, arrLen),
645 : HCCL_E_INTERNAL);
646 0 : for (u32 i = 0; i < *num; i++) {
647 0 : infoList[i].status = errCqeList[i].status;
648 0 : infoList[i].qpn = errCqeList[i].qpn;
649 0 : infoList[i].time = errCqeList[i].time;
650 0 : time_t tmpt = static_cast<time_t>(errCqeList[i].time.tv_sec);
651 : struct tm errTime;
652 0 : localtime_r(&tmpt, &errTime);
653 0 : HCCL_INFO(
654 : "[HcclGetCqeErrInfoList] Err Cqe status[%d], qpn[%d], time[%04u-%02d-%02d %02d:%0d:%02d.%06u]",
655 : errCqeList[i].status, errCqeList[i].qpn, errTime.tm_year + TIME_FROM_1900, errTime.tm_mon + 1,
656 : errTime.tm_mday, errTime.tm_hour, errTime.tm_min, errTime.tm_sec,
657 : static_cast<u32>(errCqeList[i].time.tv_usec));
658 : }
659 0 : return HCCL_SUCCESS;
660 0 : }
661 :
662 0 : HcclResult HcclGetCqeErrInfoListByQpn(uint32_t qpn, struct HcclErrCqeInfo* infoList, uint32_t* num)
663 : {
664 0 : s32 deviceLogicId = 0;
665 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
666 0 : CHK_PTR_NULL(infoList);
667 0 : CHK_PTR_NULL(num);
668 0 : CHK_RET(RdmaResourceManager::GetInstance().GetCqeErrInfoByQpn(qpn, infoList, num));
669 0 : return HCCL_SUCCESS;
670 : }
671 :
672 0 : HcclResult HcclPutByAscendQP(
673 : void* putBuf, uint64_t count, HcclDataType dataType, AscendSendRecvInfo* sendRecvInfo, aclrtStream stream)
674 : {
675 0 : CHK_PTR_NULL(stream);
676 0 : s32 deviceLogicId = 0;
677 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
678 0 : CHK_RET(CheckParam(putBuf, count, dataType, stream));
679 : QpHandle qpHandle;
680 0 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvInfo->localQPinfo->qpn, qpHandle));
681 : SendRecvExecutor executor(
682 0 : stream, qpHandle, AscendMrInfo2MrInfo(sendRecvInfo->localWindowMem),
683 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteWindowMem), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemPrepare),
684 0 : AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemDone), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemAck),
685 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemPrepare), AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemDone),
686 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemAck), sendRecvInfo->immData);
687 0 : CHK_RET(executor.Init());
688 0 : CHK_RET(executor.Put(putBuf, count, dataType));
689 0 : return HCCL_SUCCESS;
690 0 : }
691 :
692 19 : HcclResult HcclBatchPutMRByAscendQP(
693 : unsigned int num, AscendMrInfo* putMRList, AscendMrInfo* remoteMRList, AscendSendRecvLinkInfo* sendRecvLinkInfo,
694 : aclrtStream stream)
695 : {
696 19 : s32 deviceLogicId = 0;
697 19 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
698 19 : CHK_PRT_RET(
699 : num == 0, HCCL_INFO("[HcclBatchPutMRByAscendQP] mr list len is 0. No need to send data."), HCCL_SUCCESS);
700 19 : CHK_PTR_NULL(putMRList);
701 19 : CHK_PTR_NULL(remoteMRList);
702 19 : CHK_PTR_NULL(sendRecvLinkInfo);
703 19 : CHK_PTR_NULL(stream);
704 19 : CHK_RET(CheckSendRecvLinkInfo(sendRecvLinkInfo));
705 19 : CHK_PRT_RET(
706 : sendRecvLinkInfo->wqePerDoorbell == 0 || sendRecvLinkInfo->wqePerDoorbell > MAX_WQE_PER_DOORBELL,
707 : HCCL_ERROR("[HcclBatchPutMRByAscendQP] The value of wqePerDoorbell is exceed 300 or equal to 0."), HCCL_E_PARA);
708 : QpHandle qpHandle;
709 19 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvLinkInfo->localQPinfo->qpn, qpHandle));
710 :
711 19 : SendRecvExecutor executor(stream, qpHandle, sendRecvLinkInfo);
712 19 : CHK_RET(executor.Init());
713 19 : CHK_RET(executor.BatchPutMR(num, putMRList, remoteMRList));
714 :
715 19 : return HCCL_SUCCESS;
716 19 : }
717 :
718 19 : HcclResult HcclWaitPutMRByAscendQP(AscendSendRecvLinkInfo* sendRecvLinkInfo, aclrtStream stream)
719 : {
720 19 : s32 deviceLogicId = 0;
721 19 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
722 19 : CHK_PTR_NULL(sendRecvLinkInfo);
723 19 : CHK_PTR_NULL(stream);
724 19 : CHK_PTR_NULL(sendRecvLinkInfo->remoteSyncMemAck);
725 19 : CHK_PTR_NULL(sendRecvLinkInfo->localSyncMemDone);
726 : QpHandle qpHandle;
727 19 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvLinkInfo->localQPinfo->qpn, qpHandle));
728 :
729 19 : SendRecvExecutor executor(stream, qpHandle, sendRecvLinkInfo->localSyncMemDone, sendRecvLinkInfo->remoteSyncMemAck);
730 19 : CHK_RET(executor.WaitPutInit());
731 19 : CHK_RET(executor.WaitPutMR());
732 19 : return HCCL_SUCCESS;
733 19 : }
734 :
735 0 : HcclResult HcclWaitPutMRDoWait(AscendSendRecvLinkInfo* sendRecvLinkInfo, aclrtStream stream)
736 : {
737 0 : s32 deviceLogicId = 0;
738 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
739 0 : CHK_PTR_NULL(sendRecvLinkInfo);
740 0 : CHK_PTR_NULL(stream);
741 0 : CHK_PTR_NULL(sendRecvLinkInfo->remoteSyncMemAck);
742 0 : CHK_PTR_NULL(sendRecvLinkInfo->localSyncMemDone);
743 : QpHandle qpHandle;
744 0 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvLinkInfo->localQPinfo->qpn, qpHandle));
745 :
746 0 : SendRecvExecutor executor(stream, qpHandle, sendRecvLinkInfo->localSyncMemDone, sendRecvLinkInfo->remoteSyncMemAck);
747 0 : CHK_RET(executor.WaitPutInit());
748 0 : CHK_RET(executor.WaitPutMROnlyWait());
749 0 : return HCCL_SUCCESS;
750 0 : }
751 :
752 0 : HcclResult HcclWaitPutMRDoRecord(AscendSendRecvLinkInfo* sendRecvLinkInfo, aclrtStream stream)
753 : {
754 0 : s32 deviceLogicId = 0;
755 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
756 0 : CHK_PTR_NULL(sendRecvLinkInfo);
757 0 : CHK_PTR_NULL(stream);
758 0 : CHK_PTR_NULL(sendRecvLinkInfo->remoteSyncMemAck);
759 0 : CHK_PTR_NULL(sendRecvLinkInfo->localSyncMemDone);
760 : QpHandle qpHandle;
761 0 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvLinkInfo->localQPinfo->qpn, qpHandle));
762 :
763 0 : SendRecvExecutor executor(stream, qpHandle, sendRecvLinkInfo->localSyncMemDone, sendRecvLinkInfo->remoteSyncMemAck);
764 0 : CHK_RET(executor.WaitPutInit());
765 0 : CHK_RET(executor.WaitPutMROnlyRecord());
766 0 : return HCCL_SUCCESS;
767 0 : }
768 :
769 90 : HcclResult hcclGetSyncMemRegKey(AscendMrInfo* memInfo)
770 : {
771 90 : s32 deviceLogicId = 0;
772 90 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
773 90 : CHK_PTR_NULL(memInfo);
774 90 : struct MrInfoT mrInfo {};
775 90 : CHK_RET(RdmaResourceManager::GetInstance().GetNotifyMrInfo(mrInfo));
776 90 : memInfo->key = mrInfo.lkey;
777 90 : HCCL_RUN_INFO(
778 : "[hcclGetSyncMemRegKey] SyncMem addr[%p], size[%llu], key[%u].", memInfo->addr, memInfo->size, memInfo->key);
779 90 : return HCCL_SUCCESS;
780 : }
781 :
782 11 : HcclResult HcclOneSideBatchPutByAscendQP(
783 : unsigned int num, AscendMrInfo* putMRList, AscendMrInfo* remoteMRList, AscendSendLinkInfo* sendlinkInfo,
784 : aclrtStream stream)
785 : {
786 11 : s32 deviceLogicId = 0;
787 11 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
788 11 : CHK_PRT_RET(
789 : num == 0, HCCL_INFO("[HcclOneSideBatchPutByAscendQP] mr list len is 0. No need to send data."), HCCL_SUCCESS);
790 11 : CHK_PTR_NULL(putMRList);
791 11 : CHK_PTR_NULL(remoteMRList);
792 11 : CHK_PTR_NULL(sendlinkInfo);
793 11 : CHK_PTR_NULL(stream);
794 11 : CHK_RET(CheckSendLinkInfo(sendlinkInfo));
795 10 : CHK_PRT_RET(
796 : sendlinkInfo->wqePerDoorbell == 0 || sendlinkInfo->wqePerDoorbell > MAX_WQE_PER_DOORBELL,
797 : HCCL_ERROR("[HcclOneSideBatchPutByAscendQP] The value of wqePerDoorbell is exceed 300 or equal to 0."),
798 : HCCL_E_PARA);
799 : QpHandle qpHandle;
800 10 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendlinkInfo->localQPinfo->qpn, qpHandle));
801 :
802 10 : SendRecvExecutor executor(stream, qpHandle, sendlinkInfo);
803 10 : CHK_RET(executor.OneSideBatchPutMR(num, putMRList, remoteMRList));
804 :
805 10 : return HCCL_SUCCESS;
806 10 : }
|