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 3 : CcuRepLocCpy::CcuRepLocCpy(Memory dst, Memory src, Variable len, MaskSignal sem, uint16_t mask)
19 3 : : dst(dst),
20 3 : src(src),
21 3 : len(len),
22 3 : sem(sem),
23 3 : mask(mask)
24 : {
25 3 : type = CcuRepType::LOCAL_CPY;
26 3 : instrCount = 1;
27 3 : }
28 :
29 3 : CcuRepLocCpy::CcuRepLocCpy(
30 3 : Memory dst, Memory src, Variable len, uint16_t dataType, uint16_t opType, MaskSignal sem, uint16_t mask)
31 3 : : dst(dst),
32 3 : src(src),
33 3 : len(len),
34 3 : sem(sem),
35 3 : mask(mask),
36 3 : dataType(dataType),
37 3 : opType(opType),
38 3 : reduceFlag(1)
39 : {
40 3 : type = CcuRepType::LOCAL_REDUCE;
41 3 : instrCount = 1;
42 3 : }
43 :
44 4 : bool CcuRepLocCpy::Translate(CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
45 : {
46 4 : this->instrId = instrId;
47 4 : translated = true;
48 :
49 4 : if (reduceFlag == 0) {
50 14 : TransLocMemToLocMemInstr(
51 2 : instr++, dst.addr.Id(), dst.token.Id(), src.addr.Id(), src.token.Id(), len.Id(),
52 2 : dep.reserveChannalId[0], sem.Id(), mask, 0, 0, 1, 1);
53 : } else {
54 : // 这个翻译需要验证
55 14 : TransLocMemToRmtMemInstr(
56 2 : instr++, dst.addr.Id(), dst.token.Id(), src.addr.Id(), src.token.Id(), len.Id(),
57 2 : dep.reserveChannalId[0], dataType, opType, sem.Id(), mask, 0, 0, 1, 1, reduceFlag);
58 : }
59 :
60 4 : instrId += instrCount;
61 :
62 4 : return translated;
63 : }
64 :
65 6 : std::string CcuRepLocCpy::Describe()
66 : {
67 : return StringFormat(
68 : "Read Memory[%u] to Memory[%u], length[%u], set sem[%u] with mask[%04x], dataType[%u], opType[%u]",
69 6 : src.addr.Id(), dst.addr.Id(), len.Id(), sem.Id(), mask, dataType, opType);
70 : }
71 :
72 : }; // namespace CcuRep
73 : }; // namespace Hccl
|