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 "aicpu_hdc.h"
12 : #include "utils/aicpu_hdc_utils.h"
13 :
14 : using namespace hccl;
15 :
16 1 : HcclResult AicpuHdc::InitOpExecStatus(std::shared_ptr<hccl::HDCommunicate> d2hTransfer, HcclOpIdentifier &opId)
17 : {
18 1 : return AicpuHdcUtils::InitOpExecStatus(d2hTransfer, opId);
19 : }
20 :
21 9 : HcclResult AicpuHdc::SetOpExecStatus(std::shared_ptr<HDCommunicate> d2hTransfer, KfcStatus state,
22 : KfcError errorCode, u32 retryCount)
23 : {
24 9 : return AicpuHdcUtils::SetOpExecStatus(d2hTransfer, state, errorCode, retryCount);
25 : }
26 :
27 0 : HcclResult AicpuHdc::SetErrorMessage(std::shared_ptr<hccl::HDCommunicate> d2hTransfer, ErrorMessageReport &emrInfo)
28 : {
29 0 : return AicpuHdcUtils::SetErrorMessage(d2hTransfer, emrInfo);
30 : }
31 :
32 34 : HcclResult AicpuHdc::GetOpExecCtrlCmd(std::shared_ptr<HDCommunicate> h2dTransfer, KfcCommand &cmd)
33 : {
34 34 : if (!h2dTransfer) {
35 34 : return HCCL_SUCCESS;
36 : }
37 0 : CHK_RET(h2dTransfer->Get(0, sizeof(cmd), reinterpret_cast<uint8_t *>(&cmd)));
38 :
39 0 : if (lastCmd_ != cmd) {
40 0 : HCCL_RUN_INFO("hccl aicpu get cmd:%u", cmd);
41 0 : lastCmd_ = cmd;
42 : }
43 0 : return HCCL_SUCCESS;
44 : }
45 :
46 0 : HcclResult AicpuHdc::SetOpExecStatus(std::shared_ptr<HDCommunicate> d2hTransfer, HcclOpIdentifier &opId,
47 : KfcStatus state, KfcError errorCode, u32 retryCount)
48 : {
49 0 : if (!d2hTransfer) {
50 0 : return HCCL_SUCCESS;
51 : }
52 0 : KfcExecStatus status;
53 0 : status.opId = opId;
54 0 : status.execStatus.kfcStatus = state;
55 0 : status.execStatus.kfcError = errorCode;
56 0 : status.execStatus.retryInfo.retryCount = retryCount;
57 0 : HCCL_DEBUG("SetOpExecStatus: state:%u", state);
58 0 : return d2hTransfer->Put(0, sizeof(status.opId) + sizeof(status.execStatus), reinterpret_cast<uint8_t *>(&status));
59 : }
60 :
61 0 : HcclResult AicpuHdc::GetOpExecCtrlTargetOp(std::shared_ptr<HDCommunicate> h2dTransfer, HcclOpIdentifier &opId)
62 : {
63 0 : if (!h2dTransfer) {
64 0 : return HCCL_SUCCESS;
65 : }
66 :
67 0 : KfcExecControl ctrlCmd;
68 0 : CHK_RET(h2dTransfer->Get(0, sizeof(KfcExecControl), reinterpret_cast<uint8_t *>(&ctrlCmd)));
69 :
70 0 : opId = ctrlCmd.targetOp;
71 0 : HCCL_DEBUG("[OpRetry][GetOpExecCtrlTargetOp]tag[%s], index[%u], srcRank[%u], detRank[%u], isSendRecv[%d], "
72 : "streamid[%u]",
73 : opId.tag, opId.index, opId.srcRank, opId.detRank, opId.isSendRecv, opId.streamId);
74 0 : return HCCL_SUCCESS;
75 : }
76 :
77 0 : HcclResult AicpuHdc::GetOpExecChangeLink(std::shared_ptr<HDCommunicate> h2dTransfer, ChangeLinkInfo &changeLinkInfo)
78 : {
79 0 : if (!h2dTransfer) {
80 0 : return HCCL_SUCCESS;
81 : }
82 :
83 0 : KfcExecControl kfcExecControl;
84 0 : CHK_RET(h2dTransfer->Get(0, sizeof(KfcExecControl), reinterpret_cast<uint8_t *>(&kfcExecControl)));
85 0 : changeLinkInfo = kfcExecControl.changeLinkInfo;
86 0 : return HCCL_SUCCESS;
87 : }
|