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-07-28 10:54:05 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              : 
      49            4 : ComputeProcess& ComputeProcess::GetInstance()
      50              : {
      51            4 :     static ComputeProcess instance;
      52            4 :     return instance;
      53              : }
      54              : 
      55            3 : int32_t ComputeProcess::Start(const std::vector<uint32_t> &deviceVec,
      56              :                               const pid_t hostPid,
      57              :                               const std::string &pidSign,
      58              :                               const uint32_t profilMode,
      59              :                               const uint32_t vfId,
      60              :                               const aicpu::AicpuRunMode runMode)
      61              : {
      62            3 :     aicpusd_info("Aicpu scheduler start, hostpid[%d], profilingMode[%u], runMode[%u], vfId[%u].",
      63              :                  hostPid, profilMode, runMode, vfId);
      64            3 :     if (deviceVec.empty()) {
      65            0 :         aicpusd_err("device vector is empty.");
      66            0 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      67              :     }
      68            3 :     const AicpuSchedule::AicpuDrvManager &drvMgr = AicpuSchedule::AicpuDrvManager::GetInstance();
      69            3 :     deviceVec_ = deviceVec;
      70            3 :     aicpuNum_ = drvMgr.GetAicpuNum();
      71            3 :     hostPid_ = hostPid;
      72            3 :     pidSign_ = pidSign;
      73            3 :     runMode_ = runMode;
      74            3 :     vfId_ = vfId;
      75              : 
      76            3 :     aicpusd_info("ComputeProcess::Start: profilingMode[%u]", profilMode);
      77              : 
      78            3 :     auto ret = AicpuSchedule::ThreadPool::Instance().CreateWorker(SCHED_MODE_INTERRUPT);
      79            3 :     if (ret != AICPU_SCHEDULE_OK) {
      80            1 :         aicpusd_err("Drv create aicpu work tasks failed, ret[%d].", ret);
      81            1 :         return ret;
      82              :     }
      83            2 :     aicpusd_info("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              : {
      90            1 : }
      91              : }
        

Generated by: LCOV version 2.0-1