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 2 : QpConfigWithCQInfo qpConfigInfo{};
166 2 : qpConfigInfo.sendCqn = ascendSendCQInfo->cqn;
167 2 : qpConfigInfo.recvCqn = ascendRecvCQInfo->cqn;
168 :
169 2 : if (ascendQPInfo->cap.maxSendWr == 0) {
170 1 : qpConfigInfo.sq_depth = DEFAULT_OPBASE_MAX_SEND_WR;
171 : } else {
172 1 : CHK_RET(CheckDepth(ascendQPInfo->cap.maxSendWr));
173 1 : qpConfigInfo.sq_depth = ascendQPInfo->cap.maxSendWr;
174 : }
175 2 : if (ascendQPInfo->cap.maxRecvWr == 0) {
176 1 : qpConfigInfo.rq_depth = DEFAULT_MAX_RECV_WR;
177 : } else {
178 1 : CHK_RET(CheckDepth(ascendQPInfo->cap.maxRecvWr));
179 1 : qpConfigInfo.rq_depth = ascendQPInfo->cap.maxRecvWr;
180 : }
181 :
182 2 : CHK_RET(TypicalQpManager::GetInstance().GetCqDepth(ascendSendCQInfo->cqn, qpConfigInfo.scq_depth));
183 2 : CHK_RET(TypicalQpManager::GetInstance().GetCqDepth(ascendRecvCQInfo->cqn, qpConfigInfo.rcq_depth));
184 :
185 2 : if (ascendQPInfo->qp_type == 0) {
186 1 : ascendQPInfo->qp_type = ASCEND_QPT_RC;
187 : }
188 :
189 2 : qpConfigInfo.sq_sig_all = ascendQPInfo->sqSigAll;
190 :
191 2 : if (ascendQPInfo->cap.maxSendSge == 0) {
192 1 : qpConfigInfo.max_send_sge = DEFAULT_MAX_SEND_SGE;
193 : } else {
194 1 : qpConfigInfo.max_send_sge = ascendQPInfo->cap.maxSendSge;
195 : }
196 2 : if (ascendQPInfo->cap.maxRecvSge == 0) {
197 1 : qpConfigInfo.max_recv_sge = DEFAULT_MAX_RECV_SGE;
198 : } else {
199 1 : qpConfigInfo.max_recv_sge = ascendQPInfo->cap.maxRecvSge;
200 : }
201 2 : if (ascendQPInfo->cap.maxInlineData == 0) {
202 1 : qpConfigInfo.max_inline_data = DEFAULT_MAX_INLINE_DATA;
203 : } else {
204 1 : qpConfigInfo.max_inline_data = ascendQPInfo->cap.maxInlineData;
205 : }
206 :
207 : u32 poolId;
208 2 : if (HCCL_SUCCESS == RdmaResourceManager::GetInstance().GetResvMemPoolIdByType(HCCN_RESV_MEM_TYPE_PDCCL, poolId)) {
209 0 : qpConfigInfo.use_resv_mem = 1;
210 0 : qpConfigInfo.resv_mem_pool_id = poolId;
211 : }
212 2 : CHK_RET(TypicalQpManager::GetInstance().CreateQpWithCQ(qpInfo, qpConfigInfo));
213 2 : ascendQPInfo->qpn = qpInfo.qpn;
214 2 : ascendQPInfo->gidIdx = qpInfo.gidIdx;
215 34 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
216 32 : ascendQPInfo->gid[i] = qpInfo.gid[i];
217 : }
218 2 : ascendQPInfo->psn = qpInfo.psn;
219 2 : HCCL_INFO(
220 : "hcclCreateAscendQPWithCQWithAttr success! qpn[%u], gid index[%u], psn[%u], sendCqn[%u], recvCqn[%u]",
221 : ascendQPInfo->qpn, ascendQPInfo->gidIdx, ascendQPInfo->psn, ascendSendCQInfo->cqn, ascendRecvCQInfo->cqn);
222 :
223 2 : return HCCL_SUCCESS;
224 : }
225 :
226 3 : HcclResult hcclDestroyAscendVerbsQP(AscendVerbsQPInfo* ascendQPVerbsInfo)
227 : {
228 3 : s32 deviceLogicId = 0;
229 3 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
230 3 : CHK_PTR_NULL(ascendQPVerbsInfo);
231 : struct TypicalQp qpInfo;
232 2 : qpInfo.qpn = ascendQPVerbsInfo->qpn;
233 2 : qpInfo.gidIdx = ascendQPVerbsInfo->gidIdx;
234 34 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
235 32 : qpInfo.gid[i] = ascendQPVerbsInfo->gid[i];
236 : }
237 2 : qpInfo.psn = ascendQPVerbsInfo->psn;
238 2 : CHK_RET(TypicalQpManager::GetInstance().DestroyQpWithoutCQ(qpInfo));
239 1 : HCCL_INFO("hcclDestroyAscendVerbsQP success! qpn[%u]", ascendQPVerbsInfo->qpn);
240 1 : return HCCL_SUCCESS;
241 : }
242 :
243 0 : HcclResult hcclModifyAscendQP(AscendQPInfo* localQPInfo, AscendQPInfo* remoteQPInfo)
244 : {
245 0 : s32 deviceLogicId = 0;
246 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
247 : AscendQPQos qpQos;
248 0 : qpQos.sl = GetExternalInputRdmaServerLevel();
249 0 : qpQos.tc = GetExternalInputRdmaTrafficClass();
250 0 : CHK_RET(hcclModifyAscendQPEx(localQPInfo, remoteQPInfo, &qpQos));
251 0 : return HCCL_SUCCESS;
252 : }
253 :
254 30 : HcclResult hcclModifyAscendQPEx(AscendQPInfo* localQPInfo, AscendQPInfo* remoteQPInfo, AscendQPQos* qpQos)
255 : {
256 30 : s32 deviceLogicId = 0;
257 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
258 30 : CHK_PTR_NULL(localQPInfo);
259 30 : CHK_PTR_NULL(remoteQPInfo);
260 30 : CHK_PTR_NULL(qpQos);
261 30 : CHK_PRT_RET(
262 : (qpQos->sl > HCCL_RDMA_SL_MAX),
263 : HCCL_ERROR(
264 : "[hcclModifyAscendQPEx]The value of sl[%u] is invalid. except: [%u, %u].", qpQos->sl, HCCL_RDMA_SL_MIN,
265 : HCCL_RDMA_SL_MAX),
266 : HCCL_E_PARA);
267 30 : CHK_PRT_RET(
268 : (qpQos->tc > HCCL_RDMA_TC_MAX),
269 : HCCL_ERROR(
270 : "[hcclModifyAscendQPEx]The value of tc[%u] is invalid. except: [%u, %u].", qpQos->tc, HCCL_RDMA_TC_MIN,
271 : HCCL_RDMA_TC_MAX),
272 : HCCL_E_PARA);
273 :
274 : // 设置的RDMATrafficClass需要是4的整数倍, 否则报错
275 30 : CHK_PRT_RET(
276 : qpQos->tc % DEVISOR_VALUE_FOUR != 0,
277 : HCCL_ERROR("[hcclModifyAscendQPEx]The value of tc[%u] is not a multiple of 4.", qpQos->tc), HCCL_E_PARA);
278 :
279 : struct TypicalQp localQp;
280 30 : localQp.qpn = localQPInfo->qpn;
281 30 : localQp.gidIdx = localQPInfo->gidIdx;
282 510 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
283 480 : localQp.gid[i] = localQPInfo->gid[i];
284 : }
285 30 : localQp.psn = localQPInfo->psn;
286 30 : localQp.sl = qpQos->sl;
287 30 : localQp.tc = qpQos->tc;
288 :
289 30 : struct TypicalQp remoteQp = {};
290 30 : remoteQp.qpn = remoteQPInfo->qpn;
291 30 : remoteQp.gidIdx = remoteQPInfo->gidIdx;
292 510 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
293 480 : remoteQp.gid[i] = remoteQPInfo->gid[i];
294 : }
295 30 : remoteQp.psn = remoteQPInfo->psn;
296 30 : CHK_RET(TypicalQpManager::GetInstance().ModifyQp(localQp, remoteQp));
297 30 : return HCCL_SUCCESS;
298 : }
299 :
300 2 : HcclResult hcclModifyAscendVerbsQP(AscendVerbsQPInfo* localQPInfo, AscendVerbsQPInfo* remoteQPInfo)
301 : {
302 2 : s32 deviceLogicId = 0;
303 2 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
304 : AscendQPQos qpQos;
305 1 : qpQos.sl = GetExternalInputRdmaServerLevel();
306 1 : qpQos.tc = GetExternalInputRdmaTrafficClass();
307 1 : CHK_RET(hcclModifyAscendVerbsQPEx(localQPInfo, remoteQPInfo, &qpQos));
308 1 : return HCCL_SUCCESS;
309 : }
310 :
311 : HcclResult
312 9 : hcclModifyAscendVerbsQPEx(AscendVerbsQPInfo* localQPVerbsInfo, AscendVerbsQPInfo* remoteQPVerbsInfo, AscendQPQos* qpQos)
313 : {
314 9 : s32 deviceLogicId = 0;
315 9 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
316 9 : CHK_PTR_NULL(localQPVerbsInfo);
317 8 : CHK_PTR_NULL(remoteQPVerbsInfo);
318 7 : CHK_PTR_NULL(qpQos);
319 6 : CHK_PRT_RET(
320 : (qpQos->sl > HCCL_RDMA_SL_MAX),
321 : HCCL_ERROR(
322 : "[hcclModifyAscendVerbsQPEx]The value of sl[%u] is invalid. except: [%u, %u].", qpQos->sl, HCCL_RDMA_SL_MIN,
323 : HCCL_RDMA_SL_MAX),
324 : HCCL_E_PARA);
325 5 : CHK_PRT_RET(
326 : (qpQos->tc > HCCL_RDMA_TC_MAX),
327 : HCCL_ERROR(
328 : "[hcclModifyAscendVerbsQPEx]The value of tc[%u] is invalid. except: [%u, %u].", qpQos->tc, HCCL_RDMA_TC_MIN,
329 : HCCL_RDMA_TC_MAX),
330 : HCCL_E_PARA);
331 :
332 4 : CHK_PRT_RET(
333 : qpQos->tc % DEVISOR_VALUE_FOUR != 0,
334 : HCCL_ERROR("[hcclModifyAscendVerbsQPEx]The value of tc[%u] is not a multiple of 4.", qpQos->tc), HCCL_E_PARA);
335 :
336 : struct TypicalQp localQp;
337 3 : localQp.qpn = localQPVerbsInfo->qpn;
338 3 : localQp.gidIdx = localQPVerbsInfo->gidIdx;
339 51 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
340 48 : localQp.gid[i] = localQPVerbsInfo->gid[i];
341 : }
342 3 : localQp.psn = localQPVerbsInfo->psn;
343 3 : localQp.sl = qpQos->sl;
344 3 : localQp.tc = qpQos->tc;
345 :
346 3 : struct TypicalQp remoteQp = {};
347 3 : remoteQp.qpn = remoteQPVerbsInfo->qpn;
348 3 : remoteQp.gidIdx = remoteQPVerbsInfo->gidIdx;
349 51 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
350 48 : remoteQp.gid[i] = remoteQPVerbsInfo->gid[i];
351 : }
352 3 : remoteQp.psn = remoteQPVerbsInfo->psn;
353 3 : CHK_RET(TypicalQpManager::GetInstance().ModifyVerbsQp(localQp, remoteQp));
354 2 : return HCCL_SUCCESS;
355 : }
356 :
357 30 : HcclResult hcclDestroyAscendQP(AscendQPInfo* ascendQPInfo)
358 : {
359 30 : s32 deviceLogicId = 0;
360 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
361 30 : CHK_PTR_NULL(ascendQPInfo);
362 : struct TypicalQp qpInfo;
363 30 : qpInfo.qpn = ascendQPInfo->qpn;
364 30 : qpInfo.gidIdx = ascendQPInfo->gidIdx;
365 510 : for (uint32_t i = 0; i < GID_LENGTH; i++) {
366 480 : qpInfo.gid[i] = ascendQPInfo->gid[i];
367 : }
368 30 : qpInfo.psn = ascendQPInfo->psn;
369 30 : CHK_RET(TypicalQpManager::GetInstance().DestroyQp(qpInfo));
370 30 : return HCCL_SUCCESS;
371 : }
372 :
373 30 : HcclResult hcclAllocWindowMem(void** ptr, size_t len)
374 : {
375 30 : s32 deviceLogicId = 0;
376 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
377 30 : return TypicalWindowMem::GetInstance().AllocWindowMem(ptr, len);
378 : }
379 :
380 30 : HcclResult hcclFreeWindowMem(void* ptr)
381 : {
382 30 : s32 deviceLogicId = 0;
383 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
384 30 : return TypicalWindowMem::GetInstance().FreeWindowMem(ptr);
385 : }
386 :
387 90 : HcclResult hcclAllocSyncMem(int32_t** ptr)
388 : {
389 90 : s32 deviceLogicId = 0;
390 90 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
391 90 : return TypicalSyncMem::GetInstance().AllocSyncMem(ptr);
392 : }
393 :
394 90 : HcclResult hcclFreeSyncMem(int32_t* ptr)
395 : {
396 90 : s32 deviceLogicId = 0;
397 90 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
398 90 : return TypicalSyncMem::GetInstance().FreeSyncMem(ptr);
399 : }
400 :
401 30 : HcclResult hcclRegisterMem(AscendMrInfo* memInfo)
402 : {
403 30 : s32 deviceLogicId = 0;
404 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
405 30 : CHK_PTR_NULL(memInfo);
406 30 : MrInfoT mrInfo = {};
407 30 : mrInfo.addr = reinterpret_cast<void*>(static_cast<uintptr_t>(memInfo->addr));
408 30 : mrInfo.size = memInfo->size;
409 30 : mrInfo.access = RA_ACCESS_REMOTE_WRITE | RA_ACCESS_LOCAL_WRITE | RA_ACCESS_REMOTE_READ;
410 30 : CHK_RET(TypicalMrManager::GetInstance().RegisterMem(mrInfo));
411 30 : memInfo->key = mrInfo.lkey;
412 30 : HCCL_RUN_INFO(
413 : "[hcclRegisterMem] Register WindowMem addr[%p], size[%llu], key[%u].", mrInfo.addr, mrInfo.size, mrInfo.lkey);
414 30 : return HCCL_SUCCESS;
415 : }
416 :
417 30 : HcclResult hcclDeRegisterMem(AscendMrInfo* memInfo)
418 : {
419 30 : s32 deviceLogicId = 0;
420 30 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
421 30 : CHK_PTR_NULL(memInfo);
422 30 : MrInfoT mrInfo = {};
423 30 : mrInfo.addr = reinterpret_cast<void*>(static_cast<uintptr_t>(memInfo->addr));
424 30 : mrInfo.size = memInfo->size;
425 30 : mrInfo.access = RA_ACCESS_REMOTE_WRITE | RA_ACCESS_LOCAL_WRITE | RA_ACCESS_REMOTE_READ;
426 30 : mrInfo.lkey = memInfo->key;
427 30 : CHK_RET(TypicalMrManager::GetInstance().DeRegisterMem(mrInfo));
428 30 : HCCL_RUN_INFO(
429 : "[hcclDeRegisterMem] DeRegister WindowMem addr[%p], size[%llu], key[%u].", mrInfo.addr, mrInfo.size,
430 : mrInfo.lkey);
431 30 : return HCCL_SUCCESS;
432 : }
433 :
434 3 : HcclResult hcclRdmaMemRegister(AscendMrAttr* memInfo)
435 : {
436 3 : s32 deviceLogicId = 0;
437 3 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
438 3 : CHK_PTR_NULL(memInfo);
439 2 : MrInfoT mrInfo = {};
440 2 : mrInfo.addr = reinterpret_cast<void*>(static_cast<uintptr_t>(memInfo->addr));
441 2 : mrInfo.size = memInfo->size;
442 2 : mrInfo.access = RA_ACCESS_REMOTE_WRITE | RA_ACCESS_LOCAL_WRITE | RA_ACCESS_REMOTE_READ;
443 2 : CHK_RET(TypicalMrManager::GetInstance().RegisterMem(mrInfo));
444 1 : memInfo->lkey = mrInfo.lkey;
445 1 : memInfo->rkey = mrInfo.rkey;
446 1 : HCCL_RUN_INFO(
447 : "[hcclRdmaMemRegister] Register MR addr[%p], size[%llu], lkey[%u], rkey[%u].", mrInfo.addr, mrInfo.size,
448 : mrInfo.lkey, mrInfo.rkey);
449 1 : return HCCL_SUCCESS;
450 : }
451 :
452 3 : HcclResult hcclRdmaMemDeRegister(AscendMrAttr* memInfo)
453 : {
454 3 : s32 deviceLogicId = 0;
455 3 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
456 3 : CHK_PTR_NULL(memInfo);
457 2 : MrInfoT mrInfo = {};
458 2 : mrInfo.addr = reinterpret_cast<void*>(static_cast<uintptr_t>(memInfo->addr));
459 2 : mrInfo.size = memInfo->size;
460 2 : mrInfo.access = RA_ACCESS_REMOTE_WRITE | RA_ACCESS_LOCAL_WRITE | RA_ACCESS_REMOTE_READ;
461 2 : mrInfo.lkey = memInfo->lkey;
462 2 : CHK_RET(TypicalMrManager::GetInstance().DeRegisterMem(mrInfo));
463 1 : HCCL_RUN_INFO(
464 : "[hcclRdmaMemDeRegister] DeRegister MR addr[%p], size[%llu], lkey[%u].", mrInfo.addr, mrInfo.size, mrInfo.lkey);
465 1 : return HCCL_SUCCESS;
466 : }
467 :
468 8 : HcclResult hcclAscendPostSend(
469 : AscendVerbsQPInfo* qpInfo, struct AscendSendWr* sendWr, aclrtStream stream, struct AscendSendWr** badWr)
470 : {
471 8 : s32 deviceLogicId = 0;
472 8 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
473 8 : CHK_PTR_NULL(qpInfo);
474 7 : CHK_PTR_NULL(sendWr);
475 6 : CHK_PTR_NULL(badWr);
476 5 : CHK_PTR_NULL(stream);
477 :
478 : QpHandle qpHandle;
479 4 : CHK_RET(TypicalQpManager::GetInstance().GetVerbsQpHandleByQpn(qpInfo->qpn, qpHandle));
480 :
481 4 : constexpr u32 MAX_SGLIST_VERBS = 16;
482 4 : struct AscendSendWr* curWr = sendWr;
483 8 : while (curWr != nullptr) {
484 7 : CHK_PRT_RET(
485 : static_cast<u32>(curWr->numSge) > MAX_SGLIST_VERBS,
486 : HCCL_ERROR("[hcclAscendPostSend] numSge[%d] exceeds MAX_SGLIST_VERBS[%u]", curWr->numSge, MAX_SGLIST_VERBS),
487 : HCCL_E_PARA);
488 5 : CHK_PTR_NULL(curWr->sgList);
489 :
490 : struct SgList sgeList[MAX_SGLIST_VERBS];
491 8 : for (int i = 0; i < curWr->numSge; i++) {
492 4 : sgeList[i].addr = curWr->sgList[i].addr;
493 4 : sgeList[i].len = curWr->sgList[i].len;
494 4 : sgeList[i].lkey = curWr->sgList[i].lkey;
495 : }
496 :
497 4 : struct SendWrVerbs wr = {};
498 4 : struct SendWrRsp opRsp = {};
499 4 : wr.wrId = curWr->wrId;
500 4 : wr.sgList = sgeList;
501 4 : wr.numSge = curWr->numSge;
502 4 : wr.remoteAddr = curWr->wr.rdma.remoteAddr;
503 4 : wr.rkey = curWr->wr.rdma.rkey;
504 4 : wr.opcode = static_cast<uint32_t>(curWr->opcode);
505 4 : wr.sendFlags = static_cast<int>(curWr->sendFlags);
506 4 : wr.immData = curWr->immData;
507 :
508 4 : CHK_RET(HrtRaSendWrVerbs(qpHandle, &wr, &opRsp));
509 :
510 4 : if (curWr->next == nullptr) {
511 2 : CHK_RET(hrtRDMADBSend(opRsp.db.dbIndex, opRsp.db.dbInfo, stream));
512 : }
513 :
514 4 : curWr = curWr->next;
515 : }
516 :
517 2 : *badWr = nullptr;
518 2 : return HCCL_SUCCESS;
519 : }
520 :
521 8 : HcclResult hcclAscendPostRecv(
522 : AscendVerbsQPInfo* qpInfo, struct AscendRecvWr* recvWr, aclrtStream stream, struct AscendRecvWr** badWr)
523 : {
524 8 : s32 deviceLogicId = 0;
525 8 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
526 8 : CHK_PTR_NULL(qpInfo);
527 7 : CHK_PTR_NULL(recvWr);
528 6 : CHK_PTR_NULL(badWr);
529 5 : CHK_PTR_NULL(stream);
530 :
531 : QpHandle qpHandle;
532 4 : CHK_RET(TypicalQpManager::GetInstance().GetVerbsQpHandleByQpn(qpInfo->qpn, qpHandle));
533 :
534 4 : constexpr u32 MAX_SGLIST_RECV = 16;
535 4 : struct AscendRecvWr* curWr = recvWr;
536 8 : while (curWr != nullptr) {
537 7 : CHK_PRT_RET(
538 : static_cast<u32>(curWr->numSge) > MAX_SGLIST_RECV,
539 : HCCL_ERROR("[hcclAscendPostRecv] numSge[%d] exceeds MAX_SGLIST_RECV[%u]", curWr->numSge, MAX_SGLIST_RECV),
540 : HCCL_E_PARA);
541 5 : CHK_PTR_NULL(curWr->sgList);
542 :
543 : struct SgList sgeList[MAX_SGLIST_RECV];
544 8 : for (int i = 0; i < curWr->numSge; i++) {
545 4 : sgeList[i].addr = curWr->sgList[i].addr;
546 4 : sgeList[i].len = curWr->sgList[i].len;
547 4 : sgeList[i].lkey = curWr->sgList[i].lkey;
548 : }
549 :
550 4 : struct RecvWrVerbs wr = {};
551 4 : wr.wrId = curWr->wrId;
552 4 : wr.sgList = sgeList;
553 4 : wr.numSge = curWr->numSge;
554 :
555 4 : CHK_RET(HrtRaRecvWrVerbs(qpHandle, &wr));
556 :
557 4 : curWr = curWr->next;
558 : }
559 :
560 2 : *badWr = nullptr;
561 2 : return HCCL_SUCCESS;
562 : }
563 :
564 0 : HcclResult HcclSendByAscendQP(
565 : void* sendBuf, uint64_t count, HcclDataType dataType, AscendSendRecvInfo* sendRecvInfo, aclrtStream stream)
566 : {
567 0 : s32 deviceLogicId = 0;
568 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
569 0 : CHK_RET(CheckParam(sendBuf, count, dataType, stream));
570 0 : CHK_RET(CheckSendRecvInfo(sendRecvInfo));
571 : QpHandle qpHandle;
572 0 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvInfo->localQPinfo->qpn, qpHandle));
573 : SendRecvExecutor executor(
574 0 : stream, qpHandle, AscendMrInfo2MrInfo(sendRecvInfo->localWindowMem),
575 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteWindowMem), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemPrepare),
576 0 : AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemDone), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemAck),
577 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemPrepare), AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemDone),
578 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemAck), sendRecvInfo->immData);
579 0 : CHK_RET(executor.Init());
580 0 : CHK_RET(executor.Send(sendBuf, count, dataType));
581 0 : return HCCL_SUCCESS;
582 0 : }
583 :
584 0 : HcclResult HcclRecvByAscendQP(
585 : void* recvBuf, uint64_t count, HcclDataType dataType, AscendSendRecvInfo* sendRecvInfo, aclrtStream stream)
586 : {
587 0 : s32 deviceLogicId = 0;
588 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
589 0 : CHK_RET(CheckParam(recvBuf, count, dataType, stream));
590 0 : CHK_RET(CheckSendRecvInfo(sendRecvInfo));
591 : QpHandle qpHandle;
592 0 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvInfo->localQPinfo->qpn, qpHandle));
593 : SendRecvExecutor executor(
594 0 : stream, qpHandle, AscendMrInfo2MrInfo(sendRecvInfo->localWindowMem),
595 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteWindowMem), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemPrepare),
596 0 : AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemDone), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemAck),
597 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemPrepare), AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemDone),
598 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemAck), sendRecvInfo->immData);
599 0 : CHK_RET(executor.Init());
600 0 : CHK_RET(executor.Receive(recvBuf, count, dataType));
601 0 : return HCCL_SUCCESS;
602 0 : }
603 :
604 32 : HcclResult hcclAscendRdmaInit()
605 : {
606 32 : s32 deviceLogicId = 0;
607 32 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
608 32 : CHK_RET(RdmaResourceManager::GetInstance().Init());
609 32 : return HCCL_SUCCESS;
610 : }
611 3 : HcclResult hcclAscendRdmaInitV2()
612 : {
613 3 : s32 deviceLogicId = 0;
614 3 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
615 2 : RdmaResourceManager::GetInstance().SetDisableLiteThread(true);
616 2 : CHK_RET(RdmaResourceManager::GetInstance().Init());
617 1 : return HCCL_SUCCESS;
618 : }
619 32 : HcclResult hcclAscendRdmaDeInit()
620 : {
621 32 : s32 deviceLogicId = 0;
622 32 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
623 32 : CHK_RET(RdmaResourceManager::GetInstance().DeInit());
624 32 : return HCCL_SUCCESS;
625 : }
626 :
627 0 : HcclResult HcclGetCqeErrInfoList(struct HcclErrCqeInfo* infoList, uint32_t* num)
628 : {
629 0 : s32 deviceLogicId = 0;
630 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
631 0 : CHK_PTR_NULL(infoList);
632 0 : CHK_PTR_NULL(num);
633 0 : u32 arrLen = *num;
634 0 : struct CqeErrInfo errCqeList[arrLen];
635 0 : CHK_RET(RdmaResourceManager::GetInstance().GetCqeErrInfo(errCqeList, num));
636 :
637 0 : CHK_PRT_RET(
638 : *num > arrLen,
639 : HCCL_ERROR(
640 : "[HcclGetCqeErrInfoList] GetCqeErrInfo num[%u] is larger than "
641 : "infoList user given[%u].",
642 : num, arrLen),
643 : HCCL_E_INTERNAL);
644 0 : for (u32 i = 0; i < *num; i++) {
645 0 : infoList[i].status = errCqeList[i].status;
646 0 : infoList[i].qpn = errCqeList[i].qpn;
647 0 : infoList[i].time = errCqeList[i].time;
648 0 : time_t tmpt = static_cast<time_t>(errCqeList[i].time.tv_sec);
649 : struct tm errTime;
650 0 : localtime_r(&tmpt, &errTime);
651 0 : HCCL_INFO(
652 : "[HcclGetCqeErrInfoList] Err Cqe status[%d], qpn[%d], time[%04u-%02d-%02d %02d:%0d:%02d.%06u]",
653 : errCqeList[i].status, errCqeList[i].qpn, errTime.tm_year + TIME_FROM_1900, errTime.tm_mon + 1,
654 : errTime.tm_mday, errTime.tm_hour, errTime.tm_min, errTime.tm_sec,
655 : static_cast<u32>(errCqeList[i].time.tv_usec));
656 : }
657 0 : return HCCL_SUCCESS;
658 0 : }
659 :
660 0 : HcclResult HcclGetCqeErrInfoListByQpn(uint32_t qpn, struct HcclErrCqeInfo* infoList, uint32_t* num)
661 : {
662 0 : s32 deviceLogicId = 0;
663 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
664 0 : CHK_PTR_NULL(infoList);
665 0 : CHK_PTR_NULL(num);
666 0 : CHK_RET(RdmaResourceManager::GetInstance().GetCqeErrInfoByQpn(qpn, infoList, num));
667 0 : return HCCL_SUCCESS;
668 : }
669 :
670 0 : HcclResult HcclPutByAscendQP(
671 : void* putBuf, uint64_t count, HcclDataType dataType, AscendSendRecvInfo* sendRecvInfo, aclrtStream stream)
672 : {
673 0 : CHK_PTR_NULL(stream);
674 0 : s32 deviceLogicId = 0;
675 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
676 0 : CHK_RET(CheckParam(putBuf, count, dataType, stream));
677 : QpHandle qpHandle;
678 0 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvInfo->localQPinfo->qpn, qpHandle));
679 : SendRecvExecutor executor(
680 0 : stream, qpHandle, AscendMrInfo2MrInfo(sendRecvInfo->localWindowMem),
681 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteWindowMem), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemPrepare),
682 0 : AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemDone), AscendMrInfo2MrInfo(sendRecvInfo->localSyncMemAck),
683 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemPrepare), AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemDone),
684 0 : AscendMrInfo2MrInfo(sendRecvInfo->remoteSyncMemAck), sendRecvInfo->immData);
685 0 : CHK_RET(executor.Init());
686 0 : CHK_RET(executor.Put(putBuf, count, dataType));
687 0 : return HCCL_SUCCESS;
688 0 : }
689 :
690 19 : HcclResult HcclBatchPutMRByAscendQP(
691 : unsigned int num, AscendMrInfo* putMRList, AscendMrInfo* remoteMRList, AscendSendRecvLinkInfo* sendRecvLinkInfo,
692 : aclrtStream stream)
693 : {
694 19 : s32 deviceLogicId = 0;
695 19 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
696 19 : CHK_PRT_RET(
697 : num == 0, HCCL_INFO("[HcclBatchPutMRByAscendQP] mr list len is 0. No need to send data."), HCCL_SUCCESS);
698 19 : CHK_PTR_NULL(putMRList);
699 19 : CHK_PTR_NULL(remoteMRList);
700 19 : CHK_PTR_NULL(sendRecvLinkInfo);
701 19 : CHK_PTR_NULL(stream);
702 19 : CHK_RET(CheckSendRecvLinkInfo(sendRecvLinkInfo));
703 19 : CHK_PRT_RET(
704 : sendRecvLinkInfo->wqePerDoorbell == 0 || sendRecvLinkInfo->wqePerDoorbell > MAX_WQE_PER_DOORBELL,
705 : HCCL_ERROR("[HcclBatchPutMRByAscendQP] The value of wqePerDoorbell is exceed 300 or equal to 0."), HCCL_E_PARA);
706 : QpHandle qpHandle;
707 19 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvLinkInfo->localQPinfo->qpn, qpHandle));
708 :
709 19 : SendRecvExecutor executor(stream, qpHandle, sendRecvLinkInfo);
710 19 : CHK_RET(executor.Init());
711 19 : CHK_RET(executor.BatchPutMR(num, putMRList, remoteMRList));
712 :
713 19 : return HCCL_SUCCESS;
714 19 : }
715 :
716 19 : HcclResult HcclWaitPutMRByAscendQP(AscendSendRecvLinkInfo* sendRecvLinkInfo, aclrtStream stream)
717 : {
718 19 : s32 deviceLogicId = 0;
719 19 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
720 19 : CHK_PTR_NULL(sendRecvLinkInfo);
721 19 : CHK_PTR_NULL(stream);
722 19 : CHK_PTR_NULL(sendRecvLinkInfo->remoteSyncMemAck);
723 19 : CHK_PTR_NULL(sendRecvLinkInfo->localSyncMemDone);
724 : QpHandle qpHandle;
725 19 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvLinkInfo->localQPinfo->qpn, qpHandle));
726 :
727 19 : SendRecvExecutor executor(stream, qpHandle, sendRecvLinkInfo->localSyncMemDone, sendRecvLinkInfo->remoteSyncMemAck);
728 19 : CHK_RET(executor.WaitPutInit());
729 19 : CHK_RET(executor.WaitPutMR());
730 19 : return HCCL_SUCCESS;
731 19 : }
732 :
733 0 : HcclResult HcclWaitPutMRDoWait(AscendSendRecvLinkInfo* sendRecvLinkInfo, aclrtStream stream)
734 : {
735 0 : s32 deviceLogicId = 0;
736 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
737 0 : CHK_PTR_NULL(sendRecvLinkInfo);
738 0 : CHK_PTR_NULL(stream);
739 0 : CHK_PTR_NULL(sendRecvLinkInfo->remoteSyncMemAck);
740 0 : CHK_PTR_NULL(sendRecvLinkInfo->localSyncMemDone);
741 : QpHandle qpHandle;
742 0 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvLinkInfo->localQPinfo->qpn, qpHandle));
743 :
744 0 : SendRecvExecutor executor(stream, qpHandle, sendRecvLinkInfo->localSyncMemDone, sendRecvLinkInfo->remoteSyncMemAck);
745 0 : CHK_RET(executor.WaitPutInit());
746 0 : CHK_RET(executor.WaitPutMROnlyWait());
747 0 : return HCCL_SUCCESS;
748 0 : }
749 :
750 0 : HcclResult HcclWaitPutMRDoRecord(AscendSendRecvLinkInfo* sendRecvLinkInfo, aclrtStream stream)
751 : {
752 0 : s32 deviceLogicId = 0;
753 0 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
754 0 : CHK_PTR_NULL(sendRecvLinkInfo);
755 0 : CHK_PTR_NULL(stream);
756 0 : CHK_PTR_NULL(sendRecvLinkInfo->remoteSyncMemAck);
757 0 : CHK_PTR_NULL(sendRecvLinkInfo->localSyncMemDone);
758 : QpHandle qpHandle;
759 0 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendRecvLinkInfo->localQPinfo->qpn, qpHandle));
760 :
761 0 : SendRecvExecutor executor(stream, qpHandle, sendRecvLinkInfo->localSyncMemDone, sendRecvLinkInfo->remoteSyncMemAck);
762 0 : CHK_RET(executor.WaitPutInit());
763 0 : CHK_RET(executor.WaitPutMROnlyRecord());
764 0 : return HCCL_SUCCESS;
765 0 : }
766 :
767 90 : HcclResult hcclGetSyncMemRegKey(AscendMrInfo* memInfo)
768 : {
769 90 : s32 deviceLogicId = 0;
770 90 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
771 90 : CHK_PTR_NULL(memInfo);
772 90 : struct MrInfoT mrInfo {};
773 90 : CHK_RET(RdmaResourceManager::GetInstance().GetNotifyMrInfo(mrInfo));
774 90 : memInfo->key = mrInfo.lkey;
775 90 : HCCL_RUN_INFO(
776 : "[hcclGetSyncMemRegKey] SyncMem addr[%p], size[%llu], key[%u].", memInfo->addr, memInfo->size, memInfo->key);
777 90 : return HCCL_SUCCESS;
778 : }
779 :
780 11 : HcclResult HcclOneSideBatchPutByAscendQP(
781 : unsigned int num, AscendMrInfo* putMRList, AscendMrInfo* remoteMRList, AscendSendLinkInfo* sendlinkInfo,
782 : aclrtStream stream)
783 : {
784 11 : s32 deviceLogicId = 0;
785 11 : CHK_RET(hrtGetDeviceRefresh(&deviceLogicId));
786 11 : CHK_PRT_RET(
787 : num == 0, HCCL_INFO("[HcclOneSideBatchPutByAscendQP] mr list len is 0. No need to send data."), HCCL_SUCCESS);
788 11 : CHK_PTR_NULL(putMRList);
789 11 : CHK_PTR_NULL(remoteMRList);
790 11 : CHK_PTR_NULL(sendlinkInfo);
791 11 : CHK_PTR_NULL(stream);
792 11 : CHK_RET(CheckSendLinkInfo(sendlinkInfo));
793 10 : CHK_PRT_RET(
794 : sendlinkInfo->wqePerDoorbell == 0 || sendlinkInfo->wqePerDoorbell > MAX_WQE_PER_DOORBELL,
795 : HCCL_ERROR("[HcclOneSideBatchPutByAscendQP] The value of wqePerDoorbell is exceed 300 or equal to 0."),
796 : HCCL_E_PARA);
797 : QpHandle qpHandle;
798 10 : CHK_RET(TypicalQpManager::GetInstance().GetQpHandleByQpn(sendlinkInfo->localQPinfo->qpn, qpHandle));
799 :
800 10 : SendRecvExecutor executor(stream, qpHandle, sendlinkInfo);
801 10 : CHK_RET(executor.OneSideBatchPutMR(num, putMRList, remoteMRList));
802 :
803 10 : return HCCL_SUCCESS;
804 10 : }
|