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