grass icon indicating copy to clipboard operation
grass copied to clipboard

r.horizon: Support parallel computing for the raster mode by OpenMP

Open cyliang368 opened this issue 1 year ago • 1 comments

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).

cyliang368 avatar Jun 18 '24 19:06 cyliang368

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.

r_horizon_point_time r_horizon_raster_time

cyliang368 avatar Jun 18 '24 19:06 cyliang368

Here are benchmarks with Intel(R) Core(TM) i9-10940X CPU @ 3.30GHz: benchmark_time benchmark_speedup benchmark_efficiency

petrasovaa avatar Aug 01 '24 15:08 petrasovaa

Maybe first merging #3929 (helper function) and updating this PR with it?

petrasovaa avatar Aug 01 '24 15:08 petrasovaa

@marisn Can you open a new issue regarding the error of G_percent you found by running Valgrind through this parallelization?

cyliang368 avatar May 25 '25 02:05 cyliang368

@marisn Can you open a new issue regarding the error of G_percent you 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

marisn avatar May 27 '25 02:05 marisn