LCOV - code coverage report
Current view: top level - aicpu_schedule/core - aicpusd_threads_process.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-12 11:05:02 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              : #ifndef AICPUSD_THREADS_PROCESS_H
      11              : #define AICPUSD_THREADS_PROCESS_H
      12              : 
      13              : #include <cstdint>
      14              : #include <sys/types.h>
      15              : #include <pthread.h>
      16              : #include "aicpu_sharder.h"
      17              : #include "aicpusd_task_queue.h"
      18              : #include "aicpu_context.h"
      19              : #include "aicpusd_interface.h"
      20              : 
      21              : namespace AicpuSchedule {
      22              : /**
      23              :  * compute process class.
      24              :  */
      25              : class ComputeProcess {
      26              : public:
      27              :     /**
      28              :      * Get instance.
      29              :      * @return instance.
      30              :      */
      31              :     static ComputeProcess& GetInstance();
      32              : 
      33              :     /**
      34              :      * start compute process.
      35              :      * @param  deviceId       device id
      36              :      * @param  hostPid        host pid
      37              :      * @param  profilingMode  profiling Mode
      38              :      * @param  pidSign        pid signature
      39              :      * @param  vfId           vfId
      40              :      * @param  runMode        aicpu run mode
      41              :      * @return 0:success, other:fail
      42              :      */
      43              :     int32_t Start(
      44              :         const std::vector<uint32_t>& deviceVec, const pid_t hostPid, const std::string& pidSign,
      45              :         const uint32_t profilMode, const uint32_t vfId, const aicpu::AicpuRunMode runMode);
      46              :     /**
      47              :      * stop compute process.
      48              :      */
      49              :     void Stop();
      50              : 
      51              :     /**
      52              :      * update profiling Mode.
      53              :      */
      54              :     void UpdateProfilingMode(const ProfilingMode mode) const;
      55              : 
      56              :     /**
      57              :      * update profiling Model Mode.
      58              :      */
      59              :     void UpdateProfilingModelMode(const bool mode) const;
      60              : 
      61              :     std::string DebugString();
      62              :     bool DoSplitKernelTask(const AICPUSharderTaskInfo& taskInfo);
      63              :     bool DoRandomKernelTask();
      64              : 
      65              : private:
      66              :     ComputeProcess();
      67           22 :     ~ComputeProcess() = default;
      68              : 
      69              :     // not allow copy constructor and assignment operators
      70              :     ComputeProcess(ComputeProcess&) = delete;
      71              :     ComputeProcess& operator=(ComputeProcess&) = delete;
      72              : 
      73              :     /**
      74              :      * start tdt server.
      75              :      */
      76              :     int32_t StartTdtServer();
      77              : 
      78              :     /**
      79              :      * stop tdt server.
      80              :      */
      81              :     void StopTdtServer() const;
      82              : 
      83              :     /**
      84              :      * register sharder task
      85              :      * @return 0:success, other:fail
      86              :      */
      87              :     int32_t RegisterScheduleTask();
      88              : 
      89              :     uint32_t SubmitRandomKernelTask(const aicpu::Closure& task);
      90              :     uint32_t SubmitSplitKernelTask(const AICPUSharderTaskInfo& taskInfo, const std::queue<aicpu::Closure>& taskQueue);
      91              :     uint32_t SubmitBatchSplitKernelEventOneByOne(const AICPUSharderTaskInfo& taskInfo) const;
      92              :     uint32_t SubmitBatchSplitKernelEventDc(const AICPUSharderTaskInfo& taskInfo);
      93              :     uint32_t SubmitOneSplitKernelEvent(const AICPUSharderTaskInfo& taskInfo) const;
      94              :     bool GetAndDoSplitKernelTask();
      95              : 
      96              :     int32_t MemorySvmDevice();
      97              :     void LoadKernelSo();
      98              : 
      99              :     void LoadExtendKernelSo();
     100              : 
     101              : private:
     102              :     // the device id
     103              :     std::vector<uint32_t> deviceVec_;
     104              : 
     105              :     // host device id
     106              :     uint32_t hostDeviceId_;
     107              : 
     108              :     // the pid of host process
     109              :     pid_t hostPid_;
     110              : 
     111              :     // the pid sign of host process
     112              :     std::string pidSign_;
     113              : 
     114              :     // aicpu num of all device
     115              :     uint32_t aicpuNum_;
     116              : 
     117              :     // the Mode decide if profiling open
     118              :     ProfilingMode profilingMode_;
     119              : 
     120              :     // sharder task for split kernel
     121              :     TaskMap splitKernelTask_;
     122              : 
     123              :     // sharder task for random kernel
     124              :     TaskQueue randomKernelTask_;
     125              : 
     126              :     // vf id
     127              :     uint32_t vfId_;
     128              : 
     129              :     // it is used to mark whether the tdt server is opened.
     130              :     bool isStartTdtFlag_;
     131              : 
     132              :     // aicpu run mode
     133              :     aicpu::AicpuRunMode runMode_;
     134              : };
     135              : } // namespace AicpuSchedule
     136              : 
     137              : #endif
        

Generated by: LCOV version 2.0-1