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 "string_util.h"
13 : #include "ccu_ins_generator_v1.h"
14 : #include "ccu_api_exception.h"
15 : #include "ccu_kernel.h"
16 : namespace hcomm {
17 : namespace CcuRep {
18 :
19 4 : CcuRepRecordSharedNotify::CcuRepRecordSharedNotify(
20 4 : CcuInsGeneratorBase* insGenPtr, const LocalNotify& notify, uint16_t mask)
21 4 : : insGenPtr(insGenPtr),
22 4 : notify_(notify),
23 4 : mask_(mask)
24 : {
25 4 : type = CcuRepType::RECORD_SHARED_NOTIFY;
26 4 : instrCount = insGenPtr->GetInstrCount(type);
27 4 : }
28 :
29 : bool
30 2 : CcuRepRecordSharedNotify::Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
31 : {
32 2 : this->instrId = instrId;
33 2 : translated = true;
34 :
35 2 : CHK_PRT_THROW(
36 : insGenPtr->CcuRepRecordSharedNotifyTranslate(ccuKernel, instr, this, dep) != HcclResult::HCCL_SUCCESS,
37 : HCCL_ERROR("[CcuRepRecordSharedNotify][Translate] failed to translate for instrId[%u]", instrId),
38 : Hccl::CcuApiException, "CcuRepRecordSharedNotify translate failed");
39 2 : CHK_PRT_THROW(
40 : (instrId > UINT16_MAX - instrCount),
41 : HCCL_ERROR(
42 : "[CcuRepRecordSharedNotify::Translate]uint16 integer overflow occurs, "
43 : "instrId = [%hu], instrCount = [%hu]",
44 : instrId, instrCount),
45 : Hccl::InternalException, "integer overflow");
46 2 : instrId += instrCount;
47 :
48 2 : return translated;
49 : }
50 :
51 1 : std::string CcuRepRecordSharedNotify::Describe()
52 : {
53 1 : return Hccl::StringFormat("Post, Use semIndex[%u] and mask[%04x]", notify_.Id(), mask_);
54 : }
55 :
56 : }; // namespace CcuRep
57 : }; // namespace hcomm
|