LCOV - code coverage report
Current view: top level - aicpu_cust_schedule/core - aicpusd_threads_process.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-07-28 10:54:05 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 CUST_AICPUSD_THREADS_PROCESS_H
      12              : #define CUST_AICPUSD_THREADS_PROCESS_H
      13              : 
      14              : 
      15              : #include <string>
      16              : #include <cstdint>
      17              : #include <sys/types.h>
      18              : #include "aicpusd_task_queue.h"
      19              : #include "aicpu_context.h"
      20              : 
      21              : namespace AicpuSchedule {
      22              : /**
      23              :  * compute process result code.
      24              :  */
      25              : enum class ComputProcessRetCode {
      26              :     CP_RET_SUCCESS = 0,     // success
      27              :     CP_RET_COMMON_ERROR,    // common error
      28              : };
      29              : 
      30              : /**
      31              :  * compute process class.
      32              :  */
      33              : class ComputeProcess {
      34              : public:
      35              : 
      36              :     /**
      37              :      * Get instance.
      38              :      * @return instance.
      39              :      */
      40              :     static ComputeProcess &GetInstance();
      41              : 
      42              :     /**
      43              :      * start compute process.
      44              :      * @param  deviceId device id
      45              :      * @param  hostPid  host pid
      46              :      * @param  pidSign pid signature
      47              :      * @param  profilingMode profiling Mode
      48              :      * @param  aicpuPid aicpu-sd pid
      49              :      * @param  vfId vf id
      50              :      * @param  runMode pcie socket or thread run mode
      51              :      * @return 0:success, other:fail
      52              :      */
      53              :     int32_t Start(const uint32_t deviceId,
      54              :                   const pid_t hostPid,
      55              :                   const uint32_t profilingMode,
      56              :                   const pid_t aicpuPid,
      57              :                   const uint32_t vfId,
      58              :                   const aicpu::AicpuRunMode runMode);
      59              : 
      60              :     void UpdateProfilingSetting(uint32_t flag);
      61              : 
      62              :     bool DoSplitKernelTask(const AICPUSharderTaskInfo &taskInfo);
      63              :     bool DoRandomKernelTask();
      64              : 
      65              :     /**
      66              :      * stop compute process.
      67              :      */
      68              :     void Stop();
      69              : private:
      70              :     ComputeProcess();
      71           18 :     ~ComputeProcess() = default;
      72              : 
      73              :     // not allow copy constructor and assignment operators
      74              :     ComputeProcess(const ComputeProcess &) = delete;
      75              :     ComputeProcess &operator=(const ComputeProcess &) = delete;
      76              : 
      77              :     uint32_t RegisterScheduleTask();
      78              :     uint32_t SubmitRandomKernelTask(const aicpu::Closure &task);
      79              :     uint32_t SubmitSplitKernelTask(const AICPUSharderTaskInfo &taskInfo,
      80              :                                    const std::queue<aicpu::Closure> &taskQueue);
      81              :     uint32_t SubmitBatchSplitKernelEventOneByOne(const AICPUSharderTaskInfo &taskInfo) const;
      82              :     uint32_t SubmitBatchSplitKernelEventDc(const AICPUSharderTaskInfo &taskInfo);
      83              :     uint32_t SubmitOneSplitKernelEvent(const AICPUSharderTaskInfo &taskInfo) const;
      84              :     bool GetAndDoSplitKernelTask();
      85              : 
      86              :     // the device id
      87              :     uint32_t deviceId_;
      88              : 
      89              :     // the pid of host process
      90              :     pid_t hostPid_;
      91              : 
      92              :     // number of aicpu
      93              :     uint32_t aicpuNum_;
      94              : 
      95              :     // the Mode decide if profiling open
      96              :     ProfilingMode profilingMode_;
      97              : 
      98              :     // the pid of aicpu-sd process
      99              :     pid_t aicpuPid_;
     100              : 
     101              :     // vf id
     102              :     uint32_t vfId_;
     103              : 
     104              :     // sharder task for split kernel
     105              :     TaskMap splitKernelTask_;
     106              :  
     107              :     // sharder task for random kernel
     108              :     TaskQueue randomKernelTask_;
     109              : 
     110              :     // cust aicpusd run mode : thread pice socket
     111              :     aicpu::AicpuRunMode runMode_;
     112              : };
     113              : }
     114              : #endif
        

Generated by: LCOV version 2.0-1