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 "cloud_v2_platform.h"
11 :
12 : #include <string>
13 : #include "runtime/base.h"
14 : #include "log/adx_log.h"
15 : #include "adump_platform_registry.h"
16 : #include "kernel_pc_fixer.h"
17 : #include "register_config.h"
18 : #include "dump_common.h"
19 : #include "dump_core.h"
20 : #include "hccl_mc2_define.h"
21 :
22 : namespace Adx {
23 :
24 : ADUMP_PLATFORM_REGISTER(ExceptionDumpInterface, PlatformType::CHIP_CLOUD_TYPE, CloudLegacyException);
25 : ADUMP_PLATFORM_REGISTER(FeaturesSupportInterface, PlatformType::CHIP_CLOUD_V2, CloudV2Features);
26 : ADUMP_PLATFORM_REGISTER(CoredumpInterface, PlatformType::CHIP_CLOUD_V2, CloudV2Coredump);
27 : ADUMP_PLATFORM_REGISTER(ExceptionDumpInterface, PlatformType::CHIP_CLOUD_V2, CloudV2Exception);
28 : ADUMP_PLATFORM_REGISTER(DataDumpInterface, PlatformType::CHIP_CLOUD_V2, CloudV2DataDump);
29 :
30 : namespace {
31 17 : uint64_t GetAscend910Mc2StructSize()
32 : {
33 17 : constexpr uint32_t socVersionLength = 128U;
34 17 : char version[socVersionLength] = {0};
35 17 : rtError_t ret = rtGetSocVersion(version, socVersionLength);
36 17 : if (ret != RT_ERROR_NONE) {
37 3 : IDE_LOGE("[AdumpPlatform] Get soc version failed for mc2 struct size.");
38 3 : return 0;
39 : }
40 28 : if (std::string(version).find("Ascend910_93") != std::string::npos) {
41 7 : return sizeof(HcclOpResParam);
42 : }
43 7 : return sizeof(HcclCombinOpParam);
44 : }
45 : } // namespace
46 :
47 3 : bool CloudLegacyException::SupportMc2SpacesDump() const { return true; }
48 :
49 6 : uint64_t CloudLegacyException::GetMc2StructSize() const { return GetAscend910Mc2StructSize(); }
50 :
51 4 : CloudV2Features::CloudV2Features()
52 : {
53 : supported_ = {
54 : AdumpPlatformFeature::FEATURE_DATA_DUMP, AdumpPlatformFeature::FEATURE_OVERFLOW_DUMP,
55 : AdumpPlatformFeature::FEATURE_EXCEPTION_DUMP_L0, AdumpPlatformFeature::FEATURE_EXCEPTION_DUMP_L1,
56 : AdumpPlatformFeature::FEATURE_CORE_DUMP,
57 4 : };
58 4 : }
59 :
60 7 : std::unique_ptr<PcFixerInterface> CloudV2Coredump::CreatePcFixer() const
61 : {
62 14 : return std::unique_ptr<PcFixerInterface>(new (std::nothrow) CloudV2PcFixer());
63 : }
64 :
65 10 : std::shared_ptr<RegisterInterface> CloudV2Coredump::CreateRegister() const
66 : {
67 10 : return std::make_shared<CloudV2Register>();
68 : }
69 :
70 83 : void CloudV2Coredump::DumpRegister(DumpCore& core, uint8_t coreType, uint16_t coreId) const
71 : {
72 83 : core.DumpV2Register(coreType, coreId);
73 83 : }
74 :
75 206 : uint16_t CloudV2Coredump::ConvertCoreId(uint8_t coreType, uint16_t coreId) const
76 : {
77 206 : return (coreType == CORE_TYPE_AIC) ? coreId : static_cast<uint16_t>(CORE_SIZE_AIC + coreId);
78 : }
79 :
80 6 : bool CloudV2Exception::SupportMc2SpacesDump() const { return true; }
81 :
82 11 : uint64_t CloudV2Exception::GetMc2StructSize() const { return GetAscend910Mc2StructSize(); }
83 :
84 6 : bool CloudV2Exception::IsArgsDataTypeSizeByByte() const { return true; }
85 :
86 21 : uint64_t CloudV2DataDump::GetKfcStackSize() const
87 : {
88 21 : constexpr uint32_t OP_STACK_910B = 75;
89 21 : return CalcKfcStackSize(OP_STACK_910B);
90 : }
91 :
92 6 : std::vector<std::string> CloudV2DataDump::GetKfcBinNames() const
93 : {
94 18 : return {"dump_stat_op_ascend910B.o", "kfc_dump_stat_ascend910B.o"};
95 : }
96 :
97 18 : bool CloudV2DataDump::IsUbFromAiCore() const { return true; }
98 :
99 : } // namespace Adx
|