LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/dfx/common - mirror_task_manager.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-04 10:52:23 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 MIRROR_TASK_MANAGER_H
      11              : #define MIRROR_TASK_MANAGER_H
      12              : 
      13              : #include <unordered_map>
      14              : #include <memory>
      15              : #include <functional>
      16              : #include "circular_queue.h"
      17              : #include "task_info.h"
      18              : #include "global_mirror_tasks.h"
      19              : #include <mutex>
      20              : 
      21              : namespace Hccl {
      22              : 
      23              : using TaskInfoQueue = Queue<std::unique_ptr<TaskInfo>>;
      24              : 
      25              : struct MirrorStreamQueueEntry {
      26              :     TaskInfoQueue *queue = nullptr;
      27              :     QueueType queueType = QueueType::Vector_Queue;
      28              :     u32 taskNum = 0;
      29              : };
      30              : 
      31              : class MirrorTaskManager {
      32              : public:
      33              :     MirrorTaskManager(u32 devId, GlobalMirrorTasks *globalMirrorTasks, bool devUsed);
      34              : 
      35              :     void RegFullyCallBack(std::function<void()> callBack);
      36              :     void AddTaskInfo(std::unique_ptr<TaskInfo> &&taskInfo);
      37              :     HcclResult AddTaskInfo(u32 streamId, u32 taskId, u32 remoteRankId,
      38              :                            const TaskParam &taskParam, std::shared_ptr<DfxOpInfo> dfxOpInfo, bool isMaster);
      39              :     void SetCurrDfxOpInfo(std::shared_ptr<DfxOpInfo> dfxOpInfo);
      40              : 
      41              :     std::shared_ptr<DfxOpInfo> GetCurrDfxOpInfo() const;
      42              :     TaskInfoQueue             *GetQueue(u32 streamId) const;
      43              : 
      44              : public:
      45              :     std::unordered_map<u32, MirrorStreamQueueEntry>::iterator Begin();
      46              :     std::unordered_map<u32, MirrorStreamQueueEntry>::iterator End();
      47            7 :     std::mutex &GetTaskMutex() { return profMutex; }
      48              :     ~MirrorTaskManager();
      49              : 
      50              : private:
      51              :     u32                            devId_;
      52              :     GlobalMirrorTasks             *globalMirrorTasks_{nullptr};
      53              :     bool                           devUsed_{false};
      54              :     bool                           isStaticGraphMode_{false};
      55              :     OpMode                         opMode_{OpMode::OPBASE};
      56              :     std::unordered_map<u32, MirrorStreamQueueEntry> streamQueues_{};
      57              :     std::shared_ptr<DfxOpInfo>     currDfxOpInfo_{nullptr};
      58              :     std::function<void()>          fullyCallBack_{};
      59              :     std::mutex                      profMutex;
      60              : private:
      61              :     bool      IsStaticGraphMode(const CollOperator &collOperator) const;
      62              :     QueueType GetQueueType() const;
      63              : };
      64              : 
      65              : } // namespace Hccl
      66              : 
      67              : #endif // MIRROR_TASK_MANAGER_H
        

Generated by: LCOV version 2.0-1