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 35 : CcuRepRemWaitSem::CcuRepRemWaitSem(const CcuTransport &transport, uint16_t semIndex, uint16_t mask, bool isProfiling)
19 35 : : transport(transport), semIndex(semIndex), mask(mask), isProfiling(isProfiling)
20 : {
21 35 : type = CcuRepType::REM_WAIT_SEM;
22 35 : instrCount = 1;
23 35 : }
24 :
25 1 : bool CcuRepRemWaitSem::Translate(CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
26 : {
27 1 : this->instrId = instrId;
28 1 : translated = true;
29 :
30 : // 需要profiling的使用SetCKEInstr, 否则使用ClearCKEInstr
31 1 : if (isProfiling) {
32 1 : SetCKEInstr(instr++, 0, 0, transport.GetLocCkeByIndex(semIndex), mask, 1);
33 : } else {
34 0 : ClearCKEInstr(instr++, 0, 0, transport.GetLocCkeByIndex(semIndex), mask, 1);
35 : }
36 1 : CHK_PRT_THROW(instrId > UINT16_MAX - instrCount,
37 : HCCL_ERROR("[CcuRepRemWaitSem::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]", instrId, instrCount),
38 : InternalException, "integer overflow");
39 1 : instrId += instrCount;
40 :
41 1 : return translated;
42 : }
43 :
44 2 : std::string CcuRepRemWaitSem::Describe()
45 : {
46 2 : return StringFormat("Wait, Use semIndex[%u] and mask[%04x]", semIndex, mask);
47 : }
48 :
49 : }; // namespace CcuRep
50 : }; // namespace Hccl
|