Преглед изворни кода

parser: Add NPROCS GIS env var to set default for nprocs (#1734)

* 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.
Aaron Saw Min Sern пре 3 година
родитељ
комит
f12f145790
2 измењених фајлова са 13 додато и 0 уклоњено
  1. 6 0
      lib/gis/parser_standard_options.c
  2. 7 0
      lib/init/variables.html

+ 6 - 0
lib/gis/parser_standard_options.c

@@ -762,6 +762,12 @@ struct Option *G_define_standard_option(int opt)
         Opt->required = NO;
         Opt->required = NO;
         Opt->multiple = NO;
         Opt->multiple = NO;
         Opt->answer = "1";
         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");
         Opt->description = _("Number of threads for parallel computing");
         break;
         break;
 
 

+ 7 - 0
lib/init/variables.html

@@ -535,6 +535,13 @@ g.gisenv set=DEBUG=0
 # set to 6 GB (default: 300 MB)
 # set to 6 GB (default: 300 MB)
 g.gisenv set="MEMORYMB=6000"
 g.gisenv set="MEMORYMB=6000"
 </pre></div>
 </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>
   <dt>OVERWRITE</dt>
   <dd>[all modules]<br>
   <dd>[all modules]<br>