Skip to content

Commit

Permalink
Fix build configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsms committed Jun 12, 2021
1 parent 7f9cee0 commit 33021ac
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 279 deletions.
59 changes: 59 additions & 0 deletions raster/r.univar/benchmark/benchmark_r_univar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Benchmarking of r.univar
@author Aaron Saw Min Sern
"""

from grass.pygrass.modules import Module
from subprocess import DEVNULL
import os

ITERATION = 5
UP_TO_THREADS = 12


def benchmark(module):
term_size = os.get_terminal_size()
print(module.get_bash())

min_ave = float("inf")
min_t = 1
for t in range(1, UP_TO_THREADS + 1):
print("\u2500" * term_size.columns)
print(f"Benchmark with {t} thread(s)...\n")
sum = 0
for _ in range(ITERATION):
module(nprocs=t).run()
print(f"{module.time}s")
sum += module.time

ave = sum / ITERATION
if t == 1:
serial_ave = ave
if ave < min_ave:
min_ave = ave
min_t = t
print(f"\nResult - {ave}s")

print("\u2500" * term_size.columns)
print(f"\nSerial average time - {serial_ave}s")
print(f"Best average time - {min_ave}s ({min_t} threads)\n")


def main():
multiple_maps_parallel = Module(
"r.univar", map=["elevation"] * 10, flags="g", stdout_=DEVNULL
)
multiple_maps_with_zone_parallel = Module(
"r.univar",
map=["elevation"] * 10,
zones="basin_50K",
flags="g",
stdout_=DEVNULL,
)

benchmark(multiple_maps_parallel)
benchmark(multiple_maps_with_zone_parallel)


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions raster/r.univar/r.univar_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ process_raster(univar_stat * stats, int fd, int fdz, const struct Cell_head *reg

}

#if defined(_OPENMP)
static void
process_raster_threaded(univar_stat * stats, char *fname, char *zone_fname, const struct Cell_head *region, const int threads)
{
Expand Down Expand Up @@ -626,3 +627,4 @@ process_raster_threaded(univar_stat * stats, char *fname, char *zone_fname, cons
if (n_zones)
G_free(zoneraster_row);
}
#endif
279 changes: 0 additions & 279 deletions raster/r.univar/testsuite/test_r_univar.py

This file was deleted.

0 comments on commit 33021ac

Please sign in to comment.