Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
1da040c
start the port of the GPU4S benchmark for the matrix_multiplication_b…
EmbeddedFrime Jun 4, 2026
4f4044c
fix the opencl-lib for matrix_multiplication_bench
EmbeddedFrime Jun 5, 2026
f2650cd
All framework working on pc CPU / CUDA / CUDA-opt / CUDA-lib / OpenCL…
EmbeddedFrime Jun 8, 2026
ecd787f
add chrono for android target for the android opencl lib benchmark
EmbeddedFrime Jun 11, 2026
3785cef
Compatible android avec toutes les API : openCL, openMP, cpu
EmbeddedFrime Jun 15, 2026
b88ba4b
sorting all the android file in one folder + enchanced the make to ha…
EmbeddedFrime Jun 16, 2026
1a79930
creation of the cmake : work with cpu
EmbeddedFrime Jun 16, 2026
549b7f7
cmake can now handle : opencl-lib opencl-opt and opencl
EmbeddedFrime Jun 16, 2026
851d369
add cmake support for cuda HIP and openMP
EmbeddedFrime Jun 18, 2026
0a333b9
add HIP compilation + clean some variable
EmbeddedFrime Jun 18, 2026
3fc1cc3
function blue print
EmbeddedFrime Jun 19, 2026
9993380
add libs dependancy verification and auto headers download
EmbeddedFrime Jun 19, 2026
804d98d
add shorcuts (all-)
EmbeddedFrime Jun 22, 2026
91d03e0
fix opencl_lib for android
EmbeddedFrime Jun 23, 2026
a439a6a
fix opencl lib for android + fix float16 (half) memory leaks
EmbeddedFrime Jun 23, 2026
9b584bc
gitignore update
EmbeddedFrime Jun 23, 2026
7551a3a
remove headers files
EmbeddedFrime Jun 23, 2026
4387dfd
add error check for matrix native & fp16 benchmark
EmbeddedFrime Jun 23, 2026
a800dfd
fix the chrono (host<=> device) for all the matrix mult benchmark
EmbeddedFrime Jun 23, 2026
64fedbc
fix the kernel.cl file
EmbeddedFrime Jun 23, 2026
ea095fb
fix bug on max_pooling_bench + improve some line + add the cmake + fi…
EmbeddedFrime Jun 25, 2026
41cba55
fix for max pooling bench: opencl for android + add cmake + hip
EmbeddedFrime Jun 25, 2026
241d3ed
add cmake support for memory bandwidth benchmark
EmbeddedFrime Jun 26, 2026
fc475b7
add cmake support for memory bandwidth benchmark
EmbeddedFrime Jun 26, 2026
a726a6c
fix for relu_bench : add android + cmake
EmbeddedFrime Jun 26, 2026
7be250f
fix: all the (void) hip message
EmbeddedFrime Jun 26, 2026
ffb2286
fix: all the (void) hip message
EmbeddedFrime Jun 26, 2026
55504d1
fix: hip (void) cast
EmbeddedFrime Jun 26, 2026
b1a39ca
fix softmax: cmake + opencl chronos and bug
EmbeddedFrime Jun 26, 2026
35b3f0b
fix makefile: add the fPIC flag + hip root + cuda arch = native
EmbeddedFrime Jun 26, 2026
0d5ed8a
add wavelet_transform bench : fix make file, new .cmake module to sp…
EmbeddedFrime Jun 26, 2026
19aabea
add wavelet_transform bench : fix make file, new .cmake module to sp…
EmbeddedFrime Jun 26, 2026
9982c8a
fix cifar_10: add cmake, fix hip loop unroll warning, fix cudnn openc…
EmbeddedFrime Jun 29, 2026
a6bbf93
FIX cifar_10_mutiple: fix lib_cpu relu_linear_kernel function
EmbeddedFrime Jun 29, 2026
5587926
fix all the benchmark_library.H + FIX cifar_10_multiple: add cmake, f…
EmbeddedFrime Jun 29, 2026
2a02fa6
FIX all lib_cpu : remove the multiplication by *1000 and add flaot di…
EmbeddedFrime Jun 30, 2026
c1d5de2
FIX convolution 2D: add cmake, fix cpu lib, fix cuda lib, add chrono …
EmbeddedFrime Jun 30, 2026
31dad88
FIX correlation 2d bench: add cmake, add chronos for android
EmbeddedFrime Jun 30, 2026
a374aab
fix fft2D fft windows and fir
EmbeddedFrime Jun 30, 2026
480fbfe
fix matrix_mult_fp16 : fix cuda-lib and cuda + fix benchmark_lib.h fo…
EmbeddedFrime Jul 1, 2026
88804e4
fix all the android clock for opencl for all benchmark
EmbeddedFrime Jul 1, 2026
38b0771
fix cmakefile for max pooling bench
EmbeddedFrime Jul 1, 2026
583a7f0
fix cmake benchmark
EmbeddedFrime Jul 1, 2026
084286d
fix = in the cmake
EmbeddedFrime Jul 2, 2026
aee3dd5
add license
EmbeddedFrime Jul 2, 2026
c24b344
starting to refactor the benchmark_lib
EmbeddedFrime Jul 2, 2026
d39af9d
start refactoring
EmbeddedFrime Jul 3, 2026
84a5bb7
update/refactoring all the benchmark lib :cifar_10,cifar10_multiple,c…
EmbeddedFrime Jul 3, 2026
77ec9ab
merge CLHT.sh refactoring all the benchmarking to centralized variable
EmbeddedFrime Jul 3, 2026
985f7b0
merge the prototype of function to the dedicated files
EmbeddedFrime Jul 16, 2026
6ab1caa
fix: create a common type kernel and normal type kernel for specefic …
EmbeddedFrime Jul 21, 2026
95ec116
fix GraficCommon
EmbeddedFrime Jul 21, 2026
047d15d
Merge pull request #1 from EmbeddedFrime/refactor-common
EmbeddedFrime Jul 21, 2026
b15efa0
add compatibility for android to fftw lib
EmbeddedFrime Jul 22, 2026
11f052c
add verif for FFTW
EmbeddedFrime Jul 22, 2026
e089ec1
add check for cudnn
EmbeddedFrime Jul 22, 2026
a1f5235
fix NSTREAMS only use in cifar_10_multiple
EmbeddedFrime Jul 22, 2026
c4ad013
Merge pull request #2 from EmbeddedFrime/update_FFT_lib
EmbeddedFrime Jul 22, 2026
b1b53de
remove vkFFT.h
EmbeddedFrime Jul 22, 2026
a58f6b0
Untrack common/extern directory
EmbeddedFrime Jul 22, 2026
5c761bd
clean the lib for repo
EmbeddedFrime Jul 22, 2026
b5221f3
add extern
EmbeddedFrime Jul 22, 2026
7401105
clean github repo
EmbeddedFrime Jul 22, 2026
1dcec93
change all the clock_gettime to the clock.h lib
EmbeddedFrime Jul 23, 2026
10884f3
add a cmake module to show the configuration of the benchmark
EmbeddedFrime Jul 23, 2026
cb7856d
fix the cpu clock
EmbeddedFrime Jul 24, 2026
95f4a69
add the option for clock profiling for all opengl file
EmbeddedFrime Jul 24, 2026
cdaa088
add cuda profiling
EmbeddedFrime Jul 24, 2026
1f79e0a
add cuda profiling
EmbeddedFrime Jul 24, 2026
4682cee
add hip profiling
EmbeddedFrime Jul 24, 2026
5d135e8
fix clock profiling cuda & hip
EmbeddedFrime Jul 24, 2026
055d06a
fix clock profiling cuda & hip
EmbeddedFrime Jul 24, 2026
28c53dd
add fft2D cpu and memory bandwith cpu
EmbeddedFrime Jul 24, 2026
337f56a
add unified memory for matrix mult
EmbeddedFrime Jul 27, 2026
7d0f62e
fix bug on benchmark
EmbeddedFrime Jul 29, 2026
be49273
V1 functionnal UMA memroy
EmbeddedFrime Aug 3, 2026
7a18151
fix opencl lib issue with malloc so we need to add buffer initiliazation
EmbeddedFrime Aug 3, 2026
35512bc
fix opencl lib issue with malloc so we need to add buffer initiliazation
EmbeddedFrime Aug 3, 2026
049f3e5
fix memory bench : cpu vérification
EmbeddedFrime Aug 3, 2026
34644d5
fix: no result error for cifar_10 it was error due to tolerance for c…
EmbeddedFrime Aug 4, 2026
3cf588e
fix softmax kernel for hip opt
EmbeddedFrime Aug 4, 2026
f1d3e40
FIX: cuda/hip opt ---> fix the mean matrices kernels
EmbeddedFrime Aug 4, 2026
da731bf
FIX result error fft 2D: fix tolerence is check due to huge 32 bit nu…
EmbeddedFrime Aug 4, 2026
5ab52f2
FIX FFT : fix tolerence for the lib
EmbeddedFrime Aug 4, 2026
9f6fa7c
FIX FFT windows : fix openmp implementation
EmbeddedFrime Aug 4, 2026
3925147
fix FIR cuda & hip : use int to not loose precision
EmbeddedFrime Aug 4, 2026
b1145c8
fix all the benchmark result error
EmbeddedFrime Aug 4, 2026
573195c
fix start common for opencl
EmbeddedFrime Aug 5, 2026
5c85349
refactor matrix mult opencl common
EmbeddedFrime Aug 5, 2026
c28e7f6
add all the common.h and .cpp file
EmbeddedFrime Aug 5, 2026
60d185d
refactor hip
EmbeddedFrime Aug 5, 2026
bf5cfb0
refactor all common framework matrix_mult
EmbeddedFrime Aug 5, 2026
f6f1c00
fix hip comment
EmbeddedFrime Aug 5, 2026
aac05ab
refactor cifar 10 bench
EmbeddedFrime Aug 5, 2026
ba65519
refactor opencl
EmbeddedFrime Aug 5, 2026
5c6d68b
fix refactor problem cifar10
EmbeddedFrime Aug 5, 2026
ccc4b6f
refactor cifar_10_multiple extract to common all framework
EmbeddedFrime Aug 5, 2026
0e52e8a
refactor convolution 2D all frameworks: extract common
EmbeddedFrime Aug 5, 2026
a692e58
refactor correlation 2D : all frameworks extract common
EmbeddedFrime Aug 5, 2026
5e1370d
start refactor fft
EmbeddedFrime Aug 5, 2026
75d650e
refactor fft
EmbeddedFrime Aug 5, 2026
2840ba3
start refactor fft window
EmbeddedFrime Aug 5, 2026
b49572c
refactor LRN bench: extract common + fix openmp for matrix mult
EmbeddedFrime Aug 6, 2026
e699b47
fix opencl float16 + refactor matrix mult fp16
EmbeddedFrime Aug 6, 2026
6ff41ac
refactor matrix mult tensor : extract the common
EmbeddedFrime Aug 6, 2026
1c70c04
refactor max pooling: extract common
EmbeddedFrime Aug 6, 2026
e27e9c9
refactor softmax: extract common
EmbeddedFrime Aug 6, 2026
222b909
refactor wavelet transform: extract common
EmbeddedFrime Aug 6, 2026
231311f
fix result error cuda lib
EmbeddedFrime Aug 6, 2026
a67d185
fix all result error that appears during refactoring
EmbeddedFrime Aug 6, 2026
2675dbb
Merge pull request #3 from EmbeddedFrime/refactor/framework-extract-c…
EmbeddedFrime Aug 6, 2026
c82731e
improve cuda clock profiling
EmbeddedFrime Aug 6, 2026
fea941b
change clock profilling for matrix mult
EmbeddedFrime Aug 6, 2026
a3f50db
keep useful comment
EmbeddedFrime Aug 7, 2026
ea41923
re add time variable in benchmark_common
EmbeddedFrime Aug 7, 2026
cd17651
fix all the main to have profiling clock in argument handler, fix mat…
EmbeddedFrime Aug 7, 2026
bbe8ca8
improve clock for hip file
EmbeddedFrime Aug 7, 2026
8ea7f1e
opencl fix clock profilling
EmbeddedFrime Aug 7, 2026
9ecba03
add verif during copy to host
EmbeddedFrime Aug 7, 2026
b02b983
add verif during copy to host for hip
EmbeddedFrime Aug 7, 2026
5fc331e
add verif during copy to host for opencl
EmbeddedFrime Aug 7, 2026
cd0dfe3
fix every help message to show profiling clock
EmbeddedFrime Aug 10, 2026
cdc0b21
fix profiling clock message variable
EmbeddedFrime Aug 10, 2026
4ea5b6b
fix profiling clock in main and remove it from cmake conf
EmbeddedFrime Aug 10, 2026
e9a4caf
add or fix in clean function hipfree and cudafree error check
EmbeddedFrime Aug 10, 2026
82b7b06
+doc
EmbeddedFrime Aug 10, 2026
125f6ec
Merge pull request #4 from EmbeddedFrime/feature/improve_clock
EmbeddedFrime Aug 10, 2026
8966655
fix comment in main
EmbeddedFrime Aug 10, 2026
485154c
FIX: FFT_2D opencl_LIB +correlation 2D opencl opt + matrix mutl openm…
EmbeddedFrime Aug 10, 2026
43d1487
UMA for matrix mult opencl
EmbeddedFrime Aug 11, 2026
52861af
rename common file inside framework
EmbeddedFrime Aug 11, 2026
6de109d
refactor main for relu + create a common for opencl UMA
EmbeddedFrime Aug 11, 2026
06db52b
add cl check for unmap and map fucntion
EmbeddedFrime Aug 12, 2026
4881a87
fix main.cpp cifar_10_mutiple
EmbeddedFrime Aug 12, 2026
057bcc7
first UMA for 2D FFT
EmbeddedFrime Aug 13, 2026
dee328b
implementation of UMA in FFT bench
EmbeddedFrime Aug 13, 2026
2d41e22
add UMA on fft windows bench
EmbeddedFrime Aug 13, 2026
3803ef5
small fix for previous UMA refactor
EmbeddedFrime Aug 13, 2026
0959099
fix kernel size for 2D convolution UMA
EmbeddedFrime Aug 13, 2026
528603a
add UMA for FIR bench
EmbeddedFrime Aug 13, 2026
a6767ff
add UMA ofr LRN bench
EmbeddedFrime Aug 13, 2026
9e24a5c
add float android uma for matrix mult fp16 bench
EmbeddedFrime Aug 13, 2026
70c8fe7
add android UMA for matrix mult tensor bench
EmbeddedFrime Aug 13, 2026
c7b0be1
add UMA for android
EmbeddedFrime Aug 13, 2026
4f9cb99
add androdi uma for android
EmbeddedFrime Aug 14, 2026
0670bfb
delete opencl lib (it was a buggy opt version) add uma for softmax
EmbeddedFrime Aug 14, 2026
dcc6062
add UMA for wavelet transform
EmbeddedFrime Aug 14, 2026
a1d18a7
small fix in previosu benchmark for android UMA
EmbeddedFrime Aug 14, 2026
34cdf31
fix android bug by using cifar_10 kernel code
EmbeddedFrime Aug 14, 2026
43afd09
add UMA for cifar_10 mutiple
EmbeddedFrime Aug 14, 2026
6e57a23
fix UMA for android
EmbeddedFrime Aug 14, 2026
98bb06c
add comment for uma function in main
EmbeddedFrime Aug 14, 2026
05f64b5
add comment for uma function in main
EmbeddedFrime Aug 14, 2026
057a8aa
add comment for uma function in .h
EmbeddedFrime Aug 14, 2026
713e587
improve comment for UMA
EmbeddedFrime Aug 17, 2026
53a1523
improve comment for opencl_common
EmbeddedFrime Aug 17, 2026
b175fde
Merge pull request #5 from EmbeddedFrime/feature/uma_android
EmbeddedFrime Aug 17, 2026
312bef9
create big cmake + fix the specefic cmakein order to be compatible wi…
EmbeddedFrime Aug 17, 2026
78ad293
delete build file
EmbeddedFrime Aug 17, 2026
0925a74
merge by delete opencl lib for softamx
EmbeddedFrime Aug 17, 2026
da4baf3
Merge pull request #6 from EmbeddedFrime/global-cmake
EmbeddedFrime Aug 17, 2026
4e6f8df
start new doc
EmbeddedFrime Aug 18, 2026
d8dc928
add csv time stamp for matrix mult fp16
EmbeddedFrime Aug 18, 2026
d766c9f
add csv time stamp for matrix mult tensor
EmbeddedFrime Aug 18, 2026
5efc7b7
add csv time stamp for memory bench
EmbeddedFrime Aug 18, 2026
ecc7829
add all shortcut for global cmake
EmbeddedFrime Aug 18, 2026
d0eb24e
fix cmake shortcut
EmbeddedFrime Aug 20, 2026
b21d2bb
add python script + enchanced the doc
EmbeddedFrime Aug 21, 2026
a1822f1
fix doc
EmbeddedFrime Aug 21, 2026
62a807b
Merge pull request #7 from EmbeddedFrime/feature/android-port
EmbeddedFrime Aug 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,23 @@
*.exe
*.out
*.app

#vscode
.vscode/

#cmake build
**/build/
**/build-android/


**/extern/*
!**/extern/.gitkeep



# OpenCL Dependency Downloads
**/opencl/opencl_headers/
**/opencl/tmp/

**/android/include/*.h
**/android/include/CL/
273 changes: 273 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

166 changes: 101 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,110 @@
# **GPU4S Bench - OBPMark-Kernel**
## **Authors**
- Ivan Rodriguez Ferrandez (UPC-BSC)
- Alvaro Jover-Alvarez (UPC-BSC)
- Leonidas Kosmidis (BSC-UPC)
- David Steenari (ESA)
# GPU4S Benchmark Suite documentation

## Introduction
GPU4S is a benchmarking suite that rely on OBPMark-Kernel to test perfomance and reliability of GPUs and multi-threaded processors for space applications.

The benchmarking suites have been developed in order to be compatible with heterogeneous platforms:

### **Version: 1.0**
- Computer (x86_64, x86_32)
- Android (ARM64, ARM32)
- Nvidia Xavier/TX2 (ARM64) (currently in development)

<br/>
<details>
<summary><b style="font-size: 1em;">List of tested devices</b></summary>
Up to this date, the suite has been successfully compiled and executed on the following devices:

## **Description**
Embedded GPUs have been identified from both private and government space agencies as promising hardware technologies to satisfy the increased needs of payload processing.The GPU4S (GPU for Space) project funded from the EuropeanSpace Agency (ESA) has explored in detail the feasibility and the benefit of using them for space workloads. Currently at the closing phases of the project, in this paper we describe the main project outcomes and explain the lessons we learnt. In addition,we provide some guidelines for the next steps towards their adoption in space.
| Platform | Operating System | CPU | GPU | Frameworks Tested |
| :--- | :--- | :--- | :--- | :--- |
| **High-end Laptop (x86_64)** | Fedora | AMD Ryzen 7 7840HS | NVIDIA GeForce RTX 4060 Laptop | CPU, OpenMP, CUDA, OpenCL, HIP |
| **Smartphone (ARM64)** | Android 5 | Qualcomm Snapdragon 810 | Adreno 430 | CPU, OpenMP, OpenCL |
</details>
<br>


## **Implemented Languages**
- Standard C
The benchmark uses a couple of different programming languages, libraries and frameworks to be able to compare perfomance of the same benchmark across most of devices:
- Standard C/C++
- CUDA
- HIP
- OpenCL
- OpenMP
- HIP

## **Benchmark List and Basic Description**

For most of the benchmark suite there is a naïve, optimize and library versions. The benchmarks with their implementations are listed below.
- Cifar 10
- Naïve,optimize and library (only for CUDA)
- Cifar 10 Multiple
- Naïve,optimize and library (only for CUDA)
- Convolution 2D
- Naïve,optimize and library (only for CUDA)
- Correlation 2D
- Naïve,optimize
- Fast fourier transform 2D bench
- Library
- Fast fourier transform
- Naïve,optimize and library
- Fast fourier transform Window
- Naïve,optimize and library
- Finite impulse response filter
- Naïve
- Local response normalization (LRN)
- Naïve,optimize and library (only for CUDA)
- Matrix multiplication
- Naïve,optimize and library
- Max pooling bench
- Naïve,optimize and library (only for CUDA)
- Memory Bandwidth
- Naïve
- Relu
- Naïve,optimize and library (only for CUDA)
- Softmax
- Naïve,optimize and library (only for CUDA)
- Wavelet transform
- Naïve,optimize


## **Benchmark Compilation**
For compile each of the benchmarks first you need to go to the folder for the specific benchmark that you want to compile.
Inside of the folder you can call the Makefile for compilation. All of the Makefiles behaves the same for compilation.

There is three parts for the make file.
First is the type of benchmark that you want to compile, that could be *cuda* (this will compile cuda naïve) will be the same for the rest of the languages, for different version will be will the suffixes -opt, -lib for the optimize and library versions, example cuda-opt, opencl-lib.

The second part is the definition of the data type, for all of the benchmarks float and double is supported and some of the benchmarks supports also integer. For specify the data type you need to add *-DATATYPE=(language)* for the languages the naming is in capital letters and are FLOAT,DOUBLE and INT.

The last parameter is the block size, this is only needed for the GPU code versions (OpenMP does not need this parameter). For the Makefile you need to provide *-BLOCKSIZE=(SIZE)* the block size is use square of the size that you provide, the recommended values are 4,8,16,32.

A full example will be as follows

``` make opencl-opt DATATYPE=FLOAT BLOCKSIZE=16 ```

The compiled binary will be in the bin folder.


## Background

Embedded GPUs have been identified by both private companies and government space agencies as a promising technology to meet the growing demands of payload processing. The GPU4S (GPU for Space) project, funded by the European Space Agency (ESA), explores the feasibility and benefits of using embedded GPUs for space workloads, and provides guidelines for their adoption in space applications.

## Benchmark List and Basic Description

For most of the benchmark suite there is a naïve, optimized and library version. The benchmarks with their implementations are listed below.

| Benchmark | Naïve | Optimized | Library |
|---|:---:|:---:|:---:|
| Cifar 10 | ✅ | ✅ | ✅ (CUDA only) |
| Cifar 10 Multiple | ✅ | ✅ | ✅ (CUDA only) |
| Convolution 2D | ✅ | ✅ | ✅ (CUDA only) |
| Correlation 2D | ✅ | ✅ | ❌ |
| Fast Fourier Transform 2D | ❌ | ❌ | ✅ |
| Fast Fourier Transform | ✅ | ✅ | ✅ |
| Fast Fourier Transform Window | ✅ | ✅ | ✅ |
| Finite Impulse Response Filter | ✅ | ❌ | ❌ |
| Local Response Normalization (LRN) | ✅ | ✅ | ✅ (CUDA only) |
| Matrix Multiplication | ✅ | ✅ | ✅ |
| Max Pooling | ✅ | ✅ | ✅ (CUDA only) |
| Memory Bandwidth | ✅ | ❌ | ❌ |
| ReLU | ✅ | ✅ | ✅ (CUDA only) |
| Softmax | ✅ | ✅ | ✅ (CUDA only) |
| Wavelet Transform | ✅ | ✅ | ❌ |

## Quick Start

If you already have the basic C/C++ programming tools installed (GCC/Clang, CMake ≥ 3.24, Git — see [**Prerequisites**](./docs/INSTALL.md) if not), you can try to compile and run the CPU version of the matrix multiplication benchmark in 3 steps:

```bash
# 1. Go to the benchmark directory
cd gpu4s_benchmark/matrix_multiplication_bench

# 2. Generate build files and compile the matrix_mult CPU target
cmake -B build
cmake --build build --target cpu -j$(nproc)

# 3. Run it
./build/bin/matrix_mult_cpu -s 512 -t
```

- `-s 512` runs the benchmark on a 512x512 matrix
- `-t` prints the execution time

Congratulations! You have successfully built and run your first GPU4S benchmark.

> Wanting to build with CUDA, HIP, OpenCL, or for Android? See [docs/INSTALL.md](docs/INSTALL.md) for prerequisites and [docs/BUILD_AND_RUN.md](docs/BUILD_AND_RUN.md) for building targets and check the runtime options.



## Road map
**Main focus**:

- [X] fix issue of correctness between cpu and gpu in some benchmarks
- [X] refactor to extract the common of frameworks
- [X] fix of the clock to be executed in runtime + kernerCLK->deviceOBJ
- [X] Check for cl error during memory copy to host and clean
- [X] add UMA implementation for Android
- [X] Big cmake to compile everything
- [ ] be compatible with jetson board + add UMA for jetson board

**Bonus**:
- [ ] create a test with vulkan for android to have best performance (with softmax ?)
- [ ] add map for verification of the result (ANDROID UMA)
- [ ] refactor main, cuda, hip, opencl, OpenMP, -> create common
- [ ] refactor cpu function -> create common (most important and easier)
- [ ] add a get elapsed time function that print in this cpu function

## The Authors
- Ivan Rodriguez Ferrandez (BSC-UPC)
- Alvaro Jover-Alvarez (BSC-UPC)
- Leonidas Kosmidis (BSC-UPC)
- Noah Perret (BSC-Centrale Nantes)
- David Steenari (ESA)

## License

[ESA-PL Strong Copyleft – v2.5](./LICENSE)
177 changes: 177 additions & 0 deletions docs/BUILD&RUN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# GPU4S: Build & Usage Guide
This document describes how to build and run all the benchmarks of GPU4S. For general information about the project, check the main [README](../README.md).

## Build Instructions

GPU4S Bench can be built with 2 different methods:

- **globally**: all 17 benchmarks at once, from the `gpu4s` root
- **standalone**: single benchmark, from its own subfolder

Both follow the same two steps: configure with CMake, then build.

### 1. Configure

**Host (x86_64 / Linux):**
```bash
cmake -B build
```
**Android:**
```bash
cmake -B build-android \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk/27.3.13750724/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-21
```


>**Notes**: You can name the build directory however you like, which makes it easy to keep multiple configurations side by side:
> ```bash
> cmake -B build-float-256 -DDATATYPE=FLOAT -DBLOCKSIZE=256
> cmake -B build-double-128 -DDATATYPE=DOUBLE -DBLOCKSIZE=128
> ```

<br>


### 2. Build

**Build every target:**
```bash
cmake --build build -j$(nproc) # host
cmake --build build-android -j$(nproc) # android
```

>**Notes**: The option `-j$(nproc)` forces your CPU to use all of its core to speed up the process.


**Build a specific target (optional):**
```bash
# Standalone (e.g.: from inside matrix_multiplication_bench/)
cmake --build build --target cpu
cmake --build build --target all-opencl
cmake --build build --target cuda-opt

# Global (from gpu4s_benchmark/ root)
cmake --build build --target matrix_mult-cpu
cmake --build build --target matrix_mult-all-opencl
cmake --build build --target matrix_mult-cuda-opt
```
>**Notes**: The option `--target` can be used to select a specific target.


<details>
<summary><b style="font-size: 1.25em;">📋 List of Target Shortcuts</b></summary>

- **CPU**: `cpu`, `CPU`
- **HIP**: `hip-`, `HIP`, `hip-opt`, `HIP-opt`, `all-hip`
- **CUDA**: `cuda`, `CUDA`, `cuda-opt`, `CUDA-opt`, `cuda-lib`, `CUDA-lib`, `all-cuda`
- **OpenCL**: `cl`, `OpenCL`, `opencl-opt`, `OpenCL-opt`, `opencl-lib`, `OpenCL-lib`, `all-opencl`
- **OpenMP**: `openmp`, `OpenMP`, `openmp-opt`, `OpenMP-opt`, `openmp-lib`, `OpenMP-lib`, `all-openmp`
</details>

<br>

### 3. Compile options

You can customize compilation options during the configuration step by adding `-D<PARAMETER>=<VALUE>` to `cmake -B ...`:

#### Available Parameters

| Parameter | Default | Allowed Values | Description |
| :--- | :--- | :--- | :--- |
| `DATATYPE` | `FLOAT` | `FLOAT`, `DOUBLE`, `INT` | Data type used in computations |
| `BLOCKSIZE` | `16` | `4`, `8`, `16`, `32`, etc. | 2D tile/block size for GPU kernels |
| `OPT_FLAG` | `-O3` | `-O2`, `-O3`, `-Ofast` | Host compiler optimization level |
| `CUDA_ARCH` | `native` | `native`, `sm_70`, `sm_75`, `sm_80`, `sm_86`, etc. | NVIDIA GPU compute architecture |
| `OPENCL_VERSION` | `300` | `200`, `210`, `220`, `300`, `310` | OpenCL target API version |
| `BLA_VENDOR` | `OpenBLAS` | `OpenBLAS`, `ATLAS`, `Generic` | BLAS library vendor for OpenMP-lib |
| `NSTREAMS` | `4` | Integer $\ge 1$ | Number of concurrent streams (`cifar_10_multiple`) |


<details>
<summary><b style="font-size: 1.25em;">Usage examples</b></summary>

**Simple — change the data type:**

```bash
# e.g. Use double precision instead of float
cmake -B build -DDATATYPE=DOUBLE
```
**Combined — fully customize multiple parameters:**

Chain multiple `-D` flags to customize data type, tuning, and target hardware in a single command. Example: double precision, 32x32 block size, targeting an Ampere GPU with `-Ofast`:

```bash
cmake -B build \
-DDATATYPE=DOUBLE \
-DBLOCKSIZE=32 \
-DCUDA_ARCH=sm_86 \
-DOPT_FLAG=-Ofast
```
</details>

<br>

### 4. Cleaning up the workspace
In order to reset your build environment, you can remove all generated build directories and start fresh:

```bash
rm -rf build*
```

## Usage

Once compiled, the executables are located in `./<build-directory>/bin`.


### 1. Running on Host (Linux / PC)

To execute a benchmark on your local machine, simply launch the generated executable from the terminal.

```bash
# General syntax
./build/bin/<target_name> [arguments]

# Example: Running the standard CPU matrix multiplication
./build/bin/matrix_mult_cpu -s 1024

# Example: Running the optimized CUDA version
./build/bin/matrix_mult_cuda_opt -s 2048
```

### 2. Running on Android

The launch command is the same, but you first need to push the executable file to your phone, then you can execute it through `adb shell`.


```bash
# Push all binaries to the device
adb push ./build-android/bin/* /data/local/tmp/

# Grant execution permissions to the binaries
adb shell chmod 755 /data/local/tmp/*

# Execute the benchmarks on the Android device
adb shell /data/local/tmp/matrix_mult_opencl -s 1024 -t -v
```

### Runtime Parameters

All devices share the same set of flags. For most benchmarks, you will need to provide at bare minimum a size flag (`-s`), which indicates how demanding the benchmark will be by changing the size of the calculation, and at least one of the timing/profiling output flags (`-t`, `-c`, `-C`) so the benchmark actually returns some result.

| Flag | Name | Description |
| :--- | :--- | :--- |
| `-s <size>` | **Size** | Sets the X and Y dimensions for the benchmark (e.g., matrix size $N \times N$). |
| `-v` | **Verify** | Executes a CPU baseline calculation and compares it with the GPU output to verify correctness. |
| `-t` | **Timing** | Prints the elapsed execution time to the console. |
| `-c` / `-C` | **CSV format** | Prints timing results in CSV format. Use `-C` to include a timestamp. |
| `-u` | **Unified Memory** | Enables Unified Memory mapping (Zero-Copy). **Highly recommended for Android and Jetson** platforms to prevent unnecessary memory transfers. |
| `-p` | **Profiling** | Enables internal clock profiling for more granular hardware timing. |
| `-d <id>` | **Device ID** | Selects the specific GPU device ID to use (default is usually 0). |
| `-o` | **Print Output** | Prints the resulting matrix or array directly to the terminal. |
| `-f` | **Mute** | Mutes all standard print messages (useful for batch testing scripts). |
| `-i <fileA> <fileB>`| **Input Files** | Loads custom hexadecimal input files instead of using randomized data generation. |
| `-g` / `-e` | **Export** | `-g` exports the GPU result to `gpu_file.out`. `-e` exports both GPU and CPU results in hex format (automatically enables `-v`). |
| `-k <size>` | **Kernel Size** | *(Specific to `convolution_2D`, `FIR_filter`)* Defines the size of the convolution filter / mask ($K \times K$) or FIR tap length. |
| `-l <stride>`| **Stride Size** | *(Specific to `max_pooling`)* Defines the horizontal and vertical step size of the pooling sliding window. |
Loading