Aleksandar Donev writes:
> > If I were doing this in Fortran 77, I would write something like
...
> I never use F77 constructs such as COMMON, EQUIVALENCE, SEQUENCE, GOTO, etc.
> (simply because there are better F90 alternatives), it never occured to me
> to use EQUIVALENCE (sort of a Fortran union).
Oh. It tends not to occur to me that people wouldn't be aware of how
to use EQUIVALENCE for this kind of thing. I figure that people
already know about that, but are looking for possible alternatives.
This is undoubtedly a narrowness in my viewpoint; I should be more
careful about that assumption.
> It should also be trivial for compilers to use as an idiom when
> they see TRANSFER and then use the old equivalence
> optimizations/translation.
I'm not a compiler writer either, and I also once used to assume
that TRANSFER was trivial and would be fast. Some cases indeed
are trivial. Others are not. Consider things like
a = transfer(b,a)
Looks simple. But if A and B are assumed shape dummy arrays, possibly
non-contiguous, with different strides, and with different element
sizes, then this isn't nearly so trivial. Yes, the concept is
trivial enough, but trivial efficient implementation of the general
case is not so obvious. (A naive implementation might involve
allocating a temporary contiguous array, copying the bits from B
into that array, and then copying from that array out to A. That's
simple enough, but not particularly efficient).
I'd say that a crucial point would be for compilers to be able to
distinguish the trivial cases from the non-trivial ones. Let the
non-trivial ones be slow, but do the "obvious" optimizations for the
simple cases. From my naive, non-compiler-writer viewpoint, this
seems like it should be practical - probably just needs sufficient
motivation to make it worth the compiler-writers' bother.
"Motivation" in this case probably translates roughly into customers
that complain and might even use it as a consideration affecting
competitive choices.
--
Richard Maine | Good judgement comes from experience;
[log in to unmask] | experience comes from bad judgement.
| -- Mark Twain
|