grass
grass copied to clipboard
r.horizon: Support parallel computing for the raster mode by OpenMP
This PR parallelizes r.horizon module by OpenMP and creates parallelization benchmarks. It was tested on my fork repository (https://github.com/cyliang368/grass/pull/10).
r.horizon runs in two modes (point mode and raster mode). The raster mode requires calculation across every cell in the raster in the given area, which can be greatly improved by parallelization.
~~The point mode is multithreading for multi-directions.~~ The point mode is highly serialized, especially when only a point and a direction are specified. The new_point function runs step by step accumulatively, so it is hard to parallelize it. Since it just does a small amount of computations, so I didn't parallelize it (r.horizon for ~~1 point & 1 direction~~ the point mode is still serial).
The figures below show that running the point mode (1 point, 1 direction) takes around 100 times less time than the raster mode. Parallelization won't significantly benefit this. In conclusion, I will leave it serial now and work on other heavy computing modules.
Here are benchmarks with Intel(R) Core(TM) i9-10940X CPU @ 3.30GHz:
Maybe first merging #3929 (helper function) and updating this PR with it?
@marisn Can you open a new issue regarding the error of G_percent you found by running Valgrind through this parallelization?
@marisn Can you open a new issue regarding the error of
G_percentyou found by running Valgrind through this parallelization?
It is more generic issue as it affects all parallelized modules: https://github.com/OSGeo/grass/issues/5776