In computer science, software pipelining is a technique used to optimize loops, in a manner that parallels hardware pipelining. Software pipelining is a type of out-of-order execution, except that the reordering is done by a compiler (or in the case of hand written assembly code, by the programmer) instead of the processor. Some computer architectures have explicit support for software pipelining, notably Intel's IA-64 architecture.
It is important to distinguish software pipelining which is a target code technique for overlapping loop iterations, from modulo scheduling, the currently most effective known compiler technique for generating software pipelined loops. Software pipelining has been known to assembly language programmers of machines with instruction level parallelism since such architectures existed. Effective compiler generation of such code dates to the invention of modulo scheduling by Rau and Glaeser. Lam showed that special hardware is unnecessary for effective modulo scheduling. Her technique, modulo renaming is widely used in practice. Gao et al. formulated optimal software pipelining in integer linear programming, culminating in validation of advanced heuristics in an evaluation paper. This paper has a good set of references on the topic.
Consider the following loop:
In this example, let A(i)
, B(i)
, C(i)
be instructions, each operating on data i
, that are dependent on each other. In other words, A(i)
must complete before B(i)
can start. For example, A
could load data from memory into a register, B
could perform some arithmetic operation on the data, and C
could store the data back into memory. However, let there be no dependence between operations for different values of i
. In other words, A(2)
can begin before A(1)
finishes.