Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 : #ifndef HCOMM_CCU_REPRESENTATION_LOCCPY_H
12 : #define HCOMM_CCU_REPRESENTATION_LOCCPY_H
13 :
14 : #include "ccu_rep_base_v1.h"
15 : #include "ccu_datatype_v1.h"
16 :
17 : namespace hcomm {
18 : namespace CcuRep {
19 :
20 : class CcuRepLocCpy : public CcuRepBase {
21 : public:
22 : CcuRepLocCpy(
23 : CcuInsGeneratorBase* insGenPtr, LocalAddr dst, LocalAddr src, Variable len, CompletedEvent sem,
24 : uint16_t mask);
25 : CcuRepLocCpy(
26 : CcuInsGeneratorBase* insGenPtr, LocalAddr dst, LocalAddr src, Variable len, uint16_t dataType,
27 : uint16_t opType, CompletedEvent sem, uint16_t mask);
28 :
29 : // A6场景预埋
30 : CcuRepLocCpy(
31 : CcuInsGeneratorBase* insGenPtr, LocalAddr dst, LocalAddr src, Variable len, const std::vector<CcuBuf>& bufs,
32 : CompletedEvent sem, uint16_t mask);
33 :
34 : bool Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep) override;
35 : std::string Describe() override;
36 0 : uint16_t GetSrcAddrId() { return src.addr.Id(); }
37 0 : uint16_t GetSrcTokenId() { return src.token.Id(); }
38 0 : uint16_t GetDstAddrId() { return dst.addr.Id(); }
39 0 : uint16_t GetDstTokenId() { return dst.token.Id(); }
40 0 : uint16_t GetLenId() { return len.Id(); }
41 0 : uint16_t GetSemId() { return sem.Id(); }
42 1 : uint16_t GetDataType() { return dataType; }
43 1 : uint16_t GetOpType() { return opType; }
44 : const std::vector<CcuBuf>& GetBufs() { return bufs; }
45 :
46 6 : LocalAddr GetDst() { return dst; }
47 6 : LocalAddr GetSrc() { return src; }
48 3 : Variable GetLen() { return len; }
49 3 : CompletedEvent GetSem() { return sem; }
50 4 : uint16_t GetMask() { return mask; }
51 4 : uint16_t GetReduceFlag() { return reduceFlag; }
52 0 : bool GetUseCcuBuffer() { return useCcuBuffer; }
53 :
54 : uint16_t GetFirstBufId();
55 : uint16_t GetUsedBufNum();
56 :
57 : private:
58 : void ValidateInsGeneratorForLocCpy();
59 :
60 : CcuInsGeneratorBase* insGenPtr{nullptr};
61 : LocalAddr dst;
62 : LocalAddr src;
63 : Variable len;
64 :
65 : // 用于A6场景locmem2locmem搬运
66 : std::vector<CcuBuf> bufs;
67 :
68 : CompletedEvent sem;
69 : uint16_t mask{0};
70 :
71 : uint16_t dataType{0};
72 : uint16_t opType{0};
73 : uint16_t reduceFlag{0};
74 :
75 : bool useCcuBuffer = false;
76 : };
77 :
78 : }; // namespace CcuRep
79 : }; // namespace hcomm
80 : #endif // HCOMM_CCU_REPRESENTATION_LOCCPY_H
|