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 "ccu_datatype.h"
12 : #include "ccu_rep.h"
13 : #include "ccu_context_resource.h"
14 : #include "ccu_interface_assist.h"
15 :
16 : #include "exception_util.h"
17 : #include "ccu_api_exception.h"
18 :
19 : namespace Hccl {
20 : namespace CcuRep {
21 :
22 4328 : uint16_t CcuPhyRes::Id() const { return id; }
23 116 : uint16_t CcuPhyRes::DieId() const { return dieId; }
24 25539 : void CcuPhyRes::Reset(uint16_t id) { this->id = id; }
25 21581 : void CcuPhyRes::SetDieId(uint16_t dieId) { this->dieId = dieId; }
26 :
27 56836 : CcuVirRes::CcuVirRes(CcuRepContext* context) : context(context) { phyRes = std::make_shared<CcuPhyRes>(); }
28 :
29 3959 : void CcuVirRes::Reset(uint16_t id) { phyRes->Reset(id); }
30 :
31 21580 : void CcuVirRes::Reset(uint16_t id, uint16_t dieId)
32 : {
33 21580 : phyRes->Reset(id);
34 21580 : phyRes->SetDieId(dieId);
35 21580 : }
36 :
37 1 : void CcuVirRes::SetDieId(uint16_t dieId) { phyRes->SetDieId(dieId); }
38 :
39 4239 : uint16_t CcuVirRes::Id() const { return phyRes->Id(); }
40 :
41 27 : uint16_t CcuVirRes::DieId() const { return phyRes->DieId(); }
42 :
43 6287 : Variable::Variable(CcuRepContext* context) : CcuVirRes(context) {}
44 :
45 21447 : Variable::Variable(const Variable& other) : CcuVirRes(other.context) { phyRes = other.phyRes; }
46 :
47 355 : void Variable::operator=(Variable&& other)
48 : {
49 355 : phyRes = other.phyRes;
50 355 : context = other.context;
51 355 : }
52 :
53 163 : void Variable::operator=(const Variable& other)
54 : {
55 163 : AppendToContext(context, std::make_shared<CcuRepAssign>(*this, other));
56 163 : }
57 :
58 182 : void Variable::operator=(uint64_t immediate)
59 : {
60 182 : AppendToContext(context, std::make_shared<CcuRepAssign>(*this, immediate));
61 182 : }
62 :
63 1 : void Variable::operator=(CcuArithmeticOperator<Variable, Variable> op)
64 : {
65 1 : AppendToContext(context, std::make_shared<CcuRepAdd>(*this, op.lhs, op.rhs));
66 1 : }
67 :
68 26 : void Variable::operator+=(const Variable& other)
69 : {
70 26 : AppendToContext(context, std::make_shared<CcuRepAdd>(*this, other));
71 26 : }
72 :
73 2881 : Address::Address(CcuRepContext* context) : CcuVirRes(context) {}
74 :
75 6296 : Address::Address(const Address& other) : CcuVirRes(other.context) { phyRes = other.phyRes; }
76 :
77 2 : void Address::operator=(Address&& other)
78 : {
79 2 : phyRes = other.phyRes;
80 2 : context = other.context;
81 2 : }
82 :
83 8 : void Address::operator=(const Address& other)
84 : {
85 8 : AppendToContext(context, std::make_shared<CcuRepAssign>(*this, other));
86 8 : }
87 :
88 153 : void Address::operator=(const Variable& other)
89 : {
90 153 : AppendToContext(context, std::make_shared<CcuRepAssign>(*this, other));
91 153 : }
92 :
93 1 : void Address::operator=(uint64_t immediate)
94 : {
95 1 : AppendToContext(context, std::make_shared<CcuRepAssign>(*this, immediate));
96 1 : }
97 :
98 8 : void Address::operator=(CcuArithmeticOperator<Variable, Address> op)
99 : {
100 8 : AppendToContext(context, std::make_shared<CcuRepAdd>(*this, op.rhs, op.lhs));
101 8 : }
102 :
103 1 : void Address::operator=(CcuArithmeticOperator<Address, Address> op)
104 : {
105 1 : AppendToContext(context, std::make_shared<CcuRepAdd>(*this, op.lhs, op.rhs));
106 1 : }
107 :
108 456 : void Address::operator+=(const Variable& other)
109 : {
110 456 : AppendToContext(context, std::make_shared<CcuRepAdd>(*this, other));
111 456 : }
112 :
113 2221 : MaskSignal::MaskSignal(CcuRepContext* context) : CcuVirRes(context) {}
114 :
115 15724 : CcuBuffer::CcuBuffer(CcuRepContext* context) : CcuVirRes(context) {}
116 :
117 89 : uint16_t CcuBuffer::Id() const { return phyRes->Id() + CCUBUFFER_DIE_ID_BIT * phyRes->DieId(); }
118 :
119 1980 : Executor::Executor(CcuRepContext* context) : CcuVirRes(context) {}
120 :
121 : }; // namespace CcuRep
122 : }; // namespace Hccl
|