When arrays have stride equal to 1 (a very common case), it seems that code compiledfor the generic case (any nonzero stride) will often be suboptimal.
On the other hand, creating multiple versions of compiled functions andsubroutines when some of the arguments are stride=1 scales exponentially
with the number of arguments that are arrays.
What is the approach taken by Fortran compilers such as GFortran and Intel Fortran here?
I've come across this question on StackOverflow, which asks how
Fortran compilers efficiently handles dummy array arguments that
may have unit or non-unit strides (e.g., for assumed-shape arrays),
without increasing code generation patterns(?) exponentially
for getting performance.
"How do Fortran compilers handle stride=1 arrays?" https://stackoverflow.com/questions/69218925/how-do-fortran-compilers-handle-stride-1-arrays
Hello,
I've come across this question on StackOverflow, which asks how
Fortran compilers efficiently handles dummy array arguments that
may have unit or non-unit strides (e.g., for assumed-shape arrays),
without increasing code generation patterns(?) exponentially
for getting performance.
"How do Fortran compilers handle stride=1 arrays?" https://stackoverflow.com/questions/69218925/how-do-fortran-compilers-handle-stride-1-arrays
(the main text of the above question)
When arrays have stride equal to 1 (a very common case), it seems that code compiledfor the generic case (any nonzero stride) will often be suboptimal.
On the other hand, creating multiple versions of compiled functions andsubroutines when some of the arguments are stride=1 scales exponentially
with the number of arguments that are arrays.
What is the approach taken by Fortran compilers such as GFortran and Intel Fortran here?
# The comments in the Q/A page mention the CONTIGUOUS attribute, but
I guess the point of the question is not how to ensure the contiguity of a dummy array (from
the user side), but how compilers generate codes for dummy arrays that may or may not be contiguous.
# I had a similar question before, but never asked it on the net, so just curious :)
I will forward any suggested info to the Q/A page above, if necessary.
spectrum <septc...@gmail.com> schrieb:
"How do Fortran compilers handle stride=1 arrays?" https://stackoverflow.com/questions/69218925/how-do-fortran-compilers-handle-stride-1-arrays
If the dummy argument is CONTIGUOUS, then gfortran will insert
code to conditionally do copy-in/copy out of the argument.
# I had a similar question before, but never asked it on the net, so just curious :)There would also be the option of generating two loops, one for stride=1
I will forward any suggested info to the Q/A page above, if necessary.
and one for stride /= 1. There is a PR for gfortran about this, but
so far it has not attracted a patch.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 99:39:05 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,957 |