# archembaud/ncku-parallel-gpu architecture

> Architecture diagram of the GitHub repository archembaud/ncku-parallel-gpu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/archembaud/ncku-parallel-gpu
- Repository: https://github.com/archembaud/ncku-parallel-gpu

## Overview

##### Project type and purpose
- This is not a single monolithic application but a teaching repository for parallel and GPU computing.
- It contains multiple small C/CUDA/MATLAB/Python examples organized into categories:
- Basic C introduction codes
- OpenMP examples
- CUDA GPU examples
- SIMD vectorization examples (SSE/AVX)
- Mathematics & engineering algorithms (MATLAB)
- Tutorials & case-study code (e.g., 3D heat transfer)

##### File structure
- Top-level files: README.md, ALGORITHMS.md, *_README.md for each tech.
- Category directories named “0_Simple_Hello_World” through “9_OMP_…”, “A_…”, “E_…”, “G_…”, “Tutorials/…”.
- Each example has its own makefile and source files (.c/.cu/.m/.py).
- Build artifacts are produced by make (gcc or nvcc); results are CSV or plots.
- No centralized server or database—focus is local compile/run workflow.

##### README for additional insights
- The README describes how to cd into each folder, use make, run executables, inspect with valgrind, objdump, matplotlib, or MATLAB.
- External toolchain: Linux, gcc, nvcc, OpenMP, Python/matplotlib, MATLAB, VS Code with SSH.

a. Main components
- Developer environment (local/remote Linux machine, VS Code, scp)
- Source repository (categories of code examples)
- Build system (Makefiles invoking gcc or nvcc)
- Execution environments:
- CPU runtime (compiled C/OpenMP binaries)
- GPU runtime (CUDA binaries on NVIDIA GPU)
- MATLAB runtime for algorithms (.m files)
- Python runtime for plotting (plot_results.py)
- Artifacts: compiled executables, object files, results.csv, plots
b. Relationships & interactions
- Developer edits code in VS Code (ssh) → pushes to local repo
- make invokes toolchain → compiles sources → links into executables
- Executables run on CPU or dispatch kernels to GPU via CUDA/OpenMP
- Data produced (CSV, console output) flows into Python/MATLAB for visualization
c. Architectural patterns & design principles
- Modular folder-per-example structure for isolation and clarity
- Use of Makefile abstraction to standardize build/test/clean workflows
- Separation of concerns: compute kernels vs. I/O vs. visualization
- Hierarchical grouping by technology and complexity
d. Key technologies/frameworks
- C with gcc
- OpenMP pragma directives
- CUDA (nvcc compiler, .cu/.h for GPU kernels)
- SIMD intrinsics (SSE/AVX)
- MATLAB scripts for algorithms
- Python + matplotlib for plotting
- Makefiles as build orchestrators

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Environment
    DEV["Developer Environment (VS Code / SSH)"]:::dev

    %% Source Repository
    subgraph "Source Repository" 
        direction TB
        REPO_ROOT["Root README & Docs"]:::repo
        subgraph "Basic C Introduction Codes"
            direction TB
            C0["0_Simple_Hello_World/"]:::repo
            C1["1_Hello_World/"]:::repo
            C2["2_Simple_Function/"]:::repo
            C3["3_Stack_Arrays/"]:::repo
            C4["4_Heap_Arrays/"]:::repo
            C5["5_Arrays_Functions/"]:::repo
            C6["6_Writing_Files/"]:::repo
        end
        subgraph "OpenMP Examples"
            direction TB
            O7["7_OMP_Hello_World/"]:::cpu
            O8["8_OMP_Hello_Again/"]:::cpu
            O9["9_OMP_Vector_Multiply_Constant/"]:::cpu
            O10["10_OMP_For_demo/"]:::cpu
            O11["11_OMP_Dot_Product/"]:::cpu
            O12["12_OMP_Critical_Single/"]:::cpu
        end
        subgraph "CUDA GPU Examples"
            direction TB
            G1["G_1_Memory/"]:::gpu
            G2["G_2_Streams/"]:::gpu
            G3["G_3_Shared_Memory/"]:::gpu
            G4["G_4_Reduction/"]:::gpu
            G5["G_5_Pinned_Memory/"]:::gpu
            G6["G_6_Device_Functions/"]:::gpu
        end
        subgraph "3D Heat-Transfer Case Study"
            direction TB
            CHT["C_1_3D_HT/"]:::gpu
        end
        subgraph "SIMD Vectorization Examples"
            direction TB
            SSE["E_1_SSE_Addition/"]:::cpu
            AVX["E_2_AVX_Addition/"]:::cpu
        end
        subgraph "MATLAB Algorithms"
            direction TB
            MAT1["A_1_CG_Method/"]:::vis
            MAT2["A_2_1D_FTCS/"]:::vis
            MAT3["A_3_Calc_Area/"]:::vis
            MAT4["A_4_2D_FTCS/"]:::vis
        end
        subgraph "Tutorial Bug-Hunt Exercises"
            direction TB
            T1["Tutorial_1_Bug_Hunt/"]:::repo
            T2["Tutorial_2_Bug_Hunt/"]:::repo
            T3["Tutorial_3_Bug_Hunt/"]:::repo
            T4["Tutorial_4_Bug_Hunt/"]:::repo
            T5["Tutorial_5_Bug_Hunt/"]:::repo
            T6["Tutorial_6_Bug_Hunt/"]:::repo
            T7["Tutorial_7_Bug_Hunt/"]:::repo
        end
    end

    %% Build System
    MAKE["Makefile Orchestration"]:::build

    %% Execution Environments
    CPU["CPU Runtime (gcc / OpenMP)"]:::cpu
    GPU["GPU Runtime (nvcc / CUDA)"]:::gpu
    MATLAB["MATLAB Runtime"]:::vis
    PY["Python Plotting (matplotlib)"]:::vis

    %% Artifacts
    EXE["Executables / Object Files"]:::build
    CSV["Results CSV"]:::build
    PLOTS["Plots / Visuals"]:::vis

    %% Flows
    DEV -->|"edits code"| REPO_ROOT
    REPO_ROOT -->|"contains examples"| C0
    C0 --> MAKE
    C1 --> MAKE
    C2 --> MAKE
    C3 --> MAKE
    C4 --> MAKE
    C5 --> MAKE
    C6 --> MAKE
    O7 --> MAKE
    O8 --> MAKE
    O9 --> MAKE
    O10 --> MAKE
    O11 --> MAKE
    O12 --> MAKE
    G1 --> MAKE
    G2 --> MAKE
    G3 --> MAKE
    G4 --> MAKE
    G5 --> MAKE
    G6 --> MAKE
    CHT --> MAKE
    SSE --> MAKE
    AVX --> MAKE
    MAT1 --> MAKE
    MAT2 --> MAKE
    MAT3 --> MAKE
    MAT4 --> MAKE
    T1 --> MAKE
    T2 --> MAKE
    T3 --> MAKE
    T4 --> MAKE
    T5 --> MAKE
    T6 --> MAKE
    T7 --> MAKE

    MAKE -->|"compile & link"| EXE
    EXE -->|"run on CPU"| CPU
    EXE -->|"run on GPU"| GPU
    CPU -->|"output data"| CSV
    GPU -->|"output data"| CSV
    CSV --> PY
    CSV --> MATLAB
    PY --> PLOTS
    MATLAB --> PLOTS

    %% Click Events
    click C0 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/0_Simple_Hello_World/"
    click C1 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/1_Hello_World/"
    click C2 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/2_Simple_Function/"
    click C3 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/3_Stack_Arrays/"
    click C4 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/4_Heap_Arrays/"
    click C5 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/5_Arrays_Functions/"
    click C6 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/6_Writing_Files/"
    click O7 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/7_OMP_Hello_World/"
    click O8 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/8_OMP_Hello_Again/"
    click O9 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/9_OMP_Vector_Multiply_Constant/"
    click O10 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/10_OMP_For_demo/"
    click O11 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/11_OMP_Dot_Product/"
    click O12 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/12_OMP_Critical_Single/"
    click G1 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/G_1_Memory/"
    click G2 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/G_2_Streams/"
    click G3 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/G_3_Shared_Memory/"
    click G4 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/G_4_Reduction/"
    click G5 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/G_5_Pinned_Memory/"
    click G6 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/G_6_Device_Functions/"
    click CHT "https://github.com/archembaud/ncku-parallel-gpu/tree/main/C_1_3D_HT/"
    click SSE "https://github.com/archembaud/ncku-parallel-gpu/tree/main/E_1_SSE_Addition/"
    click AVX "https://github.com/archembaud/ncku-parallel-gpu/tree/main/E_2_AVX_Addition/"
    click MAT1 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/A_1_CG_Method/"
    click MAT2 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/A_2_1D_FTCS/"
    click MAT3 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/A_3_Calc_Area/"
    click MAT4 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/A_4_2D_FTCS/"
    click T1 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/Tutorials/Tutorial_1_Bug_Hunt/"
    click T2 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/Tutorials/Tutorial_2_Bug_Hunt/"
    click T3 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/Tutorials/Tutorial_3_Bug_Hunt/"
    click T4 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/Tutorials/Tutorial_4_Bug_Hunt/"
    click T5 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/Tutorials/Tutorial_5_Bug_Hunt/"
    click T6 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/Tutorials/Tutorial_6_Bug_Hunt/"
    click T7 "https://github.com/archembaud/ncku-parallel-gpu/tree/main/Tutorials/Tutorial_7_Bug_Hunt/"

    %% Styles
    classDef dev fill:#f9f,stroke:#333,stroke-width:1px
    classDef repo fill:#ddd,stroke:#333,stroke-width:1px
    classDef build fill:#b19cd9,stroke:#333,stroke-width:1px
    classDef cpu fill:#add8e6,stroke:#333,stroke-width:1px
    classDef gpu fill:#ffa500,stroke:#333,stroke-width:1px
    classDef vis fill:#90ee90,stroke:#333,stroke-width:1px
```
