Matrix multiplication is commonly written as shown in the following example:
Example 1: Typical Matrix Multiplication |
---|
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.
Example 2: Matrix Multiplication with Stride-1 |
---|
DO J=1,N |