The invention relates to power reduction in microprocessor systems comprising a microprocessor and a memory connected by at least one bus.
The methods described in this specification aim to improve the processor's average inter-instruction Hamuning distance. The next few paragraphs describe this metric and explain its relation to power efficiency.
The Hamming distance between two binary numbers is the count of the number of bits that differ between them. For example:
Hamming distance is related to power efficiency because of the way that binary numbers are represented by electrical signals. Typically a steady low voltage on a wire represents a binary 0 bit and a steady high voltage represents a binary 1 bit. A number will be represented using these voltage levels on a group of wires, with one wire per bit. Such a group of wires is called a bus. Energy is used when the voltage on a wire is changed. The amount of energy depends on the magnitude of the voltage change and the capacitance of the wire. The capacitance depends to a large extent on the physical dimensions of the wire. So when the number represented by a bus changes, the energy consumed depends on the number of bits that have changed—the Hamming distance—between the old and new values, and on the capacitance of the wires.
If one can reduce the average Hamming distance between successive values on a high-capacitance bus, keeping all other aspects of the system the same, the system's power efficiency will have been increased.
The capacitance of wires internal to an integrated circuit is small compared to the capacitance of wires fabricated on a printed circuit board due to the larger physical dimensions of the latter. Many systems have memory and microprocessor in distinct integrated circuits, interconnected by a printed circuit board. Therefore we aim to reduce the average Hamming distance between successive values on the microprocessor-memory interface bus, as this will have a particularly significant influence on power efficiency.
Even in systems where microprocessor and memory are incorporated into the same integrated circuit the capacitance of the wires connecting them will be larger than average, so even in this case reduction of average Hamming distance on the microprocessor-memory interface is worthwhile.
Processor-memory communications perform two tasks. Firstly, the processor fetches its program from the memory, one instruction at a time. Secondly, the data that the program is operating on is transferred back and forth. Instruction fetch makes up the majority of the processor-memory communications.
The instruction fetch bus is the bus on which instructions are communicated from the memory to the processor. We aim to reduce the average Hamming distance on this bus, i.e. to reduce the average Hamming distance from one instruction to the next.
Instruction formats will now be discussed.
A category of processors which is suitable for implementation of the invention is the category of RISC (Reduced Instruction Set Computer) processors. One defining characteristic of this category of processors is that they have regular, fixed-size instructions. In the example processor considered here all instructions are made up of 32 bits. This is the same as the size of the instruction fetch bus.
Each instruction needs to convey various items of information to the processor. These items include:
For example, an instruction that tells the processor to “add 10 to the value currently in register 4 and store the result in register 5” would have the opcode for ‘add’, register specifiers 4 and 5, and immediate value 10.
The instruction set for the example processor considered here has only three instruction formats. The first has a five-bit opcode and a 26-bit immediate value. The second has a five-bit opcode, two five-bit register specifiers, and a 16-bit immediate value. The third has a five-bit primary opcode, a six bit secondary opcode and three five-bit register specifiers. The fields are arranged so that the primary opcode field is always in the same bit positions for each of the different formats:
One embodiment of the invention seeks to reduce the average inter-instruction Hamming distance by assigning appropriate bit patterns to the opcodes.
The invention provides a method of reducing the power consumption of a microprocessor system, a program, and a reduced power microprocessor system, as set out in the accompanying claims.
Embodiments of the invention will now be described, by way of example only, with reference to the accompanying figure.
The accompanying figure shows a microprocessor system 2 suitable for implementation of the invention. The microprocessor system 2 comprises a microprocessor 4 connected to a memory 6 by a bus 8. The microprocessor 4 and memory 6 may of course be incorporated into the same integrated circuit.
Part of the design of an instruction set is the allocation of bit patterns to each opcode. An example of a set of opcodes and the corresponding bit patterns is shown in the table below:
When examining the behaviour of programs it is observed that some pairs of opcodes tend to be executed consecutively more frequently than others. We can therefore arrange for the pairs of opcodes that are frequently consecutive to have bit patterns with small Hamming distances between them.
To achieve this, we need to measure how frequently each of the opcodes is executed consecutively to any of the other opcodes. We can measure this from running benchmark applications. When possible, these benchmarks should be the specific application that will be run by the processor, along with representative run-time data to operate on. For a general-purpose processor, a set of representative benchmarks can be chosen.
Initially, we will consider the primary opcode bit patterns because, in the example instruction set considered above, these have the benefit that they are only ever aligned with other primary opcode bit patterns.
From the benchmark results, we construct a matrix, F, for all pairs of opcodes, which indicates the frequency with which they are executed consecutively:
We aim to choose a mapping, M, from a bit pattern to the opcode that it will represent:
When selecting this mapping, we attempt to minimise the following summation:
Where H(i,j) is the Hamming distance between bit patterns i and j, M[i] and M[j] are the opcodes assigned to bit patterns i and j respectively, F(a, b) is the frequency with which opcodes a and b are executed consecutively, and there are ‘n’ possible bit patterns that can be used to represent the opcodes. Note that not every bit pattern has to represent an opcode, in which case F(M[i], M[j]) is zero.
Various methods are possible to optimise this in order to minimise the overall Hamming distance. An exhaustive search may be possible when there are small numbers of bit patterns. Otherwise, a heuristic based minimisation algorithm can be used; for example simulated annealing or a genetic algorithm.
Next we consider optimisations relating to the secondary opcode bit patterns.
From the illustration of the three typical instruction formats given above, it can be seen that the secondary opcode field may be adjacent to an immediate value in addition to other secondary opcode fields.
In the simplest algorithm, benchmark data is used to measure the frequency with which each of the secondary opcodes occurs. The most common secondary opcodes are then assigned bit patterns that are close in terms of Hamming Distance to zero. This assumes immediate value bit patterns tend to contain mostly zeros.
A better method exists that takes the actual values of the immediate value bit patterns into account. We again construct a matrix of adjacent fields, but also include all of the possible immediate values that are adjacent to the secondary opcode fields, along with the frequency that they occur:
The bottom right quadrant of this matrix represents the frequency of consecutive immediate values, the optimisation of which is discussed in a separate patent application.
Given:
Let:
By simulation, or otherwise, we determine:
We aim to find an optimal mapping, M(a)=x, for aεS and xεP, that maps between an opcode, or an immediate value, and the bit pattern that is used to represent it. For example, M(O1)=P23 would indicate that bit pattern P23 has been allocated to opcode O1. For immediate values (aεI), the mapping defines the number representation in use, e.g. binary, two's complement binary, Gray code, sign magnitude, etc.
We find a permutation of the mapping function for the instruction opcodes (i.e. M(a), for all aεO) such that the following expression is minimized:
Once again, the optimization process can use any of the standard techniques such as an exhaustive search, or a heuristic method such as simulated annealing or using a genetic algorithm.
Although the above method has been described for secondary opcodes that may be intermixed with immediate values, it is also applicable to other control codes in an instruction. For example the codes that specify the registers to be used by each of the operations may also be aligned with each other, or with parts of an immediate value, and therefore may also be optimized using the techniques described.
More generally still, this invention may also be applied to any other environment where a data stream contains a number of aligned elements, some of which have a fixed bit pattern representation while others can be modified.
Number | Date | Country | Kind |
---|---|---|---|
0119498.4 | Aug 2001 | GB | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/GB02/03650 | 8/8/2002 | WO |