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

Generated by: LCOV version 2.0-1