Process for dividing instructions of a computer program into instruction groups for parallel processing5712996Abstract In order to be able to execute rapid processing of a program on super-scalar microprocessors, the individual instructions of this program must be divided into instruction groups, which can be processed by processing units of the microprocessor, in such a way that the instructions can be processed in parallel. In this case, it is necessary to take account of data-flow dependences and control-flow dependences as well as pipeline conflicts. For this purpose, the first step is to select the instructions whose precursor instructions have already been processed and to investigate these instructions as to whether before their execution a minimum number of delay cycles is necessary, and the instructions are stored with a minimum number in a list. From these instructions, one is selected using a heuristic selection process, and this one is classified into an instruction group in which the instruction can be processed in the earliest possible execution cycle. Claims What is claimed is: Description BACKGROUND OF THE INVENTION
______________________________________
1: 1w r3, 0 (r4) #load word
2: add r3, r3, 1 #add
3: s1 r4, 1 #shift left
4: sub r3, r3, r4 #subtract'
5: 1.s f2, 0 (r5) #load float
6: add.s f1, f2, f1 #add float
7: abs.s f3, f2 #float absolute
8: s.s f3, 0 (r5) #store float
9: bgtz r3, L1 #branch greater zero
______________________________________
The individual instructions are easy to understand with the aid of the explanations given next to the instructions. For example, instruction states that a word is to be loaded into the register r3, specifically from a memory location whose address is in register r4. In the second instruction the I is to be added to the contents of the register r3, and the result is to be stored in the register r3. Instruction 3 indicates that the data item in the register r4 is to be shifted to the left by one position. Instruction 4 is a substraction instruction, specifically that the contents of register r4 are to be subtracted from the contents of register r3 and the result stored in the register r3. The instructions I to 4 are so-called integer instructions. The instructions 5 to 9, by contrast, are floating-position instructions. Instruction 5 indicates that a floating-position number whose address is in the register r5 is to be loaded into the floating-position register f2. According to instruction 6, the contents of the floating-position register f1 are added to the contents of the floating-position register f2, and the result is stored in the floating-position register f1. The absolute value of the floating-position number is formed in the instruction 7, specifically the number which is in the register f2, and the result is stored in the floating-position register f3. The contents of the floating-position register f3 are stored in the memory at an address which is in the register r5, and at the every end there is executed in the instruction 9 a branch instruction in the case of which a jump is made to the address L1 when the contents of the register r3 are greater than zero. The graphical representation of the single FIGURE is used to show the data dependences of the individual instructions, and thereby to provide a better illustration of the problems which occur in the case of parallel processing. The representation consists of nodes and edges, there being respectively arranged at the edges a delay cycle table V-Tab which specifies whether a delay cycle is required between two successive instructions. The first number shows the delay cycles which must be ensured by explicit NO-OPERATION (noop) instructions in the instruction sequence, while the second number shows the number, conditioned by pipeline conflicts, of delay cycles which are symbolized in the program with the aid of s-noop instructions. For example, in the case of the integer instructions a delay cycle is required if the instruction 2 is executed directly after instruction 1. By contrast, the instruction 3 is independent of the execution of the instruction 2, with the result that these instructions can be executed in parallel. However, on the basis of the data dependence it can be executed only after the instruction 1, since otherwise the memory address in register r4 would be wrong. A corresponding statement also holds for the floating-position instructions, which are represented on the right-hand side of the diagram. Here, delay cycles are specified in V-Tab at the first position on the basis of data dependence; delay cycles which are present on the basis of pipeline conflicts are specified at the second position. This means, for example, that the instruction 8 "s.s" cannot be executed without additional delay cycles until two further clock cycles have elapsed after execution of the instruction 7 "abs.s". Furthermore, the dependence between instructions "add.s" and "abs.s" is specified in the single FIGURE. For example, "add .s" cannot be executed by the same processing unit after "abs.s" until after three delay cycles. Conversely, "abs.s" cannot be executed until two delay cycles after "add.s". This dependence does not exist in the case of processing on different units. Before the process according to the invention is explained in detail, some terms which are used in the process remain to be defined: 1. Blocking position L; this is occupied when an instruction causes at least one delay cycle to one of the directly following instructions. 2. Succession number; this number indicates how many data-dependent succeeding instructions follow an instruction. The more successors an instruction has the higher is its priority in the classification of the instructions into the instruction groups. 3. Distance value; it specifies the maximum distance in clock cycles between the instruction under consideration and the last instruction in the diagram. The delay cycles are also to be taken into account in this case. Let: d (n, n') be the maximum number of delay cycles between an instruction n and a directly data-dependent succeeding instruction n', and let h (n') be the distance value of n'; it is then the case that the distance value of n follows from h (n):=0, where the number of successors is equal to 0, or h (n)=h (n')+d (n, n')+1, the maximum value being taken in the case of a plurality of direct successors n'. These values are inserted into the value tables W-Tab, which are specified for the purpose of illustration at the individual nodes of the diagram of the single FIGURE. Proceeding from the left, the blocking position L is specified at the first position, the succession number at the second position, and the distance value at the third position. For example, in the case of the instruction 1 "lw", the blocking position L is set, since a delay cycle follows; the succession number is 2, since two data-dependent instructions follow directly; the distance value is 4 between the first instruction and the instruction 9. The other value tables, which are assigned to the other nodes, can be interpreted correspondingly. The process according to the invention is now explained in further detail with the aid of the diagram of the single FIGURE and using Table 1 and Table 2. Table 1 shows how the individual instructions of the program section are successively treated and then assembled, in accordance with Table 2, into instruction groups which can be executed in parallel by the processing units of the super-scalar processor. It is assumed here in this regard as an example that the super-scalar processor can load datawords with a length of 3 instructions. The investigation of the program section is always performed using the instructions which are first in the diagram according to the single FIGURE and have no precursor instructions on which they are dependent in terms of data. Subsequently, the investigation of the instructions following these instructions is performed, and it is always investigated into which instruction group an instruction is then to be classified. The aim is thus to classify the instructions into the instruction groups such that the number of required delay cycles is a minimum. This aim is achieved by means of the following process steps: In the first step, the blocking position, the succession number and the distance value are calculated for each instruction and are stored in the value table W-Tab. The delay cycles are in the V-Tab. It is ensured in the second step that all the instructions are unmarked. In the third step, a first list CS is formed into which the instructions are taken which have no unmarked precursor instruction. It is checked in the fourth step whether the first list CS is empty or not, and the process is terminated in the case in which the first list is empty. In the fifth step, those unmarked instructions from the first list are determined which can be executed after a minimum number of delay cycles, and a second list RS is formed from these instructions. In the sixth step, one of the instructions contained in the second list is selected in accordance with a heuristic selection process and is provided for classification into the instruction groups. In the seventh step, the selected instruction is inserted into one of the instruction groups in a component. To this end, the earliest possible cycle is firstly determined in which the instruction selected in step 6 can be executed. Thereafter, the instruction group is selected which is executed in this clock cycle or else as soon thereafter as possible, and into which the instruction can be placed taking account of possibly present grouping restrictions caused by the architecture of the processor. Empty positions within the instruction group before the last instruction arranged must be filled up with s-noop instructions. In step 8, the inserted instruction is marked and removed from the list CS. The process continues with step 3. The heuristic selection process (step 6) can be performed, for example, in the following way: --Firstly, there are Selected in the second list RS the instructions whose blocking position L is set. If there is only one such instruction, this instruction is selected. If there is a plurality of such instructions, or should there by no instruction having a set blocking position, the further procedure is as follows: --From the second list, instructions are selected which have the highest distance value. If there are a plurality of instructions having the highest distance value, the instructions which have the highest succession number are selected from these. --Whenever a plurality of equivalent instructions have been determined, one of the instructions can be freely selected and inserted into the instruction group in accordance with step 7. The heuristic selection process according to step 6 can, of course, also be performed in another way, for example the individual represented steps can be interchanged, which can, however, lead to worse solutions.
TABLE 1
______________________________________
Instruction
CS RS (cycle)
______________________________________
1 Iw; 1.s Iw; 1.s 1.s (1)
2 1w,add.s; abs.s
1w 1w (1)
3 add; s1; add.s; abs.s
s1; add.s; abs.s (3)
4 s1 s.s; add; add.s
abs.s s1 (2)
5 add.s; s.s; add
add; s1; add (3)
6 sub; add.s; s.s
add add.s (3)
7 sub; s.s sub; s.s; sub (4)
8 s.s.. add.s s.s (5)
9 bgzt sub; s.s bgzt (6)
s.s
bgzt
______________________________________
In Table 1, the first list is designated as CS in the first column, while the second list is designated as RS, and the third column specifies which instruction has been selected. In Table 2, the individual instruction groups BG are shown which are produced in accordance with the process. Specified in the first column is the processing cycle in which the instruction group is executed, and in a second column a first component KP1 of the instruction groups BG is specified, in a third column a second component KP2 of the instruction groups BG is specified, and in a fourth column a fourth component KP3 of the instruction groups BG is specified. Delay cycles are specified by s-noop within the individual instruction groups. At first, the two Tables 1 and 2 are empty. It is assumed that the steps 1 and 2 have already been carried out. A start is therefore made with step 3 of the process. Initially, a search is made for the nodes or instructions which have no unmarked precursor. According to the single FIGURE, these are the instruction "lw" and the instruction "l.s". These two instructions are entered into the first row in Table 1 in the column CS, It is then investigated in step 5 which of these two instructions requires a minimum number of delay cycles. Both instructions can be executed without additional delay cycles, and the instructions are consequently inserted into the column RS. One of the two instructions is selected in step 6. Since both instructions have a set blocking position, the instruction is selected which has the largest distance value, and that is the instruction "l.s.". This instruction is now inserted into an instruction group in Table 2. With the agreement that the insertion into the instruction book is performed at the earliest possible execution cycle, and that, for example, at the permissible column (component) furthest to the left, the instruction of the instruction group in the cycle 1 is assigned to the component KP1. The instruction "l.s" is marked, and a start is made in turn with step 3 of the process. After step 3, the instructions are selected which have no unmarked immediate precursors. Apart from "lw", these are now also the instructions "add.s" and "abs.s". These are inserted into the column CS. It is now investigated in step 5 which of these instructions can be processed after a minimum number of delay cycles, and these are inserted into the column RS. RS contains only the instruction lw, with the result that the latter is selected and likewise, in accordance with step 7, inserted in the first cycle at the second position KP2. Yet a third operation is to be explained. A start is made again with step 3 and it is investigated which additional instructions have no unmarked precursor instructions. These are the instructions "add" and sl". Step 5 is carried out for all the instructions from CS, and it is established which instruction becomes ready for processing after a minimum number of delay cycles. These are the instructions "sl", "add.s" and "abs.s", which are then inserted into the second column RS. The step 6 is now carried out for the three instructions contained in the column RS. Apart from these, only the instructions "abs.s" and "add.s" are provided with a set blocking position, so that that one having the highest distance value ("abs.s") is selected. The latter must now be inserted into the instruction groups in the table. In this case, it has to be taken into account that "abs.s" cannot be executed until one delay cycle after "l.s". It is thus inserted in the cycle 3 in accordance with step 7. A fourth operation is outlined as a conclusion to the explanation of the process. After marking the instruction "abs.s" in accordance with step 8, the instruction "s.s" is inserted into the column CS in step 3. The instructions "add", "sl" and "add.s" are additionally in this column. Only the instructions "add" and "sl" can be executed without a delay cycle, since "add.s" may be executed at the earliest two delay cycles after "abs.s". An instruction is selected according to step 6 between "add" and "sl". Since both have the same entries in W-Tab, one can be freely selected, for example "sl". The instruction "sl" must now be inserted into one of the instruction groups. It can be seen that the instruction "sl" can be executed immediately after execution of the instruction "lw", with the result that it can be arranged in the second cycle. In accordance with step 7, it is thus assigned to the first component KP1 of the second instruction group BG2. The instruction "sl" is marked, and then the procedure is continued again with step 3 of the process. This takes place until no more instructions are contained in column 1 of Table 1. The result is instruction sequences BG1 to BG6 in accordance with Table 2. It is positioned out that whenever in accordance with step 6 a plurality of similar instructions are present, one of the instructions can be freely selected, and consequently the instructions contained in one Instruction group can be different in accordance with this selection. All the positions not occupied so far in the instruction groups BG can be supplemented with snoop instructions. As a program array in Table 2 shows, only two processing units need to be capable of processing floating-position instructions. The graphical representation of Table 2 shows that a two-dimensional representation is developed from a program. Consequently, the super-scalar processor is capable of fething not only one instruction per cycle, but it can fetch a group of instructions which can all be executed in parallel, without conflicts arising. The aim of the code generation for super-scalar processors, which consists in a maximum number of instructions being capable of being processed in parallel, is then achieved. Super-scalar processors thus require not instruction sequences, but sequences of instruction groups. This can be read off very well in Table 2. The number of components in the program array depends on the number of instructions which the processor can load simultaneously. It remains to be mentioned that the insertion of the snoop instructions was necessary only for the explanation. For the code generation, the rows of the array are arranged one behind another, for example from left to right, and the snoop instructions are cancelled. The invention is not limited to the particular details of the method depicted and other modifications and applications are contemplated. Certain other changes may be made in the above described method without departing from the true spirit and scope of the invention herein involved. It is intended, therefore, that the subject matter in the above depiction shall be interpreted as illustrative and not in a limiting sense.
|
Same subclass Same class Consider this |
||||||||||
