This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: F95 vectorization support


2008/6/18 ASIF LAKHANY <asif.lakhany@gmail.com>:
>
> Recently I have been involved in mixed language programming on Solaris sparc/x86 using Sun CC. I clearly see amazing performance improvements when off-loading mathematically
> intensive code to F95. I am new to F95. I generally develop in C++.
> From what I see it looks that gfortran may not provide anything beyond what g++ would
> provide. Is the compiler sensitive to vectorization supported by F95?
> It is very essential for me to know this as I rather not offload calculations if there is
> no gain whatsoever.
>
> Thanks for the support.
>

There has been a discussion on comp.lang.fortran about vectorization today:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/4f1669a33990fa92/16c70cf03193418c

But lets expand a bit more on your questions:
IMHO, and many people in scientific computing will surely agree,
Fortran is very suitable for writing high-performance computationally
intensive applications, as you have obviously noticed :-) Then again,
I find performance comparison between languages is even worse than
comparisons measurements between different architectures or compilers.
As Ted mentions, there are sophisticated and yet easy-to-use tools to
use in C++ to produce high-performance code. For my part, I prefer the
clarity and conciseness of Fortran. After all, for numerical
computations you need +, -, * and / of some numbers, done in some
loops and this is where Fortran shines. Auto-parallelisation is also
available for Fortran by certain compilers, but not for C AFAIK, and I
do not know how well this works in gcc.

When talking about mixed-language code, we are talking about a
trade-off: Mixed-language code is harder to maintain than "pure" code,
but may give better performance when laid out properly, or enable to
use a funky library, as Ted mentions. If you care a lot about
performance and managed to boost performance before by using Fortran,
this may well be worth the effort. Have a look at the ISO_C_BINDING
feature of Fortran 2003 on how to mix C and Fortran in a portable
manner. You'll need gcc >= 4.3.0 to use this. If your gcc is 4.0.x or
4.1.x, you'll want to upgrade anyway to compile Fortran.

Other than that, using Fortran for the computationally intensive stuff
is certainly sensible but not necessarily faster, if you get it wrong.
When using arrays of dimension > 1, row and column major ordering play
a role, since Fortran and C have different conventions on how
multi-dimensional arrays are laid out in memory.

If you pull the mixed-language feat, you can also try the
-fexternal-blas option of gfortran and link to either a vendor BLAS,
or to a tuned ATLAS library. Maybe one of the gfortran maintainers can
comment on whether this is a Good Idea (TM) or not.

Cheers,
Dennis


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]