Line data Source code
1 : /*
2 : * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved.
3 : * Description: ccu representation load implementation file
4 : * Author: zhanhaifeng
5 : * Create: 2025-03-21
6 : */
7 :
8 : #include "ccu_rep_v1.h"
9 : #include "string_util.h"
10 : #include "exception_util.h"
11 : #include "ccu_api_exception.h"
12 :
13 : #include "ccu_ins_generater_base.h"
14 : #include "ccu_kernel.h"
15 :
16 : namespace hcomm {
17 : namespace CcuRep {
18 :
19 : using namespace Hccl;
20 :
21 5 : CcuRepLoad::CcuRepLoad(CcuInsGeneraterBase* insGenPtr, uint64_t addr, const Variable &var, uint32_t num) :
22 5 : insGeneratorPtr_(insGenPtr), var(var), addr(addr), num(num)
23 : {
24 5 : type = CcuRepType::LOAD;
25 5 : instrCount = insGeneratorPtr_->GetInstrCount(type); // 7: Load包含7条指令
26 5 : }
27 :
28 3 : bool CcuRepLoad::Translate(CcuKernel* ccuKernel, CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
29 : {
30 3 : Hccl::CHECK_NULLPTR(instr, "[HCcuRepLoad::Translate] instr is nullptr!");
31 3 : this->instrId = instrId;
32 3 : translated = true;
33 3 : CHK_RET_THROW(Hccl::CcuApiException,
34 : Hccl::StringFormat("[CcuRepLoad][%s] failed to translate repLoad for instrId[%u] ", __func__, instrId),
35 : insGeneratorPtr_->CcuRepLoadTranslate(ccuKernel, instr, instrId, this, dep));
36 3 : CHK_PRT_THROW((instrId > UINT16_MAX - instrCount),
37 : HCCL_ERROR("[CcuRepLoad::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]", instrId, instrCount),
38 : Hccl::InternalException, "integer overflow");
39 3 : instrId += instrCount;
40 :
41 3 : return translated;
42 : }
43 :
44 3 : std::string CcuRepLoad::Describe()
45 : {
46 3 : return Hccl::StringFormat("Load([%llu], [%u], [%u])", addr, var.Id(), num);
47 : }
48 :
49 : }; // namespace CcuRep
50 : }; // namespace hcomm
|