LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/interface/device - coll_alg_component_lite.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 86 0
Test Date: 2026-08-04 10:52:23 Functions: 0.0 % 8 0

            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 <iostream>
      12              : #include <string>
      13              : #include <map>
      14              : 
      15              : #include "log.h"
      16              : #include "coll_alg_component_lite.h"
      17              : 
      18              : namespace Hccl {
      19              : 
      20            0 : void CollAlgComponentLite::EnableDetour(bool enableDetour)
      21              : {
      22            0 :     enableDetour_ = enableDetour;
      23            0 :     return;
      24              : }
      25              : 
      26            0 : void CollAlgComponentLite::EnableDataAllign(bool enableAllign)
      27              : {
      28            0 :     enableAllign_ = enableAllign;
      29            0 :     return;
      30              : }
      31              : 
      32            0 : void CollAlgComponentLite::SetAllignSize(u64 allignSize)
      33              : {
      34            0 :     allignSize_ = allignSize;
      35            0 :     return;
      36              : }
      37              : 
      38            0 : void CollAlgComponentLite::SetDmaMode(const DmaMode dmaMode)
      39              : {
      40            0 :     dmaMode_ = dmaMode;
      41            0 :     return;
      42              : }
      43              : 
      44            0 : HcclResult CollAlgComponentLite::ParsePackedData(std::vector<char> packedData)
      45              : {
      46            0 :     BinaryStream binaryStream(packedData);
      47            0 :     DmaMode dmaMode;
      48            0 :     binaryStream >> dmaMode;
      49            0 :     SetDmaMode(dmaMode);
      50            0 :     return HcclResult::HCCL_SUCCESS;
      51            0 : }
      52              : 
      53            0 : HcclResult CollAlgComponentLite::Orchestrate(const CollAlgOperator &op, const std::string &algName,
      54              :                                              const AlgTopoInfo &algTopoInfo, PrimQuePtr queue)
      55              : {
      56            0 :     HCCL_DEBUG("[CollAlgComponentLite] Orchestrate Mode: Primitive.");
      57            0 :     if (rankSize_ == 1) {
      58            0 :         u64                        dataSize      = op.dataCount * DataTypeSizeGet(op.dataType);
      59            0 :         DataSlice                  usrInSlice    = DataSlice(BufferType::INPUT, 0, dataSize);
      60            0 :         DataSlice                  usrOutSlice   = DataSlice(BufferType::OUTPUT, 0, dataSize);
      61            0 :         std::unique_ptr<Primitive> primLocalCopy = std::make_unique<PrimLocalCopy>(usrInSlice, usrOutSlice);
      62            0 :         if (primLocalCopy == nullptr) {
      63            0 :             HCCL_ERROR("[CollAlgComponentLite] primLocalCopy is nullptr");
      64            0 :             return HcclResult::HCCL_E_PARA;
      65              :         }
      66            0 :         queue->Append(std::move(primLocalCopy));
      67              : 
      68            0 :         HCCL_DEBUG("[CollAlgComponentLite] rankSize = 1.");
      69            0 :         return HcclResult::HCCL_SUCCESS;
      70            0 :     }
      71              : 
      72            0 :     std::shared_ptr<CollAlgBase> primGenFunc = CollAlgRegistry::Global()->GetAlgImpl(op.opType, algName);
      73            0 :     CHK_PRT_RET(primGenFunc == nullptr,
      74              :         HCCL_ERROR("[CollAlgComponentLite] can not find collAlgName: [%s]", algName.c_str()),
      75              :         HcclResult::HCCL_E_PARA);
      76              : 
      77            0 :     CHK_PRT_RET(
      78              :         enableDetour_
      79              :             && ((algName != "AllGatherMesh") && (algName != "ReduceScatterMesh") && (algName != "AllReduceMesh")),
      80              :         HCCL_ERROR("[CollAlgComponentLite] Current algorithm can not support detouring, please check!"),
      81              :         HcclResult::HCCL_E_NOT_SUPPORT);
      82              : 
      83            0 :     primGenFunc->SetMyRank(myRank_);
      84            0 :     primGenFunc->SetRankSize(rankSize_);
      85            0 :     primGenFunc->SetDevType(devType_);
      86            0 :     primGenFunc->EnableDataAllign(enableAllign_);
      87            0 :     primGenFunc->SetAllignSize(allignSize_);
      88            0 :     primGenFunc->EnableDetour(enableDetour_);
      89            0 :     primGenFunc->SetDmaMode(dmaMode_);
      90              : 
      91            0 :     CollAlgParams params;
      92            0 :     params.maxTmpMemSize = scratchBufferSize_;
      93            0 :     params.opMode        = OpMode::OPBASE;
      94            0 :     primGenFunc->GenPrimQuesAIC(algTopoInfo, op, params, linkMgr_, queue);
      95            0 :     return HcclResult::HCCL_SUCCESS;
      96            0 : }
      97              : 
      98            0 : HcclResult CollAlgComponentLite::Orchestrate(const CollAlgOperator &op, const std::string &algName,
      99              :                                              const AlgTopoInfo &algTopoInfo, InsQuePtr queue)
     100              : {
     101            0 :     HCCL_DEBUG("[CollAlgComponentLite] Orchestrate Mode: Instruction.");
     102            0 :     bool isAlltoAll = (op.opType == OpType::ALLTOALL) || (op.opType == OpType::ALLTOALLV) || (op.opType == OpType::ALLTOALLVC);
     103            0 :     if ((rankSize_ == 1) && (!isAlltoAll)) {
     104            0 :         u64                          dataSize     = op.dataCount * DataTypeSizeGet(op.dataType);
     105            0 :         DataSlice                    usrInSlice   = DataSlice(BufferType::INPUT, 0, dataSize);
     106            0 :         DataSlice                    usrOutSlice  = DataSlice(BufferType::OUTPUT, 0, dataSize);
     107            0 :         std::unique_ptr<Instruction> insLocalCopy = std::make_unique<InsLocalCopy>(usrInSlice, usrOutSlice);
     108            0 :         if (insLocalCopy == nullptr) {
     109            0 :             HCCL_ERROR("[CollAlgComponentLite] insLocalCopy is nullptr");
     110            0 :             return HcclResult::HCCL_E_PARA;
     111              :         }
     112            0 :         queue->Append(std::move(insLocalCopy));
     113              : 
     114            0 :         HCCL_DEBUG("[CollAlgComponentLite] rankSize = 1.");
     115            0 :         HCCL_DEBUG("[CollAlgComponentLite] finish CollAlgComponentLite::Orchestrate.");
     116            0 :         return HcclResult::HCCL_SUCCESS;
     117            0 :     }
     118              : 
     119            0 :     std::shared_ptr<InsCollAlgBase> insGenFunc = InsCollAlgRegistry::Global()->GetAlgImpl(op.opType, algName);
     120            0 :     CHK_PRT_RET(insGenFunc == nullptr,
     121              :         HCCL_ERROR("[CollAlgComponentLite] can not find insCollAlgName: [%s]", algName.c_str()),
     122              :         HcclResult::HCCL_E_PARA);
     123              : 
     124            0 :     insGenFunc->SetMyRank(myRank_);
     125            0 :     insGenFunc->SetSendRecvRemoteRank(op.sendRecvRemoteRank);
     126            0 :     insGenFunc->SetRankSize(rankSize_);
     127            0 :     insGenFunc->SetDevType(devType_);
     128            0 :     insGenFunc->EnableDataAllign(enableAllign_);
     129            0 :     insGenFunc->SetAllignSize(allignSize_);
     130            0 :     insGenFunc->EnableDetour(enableDetour_);
     131            0 :     insGenFunc->SetDmaMode(dmaMode_);
     132            0 :     insGenFunc->SetRmaDataBufferMgr(rmaDataBufferMgr_);
     133              : 
     134            0 :     CollAlgParams params;
     135            0 :     params.maxTmpMemSize = scratchBufferSize_;
     136            0 :     params.opMode        = op.opMode;
     137            0 :     insGenFunc->Orchestrate(algTopoInfo, op, params, linkMgr_, queue);
     138              : 
     139            0 :     HCCL_DEBUG("finish CollAlgComponentLite Orchestrate");
     140            0 :     return HcclResult::HCCL_SUCCESS;
     141            0 : }
     142              : 
     143            0 : void CollAlgComponentLite::UpdateScratchBufferSize(u64 bufferSize)
     144              : {
     145            0 :     scratchBufferSize_ = bufferSize;
     146            0 : }
     147              : 
     148              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1