Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 "ccu_rep_v1.h"
12 :
13 : #include "string_util.h"
14 : #include "exception_util.h"
15 : #include "ccu_api_exception.h"
16 :
17 : namespace hcomm {
18 : namespace CcuRep {
19 :
20 72 : CcuRepLoopBlock::CcuRepLoopBlock(CcuInsGeneratorBase* insGenPtr, const std::string& label)
21 72 : : CcuRepBlock(insGenPtr, label)
22 : {
23 72 : type = CcuRepType::LOOP_BLOCK;
24 72 : }
25 :
26 43 : std::string CcuRepLoopBlock::Describe()
27 : {
28 43 : HCCL_INFO("Begin Describe LoopBlock[%s]", GetLabel().c_str());
29 115 : for (const auto& rep : GetReps()) {
30 72 : HCCL_INFO(" Rep: %s", rep->Describe().c_str());
31 : }
32 43 : return Hccl::StringFormat("LoopBlock[%s]", GetLabel().c_str());
33 : }
34 :
35 2 : void CcuRepLoopBlock::DefineArg(Variable var)
36 : {
37 2 : args.push_back(CcuRepArg(var));
38 2 : HCCL_INFO("Define Arg: Index[%u], Type[Variable], Id[%u]", args.size(), var.Id());
39 2 : }
40 :
41 1 : void CcuRepLoopBlock::DefineArg(Memory mem)
42 : {
43 1 : args.push_back(CcuRepArg(mem));
44 1 : HCCL_INFO("Define Arg: Index[%u], Type[Memory], Id[%u]", args.size(), mem.addr.Id());
45 1 : }
46 :
47 2 : void CcuRepLoopBlock::DefineArg(LocalAddr addr)
48 : {
49 2 : args.push_back(CcuRepArg(addr));
50 2 : HCCL_INFO("Define Arg: Index[%u], Type[LocalAddr], Id[%u]", args.size(), addr.addr.Id());
51 2 : }
52 :
53 1 : void CcuRepLoopBlock::DefineArg(RemoteAddr addr)
54 : {
55 1 : args.push_back(CcuRepArg(addr));
56 1 : HCCL_INFO("Define Arg: Index[%u], Type[RemoteAddr], Id[%u]", args.size(), addr.addr.Id());
57 1 : }
58 :
59 1 : void CcuRepLoopBlock::DefineArg(const std::vector<Variable> varList)
60 : {
61 1 : args.push_back(CcuRepArg(varList));
62 1 : HCCL_INFO("Define Arg: Index[%u], Type[Variable List]: ", args.size());
63 3 : for (uint32_t index = 0; index < varList.size(); index++) {
64 2 : HCCL_INFO(" Index[%u].Id[%u]", index, varList[index].Id());
65 : }
66 1 : }
67 :
68 1 : void CcuRepLoopBlock::DefineArg(const std::vector<LocalAddr> addrList)
69 : {
70 1 : args.push_back(CcuRepArg(addrList));
71 1 : HCCL_INFO("Define Arg: Index[%u], Type[LocalAddr List]: ", args.size());
72 3 : for (uint32_t index = 0; index < addrList.size(); index++) {
73 2 : HCCL_INFO("Index[%u].Id[%u]", index, addrList[index].addr.Id());
74 : }
75 1 : }
76 :
77 1 : void CcuRepLoopBlock::DefineArg(const std::vector<RemoteAddr> addrList)
78 : {
79 1 : args.push_back(CcuRepArg(addrList));
80 1 : HCCL_INFO("Define Arg: Index[%u], Type[RemoteAddr List]: ", args.size());
81 3 : for (uint32_t index = 0; index < addrList.size(); index++) {
82 2 : HCCL_INFO("Index[%u].Id[%u]", index, addrList[index].addr.Id());
83 : }
84 1 : }
85 :
86 1 : void CcuRepLoopBlock::DefineArg(const std::vector<Memory> memList)
87 : {
88 1 : args.push_back(CcuRepArg(memList));
89 1 : HCCL_INFO("Define Arg: Index[%u], Type[Memory List]: ", args.size());
90 3 : for (uint32_t index = 0; index < memList.size(); index++) {
91 2 : HCCL_INFO("Index[%u].Id[%u]", index, memList[index].addr.Id());
92 : }
93 1 : }
94 :
95 9 : CcuRepArg& CcuRepLoopBlock::GetArg(uint16_t index)
96 : {
97 9 : if (index >= args.size()) {
98 1 : Hccl::THROW<Hccl::CcuApiException>("CcuLoopBlock Arg Index[%u] Out of Range", index);
99 : }
100 8 : return args[index];
101 : }
102 :
103 : }; // namespace CcuRep
104 : }; // namespace hcomm
|