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 334 : CcuRepRemPostVar::CcuRepRemPostVar(Variable param, const CcuTransport &transport, uint16_t paramIndex,
19 334 : uint16_t semIndex, uint16_t mask)
20 334 : : param(param), transport(transport), paramIndex(paramIndex), semIndex(semIndex), mask(mask)
21 : {
22 334 : type = CcuRepType::REM_POST_VAR;
23 334 : instrCount = 1;
24 334 : }
25 :
26 39 : bool CcuRepRemPostVar::Translate(CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
27 : {
28 39 : this->instrId = instrId;
29 39 : translated = true;
30 :
31 39 : SyncXnInstr(instr++, transport.GetRmtXnByIndex(paramIndex), param.Id(), transport.GetChannelId(),
32 39 : transport.GetRmtCntCkeByIndex(semIndex), mask, 0, 0, 0, 0, 1);
33 39 : CHK_PRT_THROW((instrId > UINT16_MAX - instrCount),
34 : HCCL_ERROR("[CcuRepRemPostVar::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]", instrId, instrCount),
35 : InternalException, "integer overflow");
36 39 : instrId += instrCount;
37 :
38 39 : return translated;
39 : }
40 :
41 39 : std::string CcuRepRemPostVar::Describe()
42 : {
43 78 : return StringFormat("Post Variable[%u] To ParamIndex[%u], Use semIndex[%u] and mask[%04x]", param.Id(), paramIndex,
44 39 : semIndex, mask);
45 : }
46 :
47 : }; // namespace CcuRep
48 : }; // namespace Hccl
|