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 2 : CcuRepRead::CcuRepRead(
19 2 : const CcuTransport& transport, Memory loc, Memory rem, Variable len, MaskSignal sem, uint16_t mask)
20 2 : : transport(transport),
21 2 : loc(loc),
22 2 : rem(rem),
23 2 : len(len),
24 2 : sem(sem),
25 2 : mask(mask)
26 : {
27 2 : type = CcuRepType::READ;
28 2 : instrCount = 1;
29 2 : }
30 :
31 1 : CcuRepRead::CcuRepRead(
32 : const CcuTransport& transport, Memory loc, Memory rem, Variable len, uint16_t dataType, uint16_t opType,
33 1 : MaskSignal sem, uint16_t mask)
34 1 : : transport(transport),
35 1 : loc(loc),
36 1 : rem(rem),
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::READ;
45 1 : instrCount = 1;
46 1 : }
47 :
48 2 : bool CcuRepRead::Translate(CcuInstr*& instr, uint16_t& instrId, [[maybe_unused]] const TransDep& dep)
49 : {
50 2 : this->instrId = instrId;
51 2 : translated = true;
52 :
53 16 : TransRmtMemToLocMemInstr(
54 2 : instr++, loc.addr.Id(), loc.token.Id(), rem.addr.Id(), rem.token.Id(), len.Id(), transport.GetChannelId(),
55 2 : dataType, opType, sem.Id(), mask, 0, 0, 1, 1, reduceFlag);
56 :
57 2 : instrId += instrCount;
58 :
59 2 : return translated;
60 : }
61 :
62 4 : std::string CcuRepRead::Describe()
63 : {
64 : return StringFormat(
65 : "Read Memory[%u] To Memory[%u], length[%u], set sem[%u] with mask[%04x], dataType[%u], opType[%u]",
66 4 : rem.addr.Id(), loc.addr.Id(), len.Id(), sem.Id(), mask, dataType, opType);
67 : }
68 : }; // namespace CcuRep
69 : }; // namespace Hccl
|