OpenMP: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(→‎See also: +ML thread)
(+Candidates, done)
Line 48: Line 48:
   EXTRA_CFLAGS=-fopenmp
   EXTRA_CFLAGS=-fopenmp
   EXTRA_LIBS=$(GISLIB) -lgomp $(MATHLIB)
   EXTRA_LIBS=$(GISLIB) -lgomp $(MATHLIB)
== Candidates ==
It is important to understand which modules are '''processor bound''', and concentrate on them. i.e. do not needlessly complicate the code of non-long running processor bound modules.
* v.lidar: parallelize tcholDec() in {{src|vector/lidar/lidarlib/TcholBand.c}}
: This would speed up the CPU-bound v.surf.bspline and v.lidar.edgedetection considerably.
== Complete ==
* The GPDE library ({{src|lib/gpde/}}) has OpenMP support (disabled by default)
* GRASS 7 has a ./configure switch for `<tt>--with-pthread</tt>`
* Experimental {{wikipedia|Pthread}} support for [http://thread.gmane.org/gmane.comp.gis.grass.devel/30313 r.mapcalc is now in GRASS 7svn]
* Yann has added OpenMP support to {{cmd|i.atcorr}}. (not in SVN)


== See also ==
== See also ==
* [https://docs.loni.org/wiki/Introduction_to_OpenMP Introduction to OpenMP]
* [https://docs.loni.org/wiki/Introduction_to_OpenMP Introduction to OpenMP]
* [https://computing.llnl.gov/tutorials/openMP OpenMP tutorial]
* [https://computing.llnl.gov/tutorials/openMP OpenMP tutorial]
* [http://software.intel.com/en-us/articles/threading-models-for-high-performance-computing-pthreads-or-openmp/ Threading Models for High-Performance Computing: Pthreads or OpenMP?]
* [http://software.intel.com/en-us/articles/threading-models-for-high-performance-computing-pthreads-or-openmp/ Threading Models for High-Performance Computing: Pthreads or OpenMP?]
* Experimental {{wikipedia|Pthread}} support for [http://thread.gmane.org/gmane.comp.gis.grass.devel/30313 r.mapcalc is now in GRASS 7svn]
 
** it is important to understand which modules are processor bound, and concentrate on them. i.e. do not needlessly complicate the code of non-long running processor bound modules
* GRASS mailing list discussions:
* GRASS related comments:
** http://thread.gmane.org/gmane.comp.gis.grass.devel/16410/
** http://thread.gmane.org/gmane.comp.gis.grass.devel/16410/
** http://lists.osgeo.org/pipermail/grass-dev/2009-April/043375.html
** http://lists.osgeo.org/pipermail/grass-dev/2009-April/043375.html


[[Category: Development]]
[[Category: Development]]

Revision as of 19:42, 19 June 2009

Multithreaded jobs in GRASS

OpenMP is an implementation of multithreading, a method of parallelization whereby the master "thread" (a series of instructions executed consecutively) "forks" a specified number of slave "threads" and a task is divided among them (from wikipedia). The job is distributed over the available processor cores (2-core, 4-core, ...).

The (yet) only parallelized library in GRASS >=6.3 is GRASS Partial Differential Equations Library (GPDE). The library design is thread safe and supports threaded parallelism with OpenMP. The code is not yet widely used in GRASS. See here for details.

How to activate it with GCC >= 4.2 (compiler flag '-fopenmp' as well as library '-lgomp' are needed):

# GPDE with openMP support:

cd lib/gpde/
vim Makefile
# uncomment the EXTRA_CFLAGS row and switch the two existing EXTRA_LIBS rows


General code structure

Example cited from "openMP tutorial" (see below):

   #include <omp.h>
  
   int main ()  {
       int var1, var2, var3;
   
       Some serial code 
       ...
  
       /* Beginning of parallel section. Fork a team of threads. */
       /* Specify variable scoping */
  
      #pragma omp parallel private(var1, var2) shared(var3)
      {
  
       /* Parallel section executed by all threads */
       ...
  
       /* All threads join master thread and disband */
      }  /* end pragma */
  
      /* Resume serial code */
      ...
  
   }

And in the Makefile, add something like this:

  #openMP support
  EXTRA_CFLAGS=-fopenmp
  EXTRA_LIBS=$(GISLIB) -lgomp $(MATHLIB)

Candidates

It is important to understand which modules are processor bound, and concentrate on them. i.e. do not needlessly complicate the code of non-long running processor bound modules.

This would speed up the CPU-bound v.surf.bspline and v.lidar.edgedetection considerably.

Complete

  • The GPDE library (lib/gpde/) has OpenMP support (disabled by default)
  • GRASS 7 has a ./configure switch for `--with-pthread`
  • Yann has added OpenMP support to i.atcorr. (not in SVN)

See also