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 : #include "inc/hccl_mc2_ex.h"
12 : #include "inc/aicpu_mc2_handler.h"
13 : #include "log.h"
14 :
15 : using namespace Hccl;
16 3 : HcclResult HcclGetCommHandleByCtx(void *ctx, void **opHandle)
17 : {
18 3 : if (ctx == nullptr) {
19 3 : HCCL_ERROR("[HcclGetCommHandleByCtx]Args ctx is nullptr.");
20 1 : return HCCL_E_PTR;
21 : }
22 2 : if (opHandle == nullptr) {
23 3 : HCCL_ERROR("[HcclGetCommHandleByCtx]Args opHandle is nullptr.");
24 1 : return HCCL_E_PTR;
25 : }
26 1 : TRY_CATCH_RETURN(CHK_RET(AicpuMc2Handler::GetInstance().HcclGetCommHandleByCtx(ctx, opHandle)));
27 1 : return HCCL_SUCCESS;
28 : }
29 :
30 1 : HcclResult HcclReleaseComm(void *opHandle)
31 : {
32 1 : if (opHandle == nullptr) {
33 0 : HCCL_WARNING("[HcclReleaseComm] opHandle is nullptr.");
34 0 : return HCCL_E_PTR;
35 : }
36 1 : TRY_CATCH_RETURN(CHK_RET(AicpuMc2Handler::GetInstance().HcclReleaseComm(opHandle)));
37 1 : return HCCL_SUCCESS;
38 : }
39 :
40 2 : HcclResult HcclGetTaskStatus(void *opHandle, HcclTaskStatus *status)
41 : {
42 2 : if (opHandle == nullptr) {
43 3 : HCCL_ERROR("[HcclGetTaskStatus]Args opHandle is nullptr.");
44 1 : return HCCL_E_PTR;
45 : }
46 1 : if (status == nullptr) {
47 3 : HCCL_ERROR("[HcclGetTaskStatus]Args status is nullptr.");
48 1 : return HCCL_E_PTR;
49 : }
50 0 : TRY_CATCH_RETURN(CHK_RET(AicpuMc2Handler::GetInstance().HcclGetTaskStatus(opHandle, status)));
51 0 : return HCCL_SUCCESS;
52 : }
53 :
54 3 : HcclResult HcclCheckFinishByStream(void *opHandle)
55 : {
56 3 : if (opHandle == nullptr) {
57 3 : HCCL_ERROR("[HcclCheckFinishByStream]Args opHandle is nullptr.");
58 1 : return HCCL_E_PTR;
59 : }
60 5 : TRY_CATCH_RETURN(CHK_RET(AicpuMc2Handler::GetInstance().HcclCheckFinishByStream(opHandle)));
61 1 : return HCCL_SUCCESS;
62 : }
63 :
64 1 : HcclResult HcclPrintTaskExceptionAllComm(void *opHandle)
65 : {
66 1 : if (opHandle == nullptr) {
67 3 : HCCL_WARNING("[HcclPrintTaskExceptionAllComm]Args opHandle is nullptr.");
68 1 : return HCCL_E_PTR;
69 : }
70 0 : TRY_CATCH_RETURN(CHK_RET(AicpuMc2Handler::GetInstance().HcclPrintTaskExceptionAllComm(opHandle)));
71 0 : return HCCL_SUCCESS;
72 : }
73 :
74 2 : HcclResult HcclLaunchCcoreWait(void *opHandle, uint64_t waitAddr, uint32_t turnNum, uint64_t turnNumAddr, bool isLast)
75 : {
76 2 : if (opHandle == nullptr) {
77 3 : HCCL_ERROR("[HcclLaunchCcoreWait]Args opHandle is nullptr.");
78 1 : return HCCL_E_PTR;
79 : }
80 1 : TRY_CATCH_RETURN(CHK_RET(AicpuMc2Handler::GetInstance().HcclLaunchCcoreWait(opHandle, waitAddr, turnNum, turnNumAddr, isLast)));
81 1 : return HCCL_SUCCESS;
82 : }
83 :
84 2 : HcclResult HcclLaunchCcorePost(void *opHandle, uint64_t recordAddr, uint32_t turnNum, uint64_t turnNumAddr)
85 : {
86 2 : if (opHandle == nullptr) {
87 3 : HCCL_ERROR("[HcclLaunchCcorePost]Args opHandle is nullptr.");
88 1 : return HCCL_E_PTR;
89 : }
90 1 : TRY_CATCH_RETURN(CHK_RET(AicpuMc2Handler::GetInstance().HcclLaunchCcorePost(opHandle, recordAddr, turnNum, turnNumAddr)));
91 1 : return HCCL_SUCCESS;
92 : }
93 :
94 2 : HcclResult HcclLaunchOp(void *opHandle, HcclOpData *data)
95 : {
96 2 : if (opHandle == nullptr) {
97 3 : HCCL_ERROR("[HcclLaunchOp]Args opHandle is nullptr.");
98 1 : return HCCL_E_PTR;
99 : }
100 1 : if (data == nullptr) {
101 3 : HCCL_ERROR("[HcclLaunchOp]Args data is nullptr.");
102 1 : return HCCL_E_PTR;
103 : }
104 0 : TRY_CATCH_RETURN(CHK_RET(AicpuMc2Handler::GetInstance().HcclLaunchOp(opHandle, data)));
105 0 : return HCCL_SUCCESS;
106 : }
|