|
|Hello,
|I justed wanted to thank you all for your prompt responses to my
|question on
|finding indices in F90.
|
|I was intrigued by one of your comments that suggested that do loops might
|in fact be faster then the "vector" operations like PACK(with a
|MASK) etc.
|I am sure that the these intrinsic routines will contain do-loops and IF
|statements; however, aren't those instructions coded in a much lower level
|language, thus making them much faster. On the CRAYs, one is always
|encouraged to take advantage of vector operations and avoid nested
|do-loops.
Let me know if you don't recognize any of these terms...
_Most_ Crays have vector registers. On a vector machine (that is, a machine
with vector registers) one should always try to cast problems in a vector
manner to take advantage of the architecture. Not all computers have vector
registers (in fact, not all supercomputers either). This means you need a
portable way to handle vector and matrix operations.
This is often done by employing the BLAS library routines, which are not
part of any particular language. The BLAS library is a collection of
routines which encompass the most common linear algebra operations. It is
usually tailored to the machine it is running on. So on a Cray or other
vector register machine, it will written using vector instructions; on a
superscalar processor, like a Sun or Wintel machine, it will essentially be
optimized nested loops. You link to this library and call these routines
from either Fortran or C/C++.
The reason for using the BLAS instead of a language's own "vector" rotines
is that you have no certainty that the vector-based routines in any
particular compiler are done "properly"; they may just be stand-ins for do
loops _always_. This is fine for a superscalar processor, but as you
yourself stated, but it's bad news for a vector machine.
Lest I annoy the compiler guys who subscribe to the list, :-) I will add
that a good compiler should recognize the platform it runs on and do some
sort of optimization. So dot_product() in Fortran 90 _should_ be different
depending on whether the platform is a Wintel or a Cray. But I would ask.
:-)
| Any further comments on this? Since I am not a computer science type, I
|do not understand the details of compilers, just from what I run.
|
|Once again, thanks to all of you.
|
|Regards
|Ashish
Hope I've provided some insight. :-)
Alvaro
|