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 : #include "feature_ctrl.h"
11 :
12 : #include <cstring>
13 : #include "aicpusd_hal_interface_ref.h"
14 : #include "aicpusd_status.h"
15 : #include "aicpusd_common.h"
16 : #define AICPU_PLAT_GET_CHIP(type) (((type) >> 8U) & 0xffU)
17 : namespace AicpuSchedule {
18 : constexpr uint32_t SOC_VERSION_LEN = 50U;
19 :
20 : typedef enum tagChipType {
21 : CHIP_ASCEND_910A = 1,
22 : CHIP_ASCEND_910B = 5,
23 : CHIP_ASCEND_950 = 15,
24 : CHIP_ASCEND_350 = 19,
25 : } ChipType_t;
26 :
27 15 : void FeatureCtrl::Init(const int64_t hardwareVersion, const uint32_t deviceId)
28 : {
29 15 : const ChipType_t chipType = static_cast<ChipType_t>(AICPU_PLAT_GET_CHIP(static_cast<uint64_t>(hardwareVersion)));
30 :
31 15 : if ((chipType == CHIP_ASCEND_910A) || (chipType == CHIP_ASCEND_910B) || (chipType == CHIP_ASCEND_950) ||
32 : (chipType == CHIP_ASCEND_350)) {
33 3 : aicpuFeatureBindPidByHal_ = true;
34 : }
35 :
36 15 : if ((chipType == CHIP_ASCEND_910B) && (&halGetSocVersion != nullptr)) {
37 3 : char_t socVersion[SOC_VERSION_LEN] = {};
38 3 : const auto drvRet = halGetSocVersion(deviceId, &socVersion[0U], SOC_VERSION_LEN);
39 3 : aicpusd_info("socVersion is %s", &socVersion[0U]);
40 3 : if ((drvRet == DRV_ERROR_NONE) &&
41 3 : (strncmp(&socVersion[0U], "Ascend910_93", strnlen("Ascend910_93", SOC_VERSION_LEN)) == 0)) {
42 2 : aicpuFeatureDoubleDieProduct_ = true;
43 2 : aicpusd_info("set isDoubleDieProduct_");
44 : }
45 : }
46 15 : }
47 :
48 12 : bool FeatureCtrl::IsDoubleDieProduct()
49 : {
50 12 : return aicpuFeatureDoubleDieProduct_;
51 : }
52 :
53 8 : bool FeatureCtrl::IsBindPidByHal()
54 : {
55 8 : return aicpuFeatureBindPidByHal_;
56 : }
57 :
58 36 : bool FeatureCtrl::IsAosCore()
59 : {
60 36 : return false;
61 : }
62 :
63 21 : bool FeatureCtrl::ShouldInitDrvThread()
64 : {
65 21 : return aicpuFeatureInitDrvScheModule_;
66 : }
67 :
68 1 : bool FeatureCtrl::ShouldSubmitTaskOneByOne()
69 : {
70 1 : return aicpuFeatureSubmitTaskOneByOne_;
71 : }
72 : } // namespace AicpuSchedule
73 :
|