How rocm/rocprofiler-sdk works
Overall Project Type and Purpose
• Recognize that this is a performance analysis and GPU profiling toolkit. The SDK offers direct interfaces to GPU counters, API tracing (HIP, HSA, etc.), and various tracing modes (like PC sampling beta and marker/ROCTx).
• That the README highlights integration with GPU hardware, build/installation using CMake, and a strong emphasis on documentation (doxygen and Sphinx).
And Break Down Main Architectural Components
a. Command-Line Tool & User Interface:
• The “source/bin” directory shows the rocprofv3 tool (and related scripts like rocprofv3_avail.py) that users invoke. This constitutes the entry point of the profiling system.
b. Core SDK Libraries and APIs:
• The bulk of the functionality is implemented in “source/lib” and “source/include” directories. These contain modules for:
• API/Call Tracing: Modules handling HIP API, HSA API, and marker tracing.
• Counter Collection & PC Sampling: Separate modules specific to hardware counters and experimental PC sampling (see “source/lib/rocprofiler-sdk/counters”, “source/lib/rocprofiler-sdk/pc_sampling”).
• Code Object and Kernel Dispatch: Handle deeper runtime integration (under “source/lib/rocprofiler-sdk/code_object” and “source/lib/rocprofiler-sdk/kernel_dispatch”).
• Context, Registration, and Internal Utilities: Modules that facilitate call interception, memory management, and thread tracking.
c. Output and Data Formatting:
• Components in “source/lib/output” deal with producing reports in CSV, JSON, Perfetto, etc., and handle metadata and statistical analysis.
• A node titled “Data Output & Reporting” that shows how profiling data is formatted for logs, statistics, and external consumption.
d. Build/Configuration and External Dependencies:
• CMake configurations are present throughout (CMakeLists.txt files in many directories, plus custom cmake/Modules and Templates).
• External dependencies (e.g., libraries like glog, fmt, json, cereal, etc.) are placed in the “external” directory.
e. Documentation Subsystem:
• The “source/docs” folder houses doxygen and Sphinx documentation sources.
• This as “API Documentation & Guides” interacting with the main SDK.
• From core libraries, indicate calls that branch into counter collection, API tracing, and kernel dispatch routines.
• That the output modules receive data results from the core components and produce various report formats.
• Optionally, illustrate dependency links to external libraries (e.g., glog, fmt) to remind viewers of integration points.
Architectural Patterns and Design Principles
• Modular Separation: The file structure naturally segregates components (e.g., tracing, counters, documentation, samples, tests). Emphasize that the design is modular.
• Layered Design: The system is layered from user CLI down to low-level hardware interfacing, following abstraction principles.
• Use of CMake for Cross-Platform Build and Integration, which shows a separation between configuration and implementation.
• Use a tool that lets you arrange these nodes clearly – ensuring the data flow and dependencies are evident.
• Avoid overcomplicating areas where the same module may be repeated; group similar components when appropriate.