Subject: hpff-interpret: Re: Table lookups

From: [email-masked] (Chuck Koelbel)
Date: Thu, 4 Jan 1996 16:48:53 -0600

---------------------------------------------------------------------------
[email-masked] is a mailing list for corrections,
clarifications, and interpretations related to High Performance Fortran.
Instructions for adding or deleting yourself from this list appear at the
bottom of this message.
---------------------------------------------------------------------------

At 10:54 01/04/96, [email-masked] wrote:
>I'm having a bit of trouble understanding how to do table lookups.
>Using some information from The Book, the only thing I have been able
>to come up with is to go to local space to do the actual lookup (under
>the requirement of only one table/processor):

Reading between a few lines, I think this is what you are trying to do:
1. Do many lookup operations in parallel.
2. Use the same (conceptual) table for all the lookups.
   (i.e. the table values are the same on all the lookups)
3. Store a copy of the conceptual table on all processors.
4. Have only one version of the code.

So, I would suggest using ALIGN to replicate the table, and using a
straight INDEPENDENT loop.  Since the replication happens in ALIGN, the
same code should work under both HPF and F90.  I don't have an HPF compiler
handy either, but the following should do it:

     real, dimension(1024,1024) :: AA, BB
      real, dimension(137) :: table
!HPF$ DISTRIBUTE (BLOCK,BLOCK) :: AA, BB
!HPF$ TEMPLATE dummy(NUMBER_OF_PROCESORS())
!HPF$ ALIGN table(i) WITH dummy(*)
!HPF$ DISTRIBUTE dummy(BLOCK)

!HPF$ INDEPENDENT
      do i=1,1024
        do j=1,1024
          AA(i,j) = AA(i,j) + table( truncate(BB(i,j)) )
        enddo
      enddo

I think your second syntax would also work, but this seems a bit simpler.
A good compiler would even do the right thing (i.e. one copy per processor)
if you said

     real, dimension(1024,1024) :: AA, BB
      real, dimension(137) :: table
!HPF$ DISTRIBUTE (BLOCK,BLOCK) :: AA, BB
!HPF$ ALIGN table(i) WITH AA(*,*)

but it's possible that some compilers would create one copy per element of
AA, definitely not the right thing to do.

BTW, about
>! sorry - I can't currently check if this would as intended
>!HPF$ INDEPENDENT
>      do i=1,1024
>        do j=1,1024
>          AA(i,j) = AA(i,j) + table(BB(i,j))
>        enddo
>      enddo
The loop is definitely dependence-free, so it's correct to say INDEPENDENT.
Most compilers ought to notice this on their own, but you never know.
Whether your current compiler actually executes the INDEPENDENT loop in
parallel is a different question - ask you vendor.

>The short question then is - have I missed some other ways to do
>table lookups?
>
>thanks
>-dave

This is really two questions:
1. Are there other ways to do the lookups in parallel?
2. Are there other ways to copy the lookup tables?

In answer to 1., you could get the same effect with INDEPENDENT DO (see
above) and FORALL (with or without an INDEPENDENT).  This might or might
not make a difference in how your compiler handles the program.  The
EXTRINSIC routine you started with works too (assuming all the details are
right, I didn't check), but it seems like overkill- the lookups are
data-parallel, so you'd expect that HPF can handle them well without
resorting to extrinsics.

In answer to 2., ALIGN is the basic way to get replication on all
processors.  Adding a NUMBER_OF_PROCESSORS dimension as you did works, but
risks confusing the compiler (it has to realize which dimension is local).

                                                Chuck

---------------------------------------------------------------------------
To (un)subscribe to this list, send mail to
[email-masked].
Leave the subject line blank, and in the body put the line
(un)subscribe <email-address>
---------------------------------------------------------------------------