2011/4/13 jeremy rosen <[email protected]>

> OOOOkay...
>
> took me some time to figure out what was going on since I was looking
> for a bug in my code and it was actually a feature in openMP
>
> The good news.
> this is a feature. To optimize perfs, openmp will have all its threads
> busy-wait when no job is available on the assumption that it's a rare
> occurence. This explain teh CPU usage
>
> setting the environment variable OMP_WAIT_POLICY=PASSIVE will solve the
> problem
>
> the bad news...
> I was not to set it within the code. Adding a call to setenv as the
> first instruction of main() didn't work since env variables seem to be
> loaded in OMP context even before that. I couldn't find a way to set
> it and i'm open to suggestions here...
>
> Regards
> Boucman


Some stuff from the OpenMP specs (
http://www.openmp.org/mp-documents/spec30.pdf) :

P. 145

   -
   - *Modifications to the environment variables after the program has
   started, even if modified by the program itself, are ignored* by the
   OpenMP implementation. However, the settings of some of the ICVs can be
   modified during the execution of the OpenMP program by the use of the
   appropriate directive clauses or OpenMP API routines.
   -
   - OMP_WAIT_POLICY sets the wait-policy-var ICV that controls the desired
   behavior of waiting threads.

P. 30 (in the table)

ICV: wait-policy-var
Scope: global
Ways to modify value: *OMP_WAIT_POLICY*           <-- i.e. only way to
change that setting is through the environment variable
Ways to retrieve value: (none)
Initial value: Implementation defined

So, it seems you have no choice but to set the environment variable before
program execution, or find an openmp implementation that sets that
environment variable to PASSIVE by default.

Just out of curiosity (haven't followed the discussion too much so far), are
we using libgomp, or something else?

Gabba
_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev

Reply via email to