LCOV - code coverage report
Current view: top level - aicpu_cust_schedule/common - feature_ctrl.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 24 24
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 6 6

            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              : 
      16              : namespace AicpuSchedule {
      17              : // min number of vDeviceId
      18              : constexpr const uint32_t VDEVICE_MIN_CPU_NUM = 32U;
      19              : // mid number of vDeviceId
      20              : constexpr const uint32_t VDEVICE_MID_CPU_NUM = 48U;
      21              : // max number of vDeviceId
      22              : constexpr const uint32_t VDEVICE_MAX_CPU_NUM = 64U;
      23              : 
      24              : class FeatureCtrl {
      25              : public:
      26              : 
      27              :     static void Init(const int64_t hardwareVersion, const uint32_t deviceId);
      28              : 
      29              :     static bool IsDoubleDieProduct();
      30              : 
      31              :     static bool IsBindPidByHal();
      32              : 
      33              :     static bool IsAosCore();
      34              : 
      35              :     static bool ShouldInitDrvThread();
      36              : 
      37              :     static bool ShouldSubmitTaskOneByOne();
      38              : 
      39           26 :     static inline bool IsVfMode(const uint32_t deviceId, const uint32_t vfId)
      40              :     {
      41           26 :         if ((IsVfModeCheckedByDeviceId(deviceId)) || (vfId > 0)) {
      42            8 :             return true;
      43              :         } else {
      44           18 :             return false;
      45              :         }
      46              :     }
      47              : 
      48           47 :     static inline bool IsVfModeCheckedByDeviceId(const uint32_t deviceId)
      49              :     {
      50           47 :         if ((deviceId >= VDEVICE_MIN_CPU_NUM) && (deviceId < VDEVICE_MAX_CPU_NUM)) {
      51            4 :             return true;
      52              :         } else {
      53           43 :             return false;
      54              :         }
      55              :     }
      56              : 
      57           14 :     static inline bool IsVfModeDie1(const uint32_t deviceId)
      58              :     {
      59           14 :         if ((deviceId >= VDEVICE_MID_CPU_NUM) && (deviceId < VDEVICE_MAX_CPU_NUM)) {
      60            2 :             return true;
      61              :         } else {
      62           12 :             return false;
      63              :         }
      64              :     }
      65              : 
      66            2 :     static inline void SetTsMsgVersion(uint16_t version)         
      67              :     {
      68            2 :         if (isSetTsMsgVersion_) {
      69            1 :             return;
      70              :         }
      71            1 :         tsMsgVersion_ = version;
      72            1 :         isSetTsMsgVersion_ = true;
      73            1 :         return;
      74              :     }
      75              : 
      76           20 :     static inline uint16_t GetTsMsgVersion() 
      77              :     {
      78           20 :         return tsMsgVersion_;
      79              :     }
      80              : 
      81           16 :     static inline void ClearTsMsgVersionInfo() 
      82              :     {
      83           16 :         tsMsgVersion_ = 0;
      84           16 :         isSetTsMsgVersion_ = false;
      85           16 :     }
      86              : 
      87              : private:
      88              :     FeatureCtrl() = default;
      89              :     ~FeatureCtrl() = default;
      90              : 
      91              :     FeatureCtrl(FeatureCtrl const&) = delete;
      92              :     FeatureCtrl& operator=(FeatureCtrl const&) = delete;
      93              :     FeatureCtrl(FeatureCtrl&&) = delete;
      94              :     FeatureCtrl& operator=(FeatureCtrl&&) = delete;
      95              : 
      96              :     static bool aicpuFeatureBindPidByHal_;
      97              :     static bool aicpuFeatureDoubleDieProduct_;
      98              :     static bool aicpuFeatureInitDrvScheModule_;
      99              :     static bool aicpuFeatureSubmitTaskOneByOne_;
     100              :     static uint16_t tsMsgVersion_;
     101              :     static std::atomic<bool> isSetTsMsgVersion_;
     102              : };
     103              : 
     104              : } // namespace AicpuSchedule
     105              : 
     106              : #endif // COMMON_AICPUSD_FEATURE_CTRL_H
        

Generated by: LCOV version 2.0-1