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 "ccu_ins_generator_v1.h"
13 : #include "string_util.h"
14 : #include "exception_util.h"
15 : #include "ccu_api_exception.h"
16 : #include "ccu_ins_generator_base.h"
17 : #include "ccu_kernel.h"
18 :
19 : namespace hcomm {
20 : namespace CcuRep {
21 :
22 15 : CcuRepBufLocRead::CcuRepBufLocRead(
23 15 : CcuInsGeneratorBase* insGenPtr, LocalAddr src, CcuBuf dst, Variable len, CompletedEvent sem, uint16_t mask)
24 15 : : insGenPtr(insGenPtr),
25 15 : src(src),
26 15 : dst(dst),
27 15 : len(len),
28 15 : sem(sem),
29 15 : mask(mask)
30 : {
31 15 : type = CcuRepType::BUF_LOC_READ;
32 15 : instrCount = insGenPtr->GetInstrCount(type);
33 15 : }
34 :
35 13 : bool CcuRepBufLocRead::Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
36 : {
37 13 : this->instrId = instrId;
38 13 : translated = true;
39 :
40 13 : CHK_PRT_THROW(
41 : insGenPtr->CcuRepBufLocReadTranslate(ccuKernel, instr, this, dep) != HcclResult::HCCL_SUCCESS,
42 : HCCL_ERROR("[CcuRepBufLocRead][Translate] failed to translate for instrId[%u]", instrId),
43 : Hccl::CcuApiException, "CcuRepBufLocRead translate failed");
44 13 : instrId += instrCount;
45 :
46 13 : return translated;
47 : }
48 :
49 13 : std::string CcuRepBufLocRead::Describe()
50 : {
51 : return Hccl::StringFormat(
52 65 : "Read Loc Mem[%u] To CcuBuf[%u], len[%u], sem[%u], mask[%04x]", src.addr.Id(), dst.Id(), len.Id(), sem.Id(),
53 13 : mask);
54 : }
55 :
56 : }; // namespace CcuRep
57 : }; // namespace hcomm
|