[GRASS-user] Multithreading in GRASS 6.4

Hello,

I'm trying to use multithreading in GRASS 6.4 in OpenSUSE 64-bit installed
from the community repository and am wondering what the best way would be to
set my script. What I'm wanting to do is several r.sun analyses parallel to
one another using a Python script. I've read the wiki page about OpenMP at
http://grass.osgeo.org/wiki/OpenMP#Multithreaded_jobs_in_GRASS but don't
quite understand it - it seems that I can activate multithreading
capabilities in GRASS by modifying /lib/gpde/Makefile but I don't have that
file. I also wasn't able to find a whole lot of information about it that I
could understand - I meet the requirement listed at
http://grass.osgeo.org/programming6/gpdelib.html of having a compiler that
supports OpenMP (I've got gcc 4.5), but am unsure of how I should proceed.
Does anyone have any tips?

Happy New Year's and thanks a bunch in advance!
Daniel
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Multithreading-in-GRASS-6-4-tp5875866p5875866.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Hi Daniel,

On Thu, Dec 30, 2010 at 1:03 AM, LeeDaniel <Lee.Daniel.1986@gmail.com> wrote:

Hello,

I'm trying to use multithreading in GRASS 6.4 in OpenSUSE 64-bit installed

Note that there is almost no multithreading in GRASS 6 itself.

from the community repository and am wondering what the best way would be to
set my script. What I'm wanting to do is several r.sun analyses parallel to
one another using a Python script.

This is best done in parallel GRASS batch jobs runs, running each job
in a different mapset, then copying over the result into an integrated
mapset.

I've read the wiki page about OpenMP at
http://grass.osgeo.org/wiki/OpenMP#Multithreaded_jobs_in_GRASS but don't
quite understand it - it seems that I can activate multithreading
capabilities in GRASS by modifying /lib/gpde/Makefile but I don't have that
file.

No, in the /lib/gpde/Makefile you would activate it only for GPDE.
OpenMP is not really there in GRASS 6.

I also wasn't able to find a whole lot of information about it that I
could understand - I meet the requirement listed at
http://grass.osgeo.org/programming6/gpdelib.html of having a compiler that
supports OpenMP (I've got gcc 4.5), but am unsure of how I should proceed.
Does anyone have any tips?

Yes, you can rather easily use this approach:
http://grass.osgeo.org/wiki/GRASS_and_Shell#GRASS_Batch_jobs
or
http://grass.osgeo.org/wiki/Parallel_GRASS_jobs

hope this helps,
Markus

Daniel wrote:

I'm trying to use multithreading in GRASS 6.4 in OpenSUSE
64-bit installed from the community repository and am
wondering what the best way would be to set my script. What
I'm wanting to do is several r.sun analyses parallel to
one another using a Python script.

I've not done it in python, but for shell scripting see the
"poor man's multithreading" trick for r.sun on the wiki:

http://grass.osgeo.org/wiki/r.sun#Automation

as job control is very much the shell's domain & OS specific,
I personally don't feel much demand to rewrite that in python.

The above gets you going on a multicore linux or mac system when
you have lots of jobs to run.

One thing to look into is Seth's Google Summer of Code project
from last year where he's added OpenCL support to r.sun. That
way the raytracing stuff (?) is run in the GPU, which is orders
of magnitude faster for that sort of calculation than the generic
CPU. Also I think OpenCL gives you the opportunity to optionally
multithread to a multicore CPU instead of the graphics card (?)
for speeding up a single job. I am yet to merge that OpenCL code
+ the needed configure script/makefile support into GRASS 7.
(sorry for the long delay Seth..)

see http://grass.osgeo.org/wiki/R.sun#OpenCL

You'd have to assemble and recompile from source for that one,
but the speedup can be enormous.

OpenMP: not really implemented yet, although a couple of us have
been playing with it. Yann and Soeren have probably gotten the
furthest with it AFAIR.

Glynn's added pthreads support to r.mapcalc in GRASS 7 too,
AIUI that splits the I/O into one thread, and the calculations
into another. Beyond that a fast RAID array is probably your
best hope to speed up an IO limited process like r.mapcalc.

Daniel:

the last couple of questions I've posted on this list
haven't been answered at all. I can see the posts online but
I never get any answers back. Is this not getting sent out to
the subscribed users or are my questions too stupid? I don't
mean to sound annoyed or anything - I'm really truly just
wondering.

I thought we had a mention of that "why no responses?" FAQ on
the wiki at http://grass.osgeo.org/wiki/Mailing_list_etiquette
but I guess not yet. As Maris suggested, maybe no one knows the
answer, or those that do are busy or happen to be away for a few
weeks. keep trying :slight_smile:

Hamish

I haven’t done it for 6.4 but tried it in 7.0

You can follow the instruction on compiling grass here:
http://grass.osgeo.org/wiki/Compile_and_Install

Once you have all the prerequisite, you can set the environment variables
CFLAGS=“-O3 -Wall -Werror-implicit-function-declaration -fno-common -fopenmp”

LDFLAGS="-lgomp"
and then compile grass.

Cheers
Sab
 

On Wed, 2010-12-29 at 16:03 -0800, LeeDaniel wrote:

Hello,

I'm trying to use multithreading in GRASS 6.4 in OpenSUSE 64-bit installed
from the community repository and am wondering what the best way would be to
set my script. What I'm wanting to do is several r.sun analyses parallel to
one another using a Python script. I've read the wiki page about OpenMP at
[http://grass.osgeo.org/wiki/OpenMP#Multithreaded_jobs_in_GRASS](http://grass.osgeo.org/wiki/OpenMP#Multithreaded_jobs_in_GRASS) but don't
quite understand it - it seems that I can activate multithreading
capabilities in GRASS by modifying /lib/gpde/Makefile but I don't have that
file. I also wasn't able to find a whole lot of information about it that I
could understand - I meet the requirement listed at
[http://grass.osgeo.org/programming6/gpdelib.html](http://grass.osgeo.org/programming6/gpdelib.html) of having a compiler that
supports OpenMP (I've got gcc 4.5), but am unsure of how I should proceed.
Does anyone have any tips?

Happy New Year's and thanks a bunch in advance!
Daniel