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

Generated by: LCOV version 2.0-1