Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
783653c
feat: sequential convolution
RodionovMaxim05 Mar 19, 2025
f0da9f9
feat: new filters and better output
RodionovMaxim05 Mar 20, 2025
0c7779c
tests: add unit tests
RodionovMaxim05 Mar 20, 2025
a141781
refactor: code improvement
RodionovMaxim05 Mar 27, 2025
d634e5c
test: refactor tests
RodionovMaxim05 Mar 27, 2025
bda79d8
ci: add linter and formatter
RodionovMaxim05 Mar 27, 2025
bbfc842
feat: add split image into parts
RodionovMaxim05 Mar 28, 2025
8e9839f
chore: improve usage, add scripts
RodionovMaxim05 Apr 3, 2025
df781d5
test: add benchmark
RodionovMaxim05 Apr 4, 2025
f38680a
test: add perf benchmark
RodionovMaxim05 Apr 4, 2025
6add049
test: add benchmark for another image
RodionovMaxim05 Apr 5, 2025
f332d24
docs: update README
RodionovMaxim05 Apr 5, 2025
aeed502
refactor: move 'stb_image' to root of project, change 'get_time_in_se…
RodionovMaxim05 Apr 9, 2025
2138a1b
refactor: 'main.c' and 'test_main.c'
RodionovMaxim05 Apr 9, 2025
564b126
docs: add documentation
RodionovMaxim05 Apr 9, 2025
1abfccf
feat: add py requirements.txt
RodionovMaxim05 Apr 9, 2025
dbc7264
docs: update documentation
RodionovMaxim05 Apr 10, 2025
64a9fa4
tests: update benchmarks results
RodionovMaxim05 Apr 11, 2025
77527c4
docs: add analysis of benchmark results
RodionovMaxim05 Apr 11, 2025
6c20cb4
docs: update analysis
RodionovMaxim05 Apr 14, 2025
d344d1b
docs: improve Readme, add debug and release build
RodionovMaxim05 Apr 17, 2025
7a65aeb
tests: add composition tests
RodionovMaxim05 Apr 17, 2025
f40c05a
tests: add benchmark for filter composition
RodionovMaxim05 Apr 18, 2025
390831e
tests: update benchmark results
RodionovMaxim05 Apr 18, 2025
8195fdb
docs: add analysis of sequential application of filters and their com…
RodionovMaxim05 Apr 18, 2025
1fc4308
chore: minor corrections
RodionovMaxim05 Apr 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BasedOnStyle: LLVM
IndentWidth: 4
UseTab: Always
TabWidth: 4
ColumnLimit: 85
IndentCaseLabels: true
IncludeBlocks: Preserve
InsertNewlineAtEOF: true
22 changes: 22 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Checks: >
-*,
modernize-*,
performance-*,
readability-*,
bugprone-*,
-readability-isolate-declaration,
-modernize-macro-to-enum

WarningsAsErrors: '*'

CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: 65
- key: bugprone-easily-swappable-parameters.MinimumLength
value: 4
- key: readability-identifier-length.IgnoredLoopCounterNames
value: '^(i|j|k|x|y)$'
- key: readability-identifier-length.MinimumVariableNameLength
value: 2

HeaderFilterRegex: '^(?!.*stb_image).*'
30 changes: 30 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI Pipeline

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Dependencies
run: |
sudo apt update
sudo apt-get install -y clang-format clang-tidy libcmocka-dev

- name: Build
run: ./scripts/build.sh

- name: Check Code Formatting
run: ./scripts/check_format.sh

- name: Run Static Analysis
run: ./scripts/run_clang_tidy.sh

- name: Test
run: ./scripts/test.sh
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,11 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

.vscode/
.venv/
__pycache__
build
pics/
*_cat.bmp
*_monkey.bmp
156 changes: 156 additions & 0 deletions Analysis_of_benchmark_results.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.10)

project(image-convolution LANGUAGES C)

set(CMAKE_C_STANDARD 11)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")

add_subdirectory(src)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")

find_package(CMocka CONFIG)
if (CMocka_FOUND)
include(AddCMockaTest)
include(AddMockedTest)
add_subdirectory(tests)
enable_testing()
endif(CMocka_FOUND)
94 changes: 93 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,93 @@
# image-convolution
[//]: # (Project readme template from https://github.com/othneildrew/Best-README-Template/)
<a name="readme-top"></a>

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)


<h1 align="left">Image-convolution</h1>

## Description

Image-convolution is an image processing application that applies various convolution filters to images. It supports both sequential and parallel execution modes with different workload distribution strategies. The application is designed for benchmarking and comparing different parallelization approaches for image processing algorithms.

## Usage
Basic Command:
```bash
./build/src/image-convolution <image_path> <filter_name> --mode=<mode> [--thread=<num>]
```
### Options
| Parameter | Description | Required |
|--------------------|---------------------------------------------------------------------|----------|
| `<image_path>` | Path to input image or `--default-image` (predefined default image) | Yes |
| `<filter_name>` | Filter to apply (see [Available Filters](#available-filters)) | Yes |
| `--mode=<mode>` | Execution mode: `seq`, `pixel`, `row`, `column`, `block` | Yes |
| `--thread=<num>` | Number of threads (for parallel modes) | No* |

*Required for all modes except seq

### Available Filters
| Name | Description | Kernel Size |
|-----------|--------------------------------------------------------|-------------|
| `id` | Identity filter (no effect) | 3x3 |
| `fbl` | Fast blur filter | 3x3 |
| `bl` | Standard blur filter | 5x5 |
| `gbl` | Gaussian blur filter | 5x5 |
| `mbl` | Motion blur filter | 9x9 |
| `ed` | Edge detection filter | 3x3 |
| `em` | Emboss filter | 5x5 |
| `bl+gbl` | Composition of Standard blur and Gaussian blur filters | 9x9 |
| `fbl+mbl` | Composition of Fast blur and Motion blur filters | 11x11 |

### Examples
1) Sequential processing:
```bash
./build/src/image-convolution images/cat.bmp bl --mode=seq
```
2) Parallel processing (4 threads):
```bash
./build/src/image-convolution images/cat.bmp gbl --mode=block --thread=4
```

## Build
To build the project:
```bash
./scripts/build.sh --release
```

## Testing
The project includes three types of tests:
1) Unit tests - verify core functionality:
```bash
./scripts/test.sh
```
2) Performance benchmarks - measure execution times for different filters and modes:
```bash
./scripts/time_benchmark.sh <image_name>
```
3) Cache performance analysis - analyze cache behavior using `perf`:
```bash
./scripts/perf.sh <image_name>
```

## Prerequisites for Benchmarks (`Performance benchmarks` and `Cache performance analysis`)
Before running benchmarks, you need to set up a Python virtual environment and install dependencies:
1. Create a Python virtual environment:
```bash
python3 -m venv .venv
```
2. Activate the virtual environment:
```bash
source .venv/bin/activate
```
3. Install required dependencies:
```bash
pip install -r requirements.txt
```
Note: The image for benchmarks must be in the 'images' directory

## License

Distributed under the [MIT License](https://choosealicense.com/licenses/mit/). See [`LICENSE`](LICENSE) for more
information.

<p align="right">(<a href="#readme-top">back to top</a>)</p>
143 changes: 143 additions & 0 deletions cmake/Modules/AddCMockaTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#
# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
# Copyright (c) 2007-2018 Andreas Schneider <asn@cryptomilk.org>
# Copyright (c) 2018 Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#.rst:
# AddCMockaTest
# -------------
#
# This file provides a function to add a test
#
# Functions provided
# ------------------
#
# ::
#
# add_cmocka_test(target_name
# SOURCES src1 src2 ... srcN
# [COMPILE_OPTIONS opt1 opt2 ... optN]
# [LINK_LIBRARIES lib1 lib2 ... libN]
# [LINK_OPTIONS lopt1 lop2 .. loptN]
# )
#
# ``target_name``:
# Required, expects the name of the test which will be used to define a target
#
# ``SOURCES``:
# Required, expects one or more source files names
#
# ``COMPILE_OPTIONS``:
# Optional, expects one or more options to be passed to the compiler
#
# ``LINK_LIBRARIES``:
# Optional, expects one or more libraries to be linked with the test
# executable.
#
# ``LINK_OPTIONS``:
# Optional, expects one or more options to be passed to the linker
#
#
# Example:
#
# .. code-block:: cmake
#
# add_cmocka_test(my_test
# SOURCES my_test.c other_source.c
# COMPILE_OPTIONS -g -Wall
# LINK_LIBRARIES mylib
# LINK_OPTIONS -Wl,--enable-syscall-fixup
# )
#
# Where ``my_test`` is the name of the test, ``my_test.c`` and
# ``other_source.c`` are sources for the binary, ``-g -Wall`` are compiler
# options to be used, ``mylib`` is a target of a library to be linked, and
# ``-Wl,--enable-syscall-fixup`` is an option passed to the linker.
#

enable_testing()
include(CTest)

if (CMAKE_CROSSCOMPILING)
if (WIN32)
find_program(WINE_EXECUTABLE
NAMES wine)
set(TARGET_SYSTEM_EMULATOR ${WINE_EXECUTABLE} CACHE INTERNAL "")
endif()
endif()

function(ADD_CMOCKA_TEST _TARGET_NAME)

set(one_value_arguments
)

set(multi_value_arguments
SOURCES
COMPILE_OPTIONS
COMPILE_DEFINITION
LINK_LIBRARIES
LINK_OPTIONS
)

cmake_parse_arguments(_add_cmocka_test
""
"${one_value_arguments}"
"${multi_value_arguments}"
${ARGN}
)

if (NOT DEFINED _add_cmocka_test_SOURCES)
message(FATAL_ERROR "No sources provided for target ${_TARGET_NAME}")
endif()

add_executable(${_TARGET_NAME} ${_add_cmocka_test_SOURCES})

if (DEFINED _add_cmocka_test_COMPILE_OPTIONS)
target_compile_options(${_TARGET_NAME}
PRIVATE ${_add_cmocka_test_COMPILE_OPTIONS}
)
endif()

if (DEFINED _add_cmocka_test_LINK_LIBRARIES)
target_link_libraries(${_TARGET_NAME}
PRIVATE ${_add_cmocka_test_LINK_LIBRARIES}
)
endif()

if (DEFINED _add_cmocka_test_LINK_OPTIONS)
set_target_properties(${_TARGET_NAME}
PROPERTIES LINK_FLAGS
${_add_cmocka_test_LINK_OPTIONS}
)
endif()

add_test(${_TARGET_NAME}
${TARGET_SYSTEM_EMULATOR} ${_TARGET_NAME}
)

endfunction (ADD_CMOCKA_TEST)
Loading