|
tatami_mult
Multiply tatami matrices
|
We can use multiple accumulators to speed up the calculation of dot products. That is, instead of computing the dot product as:
We could instead use two accumulators:
The idea is to break dependency chains in the CPU's instruction pipeline by allowing multiple summations to occur in parallel. It also provides some opportunities for auto-vectorization of the sum in the innermost loop. However, we don't want to use too many accumulators as this could cause register spills and inflate the program size. Different numbers of accumulators may also slightly alter the output due to changes in floating-point round-off error.
The number of accumulators should be positive. (Setting it to 1 will just fall back to the obvious summation.) If multiple accumulators are to be used, we recommend setting the number of accumulators to a power of 2. This reduces the cost of the division to compute the number of loop iterations and is most compatible with vector instructions (if available). Some testing indicates that 4 accumulators is a decent default, at least on Intel.