[GRASS-git] [OSGeo/grass] 4131a7: r.mapcalc: remove static variables from mode and m...

Anna Petrasova noreply at github.com
Mon Jul 21 06:36:46 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 4131a762259443d089aeadac4d541035b2771ef5
      https://github.com/OSGeo/grass/commit/4131a762259443d089aeadac4d541035b2771ef5
  Author: Anna Petrasova <kratochanna at gmail.com>
  Date:   2025-07-21 (Mon, 21 Jul 2025)

  Changed paths:
    M lib/calc/xmedian.c
    M lib/calc/xmode.c
    M lib/calc/xnmedian.c
    M lib/calc/xnmode.c
    A raster/r.mapcalc/testsuite/test_median_mode.py

  Log Message:
  -----------
  r.mapcalc: remove static variables from mode and median to fix parallelization (#6087)

This gets rid of static variables from the r.mapcalc functions for mode and median. The static variables were there to not allocate for every row, but it complicates parallelization since that can't generally be done in parallel with static variables, see #5742. Since the size of the array is typically very small (the number of arguments of the median() or mode() function, can be raster or number), it will use array on stack and allocate only for larger sizes.

It may be slower due to more stack or heap needed, but it might be faster for cases within the threshold (using heap allocated memory instead of realloc). In any case, it will reliably work with parallelization. General solution would be using a context, but that would require a large change.



To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications


More information about the grass-commit mailing list