Global Variables in parallel run

General discussion about Elmer
Post Reply
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Global Variables in parallel run

Post by Franz Pichler »

Hello,
if i run Elmer in parallel nad have a global variable defined, would every processor have its own scalar value for that variable? Or would they all share one automatically?
best regards
Franz
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Re: Global Variables in parallel run

Post by Franz Pichler »

Hello,

i just read a bit through Lists.src where i believe the variables get allocated and if i get it right the global variables get allocated per process.

so, in a parallel run i have several instances of a global variable, one per process. (Right?)

What i would like to do now is to use the variable as a flag that if set causes a nother solver to do something. THe thin is i have to keep the flag consistent,
so every processeor either sets the flag to 1 or 0 depending on information of the processors variables.
the global flag then should be reduced to 0 if any processors flag is 0.
something like a reduce to minimum.
Any suggestions what the best way to do this is?

best regards
Franz
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Re: Global Variables in parallel run

Post by Franz Pichler »

OK, after some more research i found parallel reduction that is also ued in the solvers.
So using parallelutils i can right

Code: Select all

value =something dpending on process
 IF ( ParEnv % PEs > 1) THEN
       value = ParallelReduction(value,1)
 END IF
Var% Values(1)= value
After that i should have the min in every process right???
the whole thread was more a self discussion hehe.

thanks everybody anyways.
Franz
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Re: Global Variables in parallel run

Post by Franz Pichler »

OK still didn't understand it fuly,
i just checked the computenorm function supported by solverutiols. This is using parallelreduce.
But every processor has another value of Norm if one uses

Code: Select all

Norm=ComputeNorm(Solver, n, xx(i,1:n)-iSolver % Variable % Values)
print *,"mynorm",PArenv%mype, Norm
it shows different values for Norm.
Did i use it wrong?
or is there somekind of rely on processor number 1 thing that says only one guy will have the correct number in the end?
or do i have to use a barrier myself somewhere?

every hint and idea is highly appreciated!
thanks
best regards
Franz
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Re: Global Variables in parallel run

Post by Franz Pichler »

next bit of information:
if i print out COUNT(ParEnv % Active) and PArenv%ActiveComm

both give me zero from all processors
and the count%part gets used in sparitercomm-SParActiveSUM to check if reduction has to be done.
with IF ( COUNT(ParEnv % Active)<= 1 ) RETURN

and this is not true so the routine returns and the value is not changed.
thas why every processor has a different value. for the norm this means its just the norm of the definition.
true?
or am i just shootin too fast once again. hopefully.

byebye
Franz
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Re: Global Variables in parallel run

Post by Franz Pichler »

so,
based on this fruitful discussion i found a solution!

and the solution is:

Code: Select all

CALL ParallelActive( .True. )
This command right before a parallreduction AND also before the compute norm. ADfter that the active flags are set in the parenv and eveytthing works as expected.

the thing is now that i don't know what has "turned of" the activness. and there are some solvers which use parallelreduce (just "grep"ped the modules directory) maybe they need this line too then?

thanks for the attention,
and finally i will call it a weekend,
there is a beer waiting somewhere,
byebye
Franz
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Re: Global Variables in parallel run

Post by Franz Pichler »

Hello again,
i would really appreciate it if somone could hgave a look at my problem from above. especially the need of the parallelactivate.
thanks
Franz
raback
Site Admin
Posts: 4832
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Global Variables in parallel run

Post by raback »

Hi

The global variables are not automatically set to be the same. However, if they follow from some deterministic way, such as the "time" it will be the same for all partitions. If the value is different but should be the same, some action should be taken in the code to make the parallel reduction.

-Peter
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Re: Global Variables in parallel run

Post by Franz Pichler »

Hello Peter
thanks for the reply.

I know my message mess is not the nicest but i was allready a bit tired then.

I understand that the global variables are not automatically the same. thats how i arrived at the whole reduction issue in the first place. If you have a closer look at my messages you see that i had problems with the reduction itself. I hadd to use the parallelactive command to get the real norm of the unknowns that was computed with computenorm. When i did not use parallelactive then every parallel processor just sticked to its own version of the global variable. and this was a bit weird.
I had the same issue with "parallelreduction".

So in both cases using parallelactive solved the problem.

By just grepping parallelreduction and computenorm i found that some solvers use these functions. But the parallelactive is not used in these places. thats what was confusing me. maybe someone could check if the values in the solvers are really the same global values in every processor after reduction.

best reegards
Franz
Post Reply