Re: Derived types and allocatable
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Wed, 14 May 2008 13:27:46 -0800
James Giles wrote:
(snip on overhead for allocate on assignment)
It's still not clear to me what that overhead consists of.
In order to do a whole array assignment at all you must
do almost all (90+ %) of the work necessary to do conformance
tests. You have to find out how much data is moving and
from where to where,, that's nearly everything. Further,
that work is outside of the data movement itself, so the
remaining (<10%) of the effort is not "inside the loop".
If bounds checking is on, I agree the overhead is small.
Another consideration is in debugging where it is nice to
know the places where an array can be reallocated. If I
later find an array to be the wrong size, I have to go
through all possible reallocation statements to check.
(Partly that has to do with bugs I have chased down
in R programs, where R does allocate on assignment.
It also has to do with a feature of the R apply function.)
Since conformance testing is identical to the test for
reallocation (the only difference is what you do if
conformance didn't match), the only overhead if
both sides do conform is the test. I'm aware that
some implementors claim the overhead is significant.
I have no idea why.
Well, for small arrays in deeply nested loops it could
easily be very significant. Also, I am not sure how
good compilers are at optimizing bounds checking.
A DO variable (that isn't modified in the loop) can
be assumed to stay within the loop bounds, and should
avoid some bounds tests. I don't know which compilers
do that optimization.
Is it something inherent in the(snip)
problem, or (more likely) just something they haven't
worked out yet? The latter is likely because they can
always tell users to turn off the tests if the performance
is unacceptable. This allows them to put off the job
of fixing the performance problem. Things like that
can exist in implementations for years.
If you really need a way to defeat reallocation, how would
be:
A(::1) = b + c
I suppose that works.
-- glen
.
- Follow-Ups:
- Re: Derived types and allocatable
- From: James Giles
- Re: Derived types and allocatable
- References:
- Derived types and allocatable
- From: Gib Bogle
- Re: Derived types and allocatable
- From: Gib Bogle
- Re: Derived types and allocatable
- From: James Van Buskirk
- Re: Derived types and allocatable
- From: Steven Correll
- Re: Derived types and allocatable
- From: James Giles
- Re: Derived types and allocatable
- From: Jan Vorbrüggen
- Re: Derived types and allocatable
- From: James Giles
- Re: Derived types and allocatable
- From: glen herrmannsfeldt
- Re: Derived types and allocatable
- From: James Giles
- Derived types and allocatable
- Prev by Date: Re: advance=no problem
- Next by Date: Re: Derived types and allocatable
- Previous by thread: Re: Derived types and allocatable
- Next by thread: Re: Derived types and allocatable
- Index(es):
Relevant Pages
|