# nci900-training-organisation/intro-to-openmp architecture

> Architecture diagram of the GitHub repository nci900-training-organisation/intro-to-openmp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nci900-training-organisation/intro-to-openmp
- Repository: https://github.com/nci900-training-organisation/intro-to-openmp

## Overview

- Documentation & Visual Aids:
– README.md (project overview, explanation of OpenMP’s role in shared memory systems, explanations of parallel programming constructs)
– Applications folder (contains tutorial guides on specific applications such as π calculation, Mandelbrot fractal generation, and Cholesky factorization)

- Source Code & Exercises:
– The src directory hosts a range of C programs and one Python plotting script. Each file demonstrates a distinct OpenMP feature (e.g., openmp_parallel_region.c, openmp_reduction.c, openmp_tasks.c, etc.) and exercises that include race condition handling, false sharing issues, schedulling, and task-based computations.
– The Makefile in src is the build system for compiling these multiple modules.

- Execution & Deployment (Scripts):
– The scripts directory includes shell scripts (interactive.sh, job.sh, modules.sh) that might be used for job submission, module loading, and launching interactive sessions. These scripts support the run-time environment and could interface with cluster management or local execution.

- Development Environment:
– The .vscode folder hints at configured IDE settings for development.

##### Out Relationships and Data Flow
- Components in separate layers or modules. For example, create a “Documentation/Instruction” layer that feeds into an “Educational/Example Applications” layer that is built from the source code.
- Connection between the build system (Makefile) and the source-generated binaries. Then show that the scripts are responsible for running these binaries and setting environment variables (e.g., OMP_NUM_THREADS and OMP_DYNAMIC), which are critical to the OpenMP parallel execution model.

##### OpenMP Architectural Patterns
– Fork-Join Model: Represent the master thread forking into worker threads on encountering a parallel region.
– Worksharing Constructs: Show how loops are partitioned between threads (e.g. using #pragma omp for) and emphasize differences such as static vs. dynamic scheduling.
– Data Sharing & Synchronization: Indicate how constructs like “atomic”, “critical,” “barrier,” “nowait” are used to manage race conditions and synchronizations.

##### Technologies & Libraries
- That the projects rely on the OpenMP API for parallelization.
- Components where PAPI (Performance Application Programming Interface) is used to monitor performance—specifically in the file papi.c.
- If necessary, denote the use of standard C libraries for parallel programming with OpenMP directives, and note that one file is in Python (Mandelbrot-plot.py) which likely is used for visualization of computed data.

##### Final Assembly
- Branch out into the layers: Documentation (with README and figs) on one side, then into the Code Implementation (with src exercises, Makefile) and then into the Execution/Deployment (with scripts).
- Use annotated callouts to indicate where educational and technical content converge—such as in the sample applications (π calculation, Mandelbrot, Cholesky factorization) which are demonstrated both in the applications documentation and realized through the corresponding source files.
- Annotations for external tools (like lstopo for system architecture visualization and OMP environment variables) to tie the hands-on experiments with underlying hardware concepts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Tutorial on OpenMP Parallel Programming"]:::engine

    subgraph "Documentation & Visual Aids"
        D1["README.md"]:::documentation
        subgraph "Applications"
            App1["Cholesky"]:::documentation
            App2["Mandelbrot"]:::documentation
            App3["Pi"]:::documentation
        end
        D3["Figs"]:::documentation
    end

    subgraph "Source Code & Exercises"
        subgraph "Examples"
            EX1["openmp_parallel_region.c"]:::source
            EX2["openmp_reduction.c"]:::source
            EX3["openmp_tasks.c"]:::source
            EX4["openmp_barrier.c"]:::source
        end
        subgraph "Exercises"
            EXE1["exercise1.c"]:::source
            EXE2["exercise1_solution.c"]:::source
            EXE3["exercise2_solution.c"]:::source
            EXE4["exercise3.c"]:::source
            EXE5["exercise3_solution.c"]:::source
            EXE6["exercise4.c"]:::source
            EXE7["exercise4_solution.c"]:::source
            EXE8["exercise5.c"]:::source
            EXE9["exercise5_solution.c"]:::source
        end
        BS["Build System (Makefile)"]:::source
        PAPI["Performance Analysis (papi.c)"]:::source
        PY["Python Visualization (Mandelbrot-plot.py)"]:::source
        OMP["OpenMP Constructs: Fork-Join,Worksharing,Tasks,Sync"]:::engine
    end

    subgraph "Execution & Deployment"
        S1["interactive.sh"]:::execution
        S2["job.sh"]:::execution
        S3["modules.sh"]:::execution
    end

    DE["IDE Settings (.vscode)"]:::development

    A -->|"Guides"| D1
    A -->|"Sources"| BS
    A -->|"Executes"| S1
    A --> DE

    D1 -->|"Explains"| BS
    D1 -->|"Illustrates"| OMP
    D3 -->|"Visualizes"| OMP
    App1 -->|"Tutorial"| EXE1
    App2 -->|"Tutorial"| PY
    App3 -->|"Tutorial"| EXE2

    BS -->|"CompilesTo"| S1
    BS -->|"Utilizes"| PAPI
    BS -->|"Links"| PY

    %% Click Events for Documentation & Visual Aids
    click D1 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/README.md"
    click App1 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/applications/cholesky.md"
    click App2 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/applications/mandelbrot.md"
    click App3 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/applications/pi.md"
    click D3 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/figs/test.txt"

    %% Click Events for Source Code & Exercises - Examples
    click EX1 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/openmp_parallel_region.c"
    click EX2 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/openmp_reduction.c"
    click EX3 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/openmp_tasks.c"
    click EX4 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/openmp_barrier.c"

    %% Click Events for Source Code & Exercises - Exercises
    click EXE1 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/exercise1.c"
    click EXE2 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/exercise1_solution.c"
    click EXE3 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/exercise2_solution.c"
    click EXE4 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/exercise3.c"
    click EXE5 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/exercise3_solution.c"
    click EXE6 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/exercise4.c"
    click EXE7 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/exercise4_solution.c"
    click EXE8 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/exercise5.c"
    click EXE9 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/exercise5_solution.c"

    %% Click Events for Build System, Performance & Visualization
    click BS "https://github.com/nci900-training-organisation/intro-to-openmp/tree/main/src/Makefile"
    click PAPI "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/papi.c"
    click PY "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/src/Mandelbrot-plot.py"

    %% Click Events for Execution & Deployment Scripts
    click S1 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/scripts/interactive.sh"
    click S2 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/scripts/job.sh"
    click S3 "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/scripts/modules.sh"

    %% Click Event for Development Environment
    click DE "https://github.com/nci900-training-organisation/intro-to-openmp/blob/main/.vscode"

    classDef documentation fill:#ffcccc,stroke:#993300,stroke-width:2px;
    classDef source fill:#ccffcc,stroke:#006600,stroke-width:2px;
    classDef execution fill:#cce5ff,stroke:#003366,stroke-width:2px;
    classDef development fill:#ffffcc,stroke:#666600,stroke-width:2px;
    classDef engine fill:#f2d7ee,stroke:#8e44ad,stroke-width:2px;
```
