LCOV - code coverage report
Current view: top level - legacy/ascend910/common/debug/profiling - task_overflow.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 21.1 % 57 12
Test Date: 2026-08-17 10:19:35 Functions: 44.4 % 18 8

            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              : #include "task_overflow.h"
      12              : #include "externalinput_pub.h"
      13              : 
      14              : namespace hccl {
      15              : 
      16              : constexpr u32 DUMPTASK_COUNT_UPPER_LIMIT = 1000; // 算子溢出的task最大值为1000,防止内存占用量过大
      17              : constexpr u32 SUBTASK_DEFAULT_VALUE = 10;        // subTaskType默认参数
      18              : constexpr u32 REDUCE_INLINE = 0;
      19              : constexpr u32 REDUCE_TBE = 1;
      20              : 
      21          312 : TaskOverflow::TaskOverflow(u32 deviceLogicId) : ProfilerBase(deviceLogicId) {}
      22          624 : TaskOverflow::~TaskOverflow() {}
      23              : 
      24            0 : uint32_t TaskOverflow::GetTaskName(TaskType taskType) const
      25              : {
      26            0 :     uint32_t taskNameId = SUBTASK_DEFAULT_VALUE;
      27            0 :     switch (taskType) {
      28            0 :         case TaskType::TASK_SDMA:
      29              :         case TaskType::TASK_RDMA:
      30              :         case TaskType::TASK_NOTIFY_RECORD:
      31              :         case TaskType::TASK_NOTIFY_WAIT:
      32            0 :             break;
      33            0 :         case TaskType::TASK_REDUCE_INLINE:
      34            0 :             taskNameId = REDUCE_INLINE;
      35            0 :             break;
      36            0 :         case TaskType::TASK_REDUCE_TBE:
      37            0 :             taskNameId = REDUCE_TBE;
      38            0 :             break;
      39            0 :         default:
      40            0 :             break;
      41              :     }
      42            0 :     return taskNameId;
      43              : }
      44              : 
      45              : HcclResult
      46            9 : TaskOverflow::Save(u32 captureStreamID, u32 streamID, u32 taskID, TaskType& taskType, const TaskParaReduce& paraReduce)
      47              : {
      48            9 :     if (GetExternalInputHcclDumpDebug()) {
      49            0 :         HCCL_DEBUG("HcclDumpInfo save start");
      50            0 :         HcclDumpInfo hcclDumpInfo{};
      51            0 :         hcclDumpInfo.task_id = taskID;
      52            0 :         hcclDumpInfo.stream_id = streamID;
      53            0 :         hcclDumpInfo.output_addr = const_cast<void*>(paraReduce.dst);
      54            0 :         hcclDumpInfo.output_size = static_cast<u64>(paraReduce.size);
      55            0 :         hcclDumpInfo.input_addr = const_cast<void*>(paraReduce.src);
      56            0 :         hcclDumpInfo.input_size = static_cast<u64>(paraReduce.size);
      57            0 :         hcclDumpInfo.sub_task_type = GetTaskName(taskType);
      58              : 
      59            0 :         std::unique_lock<std::mutex> lock(dumpInfoVetcorMutex_);
      60              :         // 防止上层未及时清理dumpInfoVetcor_信息,导致内存占满。
      61            0 :         if (dumpInfoVetcor_.size() < DUMPTASK_COUNT_UPPER_LIMIT) {
      62            0 :             dumpInfoVetcor_.push_back(hcclDumpInfo);
      63            0 :             return HCCL_SUCCESS;
      64              :         }
      65            0 :     }
      66            9 :     return HCCL_SUCCESS;
      67              : }
      68              : 
      69            9 : HcclResult TaskOverflow::Save(u32& streamID, u32& taskID, TaskType& taskType, const TaskParaReduce& paraReduce)
      70              : {
      71            9 :     return Save(streamID, streamID, taskID, taskType, paraReduce);
      72              : }
      73              : 
      74              : HcclResult
      75            0 : TaskOverflow::Save(u32 captureStreamID, u32 streamID, u32 taskID, TaskType& taskType, const TaskParaDMA& paraDMA)
      76              : {
      77            0 :     return HCCL_SUCCESS;
      78              : }
      79              : 
      80           32 : HcclResult TaskOverflow::Save(u32& streamID, u32& taskID, TaskType& taskType, const TaskParaDMA& paraDMA)
      81              : {
      82           32 :     return HCCL_SUCCESS;
      83              : }
      84              : 
      85              : HcclResult
      86            0 : TaskOverflow::Save(u32 captureStreamID, u32 streamID, u32 taskID, TaskType& taskType, const TaskParaNotify& paraNotify)
      87              : {
      88            0 :     return HCCL_SUCCESS;
      89              : }
      90              : 
      91            0 : HcclResult TaskOverflow::Save(u32& streamID, u32& taskID, TaskType& taskType, const TaskParaNotify& paraNotify)
      92              : {
      93            0 :     return HCCL_SUCCESS;
      94              : }
      95              : 
      96            0 : HcclResult TaskOverflow::Save(u32 captureStreamID, u32 streamID, u32 taskID, const void* descBuf, size_t descBufLen)
      97              : {
      98            0 :     return HCCL_SUCCESS;
      99              : }
     100              : 
     101            3 : HcclResult TaskOverflow::Save(u32 captureStreamID, u32 streamID, u32 taskID, const TaskParaAiv& paraAiv)
     102              : {
     103            3 :     return HCCL_SUCCESS;
     104              : }
     105              : 
     106            2 : HcclResult TaskOverflow::Save(u32 streamID, u32 taskID, const TaskParaAiv& paraAiv) { return HCCL_SUCCESS; }
     107              : 
     108            0 : HcclResult TaskOverflow::Save(u32& streamID, u32& taskID, const void* descBuf, size_t descBufLen)
     109              : {
     110            0 :     return HCCL_SUCCESS;
     111              : }
     112              : 
     113            0 : HcclResult TaskOverflow::GetandClearOverFlowTasks(std::vector<HcclDumpInfo>& hcclDumpInfoVector)
     114              : {
     115            0 :     hcclDumpInfoVector.assign(dumpInfoVetcor_.begin(), dumpInfoVetcor_.end());
     116            0 :     dumpInfoVetcor_.clear();
     117              : 
     118            0 :     return HCCL_SUCCESS;
     119              : }
     120              : 
     121            0 : HcclResult TaskOverflow::Flush() { return HCCL_SUCCESS; }
     122              : 
     123            0 : HcclResult TaskOverflow::Run(const StepData& stepData) { return HCCL_SUCCESS; }
     124              : 
     125            0 : HcclResult TaskOverflow::SaveToLog(const TaskParaHost& paraHost) { return HCCL_SUCCESS; }
     126              : } // namespace hccl
        

Generated by: LCOV version 2.0-1