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 11 : CcuRepBufLocWrite::CcuRepBufLocWrite(
23 11 : CcuInsGeneratorBase* insGenPtr, CcuBuf src, LocalAddr dst, Variable len, CompletedEvent sem, uint32_t mask)
24 11 : : insGenPtr(insGenPtr),
25 11 : src(src),
26 11 : dst(dst),
27 11 : len(len),
28 11 : sem(sem),
29 11 : mask(mask)
30 : {
31 11 : type = CcuRepType::BUF_LOC_WRITE;
32 11 : instrCount = insGenPtr->GetInstrCount(type);
33 11 : }
34 :
35 9 : bool CcuRepBufLocWrite::Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
36 : {
37 9 : this->instrId = instrId;
38 9 : translated = true;
39 :
40 9 : CHK_PRT_THROW(
41 : insGenPtr->CcuRepBufLocWriteTranslate(ccuKernel, instr, this, dep) != HcclResult::HCCL_SUCCESS,
42 : HCCL_ERROR("[CcuRepBufLocWrite][Translate] failed to translate for instrId[%u]", instrId),
43 : Hccl::CcuApiException, "CcuRepBufLocWrite translate failed");
44 9 : instrId += instrCount;
45 :
46 9 : return translated;
47 : }
48 :
49 9 : std::string CcuRepBufLocWrite::Describe()
50 : {
51 : return Hccl::StringFormat(
52 36 : "Write CcuBuf[%u] To Loc Mem[%u], len[%u], sem[%u], mask[%04x]", src.Id(), dst.addr.Id(), len.Id(),
53 9 : sem.Id(), mask);
54 : }
55 :
56 : }; // namespace CcuRep
57 : }; // namespace hcomm
|