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 : #ifndef ADUMP_COMMON_DATA_DUMP_INTERFACE_H
11 : #define ADUMP_COMMON_DATA_DUMP_INTERFACE_H
12 :
13 : #include <cstddef>
14 : #include <cstdint>
15 : #include <string>
16 : #include <vector>
17 :
18 : namespace Adx {
19 :
20 : // Data Dump 特性下的平台差异处理,涵盖 KFC stats 参数与 dump_printf 参数。所有平台都注册
21 : // 此接口,未覆盖的方法走基类默认值(默认值对齐原 dump_printf 非 Ascend950 分支取值)。
22 : class DataDumpInterface {
23 : public:
24 72 : virtual ~DataDumpInterface() = default;
25 :
26 : // KFC stats
27 0 : virtual uint64_t GetKfcStackSize() const { return 0; }
28 0 : virtual std::vector<std::string> GetKfcBinNames() const { return {}; }
29 3 : virtual bool IsUbFromAiCore() const { return false; } // 原 CHIP_CORE_MAP
30 :
31 : // dump_printf 参数(原 Ascend950 专属逻辑,芯片身份消失)
32 11 : virtual size_t GetCoreTypeIDOffset() const { return 50U; }
33 19 : virtual size_t GetBlockNum() const { return 75U; }
34 17 : virtual int32_t GetStreamSyncTimeout() const { return 60000; }
35 5 : virtual bool IsSimtDumpEnabled(size_t /* dumpWorkSpaceSize */) const { return false; }
36 :
37 : protected:
38 30 : static uint64_t CalcKfcStackSize(uint32_t opStackCount)
39 : {
40 30 : constexpr uint32_t BLOCK_MIN_SIZE = 32;
41 30 : constexpr uint32_t INTEGER_KILOBYTE = 1024;
42 30 : return static_cast<uint64_t>(opStackCount) * BLOCK_MIN_SIZE * INTEGER_KILOBYTE;
43 : }
44 : };
45 :
46 : } // namespace Adx
47 : #endif // ADUMP_COMMON_DATA_DUMP_INTERFACE_H
|