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(
22 : std::shared_ptr<HDCommunicate> d2hTransfer, KfcStatus state, 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(
47 : std::shared_ptr<HDCommunicate> d2hTransfer, HcclOpIdentifier& opId, KfcStatus state, KfcError errorCode,
48 : u32 retryCount)
49 : {
50 0 : if (!d2hTransfer) {
51 0 : return HCCL_SUCCESS;
52 : }
53 0 : KfcExecStatus status;
54 0 : status.opId = opId;
55 0 : status.execStatus.kfcStatus = state;
56 0 : status.execStatus.kfcError = errorCode;
57 0 : status.execStatus.retryInfo.retryCount = retryCount;
58 0 : HCCL_DEBUG("SetOpExecStatus: state:%u", state);
59 0 : return d2hTransfer->Put(0, sizeof(status.opId) + sizeof(status.execStatus), reinterpret_cast<uint8_t*>(&status));
60 : }
61 :
62 0 : HcclResult AicpuHdc::GetOpExecCtrlTargetOp(std::shared_ptr<HDCommunicate> h2dTransfer, HcclOpIdentifier& opId)
63 : {
64 0 : if (!h2dTransfer) {
65 0 : return HCCL_SUCCESS;
66 : }
67 :
68 0 : KfcExecControl ctrlCmd;
69 0 : CHK_RET(h2dTransfer->Get(0, sizeof(KfcExecControl), reinterpret_cast<uint8_t*>(&ctrlCmd)));
70 :
71 0 : opId = ctrlCmd.targetOp;
72 0 : HCCL_DEBUG(
73 : "[OpRetry][GetOpExecCtrlTargetOp]tag[%s], index[%u], srcRank[%u], detRank[%u], isSendRecv[%d], "
74 : "streamid[%u]",
75 : opId.tag, opId.index, opId.srcRank, opId.detRank, opId.isSendRecv, opId.streamId);
76 0 : return HCCL_SUCCESS;
77 : }
78 :
79 0 : HcclResult AicpuHdc::GetOpExecChangeLink(std::shared_ptr<HDCommunicate> h2dTransfer, ChangeLinkInfo& changeLinkInfo)
80 : {
81 0 : if (!h2dTransfer) {
82 0 : return HCCL_SUCCESS;
83 : }
84 :
85 0 : KfcExecControl kfcExecControl;
86 0 : CHK_RET(h2dTransfer->Get(0, sizeof(KfcExecControl), reinterpret_cast<uint8_t*>(&kfcExecControl)));
87 0 : changeLinkInfo = kfcExecControl.changeLinkInfo;
88 0 : return HCCL_SUCCESS;
89 : }
|