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 : #include "ccu_assist.h"
13 :
14 : #include "string_util.h"
15 :
16 : namespace Hccl {
17 : namespace CcuRep {
18 :
19 0 : CcuRepRemMem::CcuRepRemMem(const CcuTransport &transport, Memory rem)
20 0 : : transport(transport), rem(rem)
21 : {
22 0 : type = CcuRepType::REM_MEM;
23 0 : instrCount = 2; // 指令数为2个
24 0 : }
25 :
26 0 : bool CcuRepRemMem::Translate(CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
27 : {
28 0 : this->instrId = instrId;
29 0 : translated = true;
30 :
31 0 : CcuTransport::CclBufferInfo cclBufferInfo;
32 0 : uint32_t index = 0;
33 0 : transport.GetRmtBuffer(cclBufferInfo, index);
34 0 : auto addr = cclBufferInfo.addr;
35 0 : auto tokenId = cclBufferInfo.tokenId;
36 0 : auto tokenValue = cclBufferInfo.tokenValue;
37 :
38 0 : auto tokenInfo = GetToken(tokenId, tokenValue, 1);
39 :
40 0 : LoadImdToGSAInstr(instr++, rem.addr.Id(), addr);
41 0 : LoadImdToXnInstr(instr++, rem.token.Id(), tokenInfo, CCU_LOAD_TO_XN_SEC_INFO);
42 :
43 0 : instrId += instrCount;
44 :
45 0 : return translated;
46 : }
47 :
48 0 : std::string CcuRepRemMem::Describe()
49 : {
50 0 : return StringFormat("Get Remote Buffer Addr and TokenInfo By Transport");
51 : }
52 :
53 : }; // namespace CcuRep
54 : }; // namespace Hccl
|