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 : #include "ccu_ins_group.h"
11 :
12 : namespace Hccl {
13 :
14 1 : void CcuInsGroup::SetExecId(u64 id)
15 : {
16 2 : for (auto& ins : ccuInstructions) {
17 1 : ins->SetExecId(id);
18 : }
19 :
20 1 : execId = id;
21 1 : }
22 :
23 17 : u64 CcuInsGroup::GetExecId() const { return execId; }
24 :
25 22 : void CcuInsGroup::Append(std::unique_ptr<CcuInstruction> ins) { ccuInstructions.emplace_back(std::move(ins)); }
26 :
27 2 : const std::vector<std::unique_ptr<CcuInstruction>>& CcuInsGroup::GetCcuInstructions() const { return ccuInstructions; }
28 :
29 2 : CcuCtxSignature CcuInsGroup::GetCtxSignature() const
30 : {
31 6 : HCCL_INFO("[CcuInsGroup::GetCtxSignature] start");
32 2 : CcuCtxSignature ctxSignature;
33 4 : for (auto& ins : ccuInstructions) {
34 2 : ctxSignature.Append(ins->GetCtxArg()->GetCtxSignature());
35 6 : HCCL_INFO(
36 : "[CcuInsGroup::GetCtxSignature] ins->GetCtxSignature()[%s], ctxSignature[%s]",
37 : ins->GetCtxSignature().Describe().c_str(), ctxSignature.Describe().c_str());
38 : }
39 6 : HCCL_INFO("[CcuInsGroup::GetCtxSignature] end, ctxSignature[%s]", ctxSignature.Describe().c_str());
40 2 : return ctxSignature;
41 0 : }
42 :
43 7 : std::string CcuInsGroup::Describe() const
44 : {
45 7 : return StringFormat("CcuInsGroup[ccuInstructions_size=%zu, execId=%llu]", ccuInstructions.size(), execId);
46 : }
47 :
48 0 : CcuInstType CcuInsGroup::GetInstType() const { return CcuInstType::CCU_INS_GROUP; }
49 :
50 10 : std::unique_ptr<CcuTaskArg> CcuInsGroup::GetTaskArg() const
51 : {
52 10 : if (ccuInstructions.size() == 0) {
53 1 : THROW<InternalException>("[CcuInsGroup] size is 0");
54 : }
55 9 : return ccuInstructions[0]->GetTaskArg();
56 : }
57 :
58 1 : std::unique_ptr<CcuCtxArg> CcuInsGroup::GetCtxArg() const
59 : {
60 1 : THROW<NotSupportException>("[CcuInsGroup] not support GetCtxArg");
61 : return nullptr;
62 : }
63 :
64 1 : std::vector<LinkData> CcuInsGroup::GetLinks() const
65 : {
66 1 : vector<LinkData> links;
67 2 : for (const auto& ins : GetCcuInstructions()) {
68 1 : vector<LinkData> tmpLinks = ins->GetLinks();
69 1 : links.insert(links.end(), tmpLinks.begin(), tmpLinks.end());
70 1 : }
71 3 : HCCL_INFO("[CcuInsGroup][GetInsLinks] Get all ins ccuLinks of ccuInsGroup, links size[%zu]", links.size());
72 1 : return links;
73 0 : }
74 :
75 0 : RankGroup CcuInsGroup::GetRankGroup() const
76 : {
77 0 : THROW<NotSupportException>("[CcuInsGroup] not support GetRankGroup");
78 : return RankGroup();
79 : }
80 :
81 : } // namespace Hccl
|