Re: Array intrinsics vs do loops in gfortran

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 27 2012, Chris Kerr wrote:

I'm working on RMCProfile ( http://www.rmcprofile.org ), trying to reduce the run time (which is on the order of 3 CPU years for my datasets). I've done some profiling and about 75% of the runtime is spent executing an operation of the form y(p:q) += a * x(r:s) [where q-p == s-r] - i.e. DAXPY but on slices of the original y and x arrays.

I have two questions about the above behaviour: 1) Why does the array intrinsic method use an extra instruction compared to the do loop? Is there any way of stopping this?

scientific-computing@ucs would have got to me more directly :-)
[ Aside: that is for the OP, as we work for the same university - it is
not for external use. ]

While many Fortran compilers used to generate very poor code for array
operations and intrinsics, it is typically better now, and I doubt that
the code difference you have seen is relevant.  In particular, the days
when the odd instruction made much difference are long gone.

2) Is there any way of getting these loops to use SIMD instructions such as vfmaddpd? Currently even when -march=native is switched on, the loop only uses the scalar instruction vfmaddsd. I'd rather not have to hand-code an unrolled loop, especially as I'm more used to C and Python so there would probably be off-by-one errors all over the place on my first ten tries.

Now, THAT is the issue, and you are tackling this the wrong way.  There
is no difficulty using DAXPY on slices, and that is what to do if the
slices are reasonably long.  You whould use a tuned BLAS, not the basic
Linux one, such as ATLAS, Intel MKL or AMD ACML.  All can be called
from gfortran code.  You could even do the code conversion automatically
using a Python script, if such constructions are spread all over the
code.

Now, DAXPY is only a level 2 BLAS, and it is quite likely that doing
that will give only a moderate gain.  If you contact me on that Email
with an offending procedure, I may be able to suggest a better method.


Regards,
Nick Maclaren.






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux