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