LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/ccu/ccu_representation/reps/common - ccu_rep_load.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 90.9 % 22 20
Test Date: 2026-08-04 10:52:23 Functions: 66.7 % 3 2

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 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.h"
      12              : #include "string_util.h"
      13              : 
      14              : namespace Hccl {
      15              : namespace CcuRep {
      16              : 
      17            1 : CcuRepLoad::CcuRepLoad(uint64_t addr, const Variable &var, uint32_t num) : var(var), addr(addr), num(num)
      18              : {
      19            1 :     type       = CcuRepType::LOAD;
      20            1 :     instrCount = 7; // 7: Load包含7条指令
      21            1 : }
      22              : 
      23            1 : bool CcuRepLoad::Translate(CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
      24              : {
      25            1 :     CHECK_NULLPTR(instr, "[HCcuRepLoad::Translate] instr is nullptr!");
      26            1 :     this->instrId    = instrId;
      27            1 :     translated       = true;
      28            1 :     uint64_t varAddr = dep.xnBaseAddr + CCU_RESOURCE_XN_PER_SIZE * var.Id();
      29              : 
      30            1 :     LoadImdToGSAInstr(instr++, dep.commGsa[0], varAddr);
      31            1 :     LoadImdToGSAInstr(instr++, dep.commGsa[1], addr);
      32            1 :     LoadImdToXnInstr(instr++, dep.commXn[0], dep.ccuResSpaceTokenInfo, CCU_LOAD_TO_XN_SEC_INFO);
      33            1 :     LoadImdToXnInstr(instr++, dep.commXn[1], dep.memTokenInfo, CCU_LOAD_TO_XN_SEC_INFO);
      34            1 :     LoadImdToXnInstr(instr++, dep.commXn[2], CCU_RESOURCE_XN_PER_SIZE * num);
      35            1 :     TransLocMemToLocMemInstr(instr++, dep.commGsa[0], dep.commXn[0], dep.commGsa[1], dep.commXn[1], dep.commXn[2],
      36            1 :                              dep.reserveChannalId[0], dep.commSignal, mask, 0, 0, 1, 1);
      37            1 :     SetCKEInstr(instr++, 0, 0, dep.commSignal, mask, 1);
      38            1 :     CHK_PRT_THROW((instrId > UINT16_MAX - instrCount),
      39              :                         HCCL_ERROR("[CcuRepLoad::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]", instrId, instrCount),
      40              :                           InternalException, "integer overflow");
      41            1 :     instrId += instrCount;
      42              : 
      43            1 :     return translated;
      44              : }
      45              : 
      46            0 : std::string CcuRepLoad::Describe()
      47              : {
      48            0 :     return StringFormat("Load([%llu], [%u], [%u])", addr, var.Id(), num);
      49              : }
      50              : 
      51              : }; // namespace CcuRep
      52              : }; // namespace Hccl
        

Generated by: LCOV version 2.0-1