Re: forall and do loop
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Mon, 30 Jul 2007 10:46:49 -0800
highegg wrote:
(snip regarding FORALL)
But they shouldn't be. Everyone seems to accept compiler creating
necessary temporaries when evaluating scalar expressions, and the
whole array arithmetic stuff is build around the idea of treating
arrays quite like scalars.
Fortran 2003 7.4.4.2.3:
"Execution of a forall-assignment-stmt that is an
assignment-stmt causes the evaluation of expr and all
expressions within variable for all active combinations of
index-name values. These evaluations may be done in any order.
After all these evaluations have been performed, each expr
value is assigned to the corresponding variable.
The assignments may occur in any order."
It would seem that the definition is ripe for the creation
of a temporary array. It specifically allows the evaluations to
be done in any order, followed by all the assignments done in any
order. It would seem well designed for any processor with that
(unusual) ability.
If I designed FORALL I would have allowed intermixing of evaluation
and assignment in any order, and left it to the programmer to be sure
that would work.
And strangely enough, people seem to calmly accept Matlab or Octave
making temporaries for array arithmetics all the time, but for some
reason they expect a Fortran compiler to be so ultra-mega-intelligent
and reduce the temporaries to an absolute minimum (or even below
that). Why?
That is common for interpreted languages. Note that many such
languages will dynamically create arrays when needed. They tend
to be slow in other ways, such that one doesn't notice the difference
in time to create and process such arrays.
-- glen
.
- Follow-Ups:
- Re: forall and do loop
- From: Richard Maine
- Re: forall and do loop
- References:
- forall and do loop
- From: aeroguy
- Re: forall and do loop
- From: glen herrmannsfeldt
- Re: forall and do loop
- From: aeroguy
- Re: forall and do loop
- From: *** Hendrickson
- Re: forall and do loop
- From: highegg
- Re: forall and do loop
- From: *** Hendrickson
- Re: forall and do loop
- From: highegg
- Re: forall and do loop
- From: *** Hendrickson
- Re: forall and do loop
- From: highegg
- forall and do loop
- Prev by Date: Re: forall and do loop
- Next by Date: Re: forall and do loop
- Previous by thread: Re: forall and do loop
- Next by thread: Re: forall and do loop
- Index(es):