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