Neil Carlson wrote:
>
> On Tue, 2002-05-28 at 13:24, Richard Maine wrote:
> > [ my forall example ]
> > Remember that a major motivation for FORALL is that it can be done in
> > parallel.
>
> Ah, "parallel"; that's the key concept I was overlooking. I was merely
> thinking of order independence, but still sequentially, and was
> ignoring the possibility of simultaneous execution. Yes now things
> make sense. :-)
>
> Regarding the use of an array temporary: in the case of actual
> sequential execution, is it reasonable to expect that an optimizer
> will substitute a scalar temp for the array temp? I've got no
> sense of what's easy/hard for optimizers.
>
Well, most generalizations are false, but generally I'd not expect
a compiler to replace an array temp with a scalar temp.
The problem is determing subsequent usage. With a loop set like
DO I = J,K
TEMP(I) = .....
A(I) = ...TEMP(I)...
ENDDO
DO I = L,M
TEMP(I) = ...
ENDDO
DO I = N,NN
B(I) = ...TEMP(I)...
ENDDO
That's too long of an example, but the idea is that is's usually
impossible to make sure that all of the stores into TEMP in the
first loop are overwritten by the second loop. So it will usually
not be able to substitute a scalar for the array.
But, if your question is will the compiler usually keep the value
of TEMP(I) in a register in the first loop. The answer is almost
for sure yes. The "reference" in the second line will come from
a register, not memory. Usually there would be one store into
TEMP(I) per iteration and no loads. This changes if there are
also references or definitions of TEMP(K) in the loop. It
can also change on a machine with a fast cache where there is
(almost) no penality for doing an unnecessary memory reference.
The nice thing about optimizers is that ther are no simple
questions.
Dick Hendrickson
> --
> Neil N. Carlson Motorola, Los Alamos Research Park
> Motorola Labs / PSRL 4200 W. Jemez Road, Suite 300
> Computational Nanoscience Group Los Alamos, New Mexico 87544
>
> [log in to unmask] Fax: (505) 663-5150
> Voice: (505) 663-5106 Pager: [log in to unmask] or
> 888-946-2817
|