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 :
16 : #include "ccu_ins_generator_base.h"
17 : #include "ccu_kernel.h"
18 :
19 : namespace hcomm {
20 : namespace CcuRep {
21 :
22 : using namespace Hccl;
23 :
24 9 : CcuRepLoad::CcuRepLoad(CcuInsGeneratorBase* insGenPtr, uint64_t addr, const Variable& var, uint32_t num)
25 9 : : insGeneratorPtr_(insGenPtr),
26 9 : var(var),
27 9 : addr(addr),
28 9 : num(num)
29 : {
30 9 : type = CcuRepType::LOAD;
31 9 : instrCount = insGeneratorPtr_->GetInstrCount(type); // 7: Load包含7条指令
32 9 : }
33 :
34 3 : bool CcuRepLoad::Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
35 : {
36 3 : Hccl::CHECK_NULLPTR(instr, "[HCcuRepLoad::Translate] instr is nullptr!");
37 3 : this->instrId = instrId;
38 3 : translated = true;
39 3 : CHK_PRT_THROW(
40 : insGeneratorPtr_->CcuRepLoadTranslate(ccuKernel, instr, instrId, this, dep) != HcclResult::HCCL_SUCCESS,
41 : HCCL_ERROR("[CcuRepLoad][Translate] failed to translate for instrId[%u]", instrId), Hccl::CcuApiException,
42 : "CcuRepLoad translate failed");
43 3 : CHK_PRT_THROW(
44 : (instrId > UINT16_MAX - instrCount),
45 : HCCL_ERROR(
46 : "[CcuRepLoad::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]", instrId,
47 : instrCount),
48 : Hccl::InternalException, "integer overflow");
49 3 : instrId += instrCount;
50 :
51 3 : return translated;
52 : }
53 :
54 3 : std::string CcuRepLoad::Describe() { return Hccl::StringFormat("Load([%llu], [%u], [%u])", addr, var.Id(), num); }
55 :
56 : }; // namespace CcuRep
57 : }; // namespace hcomm
|