How mahirshahriar1/dynapex works
Project Type and Purpose
• DynApex is a specialized tool built in C++ for automated source code parallelization. It performs dynamic dependency analysis and runtime profiling to determine whether code fragments should be dispatched to the CPU or GPU. The README shows that the tool uses methods such as OpenMP (with target offloading for GPUs) and produces dependency graphs and performance profiles.
File Structure
• Top-Level Directories:
• / – Contains header files for key components: dependency_checker, dispatcher, and pragma_injector.
• src/ – Implements the source code. Key files here are main.cpp (entry point), dependency_checker.cpp (analyzes code dependencies), dispatcher.cpp (makes dynamic dispatch decisions), and pragma_injector.cpp (injects OpenMP pragmas for parallelization).
• build/ – Where binaries are generated. This indicates distinct build outputs (including profiler builds).
• logs/ – Stores runtime execution logs and profiling graphs (e.g., GPU statistics and valgrind output).
• Makefile – Represents build instructions that encapsulate compilation, cleaning, and profiling operations.
• The file structure reveals a modular design where the analysis, dynamic dispatch, and code transformation are separated into distinct components.
README for Additional Insights
• The README details that the tool is designed to analyze C++ code for potential parallel executionized sections, dynamically decide on execution mode (normal, CPU, GPU), and then generate detailed performance and dependency information.
a. Main Components:
• Input Module/Main Driver: Represented by main.cpp, it is the entry point that sets up the analysis and dispatch process.
• Dependency Analysis Module: The dependency_checker component analyzes source code to determine data dependencies.
• Pragma Injection Module: The pragma_injector component prepares the source code for parallel execution by inserting OpenMP directives.
• Dynamic Dispatcher Module: The dispatcher component leverages runtime profiling data to determine whether code should run on the CPU or GPU.
• Build and Logging Components: Build directory (compiled binaries) and logs (for profiling results and dependency graphs) as outputs of the process.
• External Tools & Libraries: OpenMP for parallelization, Graphviz and gprof2dot for profiling visualization, and system libraries as per the package installation instructions.
b. Relationships and Interactions:
• The Main Module initializes the process and calls the Dependency Analysis module.
• Dependency Analysis produces data/output that is fed into the Pragma Injector (if necessary) to modify the code for safer parallel execution.
• The Dispatcher module receives profiling metrics (possibly from previous runs logged in the logs directory) and decides execution strategy (Normal/CPU/GPU).
• Outputs and performance logs are generated and stored in the logs/ directory for later inspection or visualization.
• The Build process (controlled by the Makefile) compiles these modules into the binaries shown in the build/ directory, and execution results are generated accordingly.
c. Architectural Patterns and Design Principles:
• Layered Design: Separation of concerns between code analysis (dependency_checker), transformation (pragma_injector), and dynamic execution (dispatcher).
• Modular Components: Each module exists as a distinct component in the file tree with clear responsibilities.
• Runtime Decision-Making: The dynamic dispatch mechanism makes decisions based on runtime profiling data.
• Integration with External Tools: Use of open-source libraries and external utilities that integrate with the main components.
d. Relevant Technologies and Frameworks:
• C++ as the primary programming language.
• OpenMP (and its target offloading for GPU support) for parallelization.
• Profiling tools such as Valgrind and gprof2dot.
• Build management via Makefiles.
• Visualization tools like Graphviz to render dependency graphs.