Skip to content

Conversation

@wenzeslaus
Copy link
Member

With this change, callers of gs.mapcalc can now use nprocs to set number of processes for the underlying r.mapcalc. This makes it available to a number of Python tools which use gs.mapcalc to call r.mapcalc (as well as to user scripts).

The default is set to 1. Specifically, the parameter default is None which is translated to 1 as opposed to using r.mapcalc's default. As a result, r.mapcalc's default is now independent from the default of gs.mapcalc. At this point, it makes all the Python calls using gs.mapcalc behave as before, i.e., one core only, while direct usage of r.mapcalc uses the all-cores default as do the other C tools now.

See also #6564 (discussion on default for r.mapcalc), #5731 (default for nprocs in C), and #5742 (r.mapcalc OpenMP version).

With this change, callers of gs.mapcalc can now use nprocs to set number of processes for the underlying r.mapcalc. This makes it available to a number of Python tools which use gs.mapcalc to call r.mapcalc (as well as to user scripts).

The default is set to 1. Specifically, the parameter default is None which is translated to 1 as opposed to using r.mapcalc's default. As a result, r.mapcalc's default is now independent from the default of gs.mapcalc. At this point, it makes all the Python calls using gs.mapcalc behave as before, i.e., one core only, while direct usage of r.mapcalc uses the all-cores default as do the other C tools now.

See also OSGeo#6564 (discussion on default for r.mapcalc), OSGeo#5731 (default for nprocs in C), and OSGeo#5742 (r.mapcalc OpenMP version).
@wenzeslaus wenzeslaus merged commit c2c83cc into OSGeo:main Nov 6, 2025
27 checks passed
@wenzeslaus wenzeslaus deleted the nprocs-for-gs.mapcalc branch November 6, 2025 14:16
@github-actions github-actions bot added this to the 8.5.0 milestone Nov 6, 2025
wenzeslaus added a commit that referenced this pull request Nov 6, 2025
One of the two steps in r.grow is using r.mapcalc. This allows user to control the number of cores used by r.mapcalc in that step (#5742). This is more critical with the default being all cores (#5731) even if the impact is possibly limited given that the main step is not parallelized.

This depends on #6580 for the nprocs parameter in the gs.mapcalc function.
wenzeslaus added a commit that referenced this pull request Nov 6, 2025
With r.mapcalc being parallel (#5742) and the default nprocs in C (for r.mapcalc) being all cores (#5731), it both makes sense and is necessary to have a pass-through nprocs in r.mapcalc.simple. This gives users access to the parallelization options (regardless of the default), and it allows users to avoid oversubscription (with the default being all cores).

This depends on #6580 for the nprocs parameter in the gs.mapcalc function.
wenzeslaus added a commit that referenced this pull request Nov 6, 2025
The i.image.mosaic tool uses r.mapcalc for the main processing step. This allows user to control the number of cores used by r.mapcalc (since OpenMP parallelization was added to r.mapcalc in #5742). With the default number of cores used for processing being all cores (#5731), the parallelization is enabled by default. This allows users to control number of cores used allowing for specific number of cores to be used.

This depends on #6580 for the nprocs parameter in the gs.mapcalc function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libraries Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants