<legend id='pgaMe'><style id='pgaMe'><dir id='pgaMe'><q id='pgaMe'></q></dir></style></legend>

      <small id='pgaMe'></small><noframes id='pgaMe'>

      <i id='pgaMe'><tr id='pgaMe'><dt id='pgaMe'><q id='pgaMe'><span id='pgaMe'><b id='pgaMe'><form id='pgaMe'><ins id='pgaMe'></ins><ul id='pgaMe'></ul><sub id='pgaMe'></sub></form><legend id='pgaMe'></legend><bdo id='pgaMe'><pre id='pgaMe'><center id='pgaMe'></center></pre></bdo></b><th id='pgaMe'></th></span></q></dt></tr></i><div id='pgaMe'><tfoot id='pgaMe'></tfoot><dl id='pgaMe'><fieldset id='pgaMe'></fieldset></dl></div>
      1. <tfoot id='pgaMe'></tfoot>
        • <bdo id='pgaMe'></bdo><ul id='pgaMe'></ul>

        便携式分支预测提示

        时间:2023-09-16
      2. <tfoot id='bGhoS'></tfoot>
        1. <i id='bGhoS'><tr id='bGhoS'><dt id='bGhoS'><q id='bGhoS'><span id='bGhoS'><b id='bGhoS'><form id='bGhoS'><ins id='bGhoS'></ins><ul id='bGhoS'></ul><sub id='bGhoS'></sub></form><legend id='bGhoS'></legend><bdo id='bGhoS'><pre id='bGhoS'><center id='bGhoS'></center></pre></bdo></b><th id='bGhoS'></th></span></q></dt></tr></i><div id='bGhoS'><tfoot id='bGhoS'></tfoot><dl id='bGhoS'><fieldset id='bGhoS'></fieldset></dl></div>

            <tbody id='bGhoS'></tbody>

                  <bdo id='bGhoS'></bdo><ul id='bGhoS'></ul>
                • <small id='bGhoS'></small><noframes id='bGhoS'>

                  <legend id='bGhoS'><style id='bGhoS'><dir id='bGhoS'><q id='bGhoS'></q></dir></style></legend>
                  本文介绍了便携式分支预测提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  是否有任何可移植的方式进行分支预测提示?考虑以下示例:

                  Is there any portable way of doing branch prediction hints? Consider the following example:

                    if (unlikely_condition) {
                      /* ..A.. */
                    } else {
                      /* ..B.. */
                    }
                  

                  这与做有什么不同吗:

                    if (!unlikely_condition) {
                      /* ..B.. */
                    } else {
                      /* ..A.. */
                    }
                  

                  或者是使用编译器特定提示的唯一方法?(例如 GCC 上的 __builtin_expect)

                  Or is the only way to use compiler specific hints? (e.g. __builtin_expect on GCC)

                  编译器是否会根据条件的顺序对 if 条件进行任何不同的处理?

                  Will compilers treat the if conditions any differently based on the ordering of the conditions?

                  推荐答案

                  进行静态分支预测的规范方法是 if 被预测为非分支(即每个 if> 子句被执行,而不是 else),并采用循环和向后goto.因此,如果您希望静态预测很重要,请不要将常见情况放在 else 中.绕过一个未采取的循环并不容易.我从来没有尝试过,但我想把它放在一个 else 子句中应该可以很好地移植.

                  The canonical way to do static branch prediction is that if is predicted not-branched (i.e. every if clause is executed, not else), and loops and backward-gotos are taken. So, don't put the common case in else if you expect static prediction to be significant. Getting around an untaken loop isn't as easy; I've never tried but I suppose putting it an an else clause should work pretty portably.

                  许多编译器支持某种形式的#pragma unroll,但仍然需要用某种#if来保护它以保护其他编译器.

                  Many compilers support some form of #pragma unroll, but it will still be necessary to guard it with some kind of #if to protect other compilers.

                  分支预测提示理论上可以表达一个完整的描述如何转换程序的流程控制图和如何排列可执行内存中的基本块……所以有各种各样的东西要表达,而且大多数不会很便携.

                  Branch prediction hints can theoretically express a complete description of how to transform a program's flow-control graph and arrange the basic blocks in executable memory… so there are a variety of things to express, and most won't be very portable.

                  正如 GNU 在 __builtin_expect 的文档中所推荐的那样,配置文件引导的优化优于提示,而且工作量更少.

                  As GNU recommends in the documentation for __builtin_expect, profile-guided optimization is superior to hints, and with less effort.

                  这篇关于便携式分支预测提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何加速浮点到整数的转换? 下一篇:如何使用 g++ 向量化我的循环?

                  相关文章

                  最新文章

                    <bdo id='a0hOX'></bdo><ul id='a0hOX'></ul>

                  <small id='a0hOX'></small><noframes id='a0hOX'>

                  1. <legend id='a0hOX'><style id='a0hOX'><dir id='a0hOX'><q id='a0hOX'></q></dir></style></legend>

                      <tfoot id='a0hOX'></tfoot>

                    1. <i id='a0hOX'><tr id='a0hOX'><dt id='a0hOX'><q id='a0hOX'><span id='a0hOX'><b id='a0hOX'><form id='a0hOX'><ins id='a0hOX'></ins><ul id='a0hOX'></ul><sub id='a0hOX'></sub></form><legend id='a0hOX'></legend><bdo id='a0hOX'><pre id='a0hOX'><center id='a0hOX'></center></pre></bdo></b><th id='a0hOX'></th></span></q></dt></tr></i><div id='a0hOX'><tfoot id='a0hOX'></tfoot><dl id='a0hOX'><fieldset id='a0hOX'></fieldset></dl></div>