LCOV - code coverage report
Current view: top level - aicpu_schedule/common - aicpusd_feature_ctrl.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 96.2 % 26 25
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 7 7

            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 COMMON_AICPUSD_FEATURE_CTRL_H
      11              : #define COMMON_AICPUSD_FEATURE_CTRL_H
      12              : 
      13              : #include <cstdint>
      14              : #include <atomic>
      15              : #include "aicpusd_info.h"
      16              : 
      17              : namespace AicpuSchedule {
      18              : // min number of vDeviceId
      19              : constexpr const uint32_t VDEVICE_MIN_CPU_NUM = 32U;
      20              : // mid number of vDeviceId
      21              : constexpr const uint32_t VDEVICE_MID_CPU_NUM = 48U;
      22              : // max number of vDeviceId
      23              : constexpr const uint32_t VDEVICE_MAX_CPU_NUM = 64U;
      24              : 
      25              : class FeatureCtrl {
      26              : public:
      27              :     static void Init(const int64_t hardwareVersion, const uint32_t deviceId);
      28              : 
      29              :     static bool IsAosCore();
      30              : 
      31              :     static bool ShouldAddtocGroup();
      32              : 
      33              :     static bool ShouldSkipSupplyEvent();
      34              : 
      35              :     static bool IsBindPidByHal();
      36              : 
      37              :     static bool IsHeterogeneousProduct();
      38              : 
      39              :     static bool IsNoNeedDumpOpDebugProduct();
      40              : 
      41              :     static bool IsDoubleDieProduct();
      42              : 
      43              :     static bool BindCpuOnlyOneDevice();
      44              : 
      45              :     static bool IfCheckEventSender();
      46              : 
      47              :     static bool IsUseMsqV2();
      48              : 
      49              :     static bool ShouldInitDrvThread(); 
      50              : 
      51              :     static bool ShouldLoadExtendKernelSo(); 
      52              : 
      53              :     static bool ShouldSubmitTaskOneByOne(); 
      54              : 
      55              :     static bool ShouldMonitorWork();
      56              : 
      57              :     static bool ShouldSetModuleNullData();
      58              : 
      59           32 :     static inline bool IsVfMode(const uint32_t deviceId, const uint32_t vfId)
      60              :     {
      61           32 :         if ((IsVfModeCheckedByDeviceId(deviceId)) || (vfId > 0)) {
      62            6 :             return true;
      63              :         } else {
      64           26 :             return false;
      65              :         }
      66              :     }
      67              : 
      68          209 :     static inline bool IsVfModeCheckedByDeviceId(const uint32_t deviceId)
      69              :     {
      70          209 :         if ((deviceId >= VDEVICE_MIN_CPU_NUM) && (deviceId < VDEVICE_MAX_CPU_NUM)) {
      71           12 :             return true;
      72              :         } else {
      73          197 :             return false;
      74              :         }
      75              :     }
      76              : 
      77           60 :     static inline bool IsVfModeDie1(const uint32_t deviceId)
      78              :     {
      79           60 :         if ((deviceId >= VDEVICE_MID_CPU_NUM) && (deviceId < VDEVICE_MAX_CPU_NUM)) {
      80            2 :             return true;
      81              :         } else {
      82           58 :             return false;
      83              :         }
      84              :     }
      85              : 
      86            2 :     static inline void SetTsMsgVersion(uint16_t version)         
      87              :     {
      88            2 :         if (isSetTsMsgVersion_) {
      89            0 :             return;
      90              :         }
      91            2 :         tsMsgVersion_ = version;
      92            2 :         isSetTsMsgVersion_ = true;
      93            2 :         return;
      94              :     }
      95              : 
      96          243 :     static inline uint16_t GetTsMsgVersion() 
      97              :     {
      98          243 :         return tsMsgVersion_;
      99              :     }
     100              : 
     101           25 :     static inline void ClearTsMsgVersionInfo() 
     102              :     {
     103           25 :         tsMsgVersion_ = 0;
     104           25 :         isSetTsMsgVersion_ = false;
     105           25 :     }
     106              : 
     107          136 :     static inline AicpuSchedMode GetAicpuSchedMode()
     108              :     {
     109          136 :         return aicpuSchedMode_;
     110              :     }
     111              : 
     112              : private:
     113              :     FeatureCtrl() = default;
     114              :     ~FeatureCtrl() = default;
     115              : 
     116              :     FeatureCtrl(FeatureCtrl const&) = delete;
     117              :     FeatureCtrl& operator=(FeatureCtrl const&) = delete;
     118              :     FeatureCtrl(FeatureCtrl&&) = delete;
     119              :     FeatureCtrl& operator=(FeatureCtrl&&) = delete;
     120              :     static void InitMsqEnableStatus(const uint32_t deviceId);
     121              :     static bool aicpuFeatureBindPidByHal_;
     122              :     static bool aicpuFeatureDoubleDieProduct_;
     123              :     static bool aicpuFeatureCheckEventSender_;
     124              :     static bool aicpuFeatureInitDrvScheModule_;
     125              :     static bool aicpuFeatureLoadExtendKernelSo_;
     126              :     static bool aicpuFeatureAddToCGroup_;
     127              :     static bool aicpuFeatureSubmitTaskOneByOne_;
     128              :     static bool aicpuFeatureMonitorWork_;
     129              :     static bool aicpuFeatureSetModelNullData_;
     130              :     static uint16_t tsMsgVersion_;
     131              :     static std::atomic<bool> isSetTsMsgVersion_;
     132              :     static bool aicpuFeatureUseMsqV2_;
     133              :     static AicpuSchedMode aicpuSchedMode_;
     134              : };
     135              : 
     136              : } // namespace AicpuSchedule
     137              : 
     138              : #endif // COMMON_AICPUSD_FEATURE_CTRL_H
        

Generated by: LCOV version 2.0-1