ForBenchmark: A Fortran library for benchmarking (with support for coarrays).
ForBenchmark can measure various time metrics including elapsed wall time, CPU time, OpenMP (OMP) time, MPI time, and date_and_time. Furthermore, it can compute flops based on a provided function.
- dot_product
- matmul (Under development)
This list will be updated. Feel free to add new benchmarks.
use forbenchmark
type(benchmark) :: bench
! initialize the benchmark
call bench%init(nmarks)
! start benchmark
call bench%start_benchmark(imark, method)
! loop over nloops
do nl = 1, bench%nloops
! call your function or subroutine or ...
end do
! stop benchmark
call bench%stop_benchmark()
! finalize the benchmark
call bench%finalize()! initialize the benchmark
call bench%init(nmarks, title, filename, nloops, timer)! start benchmark
call bench%start_benchmark(imark, method, description, argi, argr)! stop benchmark
call bench%stop_benchmark(flops)! finalize the benchmark
call bench%finalize()Refer to example/demo.f90 for a complete demonstration.
To use ForBenchmark as a dependency in your fpm project, include the following line in your fpm.toml file:
[dependencies]
forbenchmark = {git="https://github.com/gha3mi/forbenchmark.git"}Clone the repository:
Clone the ForBenchmark repository from GitHub using:
git clone https://github.com/gha3mi/forbenchmark.git
cd forbenchmarkRun the demo:
For non-coarray benchmarking:
fpm run --example demo --profile releaseFor coarray programs benchmarking using the Intel Fortran compiler:
fpm run --example demo --profile release --compiler ifx --flag "-coarray -coarray-num-images=4 -DUSE_COARRAY"fpm run --example demo --profile release --compiler ifort --flag "-coarray -coarray-num-images=4 -DUSE_COARRAY"After execution, the results will be displayed in the terminal and stored in the 'results' folder. See results/demo.data, results/demo_im1.data for instance.
Visualizing and exporting demo results:
To generate visual representations and export benchmarking metrics, execute the following commands in Python. Specify the relevant data file as an argument:
python results/export.py demo_<compiler>.dataThis command will produce graphical representations and an HTML table showcasing benchmarking metrics:
| Elapsed Time | Performance |
|---|---|
![]() |
![]() |
| Speedup | Average Weighted Speedup |
|---|---|
![]() |
![]() |
For Coarray benchmarks, execute:
python results/export_co.py demo_co.data
python results/export_im.py demo_im1.dataThe outputs can be found in the results directory.
- Add sphinx-gallery
- Add settings to set units.
- Add and update benchmarks for matmul and matmul_co,...
- Add MPI module.
The most up-to-date API documentation for the main branch is available
here.
To generate the API documentation for ForBenchmark using
ford run the following
command:
ford README.mdContributions to ForBenchmark are welcome!
If you find any issues or would like to suggest improvements, please open an issue.



