Be applicable to the branch prediction method that context switches
Technical field
The invention belongs to the micro-processor architecture field, particularly a kind of branch prediction method of microprocessor.
Background technology
Current various microprocessor is generally taked following two kinds of schemes when solving branch:
(1) time-out is got finger, comes out up to branch outcome.This way can take to add the method that postpones groove usually in order to reduce delay, but whether success generally all can produce certain delay no matter shift.As: the R4000 microprocessor of MIPS.
(2) take to a certain degree prediction, before branch outcome is come out, just get finger by the address of prediction.This method does not produce delay when conjecture is correct, but when conjecture is wrong, will cancels the instruction of having got into and get finger again, thereby causes the streamline cutout, has increased time-delay.As: the R10000 of MIPS, 21064,21164,21264 of Alpha, the UltraSparc series of Sun, the P6 series microprocessor of Intel etc.
Second kind of scheme is the current popular scheme, adopted by most of microprocessors.Wherein: the R10000 of MIPS, 21064,21164 of Alpha, the UltraSparc I of Sun adopts is bimodal (Bimodal Predictor) fallout predictor of two; That the UltraSparc III of the UltraSparcSun of Sun adopts is Gshare fallout predictor (Gshare Predictor); What the P6 series microprocessor of Intel adopted is the two-layer fallout predictor (Two-level Predictor) of PAs configuration (PAs configuration); That 21264 of Alpha adopts is hybrid predicting device (Hybrid Predictor).
In these schemes, bimodal (Bimodal Predictor) fallout predictor seldom uses basically, or is used with other fallout predictor, and other severally all belongs to two-layer fallout predictor, is divided into GAs, PAs and mixing (Hybrid) according to the configuration difference.Whether these schemes all are to utilize the historical record and the programmable counter PC of branch basically, form the index to pattern history table PHT (Pattem HistoryTable), shift according to the content decision of reading from PHT then.
For example, Fig. 1 is the synoptic diagram of the fallout predictor of use Gshare (belonging to the GAs configuration) method.It directly uses global branch history (Global Branch History) and a part of jump instruction address XOR mutually, at last minute jump instruction address of splicing, formation is to the index of PHT, from the PHT table, read corresponding list item with this index again, and whether predict redirect according to the content decision of reading.
The Forecasting Methodology of these fallout predictors has important disadvantages, they are not considered multi-user (multi-user), multiprogramming (multi-programming), multithreading (multi-threading), and multi-user, multiprogramming, being applied in the current and following processor of multithreading are inevitable, or even a kind of trend, so though they all have very high hit rate on the prediction monoprogrammed, but in actual applications, be subjected to the influence of the context switching (contextswitching) of process (comprising thread), effect is unsatisfactory.Some processor is in order to improve hit rate, use more position to write down transinformation, taken very big, valuable chip area, for example, 21264 the fallout predictor of Alpha has used 28K bits altogether, but the hit rate in the practical application can't be greatly improved.
The someone begins to study in theory the branch prediction of multiline procedure processor (multi-threadedprocessor) now, as: the scheme that J.Gummaraju and M.Franklin propose, but this scheme is also impracticable, because it has set up a PHT (PatternHistory Table) for each process, the quantity of the prediction bits that such fallout predictor is required, the chip area that will take will be beyond affordability in the practical application.Therefore really do not used yet.
So the context that is not suitable for the process (comprising thread) under multi-user, multiprogramming, the multi-thread environment that is applied to of existing Forecasting Methodology switches, and there is big, the unpractical deficiency of chip occupying area in theoretic multithreading Forecasting Methodology.
Summary of the invention
The object of the present invention is to provide a kind of branch prediction method that is applicable to that context switches,, run into when frequent context switches and also can bring into play good effect, and be convenient to realize even under the environment of multi-user, multiprogramming, multithreading.
A kind of branch prediction method that is applicable to that context switches of the present invention is characterized in that, comprises the following step:
A) branch instruction that will enter fallout predictor is carried out the comparison of process (comprising thread) number;
B) according to comparative result, if equal or overall situation position is " 1 ", adopt different global branch history register (Global Branch History Register) GBHR for different process numbers, and read wherein global branch history, and be " 1 " to overall situation position, use a fixing branch history register;
C) if comparative result does not wait and overall situation position is not " 1 ", select the branch history register of a sky, when not having the free branch history register, select a branch history register to replace
D) use the global branch history read to operate, the index of formation pattern list (Pattem History Table) PHT with the address of branch instruction;
E) access module table (Pattern History Table) PHT reads related content;
F) predict according to the result that finds, determine whether redirect.
Wherein in step a): the process number that relatively is to use branch instruction of process (comprising thread) number and the process number of each GBHR correspondence comprise the comparison of process indications ASID (address spaceidentifier) and the inspection of overall situation position Global.
Wherein in step b): removing Global is the GBHR that use " 1 ", and other each GBHR has the ASID of a correspondence, is used for comparing.
Description of drawings
In order further to understand technology contents of the present invention, below in conjunction with drawings and Examples the present invention is made a detailed description, wherein:
Fig. 1 is to use the synoptic diagram of the fallout predictor of Gshare method;
Fig. 2 is a branch transition fallout predictor of the present invention.
Embodiment
In the present invention, the use process represents that symbol (address space identifier) ASID and overall situation position Global come identification process, for each bar instruction, all have corresponding ASID and Global position.In the middle of general processor, the list item of preserving content corresponding is all arranged, the position difference of just depositing.
A kind of branch prediction method that is applicable to that context switches provided by the invention, shown in Figure 2 in conjunction with consulting, comprise the following step:
A) branch instruction that will enter fallout predictor is carried out the comparison of process (comprising thread) number, process (comprising thread) number relatively be to utilize to receive that Global position relevant with this branch instruction and ASID carry out with each global branch history register (Global Branch History Register) ASID that GBHR is corresponding, comprise the comparison of ASID and the inspection of Global position, see also the upper left among Fig. 2;
B) according to comparative result, if the Global position is " 1 ", the address that shows this instruction is that the overall situation is used, select to use special GBHR (Global Branch History Register), No. 0 GBHR for example, and this GBHR can not redistribute to any other process, sees also the bottom left section among Fig. 2;
C) if the Global position for " 0 " to decide according to the comparative result of ASID and select which GBHR:1 for use) have the content in the ASID territory of GBHR correspondence to equate with the ASID of this instruction, then select first equal GBHR for use; 2) if not do not equate, but also have vacant unappropriated GBHR, then select a sky, and the content in the ASID territory of correspondence is arranged to the ASID of this instruction; 3) if not do not equate, and do not have vacant unappropriated GBHR, then select a GBHR, redistribute, and make the content in the ASID territory of correspondence the ASID of this instruction into, see also the bottom left section among Fig. 2 to this ASID according to certain rule;
D) use the global branch history read to operate, the index of formation pattern list (Pattern History Table) PHT with the address of branch instruction;
E) access module table (Pattern History Table) PHT reads related content;
F) predict according to the result that finds, determine whether redirect, steps d sees also right half part among Fig. 2 to step f.
By preceding method as can be known the present invention have following a bit:
1. because the present invention has adopted the identification of special process in Forecasting Methodology, thus this be one specially at multi-user, multiprogramming, multi-thread environment, can adapt to the branch predictor method that the context of process (comprising thread) switches well.It has guaranteed, though fallout predictor be operated in multi-user, multiprogramming, multi-thread environment can be because context switches yet the performance of impact prediction device.
2. and owing to only used overall transfer history (Global BranchHistory) in predicted portions, taked the comparatively easily predict of row, avoided the realization complicacy.
Therefore the present invention has overcome the deficiency that context that the fallout predictor in the reality is not suitable for process (comprising thread) switches, and theoretic multithreading fallout predictor realizes deficiency complicated, the feasibility difference.