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 11 : CcuRepPostSharedSem::CcuRepPostSharedSem(const MaskSignal &sem, uint16_t mask) : sem(sem), mask(mask)
19 : {
20 11 : type = CcuRepType::POST_SHARED_SEM;
21 11 : instrCount = 1;
22 11 : }
23 :
24 10 : bool CcuRepPostSharedSem::Translate(CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
25 : {
26 10 : this->instrId = instrId;
27 10 : translated = true;
28 :
29 10 : if (sem.DieId() != dep.dieId) {
30 5 : SyncCKEInstr(instr++, sem.Id(), dep.reserveCkeId, mask, dep.reserveChannalId[1], 0, 0, 0, 0, 1);
31 : } else {
32 5 : SetCKEInstr(instr++, sem.Id(), mask, 0, 0, 1);
33 : }
34 10 : CHK_PRT_THROW((instrId > UINT16_MAX - instrCount),
35 : HCCL_ERROR("[CcuRepPostSharedSem::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]", instrId, instrCount),
36 : InternalException, "integer overflow");
37 10 : instrId += instrCount;
38 :
39 10 : return translated;
40 : }
41 :
42 12 : std::string CcuRepPostSharedSem::Describe()
43 : {
44 12 : return StringFormat("Post, Use semIndex[%u] and mask[%04x]", sem.Id(), mask);
45 : }
46 :
47 : }; // namespace CcuRep
48 : }; // namespace Hccl
|