
25112 Rev. 3.06 September 2005 | Software Optimization Guide for AMD64 Processors |
“dotted” with a column of BT. Once this is done, the rows of matrix A are “dotted” with the next column of BT, and the process is repeated through all the columns of BT.
From a performance standpoint, there are several caveats to recognize, as follows:
•Once all the rows of A have been multiplied with the first column of B, all the rows of A are in the cache, and subsequent accesses to them do not cause cache misses.
•The rows of BT are brought into the cache by “dotting” the first four rows of A with each row of
BT in the Ctr_row_num
•The elements of CT are not initially in the cache, and every time a new set of four rows of A are “dotted” with a new row of BT, the processor has to wait for CT to arrive in the cache before the results can be written.
You can address the last two caveats by prefetching to improve performance. However, to efficiently exploit prefetching, you must structure the code to issue the prefetch instructions such that:
•Enough time is provided for memory requests sent out through prefetch requests to bring data into the processor’s cache before the data is needed.
•The loops containing the prefetch instructions are ordered to issue sufficient prefetch instructions to fetch all the pertinent data.
The matrix order of 32 is not a coincidence. A
Assume it takes 60 ns to retrieve data from memory; then we must ensure that at least this much time elapses between issuing the prefetch instruction and the processor loading that data into its registers. The
AMD Athlon, AMD Athlon 64, and AMD Opteron processors are capable of performing a maximum of two floating point operations per clock cycle; therefore, it takes the processor no less than
256clock cycles to process each Ctr_row_num
•All three matrices A, BT, and CT can fit into the processor’s
•On a
Chapter 9 | Optimizing with SIMD Instructions | 201 |