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