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 % 26 26
Test Date: 2026-08-18 17:47:01 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),
      35           49 :           tag(0),
      36           49 :           size(0),
      37           49 :           numBlocks(0),
      38           49 :           rankSize(0),
      39           49 :           aivRdmaStep(0),
      40           49 :           flagMem(nullptr),
      41           49 :           rank(0),
      42           49 :           isOpbase(false)
      43           49 :     {}
      44            5 :     TaskParaAiv(
      45              :         HcclCMDType cmdType, u32 tag, u64 size, u32 numBlocks, u32 rankSize, s32 aivRdmaStep, void* flagMem, u32 rank,
      46              :         bool isOpbase = false)
      47            5 :         : cmdType(cmdType),
      48            5 :           tag(tag),
      49            5 :           size(size),
      50            5 :           numBlocks(numBlocks),
      51            5 :           rankSize(rankSize),
      52            5 :           aivRdmaStep(aivRdmaStep),
      53            5 :           flagMem(flagMem),
      54            5 :           rank(rank),
      55            5 :           isOpbase(isOpbase)
      56            5 :     {}
      57              : };
      58              : 
      59              : struct TaskParaGeneral {
      60              :     void* stream{nullptr};
      61              :     bool isMainStream{false};
      62              :     u64 beginTime{0};
      63              :     struct TaskParaAiv aiv;
      64              : 
      65            5 :     TaskParaGeneral() : stream(nullptr), isMainStream(false), beginTime(0) {}
      66              : 
      67            5 :     ~TaskParaGeneral() {}
      68              : };
      69              : 
      70              : class AlgWrap {
      71              : public:
      72              :     static AlgWrap& GetInstance();
      73              :     HcclResult RegisterAlgCallBack(const std::string& comm, void* userPtr, TaskCallBack callback, s32 deviceLogicID);
      74              :     void UnregisterAlgCallBack(const std::string& comm);
      75              :     HcclResult TaskAivProfiler(const std::string& comm, struct TaskParaGeneral& taskParaGeneral);
      76              : 
      77              : private:
      78           12 :     AlgWrap() { initialized_ = true; };
      79           12 :     ~AlgWrap() { initialized_ = false; };
      80              : 
      81              :     // initialized 是否已初始化,避免析构后访问类成员
      82              :     bool initialized_ = false;
      83              :     std::mutex aivCallBackMutex_;
      84              :     std::map<std::string, std::array<TaskCallBack, MAX_MODULE_DEVICE_NUM>> aivCallBackMap_;
      85              :     std::map<std::string, std::array<void*, MAX_MODULE_DEVICE_NUM>> aivCallBackUserPtrMap_;
      86              : };
      87              : 
      88              : } // namespace hccl
        

Generated by: LCOV version 2.0-1