5.4. DOTLOOP: Using a Counted Loop

In the previous chapter, we presented the DOTPROD program that computed the dot product of two 3-component vectors without using a loop. A similar program, but with greater generality, would compute the dot product of two N-component vectors. Such a program, with the dimensionality N as a symbolic parameter at the top of the listing, is presented in Figure 5-1.

This more general program uses additional registers: r17 for the dimensionality and loop control, r14 as an address pointer for vector V , r15 as an address pointer for vector W , and r16 as an address pointer for the product P. While there is a little more overhead between first and top to get everything set up, the heart of the algorithm is simplified ...

Get Itanium® Architecture for Programmers: Understanding 64-Bit Processors and EPIC Principles now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.