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(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
31 : {
32 11 : this->instrId = instrId;
33 11 : translated = true;
34 :
35 11 : CHK_PRT_THROW(
36 : insGenPtr->CcuRepLocRecordEventTranslate(ccuKernel, instr, this) != HcclResult::HCCL_SUCCESS,
37 : HCCL_ERROR("[CcuRepLocRecordEvent][Translate] failed to translate for instrId[%u]", instrId),
38 : Hccl::CcuApiException, "CcuRepLocRecordEvent translate failed");
39 :
40 11 : CHK_PRT_THROW(
41 : instrId > USHRT_MAX - instrCount,
42 : HCCL_ERROR(
43 : "[CcuRepLocRecordEvent][Translate] instrId[%u] + instrCount[%u] "
44 : "exceeds the maximum value of unsigned short int.",
45 : instrId, instrCount),
46 : Hccl::CcuApiException, "integer overflow");
47 :
48 11 : instrId += instrCount;
49 11 : return translated;
50 : }
51 :
52 11 : std::string CcuRepLocRecordEvent::Describe()
53 : {
54 11 : return Hccl::StringFormat("CcuRepLocRecordEvent=id[%u], mask[%04x]", event_.Id(), mask_);
55 : }
56 :
57 : }; // namespace CcuRep
58 : }; // namespace hcomm
|