简体   繁体   English

什么是更好的分支预测器? 双峰还是Gshare?

[英]What's a better branch predictor? Bimodal or Gshare?

Just for my own personal knowledge... 仅出于我个人的知识...

Which of the two, Bimodal or Gshare, provide more correct predictions than the other? Bimodal或Gshare中的哪一个比其他提供的预测更正确? why? 为什么?

With predictors there's no such thing as "better", you could ask which one performs better (less mispredictions) for a given workload/application, or a set of these like a benchmark suite. 使用预测变量时,没有“更好”的东西,您可以询问对于给定的工作负载/应用程序或一组类似基准套件,它们的性能更好(错误预测更少)。 The performance also depends on the parameters (table sizes, history length, etc..). 性能还取决于参数(表大小,历史记录长度等)。

The two are quite different, and each could work better for a different scenario. 两者是完全不同的,并且在不同的情况下都可以更好地工作。 You could say that the bimodal is likely to learn faster and have less collisions, but the global variants are more elaborate and have better chance to capture complicated patterns. 您可能会说,双峰模式可能学习得更快,并且碰撞更少,但是全局变量更复杂,并且捕获复杂模式的机会更大。 However it has higher collisions since the tables represent all sorts of partial histories, and has lower chances to converge in some cases. 但是,由于表代表了各种部分历史记录,因此冲突程度更高,并且在某些情况下收敛的机会较小。

It's better to demonstrate the strong/weak spots with this example: 最好通过以下示例演示强项/弱点:

for (i=0; i<N; ++i) {
    if (A[i] < 50) 
        do_stuff();
    if (A[i] > 50)
        do_other_stuff()
}

The branches are data dependent (let's say the data is randomly distributed evenly in [1..100]), so the bimodal is not likely to capture them. 分支是依赖于数据的(假设数据在[1..100]中随机分布),因此双峰不太可能捕获它们。 However a global predictor will easily learn that the second branch depends on the outcome of the first one (if the first is take, the second will never be taken, if the first isn't taken the second is very likely to be taken (the case of A[i]==50 having a 1% chance only). Now take the same code, but assume A is sorted, the bimodal will easily win, nailing almost all the predictions right except on the few transitions. 但是,全局预测器将容易地了解到,第二个分支取决于第一个分支的结果(如果第一个分支被采用,则第二个分支将永远不会被采用,如果第一个分支未被采用,则第二个分支很可能会被采用( (如果A[i]==50仅有1%的机会)的情况)现在使用相同的代码,但是假设A已排序,则双峰将很容易获胜,几乎将所有预测正确定位,除了少数过渡。

So if no predictor is superior, what should we do? 因此,如果没有任何预测指标优于我们,该怎么办? Well, build a hybrid one of course! 好吧,当然要建立一个混合动力! Many high performance CPUs today employ multiple ones, although the algorithm for combining/selecting between the results are probably not available online. 尽管可能无法在线获得用于组合/选择结果的算法,但当今许多高性能CPU都采用了多个CPU。

This explanation also disregards the design implications like size and power consumption - these of course depend too on the parameters of implementation. 这种解释也无视诸如大小和功耗之类的设计含义-这些当然也取决于实现的参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM