LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/device_mode - aicpu_ins_preprocessor.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-17 10:19:35 Functions: 100.0 % 1 1

            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              : #ifndef AICPU_INS_PREPROCESSOR_H
      11              : #define AICPU_INS_PREPROCESSOR_H
      12              : 
      13              : #include <unordered_map>
      14              : #include <memory>
      15              : #include "aicpu_ins.h"
      16              : #include "ins_queue.h"
      17              : #include "dev_buffer.h"
      18              : #include "communicator_impl.h"
      19              : #include "virtual_topo.h"
      20              : #include "connections_builder.h"
      21              : 
      22              : namespace Hccl {
      23              : 
      24              : class AicpuInsPreprocessor {
      25              : public:
      26              :     using InsIterator = HierarchicalQueue<Instruction, InsQueue>::Iterator;
      27              : 
      28          244 :     explicit AicpuInsPreprocessor(CommunicatorImpl* comm) : comm(comm) {}
      29              : 
      30              :     void Preprocess(std::shared_ptr<InsQueue>& insQueue);
      31              : 
      32              :     // AlltoallV算子使用
      33              :     void SetAicpuKernelLaunchParam(HcclKernelLaunchParam& param);
      34              :     bool IsAicpuResExisted(const std::string& algName);
      35              :     void SetAicpuResExisted(const std::string& algName);
      36              :     DevBuffer* GetAicpuResBuffer(const std::string& algName);
      37              : 
      38              : private:
      39              :     CommunicatorImpl* comm;
      40              :     std::unordered_map<std::string, std::shared_ptr<DevBuffer>> aicpuResMap; // 集合通信算子资源加载到device侧的内存
      41              :     std::unordered_map<std::string, bool> aicpuResExistedMap;
      42              : 
      43              :     std::set<LinkData> availableLinks;
      44              :     unordered_map<std::string, unique_ptr<ConnectionsBuilder>> connectionsBuilders;
      45              : 
      46              :     // AlltoallV算子使用
      47              :     std::vector<std::shared_ptr<DevBuffer>> sendCountsMem{};
      48              :     std::vector<std::shared_ptr<DevBuffer>> recvCountsMem{};
      49              :     std::vector<std::shared_ptr<DevBuffer>> sdisplsMem{};
      50              :     std::vector<std::shared_ptr<DevBuffer>> rdisplsMem{};
      51              :     bool isCountMemInited{false};
      52              :     u32 resIndex{0};
      53              :     u32 launchResIndex{0};
      54              : 
      55              :     void InsPreprocess(InsIterator& insIter);
      56              : 
      57              :     void AllocQueueNotify(std::vector<std::tuple<QId, QId, u32>>& queueNotifyReq) const;
      58              :     void AllocBcastPostCntNotify(std::vector<std::pair<QId, u32>>& bcastPostCntNotifyReq) const;
      59              :     void AllocWaitGroupCntNotify(std::vector<std::pair<QId, u32>>& waitGroupCntNotifyReq) const;
      60              :     void AllocWorkStream(u32 primQueueNum) const;
      61              :     void AllocInterRankNotifies(const vector<LinkData>& links);
      62              :     void BatchBuildTransports(const vector<LinkData>& links);
      63              : 
      64              :     void PackResAndCopyToDev(const std::string& algName, const CollAlgResReq& collAlgResReq);
      65              : 
      66              :     // AlltoallV算子使用
      67              :     void AllocAlltoallVOpMem();
      68              : 
      69              :     std::vector<char> PackOpData(const std::string& opTag, const std::string& algName, const CollAlgResReq& resReq);
      70              : };
      71              : 
      72              : } // namespace Hccl
      73              : 
      74              : #endif // AICPU_INS_PREPROCESSOR_H
        

Generated by: LCOV version 2.0-1