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 "adump_platform_api.h"
11 : #include "platform/platform_info.h"
12 : #include "adump_platform_manager.h"
13 : #include "adx_log.h"
14 :
15 : namespace Adx {
16 14 : inline bool GetPlatformInfo(const std::string socVersion, fe::PlatformInfo &platInfo, fe::OptionalInfo &optionalInfo)
17 : {
18 14 : IDE_CTRL_VALUE_FAILED(fe::PlatformInfoManager::GeInstance().InitializePlatformInfo() == 0U,
19 : return false, "Init platform info failed.");
20 14 : uint32_t ret = fe::PlatformInfoManager::GeInstance().GetPlatformInfo(socVersion, platInfo, optionalInfo);
21 14 : IDE_CTRL_VALUE_FAILED(ret == 0U, return false, "Failed to get platform info, ret is %u", ret);
22 14 : return true;
23 : }
24 :
25 6 : bool AdumpPlatformApi::GetUBSizeAndCoreNum(const std::string &socVersion, PlatformType platform, PlatformData &data)
26 : {
27 6 : fe::PlatformInfo platInfo;
28 6 : fe::OptionalInfo optionalInfo;
29 6 : IDE_CTRL_VALUE_FAILED(GetPlatformInfo(socVersion, platInfo, optionalInfo), return false,
30 : "Failed to get ub size and core number.");
31 :
32 6 : auto plat = PlatformReflection<DataDumpInterface>::CreatePlatform(platform);
33 6 : IDE_CTRL_VALUE_FAILED(plat != nullptr, return false, "Current chip type %u is not adapted.",
34 : static_cast<uint32_t>(platform));
35 3 : if (plat->IsUbFromAiCore()) {
36 3 : data.ubSize = platInfo.ai_core_spec.ub_size;
37 : } else {
38 0 : data.ubSize = platInfo.vector_core_spec.ub_size;
39 : }
40 3 : data.aiCoreCnt = platInfo.soc_info.ai_core_cnt;
41 3 : data.vectCoreCnt = platInfo.soc_info.vector_core_cnt;
42 3 : return true;
43 6 : }
44 :
45 8 : bool AdumpPlatformApi::GetAicoreSizeInfo(const std::string &socVersion, BufferSize &bufferSize)
46 : {
47 8 : fe::PlatformInfo platInfo;
48 8 : fe::OptionalInfo optionalInfo;
49 8 : IDE_CTRL_VALUE_FAILED(GetPlatformInfo(socVersion, platInfo, optionalInfo), return false,
50 : "Failed to read size information from ge platform in GetAicoreSizeInfo.");
51 :
52 8 : bufferSize.l0aSize = platInfo.ai_core_spec.l0_a_size;
53 8 : bufferSize.l0bSize = platInfo.ai_core_spec.l0_b_size;
54 8 : bufferSize.l0cSize = platInfo.ai_core_spec.l0_c_size;
55 8 : bufferSize.l1Size = platInfo.ai_core_spec.l1_size;
56 8 : bufferSize.ubSize = platInfo.ai_core_spec.ub_size;
57 8 : return true;
58 8 : }
59 : }
|