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