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_rep.h"
12 :
13 : #include "string_util.h"
14 :
15 : namespace Hccl {
16 : namespace CcuRep {
17 :
18 10 : CcuRepWrite::CcuRepWrite(
19 10 : const CcuTransport& transport, Memory rem, Memory loc, Variable len, MaskSignal sem, uint16_t mask)
20 10 : : transport(transport),
21 10 : rem(rem),
22 10 : loc(loc),
23 10 : len(len),
24 10 : sem(sem),
25 10 : mask(mask)
26 : {
27 10 : type = CcuRepType::WRITE;
28 10 : instrCount = 1;
29 10 : }
30 :
31 1 : CcuRepWrite::CcuRepWrite(
32 : const CcuTransport& transport, Memory rem, Memory loc, Variable len, uint16_t dataType, uint16_t opType,
33 1 : MaskSignal sem, uint16_t mask)
34 1 : : transport(transport),
35 1 : rem(rem),
36 1 : loc(loc),
37 1 : len(len),
38 1 : sem(sem),
39 1 : mask(mask),
40 1 : dataType(dataType),
41 1 : opType(opType),
42 1 : reduceFlag(1)
43 : {
44 1 : type = CcuRepType::WRITE;
45 1 : instrCount = 1;
46 1 : }
47 :
48 10 : bool CcuRepWrite::Translate(CcuInstr*& instr, uint16_t& instrId, [[maybe_unused]] const TransDep& dep)
49 : {
50 10 : this->instrId = instrId;
51 10 : translated = true;
52 :
53 80 : TransLocMemToRmtMemInstr(
54 10 : instr++, rem.addr.Id(), rem.token.Id(), loc.addr.Id(), loc.token.Id(), len.Id(), transport.GetChannelId(),
55 10 : dataType, opType, sem.Id(), mask, 0, 0, 1, 1, reduceFlag);
56 :
57 10 : instrId += instrCount;
58 :
59 10 : return translated;
60 : }
61 :
62 12 : std::string CcuRepWrite::Describe()
63 : {
64 : return StringFormat(
65 : "Write Memory[%u] to Memory[%u], length[%u], set sem[%u] with mask[%04x], dataType[%u], opType[%u]",
66 12 : loc.addr.Id(), rem.addr.Id(), len.Id(), sem.Id(), mask, dataType, opType);
67 : }
68 :
69 : }; // namespace CcuRep
70 : }; // namespace Hccl
|