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_loc_record_event.h"
12 : #include <climits>
13 : #include "exception_util.h"
14 : #include "ccu_api_exception.h"
15 : #include "ccu_ins_generator_base.h"
16 :
17 : namespace hcomm {
18 : namespace CcuRep {
19 :
20 17 : CcuRepLocRecordEvent::CcuRepLocRecordEvent(
21 17 : CcuInsGeneratorBase* insGenPtr, const CompletedEvent& event, uint32_t mask)
22 17 : : insGenPtr(insGenPtr),
23 17 : event_(event),
24 17 : mask_(mask)
25 : {
26 17 : type = CcuRepType::LOC_RECORD_EVENT;
27 17 : instrCount = insGenPtr->GetInstrCount(type);
28 17 : }
29 :
30 11 : bool CcuRepLocRecordEvent::Translate(
31 : CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, [[maybe_unused]] const TransDep& dep)
32 : {
33 11 : this->instrId = instrId;
34 11 : translated = true;
35 :
36 11 : CHK_PRT_THROW(
37 : insGenPtr->CcuRepLocRecordEventTranslate(ccuKernel, instr, this) != HcclResult::HCCL_SUCCESS,
38 : HCCL_ERROR("[CcuRepLocRecordEvent][Translate] failed to translate for instrId[%u]", instrId),
39 : Hccl::CcuApiException, "CcuRepLocRecordEvent translate failed");
40 :
41 11 : CHK_PRT_THROW(
42 : instrId > USHRT_MAX - instrCount,
43 : HCCL_ERROR(
44 : "[CcuRepLocRecordEvent][Translate] instrId[%u] + instrCount[%u] "
45 : "exceeds the maximum value of unsigned short int.",
46 : instrId, instrCount),
47 : Hccl::CcuApiException, "integer overflow");
48 :
49 11 : instrId += instrCount;
50 11 : return translated;
51 : }
52 :
53 11 : std::string CcuRepLocRecordEvent::Describe()
54 : {
55 11 : return Hccl::StringFormat("CcuRepLocRecordEvent=id[%u], mask[%04x]", event_.Id(), mask_);
56 : }
57 :
58 : }; // namespace CcuRep
59 : }; // namespace hcomm
|