Tobias Burnus wrote:
> On 02/24/2010 07:30 PM, Greenberg, Naomi wrote:
>> I am looking for books or articles that discuss machine efficiency issues with respect to the more OO-oriented Fortran features.
>>
>
>
> Maybe a more relevant change in Fortran 2003: If "A" is allocatable then
> doing
> A = some_expression
> will reallocate "A" if the shape of A does not match the right-hand
> side. That's a nice feature, but has some overhead.
Some compilers provide a switch to turn the feature off because of the
adverse effects on existing code. With the Cray compiler the "off"
setting is the default - you have to explicitly add -ew to the compile
command to enable this auto-reallocation.
For writing new codes,
If you do not want
> to have the reallocation, you can do:
> A(:,:) = some_expression
is the recommended way around the issue.
> which prevents the reallocation (and all compilers should be smart
> enough to figure out that this is effectively a whole-array reference).
>
> Tobias
>
> PS: Writing clean, simple, and understandable code is usually better
> than trying to blindly optimize it - which even might lead to slower
> code.
Probably the best single-sentence recommendation on this topic.
>
> PPS: Talking about efficiency in Fortran 95+: I really like the
> CONTIGUOUS attribute of Fortran 2008 - it finally combines the advantage
> of assumed-shape arrays (no copy in, copy out needed, having an array
> descriptor) with the advantages of assumed size/explicit size arrays,
> namely: having a stride of 1 which simplifies the code (in terms of
> machine instructions) and allows for vectorization. Hopefully, it will
> get soon implemented in the compilers.
We found the same interest, and have already put it into our compiler.
Cheers,
Bill
--
Bill Long [log in to unmask]
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
|