This is a collection of different C++ implementations for calculating the discrete Fréchet distance between two polygonal curves:
vanilla: A recursion-free adaptation of the original algorithm as proposed in Computing Discrete Fréchet Distance by T. Eiter and H. Mannila (1994), used as a baseline.linear: This formulation reduces the quadratic memory footprint to a linear one.SIMD: Formulation using SIMD parallelization on a single CPU core.CUDA: Formulation using CUDA.
Implementations of all these variants can be found under ffrechet-{vanilla,linear,simd,cuda}/source/ or by simply clicking on the listed names above.
This project has been primarily tested on Linux environments. Please note the following dependencies:
- SIMD implementation: Requires at least GCC-11, as it relies on the experimental SIMD implementation of the Parallelism Technical Specification (TS) v2.
- CUDA implementation: Requires a compiler version compatible with the NVCC installation.
You can customize the compiler versions by editing the respective toolchain files ffrechet-simd/ffrechet-simd_toolchain.cmake and ffrechet-simd/ffrechet-cuda_toolchain.cmake.
First, make sure that you have checked out the dependencies (google-benchmark and google-test) by running
$ git submodule init
$ git submodule updateThen, you can customize the build options in CMakeUserPresets.json or simply copy the default one from CMakeUserPresets.json.EXAMPLE:
$ cp CMakeUserPresets.json.EXAMPLE CMakeUserPresets.jsonFinally, configure and build the entire project via
$ cmake --preset=release
$ cmake --build --preset=releaseIf you want to run the benchmark, type:
$ ./build/release/install/bin/ffrechet-benchmark \
--benchmark_out_format=json \
--benchmark_out=benchmark.jsonthis will run the benchmark and store the results in benchmark.json.
Remember to enable the performance mode on your CPU before running the benchmark, e.g., via
$ sudo cpupower frequency-set --governor performanceAfterwards, you can reset the performance mode back to powersave via
$ sudo cpupower frequency-set --governor powersaveIn case you are interested in contributing to this project, you might find our debug preset helpful:
$ cmake --preset=debug
$ cmake --build --preset=debugYou can test your changes by running
$ ./build/debug/install/bin/ffrechet-testPlease make sure to obey the formatting, for example by running
$ cmake --build --preset=debug -t format-check
$ cmake --build --preset=debug -t format-fixWe use Jupyter Notebooks to render the visualizations of the results of the benchmarks. You can find them here alongside others.
Python implementations of the discrete Fréchet Distance can be found here.