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