LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/pub_inc - alg_profiling.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 13 13
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 6 6

            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              : #pragma once 
      12              : #include <string>
      13              : #include <map>
      14              : #include <array>
      15              : #include "hccl_types.h"
      16              : #include "hccl_common.h"
      17              : #include "common.h"
      18              : 
      19              : namespace hccl{
      20              : 
      21              : using TaskCallBack = void (*)(void *userPtr, void *param, u32 length);
      22              : 
      23              : struct TaskParaAiv{
      24              :     HcclCMDType cmdType;
      25              :     u32 tag;
      26              :     u64 size;
      27              :     u32 numBlocks;
      28              :     u32 rankSize;
      29              :     s32 aivRdmaStep;
      30              :     void* flagMem;
      31              :     u32 rank;
      32              :     bool isOpbase;
      33           49 :     TaskParaAiv()
      34           49 :         : cmdType(HcclCMDType::HCCL_CMD_INVALID), tag(0), size(0), numBlocks(0), rankSize(0), aivRdmaStep(0), flagMem(nullptr),
      35           49 :           rank(0), isOpbase(false)
      36           49 :     {}
      37            5 :     TaskParaAiv(
      38              :         HcclCMDType cmdType, u32 tag, u64 size, u32 numBlocks, u32 rankSize, s32 aivRdmaStep, void *flagMem, u32 rank, bool isOpbase = false)
      39            5 :         : cmdType(cmdType), tag(tag), size(size), numBlocks(numBlocks), rankSize(rankSize), aivRdmaStep(aivRdmaStep),
      40            5 :           flagMem(flagMem), rank(rank), isOpbase(isOpbase)
      41            5 :     {}
      42              : };
      43              : 
      44              : struct TaskParaGeneral{
      45              :     void* stream{nullptr};
      46              :     bool isMainStream{false};
      47              :     u64 beginTime{0};
      48              :     struct TaskParaAiv aiv;
      49              : 
      50            5 :     TaskParaGeneral() : stream(nullptr), isMainStream(false), beginTime(0)
      51            5 :     {}
      52              : 
      53            5 :     ~TaskParaGeneral() {}
      54              : };
      55              : 
      56              : class AlgWrap{
      57              : public:
      58              :     static AlgWrap& GetInstance();
      59              :     HcclResult RegisterAlgCallBack(const std::string& comm, void* userPtr, TaskCallBack callback, s32 deviceLogicID);
      60              :     void UnregisterAlgCallBack(const std::string& comm);
      61              :     HcclResult TaskAivProfiler(const std::string& comm, struct TaskParaGeneral& taskParaGeneral);
      62              : 
      63              : private:
      64           12 :     AlgWrap(){ initialized_ = true; };
      65           12 :     ~AlgWrap(){ initialized_ = false; };
      66              :     
      67              :     // initialized 是否已初始化,避免析构后访问类成员
      68              :     bool initialized_ = false;
      69              :     std::mutex aivCallBackMutex_;
      70              :     std::map<std::string, std::array<TaskCallBack, MAX_MODULE_DEVICE_NUM>> aivCallBackMap_;
      71              :     std::map<std::string, std::array<void*, MAX_MODULE_DEVICE_NUM>> aivCallBackUserPtrMap_;
      72              : };
      73              : 
      74              : }
        

Generated by: LCOV version 2.0-1