Sender: Huicai (Old Ashrau), Letter Area: Fortran
Title: Efficient use of Fortran array
Sending station: 海星 云 (October 10, 2002 23:06:02 Thursday), station letters
Efficient use of Fortran array
1, array overall access
The fastest array operation occurs when continuously accessing the entire array or most of the groups. Implementing one or several arrays of the entire array or most array operations to be much higher than the decentralized array element.
With its explicit array cycle access, it is not as follows from the basic operation of the array, for example, to add each element of the array variable A to 1:
A = a 1
When reading and writing a array, you should use the array name instead of specifying the DO loop or hidden DO loop of each element number.
2. Use the list of array access and storage
When references the so-called Fortran array, to ensure that the correct reference syntax is used and pay attention to the list of "normal" increasing sequences. For the order as the main order, the leftmost subscript change is the fastest.
The order of behavioral owners (such as C language) or arbitrary order of multi-dimensional array access often lows the use efficiency of the CPU cache, so the order of behavior should be avoided.
3. Try to use the intrins in the fortran90
4, the width of the dimensional number of dimensions
In the multidimensional array of dispersion access array elements, the width of the width of the leftmost array dimension should be avoided, such as 512.
Because the size of the cache is 2 power part, if the size of the array is also a power of 2, the use of the cache is reduced when dispersing an array element. On the alpha system, if the maximum dimension of the array is just a multiplication of the cache, this puddle is almost unable to use a cache.
This problem does not exist if it is sequential access or an overall access array.
An improved method is to increase the width of the dimension, allowing some useless elements, thereby turning the width of the left side into a power part of the non 2, for example, to change the left side 512 to 520 to more efficiently Use a cache.
In higher advanced optimization (above three or more), the compilation system will fill the use efficiency of the cache that may cause the power of the power of 2.
-
※ Source: · 海星 cloud bbs.ustc.edu.cn · [from: 210.45.124.65]
-