freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pooma-dev] Remote access of distributed multipatched arrays


From: Richard Guenther
Subject: Re: [pooma-dev] Remote access of distributed multipatched arrays
Date: Sun, 6 Apr 2003 20:31:58 +0200 (CEST)

On Sun, 6 Apr 2003, Arno Candel wrote:

> Hi everybody,
>
> I encountered a problem doing local if-statements using multiple values
> of several distributed multipatched brick arrays to calculate the value
> of one such array.
>
> Below I have included a simple test program which shows the relevant
> problem. Three 3D distributed multipatched brick arrays are created and
> allocated on different domains and thus on different patches. Two arrays
> are now used to calculate the values of the other array, using local
> if-statements. Both a "stupid serial" and a "parallel" version of the
> calculation part are implemented. The use of data-parallel expression or
> stencils was not possible, in my view.

This is not the case.

>     // "stupid serial" version
>     Pooma::blockAndEvaluate();
>     time=clock.value();
>     for (int i=ADom[0].first();i<=ADom[0].last();i++)
>     for (int j=ADom[1].first();j<=ADom[1].last();j++)
>     for (int k=ADom[2].first();k<=ADom[2].last();k++) {
>         Loc<3> x(i,j,k);
>         if ( (B(x+ez)<0.5) && (C(x-ex)>0.3) ) {
>             A(x)=B(x-ez-ex)+C(x+ez);
>         }
>     }
>     Pooma::blockAndEvaluate();
>     pout << A << "\nstupid serial version took " << clock.value()-time
> << " secs" << std::endl;

Just use

  A(Adom) = where(B(Adom+ez)<0.5 && C(Adom-ex)>0.3, B(Adom-ez-ex) +
C(Adom+ez));

here - also notice that setting external guards to zero will not work, as
you need at least as much external guards as internal ones (usually).

>
>     // "parallel" version, iterate only over local patches of A
>     Pooma::blockAndEvaluate();
>     time=clock.value();
>     for (GridLayout<3>::const_iterator it = Alayout.beginLocal(); it !=
> Alayout.endLocal(); it++) {
>         for (int i=it->domain()[0].first();i<=it->domain()[0].last();i++)
>         for (int j=it->domain()[1].first();j<=it->domain()[1].last();j++)
>         for (int k=it->domain()[2].first();k<=it->domain()[2].last();k++) {
>             Loc<3> x(i,j,k);
>             if ( (B(x+ez)<0.5) && (C(x-ex)>0.3) ) {
>                 A(x)=B(x-ez-ex)+C(x+ez);
>                 // problem: local patches of A might not contain needed
> values of B and C and remote access is forbidden!
>                 // Will crash in parallel execution!

remote access is not forbidden. But due to the guard layer setup (see
above) you may experience crashes. Otherwise this should work fine.

Hope this helps.

Richard.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]