已合并
【PR】: 提交辅助adump代码分析的skill #1967
yuanjiang_创建于 5月7日
【PR】: 提交辅助adump代码分析的skill #1967
已合并
从已删除 :master合入到cann/runtimemaster
共 2 个文件变更+158-0
| @@ -0,0 +1,135 @@ | |||
| 1 | +--- | ||
| 2 | +name: adump-architecture-analyzer | ||
| 3 | +description: Analyze the software architecture of the adump codebase, which provides tensor dump capabilities including normal data dump and exception dump scenarios. Exception dump is categorized into three levels based on information granularity: aic_err_brief_dump (L0), aic_err_norm_dump (L1), and aic_err_detail_dump (L2). Use this skill whenever the user wants to understand the adump codebase architecture, analyze dump functionality, or examine exception dump implementations, especially the detailed exception dump mechanism. | ||
| 4 | +--- | ||
| 5 | + | ||
| 6 | +# Adump Architecture Analyzer | ||
| 7 | + | ||
| 8 | +This skill analyzes the software architecture of the adump codebase, focusing on tensor dump capabilities and exception dump implementations. | ||
| 9 | + | ||
| 10 | +## Overview | ||
| 11 | + | ||
| 12 | +The adump codebase provides comprehensive tensor dump functionality for debugging and analysis: | ||
| 13 | + | ||
| 14 | +1. **Normal Data Dump**: Dump tensor data during normal business operations | ||
| 15 | +2. **Exception Dump**: Capture diagnostic information when exceptions occur, with three levels of detail | ||
| 16 | + | ||
| 17 | +## Analysis Scope | ||
| 18 | + | ||
| 19 | +### 1. Codebase Structure | ||
| 20 | + | ||
| 21 | +Analyze the overall directory structure and identify key components: | ||
| 22 | + | ||
| 23 | +- `adcore/`: Core infrastructure (common utilities, communication, device management) | ||
| 24 | +- `ad`ump/: Dump functionality implementation | ||
| 25 | +- `inc/`: Public header files and APIs | ||
| 26 | +- `proto/`: Protocol buffer definitions for dump data structures | ||
| 27 | +- `init/`: Initialization and configuration | ||
| 28 | +对外头文件目录:C:\Users\y00334430\runtime\pkg_inc\dump目录 | ||
| 29 | + | ||
| 30 | +### 2. Key Modules and Classes | ||
| 31 | + | ||
| 32 | +Identify and analyze the main components: | ||
| 33 | + | ||
| 34 | +#### Dump Management | ||
| 35 | +- `DumpManager`: Singleton class managing all dump operations | ||
| 36 | +- `DumpSetting`: Configuration management for dump settings | ||
| 37 | +- `DumpConfigConverter`: Converts JSON config to internal structures | ||
| 38 | + | ||
| 39 | +#### Dump开关定义 | ||
| 40 | +第一层开关:data dump(枚举值定义为OPERATOR),overflow dump(枚举值定义为OP_OVERFLOW),exception dump | ||
| 41 | +第二层开关:data dump分为算子级别的op dump,kernel级别的kernel dump。data dump可以控制dump不同的tensor(input、output、workspace) 。data dump可以配置dump tesnor的数据(tensor),还是统计值(stats) | ||
| 42 | + exception dump分为普通的异常dump(枚举值定义为EXCEPTION ),轻量化异常dump(枚举值定义为ARGS_EXCEPTION),细化的异常dump(枚举值定义为AIC_ERR_DETAIL_DUMP) | ||
| 43 | + | ||
| 44 | +#### 业务流程 | ||
| 45 | +data dump核心功能是对外提供了AdumpDumpTensorV2接口,支持为调用者下发dump算子,dump算子的参数就是算子的tensor信息,内容是基于op_mapping.proto定义的。dump算子的能力是其他代码仓提供的,会基于参数信息完成tensor dump。 | ||
| 46 | +exception dump基于runtime提供的exception回调机制,在回调函数中获取算子的tensor信息,将算子的tensor保存到dump文件中,dump文件头是基于op_mapping.proto定义的。 | ||
| 47 | + | ||
| 48 | +### 5. Data Structures and Protocols | ||
| 49 | + | ||
| 50 | +Analyze the protobuf definitions: | ||
| 51 | + | ||
| 52 | +#### dump_task.proto | ||
| 53 | +- `DumpData`: Main dump data structure | ||
| 54 | +- `OpInput`/`OpOutput`: Tensor data structures | ||
| 55 | +- `Workspace`: Memory workspace information | ||
| 56 | +- Data type and format definitions | ||
| 57 | + | ||
| 58 | +#### op_mapping.proto | ||
| 59 | +- `OpMappingInfo`: Operator mapping information | ||
| 60 | +- `Task`: Task-level dump information | ||
| 61 | +- Address type definitions | ||
| 62 | + | ||
| 63 | +### 6. API Surface | ||
| 64 | + | ||
| 65 | +Analyze the public API: | ||
| 66 | + | ||
| 67 | +#### Main APIs | ||
| 68 | +- `AdumpSetDump`: Configure dump settings,参数的格式是按照json组织 | ||
| 69 | +- `AdumpDumpTensorV2`: data dump功能的主要对外接口,提供下发dump算子的能力 | ||
| 70 | +- `AdumpAddExceptionOperatorInfoV2`:exception dump中的普通异常dump功能的主要对外接口,支持调用者将算子的tensor信息保存本模块中,用于后续的exception回调 | ||
| 71 | +- `AdumpGetDFXInfoAddrForDynamic`和`AdumpGetDFXInfoAddrForStatic`:exception dump中的轻量化异常dump的主要对外接口,支持调用者获取一块dump维护的内存和索引,调用者将算子的tensor信息保存到这块内存,用于后续的exception回调 | ||
| 72 | +- Exception callback registration | ||
| 73 | + | ||
| 74 | +#### Configuration | ||
| 75 | +- JSON-based configuration | ||
| 76 | +- Environment variable support | ||
| 77 | +- Dump level selection | ||
| 78 | +- Path and mode configuration | ||
| 79 | + | ||
| 80 | +## Analysis Guidelines | ||
| 81 | + | ||
| 82 | +### Code Reading Strategy | ||
| 83 | +1. Start with entry points (`adump_api.h`, `dump_manager.h`) | ||
| 84 | +2. Follow the exception dump flow from callback to file I/O | ||
| 85 | +3. Analyze data structures in protobuf files | ||
| 86 | +4. Examine platform-specific implementations | ||
| 87 | +5. Study configuration and initialization | ||
| 88 | + | ||
| 89 | +### Key Questions to Answer | ||
| 90 | +- How does the system handle large data dumps efficiently? | ||
| 91 | +- What mechanisms ensure thread safety during concurrent dumps? | ||
| 92 | +- How are exception operators tracked and identified? | ||
| 93 | +- What is the memory footprint of detailed exception dumps? | ||
| 94 | +- How do the three exception dump levels differ in implementation? | ||
| 95 | +- What platform-specific optimizations exist? | ||
| 96 | + | ||
| 97 | +### Code Patterns to Identify | ||
| 98 | +- Singleton usage (`DumpManager`) | ||
| 99 | +- RAII patterns for resource management | ||
| 100 | +- Template usage for generic data handling | ||
| 101 | +- Callback mechanisms for exception handling | ||
| 102 | +- Plugin architecture for extensibility | ||
| 103 | + | ||
| 104 | +## Analysis Execution | ||
| 105 | + | ||
| 106 | +When performing the analysis: | ||
| 107 | + | ||
| 108 | +1. **Systematic Exploration**: Read files in logical order, following dependencies | ||
| 109 | +2. **Deep Dive**: Spend extra time on aic_err_detail_dump implementation | ||
| 110 | +3. **Cross-Reference**: Verify understanding by checking multiple related files | ||
| 111 | +4. **Documentation**: Take notes on complex algorithms and data structures | ||
| 112 | +5. **Validation**: Cross-check implementation against API contracts | ||
| 113 | + | ||
| 114 | +## Output Generation | ||
| 115 | + | ||
| 116 | +Generate both Markdown and JSON outputs: | ||
| 117 | + | ||
| 118 | +### Markdown Format | ||
| 119 | +- Human-readable architecture documentation | ||
| 120 | +- Code examples and diagrams | ||
| 121 | +- Detailed explanations of complex components | ||
| 122 | + | ||
| 123 | +### JSON Format | ||
| 124 | +- Structured representation of the architecture | ||
| 125 | +- Machine-readable component metadata | ||
| 126 | +- Dependency graph information | ||
| 127 | +- API specifications | ||
| 128 | + | ||
| 129 | +## Notes | ||
| 130 | + | ||
| 131 | +- Focus on understanding the "why" behind design decisions, not just the "what" | ||
| 132 | +- Pay special attention to memory management in detailed exception dumps | ||
| 133 | +- Identify potential bottlenecks or performance concerns | ||
| 134 | +- Note any unusual or clever implementation techniques | ||
| 135 | +- Document platform-specific variations clearly | ||
| @@ -0,0 +1,23 @@ | |||
| 1 | +{ | ||
| 2 | + "skill_name": "adump-architecture-analyzer", | ||
| 3 | + "evals": [ | ||
| 4 | + { | ||
| 5 | + "id": 1, | ||
| 6 | + "prompt": "分析这个adump代码库的软件架构,重点关注exception dump的实现机制,特别是aic_err_detail_dump的实现", | ||
| 7 | + "expected_output": "Comprehensive architecture analysis covering: overall codebase structure, key components (DumpManager, ExceptionDumper, DumpOperator, DumpArgs), three exception dump levels (L0/L1/L2), detailed analysis of aic_err_detail_dump implementation including data flow, memory management, and platform-specific features", | ||
| 8 | + "files": [] | ||
| 9 | + }, | ||
| 10 | + { | ||
| 11 | + "id": 2, | ||
| 12 | + "prompt": "我需要了解adump代码库中tensor dump的工作原理,包括正常数据dump和异常dump的区别,以及不同级别的exception dump是如何实现的", | ||
| 13 | + "expected_output": "Detailed explanation of tensor dump functionality covering: normal data dump vs exception dump, three exception dump levels (aic_err_brief_dump, aic_err_norm_dump, aic_err_detail_dump), their implementations, use cases, and technical differences", | ||
| 14 | + "files": [] | ||
| 15 | + }, | ||
| 16 | + { | ||
| 17 | + "id": 3, | ||
| 18 | + "prompt": "帮我分析adump代码库中aic_err_detail_dump的详细实现,包括内存管理、数据流、以及与DumpManager和ExceptionDumper的交互", | ||
| 19 | + "expected_output": "Deep technical analysis of aic_err_detail_dump implementation focusing on: memory management (ring buffers, chunk allocation), data flow from exception callback to file I/O, integration with DumpManager and ExceptionDumper, thread safety mechanisms, and platform-specific optimizations", | ||
| 20 | + "files": [] | ||
| 21 | + } | ||
| 22 | + ] | ||
| 23 | +} | ||