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