Newsgroups: comp.parallel.mpi
From: zxu@monalisa.usc.edu (Zhiwei Xu)
Subject: Re: How to do this in F90, HPF, PVM, or MPI?
Organization: University of Southern California, Los Angeles, CA
Date: 27 Jun 1995 16:11:18 -0700
Message-ID: <3sq36m$dda@monalisa.usc.edu>

Pierre Lagier <pierre@fujitsu.co.uk> wrote:
>
>Hum, what about "fuzzy barrier" ? 
>
>..
>        VPP_InitFuzzyBarrier(10);
>>  for ( j=0 ; j<M; j++ )
>>  {
>>   if ( IsTarget(A[i][j]) )
>>   {
>>    TargetList[k].distance = i ;
>>    TargetList[k].direction = j ;
>                        if (VPP_PostFuzzyBarrier ());
>>        goto finished ;
>>   }
>>  }
>> finished:
>> -------------------------------------------------
>
>This should run on Fujitsu VPP series, using the message
>passing kernel. 
>
>Pierre Lagier / Fujitsu Systems Europe
>

Pierre, Thanks for your response. I don't know the semantics of VPP fuzzy barrier.
So I am gussing, using my understanding of fuzzy barrier, as in SGI Power C.
(Is there a ftp/www site about VPP which has info on VPP fuzzy barrier?)

It seems your solution will not work. Here is a conterexample:
Assume your code is executed by 20 processors. Each finds a target and tries to
update the TargetList. Two bad things can happen:

1. All or some of the 20 targets could be stored in the same TargetList[k].
 (your code did not ATOMICALLY increment k)
2. If your code did atomically increment k, you would get a segmentation fault,
 because TargetList can only hold 10 targets.

We have tried at least 10 different methods to solve this problem on SP2. Only
one worked, after we changed the problem a little bit.

I suspect that this deceptively simple problem is very difficult to solve
efficiently using any data parallel or message passing system.

For those who missed my original post, I enclose the problem below:

----------------------------------------------
COMPLEX                 A[N][M];
Target_Structure        TargetList[10] ;

k=0 ;
for ( i=0 ; i<N ; i++ )
        for ( j=0 ; j<M; j++ )
        {
                if ( IsTarget(A[i][j]) )
                {
                        TargetList[k].distance = i ;
                        TargetList[k].direction = j ;
                        k = k++ ;
                        if ( k==10 ) goto finished ;
                }
        }
finished:


--------------------------------------
Additional Information from the Programmer (User):

        The code tries to detect the ten closest targets (if any)

        The for (j ...) loop can be parallelized. That is, for each i,
                the data points A[i][*] can be examined in any order

        You can assume that IsTarget is a side-effect free, pure routine
----------



