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_store_var_v1.h"
12 : #include "string_util.h"
13 : #include "ccu_rep_v1.h"
14 : #include "exception_util.h"
15 : #include "ccu_api_exception.h"
16 :
17 : #include "ccu_ins_generator_base.h"
18 : #include "ccu_kernel.h"
19 :
20 : namespace hcomm {
21 : namespace CcuRep {
22 :
23 : using namespace Hccl;
24 :
25 6 : CcuRepStoreVar::CcuRepStoreVar(
26 6 : CcuInsGeneratorBase* insGeneratorPtr, const Variable& var, const Variable& dst, uint32_t num, bool hscbFlag)
27 6 : : insGeneratorPtr_(insGeneratorPtr),
28 6 : var(var),
29 6 : dst(dst),
30 6 : num(num),
31 6 : hscbFlag(hscbFlag)
32 : {
33 : // for A6 only
34 6 : type = CcuRepType::STORE_VAR;
35 6 : instrCount = insGeneratorPtr_->GetInstrCount(type);
36 6 : }
37 :
38 3 : bool CcuRepStoreVar::Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
39 : {
40 3 : this->instrId = instrId;
41 3 : translated = true;
42 :
43 3 : CHK_PRT_THROW(
44 : insGeneratorPtr_->CcuRepStoreVarTranslate(ccuKernel, instr, instrId, this, dep) != HcclResult::HCCL_SUCCESS,
45 : HCCL_ERROR("[CcuRepStoreVar][Translate] failed to translate for instrId[%u]", instrId),
46 : Hccl::CcuApiException, "CcuRepStoreVar translate failed");
47 :
48 3 : instrId += instrCount;
49 3 : return translated;
50 : }
51 :
52 3 : std::string CcuRepStoreVar::Describe()
53 : {
54 3 : return Hccl::StringFormat("Store Var([%u], [%u], [%u])", var.Id(), dst.Id(), num);
55 : }
56 :
57 : }; // namespace CcuRep
58 : }; // namespace hcomm
|