Line data Source code
1 : /**
2 : * Copyright (c) 2026 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_v1.h"
12 : #include "ccu_rep_loc_wait_notify.h"
13 : #include <climits>
14 : #include "string_util.h"
15 : #include "exception_util.h"
16 : #include "ccu_api_exception.h"
17 : #include "ccu_ins_generator_v1.h"
18 : #include "ccu_kernel.h"
19 : namespace hcomm {
20 : namespace CcuRep {
21 :
22 5 : CcuRepLocWaitNotify::CcuRepLocWaitNotify(
23 5 : CcuInsGeneratorBase* insGenPtr, const LocalNotify& notify, const uint32_t mask, bool isProfiling)
24 5 : : insGenPtr(insGenPtr),
25 5 : notify_(notify),
26 5 : mask_(mask),
27 5 : isProfiling_(isProfiling)
28 : {
29 5 : type = CcuRepType::LOC_WAIT_NOTIFY;
30 5 : instrCount = insGenPtr->GetInstrCount(type);
31 5 : }
32 :
33 2 : bool CcuRepLocWaitNotify::Translate(
34 : CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, [[maybe_unused]] const TransDep& dep)
35 : {
36 2 : this->instrId = instrId;
37 2 : translated = true;
38 :
39 2 : CHK_PRT_THROW(
40 : insGenPtr->CcuRepLocWaitNotifyTranslate(ccuKernel, instr, this) != HcclResult::HCCL_SUCCESS,
41 : HCCL_ERROR("[CcuRepLocWaitNotify][Translate] failed to translate for instrId[%u]", instrId),
42 : Hccl::CcuApiException, "CcuRepLocWaitNotify translate failed");
43 2 : CHK_PRT_THROW(
44 : (instrId > UINT16_MAX - instrCount),
45 : HCCL_ERROR(
46 : "[CcuRepLocWaitNotify::Translate]uint16 integer overflow occurs, "
47 : "instrId = [%hu], instrCount = [%hu]",
48 : instrId, instrCount),
49 : Hccl::CcuApiException, "integer overflow");
50 :
51 2 : instrId += instrCount;
52 2 : return translated;
53 : }
54 :
55 1 : std::string CcuRepLocWaitNotify::Describe()
56 : {
57 1 : return Hccl::StringFormat("CcuRepLocWaitNotify=id[%u], mask[%04x]", notify_.Id(), mask_);
58 : }
59 :
60 : }; // namespace CcuRep
61 : }; // namespace hcomm
|