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.3 % 61 13
Test Date: 2026-08-04 10:52:23 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          309 : TaskOverflow::TaskOverflow(u32 deviceLogicId) : ProfilerBase(deviceLogicId) {}
      22          618 : 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            9 : HcclResult TaskOverflow::Save(u32 captureStreamID, u32 streamID, u32 taskID, TaskType &taskType, const TaskParaReduce &paraReduce)
      46              : {
      47            9 :     if (GetExternalInputHcclDumpDebug()) {
      48            0 :         HCCL_DEBUG("HcclDumpInfo save start");
      49            0 :         HcclDumpInfo hcclDumpInfo {};
      50            0 :         hcclDumpInfo.task_id = taskID;
      51            0 :         hcclDumpInfo.stream_id = streamID;
      52            0 :         hcclDumpInfo.output_addr = const_cast<void *>(paraReduce.dst);
      53            0 :         hcclDumpInfo.output_size = static_cast<u64>(paraReduce.size);
      54            0 :         hcclDumpInfo.input_addr = const_cast<void *>(paraReduce.src);
      55            0 :         hcclDumpInfo.input_size = static_cast<u64>(paraReduce.size);
      56            0 :         hcclDumpInfo.sub_task_type = GetTaskName(taskType);
      57              : 
      58            0 :         std::unique_lock<std::mutex> lock(dumpInfoVetcorMutex_);
      59              :         // 防止上层未及时清理dumpInfoVetcor_信息,导致内存占满。
      60            0 :         if (dumpInfoVetcor_.size() < DUMPTASK_COUNT_UPPER_LIMIT) {
      61            0 :             dumpInfoVetcor_.push_back(hcclDumpInfo);
      62            0 :             return HCCL_SUCCESS;
      63              :         }
      64            0 :     }
      65            9 :     return HCCL_SUCCESS;
      66              : }
      67              : 
      68            9 : HcclResult TaskOverflow::Save(u32 &streamID, u32 &taskID, TaskType &taskType, const TaskParaReduce &paraReduce)
      69              : {
      70            9 :     return Save(streamID, streamID, taskID, taskType, paraReduce);
      71              : }
      72              : 
      73            0 : HcclResult TaskOverflow::Save(u32 captureStreamID, u32 streamID, u32 taskID, TaskType &taskType, const TaskParaDMA &paraDMA)
      74              : {
      75            0 :     return HCCL_SUCCESS;
      76              : }
      77              : 
      78           32 : HcclResult TaskOverflow::Save(u32 &streamID, u32 &taskID, TaskType &taskType, const TaskParaDMA &paraDMA)
      79              : {
      80           32 :     return HCCL_SUCCESS;
      81              : }
      82              : 
      83            0 : HcclResult TaskOverflow::Save(u32 captureStreamID, u32 streamID, u32 taskID, TaskType &taskType, const TaskParaNotify &paraNotify)
      84              : {
      85            0 :     return HCCL_SUCCESS;
      86              : }
      87              : 
      88            0 : HcclResult TaskOverflow::Save(u32 &streamID, u32 &taskID, TaskType &taskType, const TaskParaNotify &paraNotify)
      89              : {
      90            0 :     return HCCL_SUCCESS;
      91              : }
      92              : 
      93            0 : HcclResult TaskOverflow::Save(u32 captureStreamID, u32 streamID, u32 taskID, const void *descBuf, size_t descBufLen)
      94              : {
      95            0 :     return HCCL_SUCCESS;
      96              : }
      97              : 
      98            3 : HcclResult TaskOverflow::Save(u32 captureStreamID, u32 streamID, u32 taskID, const TaskParaAiv &paraAiv)
      99              : {
     100            3 :     return HCCL_SUCCESS;
     101              : }
     102              : 
     103            2 : HcclResult TaskOverflow::Save(u32 streamID, u32 taskID, const TaskParaAiv &paraAiv)
     104              : {
     105            2 :     return HCCL_SUCCESS;
     106              : }
     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()
     122              : {
     123            0 :     return HCCL_SUCCESS;
     124              : }
     125              : 
     126            0 : HcclResult TaskOverflow::Run(const StepData &stepData)
     127              : {
     128            0 :     return HCCL_SUCCESS;
     129              : }
     130              : 
     131            0 : HcclResult TaskOverflow::SaveToLog(const TaskParaHost &paraHost)
     132              : {
     133            0 :     return HCCL_SUCCESS;
     134              : }
     135              : } // namespace hccl
        

Generated by: LCOV version 2.0-1