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