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 "exception_util.h"
14 : #include "ccu_api_exception.h"
15 : #include "hcomm_c_adpt.h"
16 : #include "ccu_ins_generator_v1.h"
17 : #include "../../../../endpoint_pairs/channels/ccu/ccu_urma_channel.h"
18 : #include "ccu_kernel.h"
19 :
20 : namespace hcomm {
21 : namespace CcuRep {
22 :
23 12 : CcuRepRemPostVar::CcuRepRemPostVar(
24 : CcuInsGeneratorBase* insGenPtr, Variable param, const ChannelHandle channel, uint16_t paramIndex,
25 12 : uint16_t semIndex, uint16_t mask)
26 12 : : insGenPtr(insGenPtr),
27 12 : param(param),
28 12 : channel(channel),
29 12 : paramIndex(paramIndex),
30 12 : semIndex(semIndex),
31 12 : mask(mask)
32 : {
33 12 : type = CcuRepType::REM_POST_VAR;
34 12 : instrCount = insGenPtr->GetInstrCount(type);
35 12 : }
36 :
37 8 : bool CcuRepRemPostVar::Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
38 : {
39 8 : this->instrId = instrId;
40 8 : translated = true;
41 :
42 8 : CHK_PRT_THROW(
43 : insGenPtr->CcuRepRemPostVarTranslate(ccuKernel, instr, this) != HcclResult::HCCL_SUCCESS,
44 : HCCL_ERROR("[CcuRepRemPostVar][Translate] failed to translate for instrId[%u]", instrId),
45 : Hccl::CcuApiException, "CcuRepRemPostVar translate failed");
46 8 : CHK_PRT_THROW(
47 : (instrId > UINT16_MAX - instrCount),
48 : HCCL_ERROR(
49 : "[CcuRepRemPostVar::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]",
50 : instrId, instrCount),
51 : Hccl::InternalException, "integer overflow");
52 8 : instrId += instrCount;
53 :
54 8 : return translated;
55 : }
56 :
57 8 : std::string CcuRepRemPostVar::Describe()
58 : {
59 : return Hccl::StringFormat(
60 16 : "Post Variable[%u] To ParamIndex[%u], Use semIndex[%u] and mask[%04x]", param.Id(), paramIndex, semIndex,
61 8 : mask);
62 : }
63 :
64 : }; // namespace CcuRep
65 : }; // namespace hcomm
|