Skip to content

Commit

Permalink
parser: Add NPROCS GIS env var to set default for nprocs (#1734)
Browse files Browse the repository at this point in the history
* This adds an NPROCS GIS environment variable.
* This change allows to globally override the default value (1) with a user defined value for the nprocs option using g.gisenv.
* This follows the existing implementation for memory with MEMORYMB variable (PR #922).
* nprocs option already exists, so this adds only the variable NPROCS and its documentation.
  • Loading branch information
aaronsms committed Jul 29, 2021
1 parent e97de6b commit f12f145
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/gis/parser_standard_options.c
Expand Up @@ -762,6 +762,12 @@ struct Option *G_define_standard_option(int opt)
Opt->required = NO;
Opt->multiple = NO;
Opt->answer = "1";
/* start dynamic answer */
/* check NPROCS in GISRC, set with g.gisenv */
memstr = G_store(G_getenv_nofatal("NPROCS"));
if (memstr && *memstr)
Opt->answer = memstr;
/* end dynamic answer */
Opt->description = _("Number of threads for parallel computing");
break;

Expand Down
7 changes: 7 additions & 0 deletions lib/init/variables.html
Expand Up @@ -535,6 +535,13 @@ <h2>List of selected GRASS gisenv variables</h2>
# set to 6 GB (default: 300 MB)
g.gisenv set="MEMORYMB=6000"
</pre></div>

<dt>NPROCS</dt>
<dd>sets the number of threads for parallel computing
<div class="code"><pre>
# set to use 12 threads (default: 1)
g.gisenv set="NPROCS=12"
</pre></div></dd>

<dt>OVERWRITE</dt>
<dd>[all modules]<br>
Expand Down

0 comments on commit f12f145

Please sign in to comment.