Matrix multiplication is commonly written as shown in the following example.
DO I=1, N |
The use of B(K,J), is not a stride-1 reference and therefore will not normally be vectorizable. If the loops are interchanged, however, all the references will become stride-1 as in the Matrix Multiplication with Stride-1 example that follows.
Note
Interchanging is not always possible because of dependencies, which can
lead to different results.
Matrix Multiplication with Stride-1 |
DO J=1,N |
For additional information, see Publications on Compiler Optimizations.