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(
38 : CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, [[maybe_unused]] const TransDep& dep)
39 : {
40 8 : this->instrId = instrId;
41 8 : translated = true;
42 :
43 8 : CHK_PRT_THROW(
44 : insGenPtr->CcuRepRemPostVarTranslate(ccuKernel, instr, this) != HcclResult::HCCL_SUCCESS,
45 : HCCL_ERROR("[CcuRepRemPostVar][Translate] failed to translate for instrId[%u]", instrId),
46 : Hccl::CcuApiException, "CcuRepRemPostVar translate failed");
47 8 : CHK_PRT_THROW(
48 : (instrId > UINT16_MAX - instrCount),
49 : HCCL_ERROR(
50 : "[CcuRepRemPostVar::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]",
51 : instrId, instrCount),
52 : Hccl::InternalException, "integer overflow");
53 8 : instrId += instrCount;
54 :
55 8 : return translated;
56 : }
57 :
58 8 : std::string CcuRepRemPostVar::Describe()
59 : {
60 : return Hccl::StringFormat(
61 16 : "Post Variable[%u] To ParamIndex[%u], Use semIndex[%u] and mask[%04x]", param.Id(), paramIndex, semIndex,
62 8 : mask);
63 : }
64 :
65 : }; // namespace CcuRep
66 : }; // namespace hcomm
|