{"id":19197397,"url":"https://github.com/tanvirahmedkhan74/DynApex","last_synced_at":"2025-04-20T10:32:35.640Z","repository":{"id":261488455,"uuid":"878024485","full_name":"tanvirahmedkhan74/DynApex","owner":"tanvirahmedkhan74","description":"Dynamic Analysis and Execution Profiling for Extreme Parallelization","archived":false,"fork":false,"pushed_at":"2024-12-29T05:09:50.000Z","size":4241,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T07:11:15.271Z","etag":null,"topics":["cpp","hpc","multithreading","openmp","parallel-programming"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tanvirahmedkhan74.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-24T16:38:24.000Z","updated_at":"2024-12-29T05:09:54.000Z","dependencies_parsed_at":"2024-12-12T16:01:09.378Z","dependency_job_id":null,"html_url":"https://github.com/tanvirahmedkhan74/DynApex","commit_stats":null,"previous_names":["tanvirahmedkhan74/hybrid-cpu-gpu-accelerated-query-processing-for-dynamic-dsa","tanvirahmedkhan74/dynapex"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanvirahmedkhan74%2FDynApex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanvirahmedkhan74%2FDynApex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanvirahmedkhan74%2FDynApex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanvirahmedkhan74%2FDynApex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tanvirahmedkhan74","download_url":"https://codeload.github.com/tanvirahmedkhan74/DynApex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249881792,"owners_count":21339538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","hpc","multithreading","openmp","parallel-programming"],"created_at":"2024-11-09T12:16:37.882Z","updated_at":"2025-04-20T10:32:35.617Z","avatar_url":"https://github.com/tanvirahmedkhan74.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ~ DynApex ~\n\n#### **Table of Contents**\n\n1.  [DynApex: Dynamic Dependency Analysis and Execution Profiling for Parallelization](#dynapex-dynamic-dependency-analysis-and-execution-profiling-for-parallelization)\n2.  [Key Features](#key-features)\n3.  [System Architecture](#system-architecture)\n    *   [Directory Hierarchy](#directory-hierarchy)\n4.  [Package Installation on Ubuntu](#package-installation-on-ubuntu)\n5.  [Build and Run](#build-and-run)\n6.  [Example Execution Results](#example-execution-results)\n7.  [Limitations](#limitations)\n8.  [Future Improvements](#future-improvements)\n\n## DynApex: Dynamic Dependency Analysis and Execution Profiling for Parallelization\n\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![Build Status](https://img.shields.io/badge/Build-Passing-brightgreen.svg)](BUILD_STATUS)\n\n**DynApex** is a sophisticated tool designed for automated source code parallelization. By employing dynamic analysis and dependency checking, DynApex identifies opportunities for parallel execution and intelligently dispatches tasks to either the CPU or GPU. This system emphasizes peak performance by making runtime decisions informed by profiling data, thereby optimizing execution based on the specific characteristics of the code and the available hardware.\n\n## Key Features\n\n*   **Advanced Data Dependency Analysis**: Utilizes a robust algorithm to meticulously analyze C++ code, ensuring that only safe and parallelizable sections are targeted. This analysis prevents race conditions and maintains data integrity during parallel execution.\n*   **Intelligent Dynamic Dispatch**: Leverages profiling data to dynamically select the most suitable execution platform—either the CPU or GPU—maximizing performance based on the real-time behavior of the program.\n*   **Comprehensive Profiling and Visualization**: Provides detailed performance profiles and generates dependency graphs, which are crucial for understanding execution bottlenecks and dependency structures.\n*   **OpenMP Parallelization**: Implements parallel processing on the CPU through seamless integration with OpenMP, a widely adopted standard for shared-memory parallel programming. *(Note: GPU support currently uses OpenMP target offloading but is not fully optimized for full GPU frameworks like CUDA or OpenCL.)*\n*   **Flexible Execution Modes**: Supports multiple execution modes (Normal, CPU, and GPU) to allow for comparison and performance analysis of the impact of parallelization strategies.\n\n## System Architecture\n\nThe DynApex project is structured into the following directory layout:\n### Directory Hierarchy\n\n```\ndynamic_dispatcher/\n├── include/       // Header files\n│   └── ...\n├── src/          // Source code\n│   ├── main.cpp    // Main program\n│   ├── dependency_checker.cpp // Dependency analysis\n│   ├── pragma_injector.cpp // OpenMP pragma injection\n│   └── dispatcher.cpp       // Dynamic dispatcher\n├── build/        // Compiled binaries\n├── logs/         // Profiling logs and graphs\n└── Makefile      // Build instructions\n```\n\n## **Package Installation on Ubuntu**\n\n1.  **Update Package Lists:**\n\n    ```bash\n    sudo apt update\n    ```\n\n2.  **Install Essential Build Tools:**\n    ```bash\n    sudo apt install build-essential\n    ```\n\n3.  **Install g++ Compiler (with OpenMP support):**\n    ```bash\n    sudo apt install g++\n    ```\n\n4.  **Install GNU Make:**\n    ```bash\n    sudo apt install make\n    ```\n\n5.  **Install Valgrind (for profiling):**\n\n    ```bash\n    sudo apt install valgrind\n    ```\n\n6.  **Install Graphviz (for dependency graph visualization):**\n\n    ```bash\n    sudo apt install graphviz\n    ```\n\n7.  **Install `gprof2dot` (for call graph generation):**\n\n    ```bash\n    sudo pip install gprof2dot\n    ```\n8.  **Install NVIDIA Drivers and CUDA Toolkit (if you intend to utilize GPU):**\n    *   First, verify that you have a compatible NVIDIA GPU and that the appropriate drivers are not already installed:\n        ```bash\n         lspci | grep -i nvidia\n        ```\n    *   If no output from the command above, it is highly probable that NVIDIA drivers are not installed.\n    *   Install the NVIDIA driver with the recommended version.\n        ```bash\n        sudo apt install nvidia-driver-\u003cversion\u003e\n        ```\n         (replace `\u003cversion\u003e` with the recommended driver version of your NVIDIA GPU)\n        *You can also use `ubuntu-drivers devices` to list your GPU's available driver options*\n    *   Install the CUDA Toolkit. Download the installer from NVIDIA's website ([https://developer.nvidia.com/cuda-downloads](https://developer.nvidia.com/cuda-downloads))\n    *  Follow NVIDIA's installation steps for your specific toolkit version\n    *   Alternatively, install using:\n      ```bash\n        sudo apt install nvidia-cuda-toolkit\n      ```\n\n9.  **Verify NVIDIA Installation:**\n     *  Verify that you have the installation of `nvidia-smi` working properly\n      ```bash\n         nvidia-smi\n      ```\n     * If this does not work, reboot the system.\n\n10. **Check for OpenMP support (after installing g++):**\n\n    *   Create a test file (e.g., `test_omp.cpp`) with the following content:\n        ```cpp\n        #include \u003ciostream\u003e\n        #include \u003comp.h\u003e\n\n        int main() {\n            #pragma omp parallel\n            {\n                std::cout \u003c\u003c \"Hello from thread \" \u003c\u003c omp_get_thread_num() \u003c\u003c std::endl;\n            }\n            return 0;\n        }\n        ```\n    *   Compile and run the test:\n        ```bash\n        g++ -fopenmp test_omp.cpp -o test_omp\n        ./test_omp\n        ```\n        *   If you see output from multiple threads (e.g., \"Hello from thread 0,\" \"Hello from thread 1,\" etc.), OpenMP is working correctly. If you only see \"Hello from thread 0\", OpenMP is not enabled, try re-installing `g++`.\n\n**Important Notes:**\n\n*   **CUDA Version**: Ensure that the CUDA toolkit version you install is compatible with your NVIDIA driver.\n*   **NVIDIA Drivers:** Ensure the NVIDIA drivers are correctly installed and working; otherwise, GPU usage will not be possible. You may need to install them separately from the CUDA toolkit.\n*   **`nvidia-smi`:** Verify that you can run `nvidia-smi` to check that your drivers and GPU are working properly. It will also show the CUDA version in the output.\n*  **C++ with OpenMP:** If needed, you can include this flag to check if OpenMP flags are working, using `g++ -fopenmp -v`.\n*   **Alternatives**: If `apt` does not have the latest CUDA version, you will have to follow NVIDIA's instructions which typically involves adding their repository and then installing via `apt`.\n*   **Test Environment:** Consider testing the installation with NVIDIA's samples.\n*   **Permissions:** Depending on the NVIDIA installation, you may have to reboot the system.\n* **Troubleshooting**: If there are issues with the installation, check for driver and CUDA errors; check the installation documentation for the drivers, and ensure that you have installed the correct versions.\n*  **OpenMP**: Make sure the test program provided to test OpenMP compiles and runs correctly. If not, there may be a problem with `g++` and OpenMP, make sure you have installed `g++` with OpenMP support, and if there are still problems, consult online forums for possible solutions.\n\n\n## Build and Run\n\n### Compile Normally:\n\nRun the program without profiling:\n\n```bash\nmake\nmake run-dispatcher \n```\n\n### Profile Dispatcher:\n\nRecompile with profiling (`-pg`), run, and generate a dependency graph:\n\n```bash\nmake profile-dispatcher MODE=n \n```\n(Replace `n` with `c` for CPU-optimized or `g` for GPU-optimized mode).\n\n\n### Compare All Modes:\n\nAutomates profiling and graph generation for all modes:\n\n```bash\nmake compare\n```\n\n### Clean Project:\n\nRemove binaries, logs, and temporary files:\n\n```bash\nmake clean\n```\n\nOkay, here's the concise and smaller version of the example log output and limitations, suitable for a README file:\n\n## **Example Execution Results**\n\n```\n------------------------------------------------------\n|           DynApex Results                         |\n------------------------------------------------------\n| Mode: Normal, Time: 6.40s                         |\n------------------------------------------------------\n| Mode: CPU:                                        |\n| Time: 4.68s                                       |\n| Actual Speedup: 1.37                              |\n| Calculated Speedup (Amdahl's): 2.11               |\n------------------------------------------------------\n| Mode: GPU                                         |\n| Time: 2.75s                                       |\n| Actual Speedup: 2.33                              |          \n| Calculated Speedup (Amdahl's): 3.26               |\n------------------------------------------------------\n```\n\n**Key:**\n\n*   `Mode`: Execution mode (Normal, CPU, GPU).\n*   `Time`: Execution time in seconds.\n*   `Actual Speedup`:  Speedup vs. Normal mode.\n*   `Calculated Speedup (Amdahl's)`: Theoretical speedup.\n\n## **Limitations**\n\n*   **Dependency Analysis**: Limited handling of complex dependencies (inter-procedural, advanced array indexing).\n*  **GPU Support**: Not fully optimized for GPU utilization, memory management, or full CUDA/OpenCL usage.\n*   **Auto-Tuning**: No dynamic tuning of parallelization parameters (e.g. threads), or auto detection of parallelizable portion of the code.\n*   **Loop Resolution**: Cannot automatically resolve loop-carried dependencies (e.g. loop transformations).\n*   **Static Analysis**: Incomplete static analysis might miss runtime dependencies.\n*   **Complexity**: May struggle with very large, complex code.\n*   **General Purpose**: System is designed for a specific program and not a generic one.\n\n## **Future Improvements**\n\n-   [x] **Enhanced GPU Support**: Full integration with CUDA or OpenCL for optimal GPU performance.\n-   [ ] **Automatic Dependency Resolution**: Ability to automatically remove or resolve detected dependencies via loop transformations and data restructuring (`--rd` flag).\n-   [ ] **Advanced Profiling Tools**: Implementation of more sophisticated techniques for analyzing and visualizing performance data.\n-   [ ] **Improved Auto-Tuning**: Incorporating auto-tuning mechanisms to dynamically adjust parallelization parameters based on system characteristics.\n-   [ ] **Inter-Procedural Dependency Analysis**: Extending the dependency analysis to recognize inter-procedural dependencies for more effective parallelization.\n-   [ ] **Complex Array Access Handling**: Handling of complex array access patterns in dependency checker.\n-   [ ] **General Purpose**: Enhance the tool so that it works for any c++ program.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanvirahmedkhan74%2FDynApex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftanvirahmedkhan74%2FDynApex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanvirahmedkhan74%2FDynApex/lists"}