Line data Source code
1 : /*
2 : * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
3 : * Description: ccu representation implementation file
4 : * Author: sunzhepeng
5 : * Create: 2024-06-17
6 : */
7 :
8 : #include "ccu_rep_v1.h"
9 : #include "ccu_assist_v1.h"
10 : #include <climits>
11 :
12 : #include "string_util.h"
13 : #include "exception_util.h"
14 : #include "ccu_api_exception.h"
15 : #include "ccu_ins_generator_base.h"
16 : #include "ccu_ins_generator_v1.h"
17 : #include "ccu_kernel.h"
18 :
19 : namespace hcomm {
20 : namespace CcuRep {
21 :
22 : using namespace Hccl;
23 :
24 4 : CcuRepSetLoop::CcuRepSetLoop(CcuInsGeneratorBase* insGeneratorPtr, const Variable &loopParam, const Executor &executor, const Variable &var)
25 4 : : insGeneratorPtr_(insGeneratorPtr), loopParam(loopParam), executor(executor), var(var)
26 : {
27 4 : type = CcuRepType::SET_LOOP;
28 4 : instrCount = insGeneratorPtr_->GetInstrCount(type); // set loop 指令数量为2
29 4 : }
30 :
31 1 : bool CcuRepSetLoop::Translate(CcuKernel* ccuKernel, CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
32 : {
33 1 : this->instrId = instrId;
34 1 : translated = true;
35 :
36 1 : if (instrId > USHRT_MAX - instrCount) {
37 0 : Hccl::THROW<Hccl::InternalException>(Hccl::StringFormat("[CcuRepSetLoop][Translate] instrId[%u] + instrCount[%u] exceeds the "
38 0 : "maximum value of unsigned short int.", instrId, instrCount));
39 : }
40 1 : instrId += instrCount;
41 :
42 1 : return translated;
43 : }
44 :
45 1 : std::string CcuRepSetLoop::Describe()
46 : {
47 1 : return Hccl::StringFormat("loopParam[%u] = var[%u], execute on LoopEngine[%u]", loopParam.Id(), var.Id(), executor.Id());
48 : }
49 :
50 : }; // namespace CcuRep
51 : }; // namespace hcomm
|