# prukngan/convolution-2024-ssitw architecture

> Architecture diagram of the GitHub repository prukngan/convolution-2024-ssitw, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prukngan/convolution-2024-ssitw
- Repository: https://github.com/prukngan/convolution-2024-ssitw

## Overview

This project is a computational assignment focused on implementing a discrete 1D convolution in C, with both sequential and OpenMP-based parallel versions. The goal is to maintain the same convolution algorithm while adding parallelization only where necessary. The provided files hint at a very focused, algorithm-centric implementation supported by a simple GitHub Classroom autograding workflow.

##### Project Type and Purpose
- This is a single-program, C-based computational assignment aimed at demonstrating parallelization using OpenMP. It implements a discrete 1D convolution (akin to numpy.convolve(A, F, mode='valid')).
- The core aim is to compare sequential and parallel implementations, with a focus on performance gains under multithreading.

##### Main Components
- Input Processing: Illustrate the component that reads the input data. Inputs include an initial line specifying the dimensions (NA and NF), followed by the array elements for data (A) and filter (F). Note the variety of test input files provided (input_demo.txt, input_easy1.txt, etc.).
- Parallelization Module: Emphasize the modifications that enable parallel execution via OpenMP. Show how the same convolution algorithm is adapted – by inserting parallel for-loops, managing thread scheduling, and ensuring that the core algorithm remains intact.
- Output Generation: Show where and how the convolution result is output (as reflected by provided output files like output_demo.txt and output_easy1.txt).
- Testing/Validation: Display the role of the test case generator (via gen_case.py) and the various input/output file pairs that validate the correctness of both sequential and parallel versions.
- CI/Autograding Pipeline: Represent the GitHub workflows (.github/workflows/classroom.yml) that support continuous integration or autograding. This component automates the evaluation of the sequential version (with additional context provided via the README).

##### Relationships and Data Flow
- From Input Processing, branch into the Convolution Algorithm block which itself splits into two paths: one for running the sequential process and one for executing the OpenMP-parallel process.
- Both paths converge toward Output Generation where the computed convolution is written out.

##### Architectural Patterns and Key Technologies
- A “fork” of execution: the same underlying algorithm is executed in two versions. This reflects a key design principle where an algorithm’s core logic remains unchanged, only the execution context changes.
- Simple file-driven testing and validation mechanism as an aspect of continuous feedback used in classroom assignments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    CI_Autograding["CI/Autograding Pipeline"]:::ci
    Test_Case_Generator["Test Case Generator (gen_case.py)"]:::testing
    Input_Files["Input Files (input_demo.txt, input_easy1.txt, ...)"]:::io
    Input_Processor["Input Processor"]:::computation
    Sequential["Sequential Convolution Module"]:::computation
    Parallel["Parallel Convolution Module (OpenMP)"]:::parallel
    Output_Generator["Output Generator"]:::io

    CI_Autograding -->|"triggers_tests"| Test_Case_Generator
    Test_Case_Generator -->|"produces_test_inputs"| Input_Files
    Input_Files -->|"reads_input"| Input_Processor
    Input_Processor -->|"executes_algorithm_sequentially"| Sequential
    Input_Processor -->|"executes_algorithm_in_parallel"| Parallel
    Sequential -->|"writes_output"| Output_Generator
    Parallel -->|"writes_output"| Output_Generator

    click Input_Processor "https://github.com/prukngan/convolution-2024-ssitw/blob/master/conv_template.c"
    click Sequential "https://github.com/prukngan/convolution-2024-ssitw/blob/master/conv_template.c"
    click Parallel "https://github.com/prukngan/convolution-2024-ssitw/blob/master/conv_template.c"
    click Output_Generator "https://github.com/prukngan/convolution-2024-ssitw/blob/master/conv_template.c"
    click Test_Case_Generator "https://github.com/prukngan/convolution-2024-ssitw/blob/master/gen_case.py"
    click CI_Autograding "https://github.com/prukngan/convolution-2024-ssitw/blob/master/.github/workflows/classroom.yml"

    classDef computation fill:#f9f,stroke:#333,stroke-width:2px;
    classDef testing fill:#9f9,stroke:#333,stroke-width:2px;
    classDef ci fill:#9ff,stroke:#333,stroke-width:2px;
    classDef io fill:#ff9,stroke:#333,stroke-width:2px;
    classDef parallel fill:#ffb3b3,stroke:#333,stroke-width:2px;
```
