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