已合并
修改GetArchVersion接口 #4888
Chen Ning创建于 8月5日
修改GetArchVersion接口 #4888
已合并
共 22 个文件变更+161-81
Mdocs/zh/api/SIMD-API/basic_api/tool_interface/system_resources_and_variables/GetArchVersion.md+30-9
| @@ -11,18 +11,19 @@ | |||
| 11 | <!-- npu="910b" id3 --> | 11 | <!-- npu="910b" id3 --> |
| 12 | - Atlas A2 训练系列产品/Atlas A2 推理系列产品:支持 | 12 | - Atlas A2 训练系列产品/Atlas A2 推理系列产品:支持 |
| 13 | <!-- end id3 --> | 13 | <!-- end id3 --> |
| 14 | -<!-- npu="310b" id4 --> | 14 | +<!-- npu="310b" id7 --> |
| 15 | -- Atlas 200I/500 A2 推理产品:不支持 | 15 | +- Atlas 200I/500 A2 推理产品:支持 |
| 16 | -<!-- end id4 --> | 16 | +<!-- end id7 --> |
| 17 | <!-- npu="310p" id5 --> | 17 | <!-- npu="310p" id5 --> |
| 18 | - Atlas 推理系列产品AI Core:支持 | 18 | - Atlas 推理系列产品AI Core:支持 |
| 19 | <!-- end id5 --> | 19 | <!-- end id5 --> |
| 20 | <!-- npu="310p" id6 --> | 20 | <!-- npu="310p" id6 --> |
| 21 | - Atlas 推理系列产品Vector Core:不支持 | 21 | - Atlas 推理系列产品Vector Core:不支持 |
| 22 | <!-- end id6 --> | 22 | <!-- end id6 --> |
| 23 | -<!-- npu="910" id7 --> | 23 | +<!-- npu="910" id4 --> |
| 24 | -- Atlas 训练系列产品:不支持 | 24 | +- Atlas 训练系列产品:支持 |
| 25 | -<!-- end id7 --> | 25 | +<!-- end id4 --> |
| 26 | + | ||
| 26 | 27 | ||
| 27 | ## 功能说明 | 28 | ## 功能说明 |
| 28 | 29 | ||
| @@ -40,7 +41,7 @@ __aicore__ inline void GetArchVersion(uint32_t& coreVersion) | |||
| 40 | 41 | ||
| 41 | | 参数名 | 输入/输出 | 描述 | | 42 | | 参数名 | 输入/输出 | 描述 | |
| 42 | | --- | --- | --- | | 43 | | --- | --- | --- | |
| 43 | -| coreVersion | 输出 | AI处理器架构版本 | | 44 | +| coreVersion | 输出 | AI处理器架构版本。 | |
| 44 | 45 | ||
| 45 | ## 返回值说明 | 46 | ## 返回值说明 |
| 46 | 47 | ||
| @@ -48,7 +49,7 @@ __aicore__ inline void GetArchVersion(uint32_t& coreVersion) | |||
| 48 | 49 | ||
| 49 | ## 约束说明 | 50 | ## 约束说明 |
| 50 | 51 | ||
| 51 | -架构版本号为十六进制编码,建议使用十六进制格式(如`%x`)输出查看,或者自行转换成十六进制数。 | 52 | +无 |
| 52 | 53 | ||
| 53 | ## 调用示例 | 54 | ## 调用示例 |
| 54 | 55 | ||
| @@ -57,5 +58,25 @@ __aicore__ inline void GetArchVersion(uint32_t& coreVersion) | |||
| 57 | ```cpp | 58 | ```cpp |
| 58 | uint32_t coreVersion = 0; | 59 | uint32_t coreVersion = 0; |
| 59 | AscendC::GetArchVersion(coreVersion); | 60 | AscendC::GetArchVersion(coreVersion); |
| 60 | -AscendC::printf("core version is %x", coreVersion); //需用%x将其打印成十六进制数 | 61 | +AscendC::printf("core version is %u", coreVersion); |
| 61 | ``` | 62 | ``` |
| 63 | + | ||
| 64 | +不同型号服务器有不同的架构版本号取值,如下所示: | ||
| 65 | +<!-- npu="950" id8 --> | ||
| 66 | +- Ascend 950PR/Ascend 950DT:3510 | ||
| 67 | +<!-- end id8 --> | ||
| 68 | +<!-- npu="A3" id9 --> | ||
| 69 | +- Atlas A3 训练系列产品/Atlas A3 推理系列产品:2201 | ||
| 70 | +<!-- end id9 --> | ||
| 71 | +<!-- npu="910b" id10 --> | ||
| 72 | +- Atlas A2 训练系列产品/Atlas A2 推理系列产品:2201 | ||
| 73 | +<!-- end id10 --> | ||
| 74 | +<!-- npu="310b" id13 --> | ||
| 75 | +- Atlas 200I/500 A2 推理产品:3002 | ||
| 76 | +<!-- end id13 --> | ||
| 77 | +<!-- npu="310p" id12 --> | ||
| 78 | +- Atlas 推理系列产品AI Core:2002 | ||
| 79 | +<!-- end id12 --> | ||
| 80 | +<!-- npu="910" id11 --> | ||
| 81 | +- Atlas 训练系列产品:1001 | ||
| 82 | +<!-- end id11 --> | ||
| @@ -53,12 +53,11 @@ PIPE_S | |||
| 53 | ## 约束说明 | 53 | ## 约束说明 |
| 54 | 54 | ||
| 55 | 在调用asc_get_arch_ver接口前,需先定义core_version,调用asc_get_arch_ver接口后core_version会变成相对应架构版本号的值。 | 55 | 在调用asc_get_arch_ver接口前,需先定义core_version,调用asc_get_arch_ver接口后core_version会变成相对应架构版本号的值。 |
| 56 | -由于硬件约束,在查看转换后的AI处理器架构版本号时需要将其打印成十六进制的数或者自行转换成十六进制的数。 | ||
| 57 | 56 | ||
| 58 | ## 调用示例 | 57 | ## 调用示例 |
| 59 | 58 | ||
| 60 | ```cpp | 59 | ```cpp |
| 61 | uint32_t core_version = 0;// 定义AI处理器版本 | 60 | uint32_t core_version = 0;// 定义AI处理器版本 |
| 62 | asc_get_arch_ver(core_version); | 61 | asc_get_arch_ver(core_version); |
| 63 | -printf("core version is %x", core_version);// 需用%x将其打印成十六进制的数 | 62 | +printf("core version is %u", core_version); |
| 64 | -``` | 63 | +``` |
| @@ -78,11 +78,7 @@ __aicore__ inline int64_t GetBlockIdxImpl() | |||
| 78 | #endif | 78 | #endif |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | -__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) | 81 | +__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) { coreVersion = 3510U; } |
| 82 | -{ | ||
| 83 | - const int32_t coreVersionOffset = 32; | ||
| 84 | - coreVersion = static_cast<uint32_t>((static_cast<uint64_t>(get_arch_ver()) >> coreVersionOffset) & 0xFFF); | ||
| 85 | -} | ||
| 86 | 82 | ||
| 87 | __aicore__ inline int64_t GetSubBlockNumImpl() | 83 | __aicore__ inline int64_t GetSubBlockNumImpl() |
| 88 | { | 84 | { |
| @@ -33,11 +33,7 @@ __aicore__ inline int64_t GetTaskRationImpl() { return 1; } | |||
| 33 | 33 | ||
| 34 | __aicore__ inline int64_t GetBlockIdxImpl() { return block_idx; } | 34 | __aicore__ inline int64_t GetBlockIdxImpl() { return block_idx; } |
| 35 | 35 | ||
| 36 | -__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) | 36 | +__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) { coreVersion = 1001U; } |
| 37 | -{ | ||
| 38 | - (void)(coreVersion); | ||
| 39 | - ASCENDC_REPORT_NOT_SUPPORT(false, "GetArchVersion"); | ||
| 40 | -} | ||
| 41 | 37 | ||
| 42 | __aicore__ inline int64_t GetSubBlockNumImpl() { return 1; } | 38 | __aicore__ inline int64_t GetSubBlockNumImpl() { return 1; } |
| 43 | 39 | ||
| @@ -148,9 +148,11 @@ __aicore__ inline void FftsCrossCoreSync(pipe_t pipe, uint64_t config) { ffts_cr | |||
| 148 | __aicore__ inline int64_t Clz(uint64_t in) { return clz(in); } | 148 | __aicore__ inline int64_t Clz(uint64_t in) { return clz(in); } |
| 149 | 149 | ||
| 150 | __aicore__ inline uint64_t FakeOverFlowStatus1() { return fake_overflow_status_1(); } | 150 | __aicore__ inline uint64_t FakeOverFlowStatus1() { return fake_overflow_status_1(); } |
| 151 | - | 151 | +__aicore__ inline int64_t GetArchVer() |
| 152 | -__aicore__ inline int64_t GetArchVer() { return get_arch_ver(); } | 152 | +{ |
| 153 | - | 153 | + constexpr int64_t archVer = 2201L; |
| 154 | + return archVer; | ||
| 155 | +} | ||
| 154 | __aicore__ inline int64_t GetConditionFlag() { return get_condition_flag(); } | 156 | __aicore__ inline int64_t GetConditionFlag() { return get_condition_flag(); } |
| 155 | 157 | ||
| 156 | __aicore__ inline int64_t GetCoreid() { return get_coreid(); } | 158 | __aicore__ inline int64_t GetCoreid() { return get_coreid(); } |
| @@ -100,11 +100,7 @@ __aicore__ inline int64_t GetSystemCycleImpl() | |||
| 100 | #endif | 100 | #endif |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | -__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) | 103 | +__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) { coreVersion = 2201U; } |
| 104 | -{ | ||
| 105 | - const int32_t coreVersionOffset = 32; | ||
| 106 | - coreVersion = static_cast<uint32_t>((static_cast<uint64_t>(get_arch_ver()) >> coreVersionOffset) & 0xFFF); | ||
| 107 | -} | ||
| 108 | 104 | ||
| 109 | __aicore__ inline int64_t GetProgramCounterImpl() | 105 | __aicore__ inline int64_t GetProgramCounterImpl() |
| 110 | { | 106 | { |
| @@ -39,11 +39,7 @@ __aicore__ inline int64_t GetBlockIdxImpl() | |||
| 39 | 39 | ||
| 40 | __aicore__ inline int64_t GetSubBlockNumImpl() { return 1; } | 40 | __aicore__ inline int64_t GetSubBlockNumImpl() { return 1; } |
| 41 | 41 | ||
| 42 | -__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) | 42 | +__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) { coreVersion = 2002U; } |
C | |||
| 43 | -{ | ||
| 44 | - const int32_t coreVersionOffset = 32; | ||
| 45 | - coreVersion = static_cast<uint32_t>((static_cast<uint64_t>(get_arch_ver()) >> coreVersionOffset) & 0xFFF); | ||
| 46 | -} | ||
| 47 | 43 | ||
| 48 | __aicore__ inline int64_t GetProgramCounterImpl() | 44 | __aicore__ inline int64_t GetProgramCounterImpl() |
| 49 | { | 45 | { |
| @@ -33,11 +33,7 @@ __aicore__ inline int64_t GetTaskRationImpl() { return 1; } | |||
| 33 | 33 | ||
| 34 | __aicore__ inline int64_t GetBlockIdxImpl() { return get_block_idx(); } | 34 | __aicore__ inline int64_t GetBlockIdxImpl() { return get_block_idx(); } |
| 35 | 35 | ||
| 36 | -__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) | 36 | +__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) { coreVersion = 3002U; } |
| 37 | -{ | ||
| 38 | - (void)(coreVersion); | ||
| 39 | - ASCENDC_REPORT_NOT_SUPPORT(false, "GetArchVersion"); | ||
| 40 | -} | ||
| 41 | 37 | ||
| 42 | __aicore__ inline int64_t GetSubBlockNumImpl() { return 1; } | 38 | __aicore__ inline int64_t GetSubBlockNumImpl() { return 1; } |
| 43 | 39 | ||
| @@ -33,11 +33,7 @@ __aicore__ inline int64_t GetTaskRationImpl() { return 1; } | |||
| 33 | 33 | ||
| 34 | __aicore__ inline int64_t GetBlockIdxImpl() { return block_idx; } | 34 | __aicore__ inline int64_t GetBlockIdxImpl() { return block_idx; } |
| 35 | 35 | ||
| 36 | -__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) | 36 | +__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) { coreVersion = 3102U; } |
| 37 | -{ | ||
| 38 | - (void)(coreVersion); | ||
| 39 | - ASCENDC_ASSERT(false, { KERNEL_LOG(KERNEL_ERROR, "unsupported GetArchVersion on current device"); }); | ||
| 40 | -} | ||
| 41 | 37 | ||
| 42 | __aicore__ inline int64_t GetSubBlockNumImpl() { return 1; } | 38 | __aicore__ inline int64_t GetSubBlockNumImpl() { return 1; } |
| 43 | 39 | ||
| @@ -60,11 +60,7 @@ __aicore__ inline int64_t GetBlockIdxImpl() | |||
| 60 | #endif | 60 | #endif |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | -__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) | 63 | +__aicore__ inline void GetArchVersionImpl(uint32_t& coreVersion) { coreVersion = 5102U; } |
| 64 | -{ | ||
| 65 | - const int32_t coreVersionOffset = 32; | ||
| 66 | - coreVersion = static_cast<uint32_t>((static_cast<uint64_t>(get_arch_ver()) >> coreVersionOffset) & 0xFFF); | ||
| 67 | -} | ||
| 68 | 64 | ||
| 69 | __aicore__ inline int64_t GetSubBlockNumImpl() | 65 | __aicore__ inline int64_t GetSubBlockNumImpl() |
| 70 | { | 66 | { |
| @@ -20,12 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | #include "impl/c_api/instr_impl/npu_arch_2201/utils_impl/utils_impl.h" | 21 | #include "impl/c_api/instr_impl/npu_arch_2201/utils_impl/utils_impl.h" |
| 22 | 22 | ||
| 23 | -__aicore__ inline void asc_get_arch_ver_impl(uint32_t& core_version) | 23 | +__aicore__ inline void asc_get_arch_ver_impl(uint32_t& core_version) { core_version = 2201U; } |
| 24 | -{ | ||
| 25 | - asc_capi_arch_version ver; | ||
| 26 | - ver.full = get_arch_ver(); | ||
| 27 | - core_version = static_cast<uint32_t>(ver.core_ver); | ||
| 28 | -} | ||
| 29 | 24 | ||
| 30 | #endif | 25 | #endif |
| 31 | 26 | ||
| @@ -103,15 +103,6 @@ __aicore__ inline void asc_set_mask_count_end() | |||
| 103 | 103 | ||
| 104 | __aicore__ inline void asc_sync_post_process() { pipe_barrier(pipe_t::PIPE_ALL); } | 104 | __aicore__ inline void asc_sync_post_process() { pipe_barrier(pipe_t::PIPE_ALL); } |
| 105 | 105 | ||
| 106 | -union asc_capi_arch_version { | ||
| 107 | - uint64_t full; | ||
| 108 | - struct { | ||
| 109 | - uint64_t low_bit : 32; | ||
| 110 | - uint64_t core_ver : 12; | ||
| 111 | - uint64_t reserved : 20; | ||
| 112 | - }; | ||
| 113 | -}; | ||
| 114 | - | ||
| 115 | union asc_capi_fpc_reg_config { | 106 | union asc_capi_fpc_reg_config { |
| 116 | uint64_t config; | 107 | uint64_t config; |
| 117 | struct { | 108 | struct { |
| @@ -25,12 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | #include "impl/c_api/instr_impl/npu_arch_3510/utils_impl/utils_impl.h" | 26 | #include "impl/c_api/instr_impl/npu_arch_3510/utils_impl/utils_impl.h" |
| 27 | 27 | ||
| 28 | -__aicore__ inline void asc_get_arch_ver_impl(uint32_t& core_version) | 28 | +__aicore__ inline void asc_get_arch_ver_impl(uint32_t& core_version) { core_version = 3510U; } |
| 29 | -{ | ||
| 30 | - asc_capi_arch_version ver; | ||
| 31 | - ver.full = get_arch_ver(); | ||
| 32 | - core_version = static_cast<uint32_t>(ver.core_ver); | ||
| 33 | -} | ||
| 34 | 29 | ||
| 35 | #endif | 30 | #endif |
| 36 | 31 | ||
| @@ -0,0 +1,22 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2026 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 | + | ||
| 11 | +#include <gtest/gtest.h> | ||
| 12 | +#include "kernel_operator.h" | ||
| 13 | + | ||
| 14 | +using namespace AscendC; | ||
| 15 | + | ||
| 16 | +TEST(TEST_SYS_VAR, GetArchVersion) | ||
| 17 | +{ | ||
| 18 | + uint32_t coreVersion = 0; | ||
| 19 | + GetArchVersion(coreVersion); | ||
| 20 | + | ||
| 21 | + EXPECT_EQ(coreVersion, 3002U); | ||
| 22 | +} | ||
| @@ -23,6 +23,7 @@ TEST_F(TEST_SYS_VAR, GetSystemVariable) | |||
| 23 | 23 | ||
| 24 | uint32_t coreVersion = 0; | 24 | uint32_t coreVersion = 0; |
| 25 | GetArchVersion(coreVersion); | 25 | GetArchVersion(coreVersion); |
| 26 | + EXPECT_EQ(coreVersion, 2002U); | ||
| 26 | int64_t pc = -1; | 27 | int64_t pc = -1; |
| 27 | pc = GetProgramCounter(); | 28 | pc = GetProgramCounter(); |
| 28 | EXPECT_NE(pc, -1); | 29 | EXPECT_NE(pc, -1); |
| @@ -0,0 +1,22 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2026 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 | + | ||
| 11 | +#include <gtest/gtest.h> | ||
| 12 | +#include "kernel_operator.h" | ||
| 13 | + | ||
| 14 | +using namespace AscendC; | ||
| 15 | + | ||
| 16 | +TEST(TEST_SYS_VAR, GetArchVersion) | ||
| 17 | +{ | ||
| 18 | + uint32_t coreVersion = 0; | ||
| 19 | + GetArchVersion(coreVersion); | ||
| 20 | + | ||
| 21 | + EXPECT_EQ(coreVersion, 3102U); | ||
| 22 | +} | ||
| @@ -0,0 +1,22 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2026 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 | + | ||
| 11 | +#include <gtest/gtest.h> | ||
| 12 | +#include "kernel_operator.h" | ||
| 13 | + | ||
| 14 | +using namespace AscendC; | ||
| 15 | + | ||
| 16 | +TEST(TEST_SYS_VAR, GetArchVersion) | ||
| 17 | +{ | ||
| 18 | + uint32_t coreVersion = 0; | ||
| 19 | + GetArchVersion(coreVersion); | ||
| 20 | + | ||
| 21 | + EXPECT_EQ(coreVersion, 1001U); | ||
| 22 | +} | ||
| @@ -25,6 +25,7 @@ TEST_F(TEST_SYS_VAR, GetSystemVariable) | |||
| 25 | 25 | ||
| 26 | uint32_t coreVersion = 0; | 26 | uint32_t coreVersion = 0; |
| 27 | GetArchVersion(coreVersion); | 27 | GetArchVersion(coreVersion); |
| 28 | + EXPECT_EQ(coreVersion, 2201U); | ||
| 28 | 29 | ||
| 29 | int64_t actualSubBlockNum = GetSubBlockNum(); | 30 | int64_t actualSubBlockNum = GetSubBlockNum(); |
| 30 | EXPECT_EQ(actualSubBlockNum, subBlockNum); | 31 | EXPECT_EQ(actualSubBlockNum, subBlockNum); |
| @@ -0,0 +1,22 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2026 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 | + | ||
| 11 | +#include <gtest/gtest.h> | ||
| 12 | +#include "kernel_operator.h" | ||
| 13 | + | ||
| 14 | +using namespace AscendC; | ||
| 15 | + | ||
| 16 | +TEST(TEST_SYS_VAR, GetArchVersion) | ||
| 17 | +{ | ||
| 18 | + uint32_t coreVersion = 0; | ||
| 19 | + GetArchVersion(coreVersion); | ||
| 20 | + | ||
| 21 | + EXPECT_EQ(coreVersion, 3510U); | ||
| 22 | +} | ||
| @@ -0,0 +1,22 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2026 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 | + | ||
| 11 | +#include <gtest/gtest.h> | ||
| 12 | +#include "kernel_operator.h" | ||
| 13 | + | ||
| 14 | +using namespace AscendC; | ||
| 15 | + | ||
| 16 | +TEST(TEST_SYS_VAR, GetArchVersion) | ||
| 17 | +{ | ||
| 18 | + uint32_t coreVersion = 0; | ||
| 19 | + GetArchVersion(coreVersion); | ||
| 20 | + | ||
| 21 | + EXPECT_EQ(coreVersion, 5102U); | ||
| 22 | +} | ||
| @@ -9,7 +9,6 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #include <gtest/gtest.h> | 11 | #include <gtest/gtest.h> |
| 12 | -#include <mockcpp/mockcpp.hpp> | ||
| 13 | #include "c_api/stub/cce_stub.h" | 12 | #include "c_api/stub/cce_stub.h" |
| 14 | #include "c_api/asc_simd.h" | 13 | #include "c_api/asc_simd.h" |
| 15 | #include "c_api/utils_intf.h" | 14 | #include "c_api/utils_intf.h" |
| @@ -22,11 +21,8 @@ protected: | |||
| 22 | 21 | ||
| 23 | TEST_F(TestVectorComputeGetArchVer, get_arch_ver_Succ) | 22 | TEST_F(TestVectorComputeGetArchVer, get_arch_ver_Succ) |
| 24 | { | 23 | { |
| 25 | - MOCKER(get_arch_ver, int64_t(void)).times(1).will(returnValue(int64_t(0x123456789ABCDEF0))); | ||
| 26 | - | ||
| 27 | uint32_t core_version = 0; | 24 | uint32_t core_version = 0; |
| 28 | asc_get_arch_ver(core_version); | 25 | asc_get_arch_ver(core_version); |
| 29 | 26 | ||
| 30 | - uint32_t expectedValue = 0x678; // (0x12345678 & 0xFFF) | 27 | + EXPECT_EQ(core_version, 2201U); |
| 31 | - EXPECT_EQ(expectedValue, core_version); | ||
| 32 | } | 28 | } |
| @@ -9,9 +9,9 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #include <gtest/gtest.h> | 11 | #include <gtest/gtest.h> |
| 12 | -#include <mockcpp/mockcpp.hpp> | ||
| 13 | #include "c_api/stub/cce_stub.h" | 12 | #include "c_api/stub/cce_stub.h" |
| 14 | #include "include/c_api/asc_simd.h" | 13 | #include "include/c_api/asc_simd.h" |
| 14 | +#include "c_api/utils_intf.h" | ||
| 15 | 15 | ||
| 16 | class TestSysVarGetArchVer : public testing::Test { | 16 | class TestSysVarGetArchVer : public testing::Test { |
| 17 | protected: | 17 | protected: |
| @@ -21,11 +21,8 @@ protected: | |||
| 21 | 21 | ||
| 22 | TEST_F(TestSysVarGetArchVer, get_arch_ver_Succ) | 22 | TEST_F(TestSysVarGetArchVer, get_arch_ver_Succ) |
| 23 | { | 23 | { |
| 24 | - MOCKER(get_arch_ver, int64_t(void)).times(1).will(returnValue(int64_t(0x123456789ABCDEF0))); | ||
| 25 | - | ||
| 26 | uint32_t core_version = 0; | 24 | uint32_t core_version = 0; |
| 27 | asc_get_arch_ver(core_version); | 25 | asc_get_arch_ver(core_version); |
| 28 | 26 | ||
| 29 | - uint32_t expectedValue = 0x678; | 27 | + EXPECT_EQ(core_version, 3510U); |
| 30 | - EXPECT_EQ(expectedValue, core_version); | ||
| 31 | } | 28 | } |


其余版本不用改吗