LCOV - code coverage report
Current view: top level - aicpu_schedule/datadump - datadump_threads_process.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 94.1 % 34 32
Test Date: 2026-08-12 11:05:02 Functions: 100.0 % 4 4

            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              : #include "aicpusd_threads_process.h"
      11              : #include <cstring>
      12              : #include <unistd.h>
      13              : #include <sys/types.h>
      14              : #include "ascend_hal.h"
      15              : #include "tdt_server.h"
      16              : #include "task_queue.h"
      17              : #include "profiling_adp.h"
      18              : #include "aicpusd_util.h"
      19              : #include "aicpusd_status.h"
      20              : #include "aicpusd_common.h"
      21              : #include "aicpusd_event_manager.h"
      22              : #include "aicpusd_drv_manager.h"
      23              : #include "aicpusd_interface_process.h"
      24              : #include "aicpusd_drv_manager.h"
      25              : #include "aicpusd_worker.h"
      26              : #include "aicpu_context.h"
      27              : #include "aicpusd_monitor.h"
      28              : #include "aicpusd_msg_send.h"
      29              : #include "aicpu_async_event.h"
      30              : #include "aicpusd_hal_interface_ref.h"
      31              : #include "aicpu_prof.h"
      32              : #include "aicpu_engine.h"
      33              : namespace {
      34              : const size_t FIRST_INDEX = 0UL;
      35              : }
      36              : 
      37              : namespace AicpuSchedule {
      38            1 : ComputeProcess::ComputeProcess()
      39            2 :     : deviceVec_({}),
      40            1 :       hostDeviceId_(0U),
      41            1 :       hostPid_(-1),
      42            2 :       pidSign_(""),
      43            1 :       aicpuNum_(0U),
      44            1 :       profilingMode_(PROFILING_CLOSE),
      45            1 :       vfId_(0U),
      46            1 :       isStartTdtFlag_(false),
      47            1 :       runMode_(aicpu::AicpuRunMode::THREAD_MODE)
      48            1 : {}
      49              : 
      50            4 : ComputeProcess& ComputeProcess::GetInstance()
      51              : {
      52            4 :     static ComputeProcess instance;
      53            4 :     return instance;
      54              : }
      55              : 
      56            3 : int32_t ComputeProcess::Start(
      57              :     const std::vector<uint32_t>& deviceVec, const pid_t hostPid, const std::string& pidSign, const uint32_t profilMode,
      58              :     const uint32_t vfId, const aicpu::AicpuRunMode runMode)
      59              : {
      60            3 :     aicpusd_info(
      61              :         "Aicpu scheduler start, hostpid[%d], profilingMode[%u], runMode[%u], vfId[%u].", hostPid, profilMode, runMode,
      62              :         vfId);
      63            3 :     if (deviceVec.empty()) {
      64            0 :         aicpusd_err("device vector is empty.");
      65            0 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      66              :     }
      67            3 :     const AicpuSchedule::AicpuDrvManager& drvMgr = AicpuSchedule::AicpuDrvManager::GetInstance();
      68            3 :     deviceVec_ = deviceVec;
      69            3 :     aicpuNum_ = drvMgr.GetAicpuNum();
      70            3 :     hostPid_ = hostPid;
      71            3 :     pidSign_ = pidSign;
      72            3 :     runMode_ = runMode;
      73            3 :     vfId_ = vfId;
      74              : 
      75            3 :     aicpusd_info("ComputeProcess::Start: profilingMode[%u]", profilMode);
      76              : 
      77            3 :     auto ret = AicpuSchedule::ThreadPool::Instance().CreateWorker(SCHED_MODE_INTERRUPT);
      78            3 :     if (ret != AICPU_SCHEDULE_OK) {
      79            1 :         aicpusd_err("Drv create aicpu work tasks failed, ret[%d].", ret);
      80            1 :         return ret;
      81              :     }
      82            2 :     aicpusd_info(
      83              :         "Aicpu scheduler start successfully, deviceId[%u], hostpid[%d], profilingMode[%u], runMode[%u].",
      84              :         deviceVec_[FIRST_INDEX], hostPid, profilMode, runMode_);
      85            2 :     return AICPU_SCHEDULE_OK;
      86              : }
      87              : 
      88            1 : void ComputeProcess::Stop() {}
      89              : } // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1