branch-prediction Questions
3
Solved
I'm looking at the five stages MIPS pipeline (ID,IF,EXE,MEM,WB) in H&P 3rd ed. and it seems to me that the branch decision is resolved at the stage of ID so that while the branch instruction re...
Gilson asked 6/12, 2015 at 6:27
0
Consider the following loops:
while((expressionA) & (expressionB)){
// do something
}
while((expressionA) && (expressionB)){
// do something
}
where expressionA and expression...
Falda asked 3/12, 2015 at 8:0
1
I know that I can get the total percentage of branch mispredictions during the execution of a program with perf stat. But how can I get the statistics for a specific branch (if or switch statement ...
Unipolar asked 4/11, 2015 at 13:35
2
I've just stumbled upon this thing, and I'm really curious if maybe modern CPUs (current ones, maybe mobile ones as well (embedded)) don't actually have a branching cost in the situation below.
1....
Motherwort asked 27/9, 2015 at 9:55
3
Solved
I was testing some code on Visual Studio 2008 and noticed security_cookie. I can understand the point of it, but I don't understand what the purpose of this instruction is.
rep ret /* REP to avoi...
Intercellular asked 11/12, 2013 at 17:48
3
Solved
My code makes frequent calls to a function with multiple (unpredictable) branches. When I profiled, I found that it is a minor bottleneck, with the majority of CPU time used on the conditional JMPs...
Morningglory asked 29/8, 2015 at 21:34
3
Solved
Related to this answer.
In the above answer, it's mentioned how you can avoid branch prediction fails by avoiding branches.
The user demonstrates this by replacing:
if (data[c] >= 128)
{
sum +=...
Tungstite asked 19/8, 2015 at 23:10
2
Solved
Most, if not all modern processors utilize a technique called "branch prediction", with which it guesses what way to go in an if-then-else branch.
I have a question considering the scheme. Let's s...
Yingyingkow asked 11/8, 2015 at 23:13
4
Solved
I was writing code that looked like the following...
if(denominator == 0){
return false;
}
int result = value / denominator;
... when I thought about branching behavior in the CPU.
https://mc...
Bargainbasement asked 3/8, 2015 at 8:22
4
I’m currently coding highly optimised versions of some C99 standard library string functions, like strlen(), memset(), etc, using x86-64 assembly with SSE-2 instructions.
So far I’ve managed to ge...
Delitescent asked 7/8, 2013 at 21:18
4
Solved
I saw this comment next to a if condition:
// branch prediction favors most often used condition
in the source code of the JavaFX SkinBase class.
protected double computeMinWidth(double heigh...
Snag asked 21/5, 2015 at 9:44
1
Solved
I believe that when creating CPUs, branch prediction is a major slow down when the wrong branch is chosen. So why do CPU designers choose a branch instead of simply executing both branches, then cu...
Gradate asked 19/10, 2014 at 20:15
3
Solved
I have a loop that is running over and over again. The logic inside that loop is dependent on the mode that the program is in. To improve performance I was thinking that an array of function pointe...
Toole asked 7/10, 2014 at 15:29
1
Solved
This is the second time I'm asking this question; the first time someone did reply but I took too long to reply back to them and therefore didn't get the full understanding.
What I'm trying to do...
Phrenic asked 20/7, 2014 at 16:41
1
Going trough chapter 3 of this book called Computer Systems Architecture: A programmer's perspective, it is stated that an implementation like
testl %eax, %eax
cmovne (%eax), %edx
is invalid bec...
Category asked 7/7, 2014 at 13:10
1
Solved
How "sticky" is the branch predictor logic? If code is being removed from the instruction caches, do the statistics stay with it?
Put another way, if the code is complex or not processing things i...
Wehner asked 10/6, 2014 at 21:42
3
Solved
I have a custom ASSERT(...) macro which I use in a C++ application.
#include <stdlib.h>
#include <iostream>
/// ASSERT(expr) checks if expr is true. If not, error details are logged
/...
Dichromic asked 28/5, 2014 at 11:28
5
Due to the huge impact on performance, I never wonder if my current day desktop CPU has branch prediction. Of course it does. But how about the various ARM offerings? Does iPhone or android phones ...
Rosabelle asked 23/11, 2011 at 11:31
2
EDIT: My confusion arises because surely by predicting which branch is taken, you are effectively doing the target prediction too??
This question is intrinsically linked to my first question on th...
Continental asked 14/2, 2014 at 19:1
2
I'm writing some audio code where basically everything is a tiny loop. Branch prediction failures as I understand them is a big enough performance issue that I struggle to keep the code branch free...
Deus asked 13/2, 2014 at 13:20
2
Solved
I have a switch statement in some time-critical code. I was trying to optimize it with __builtin_expect, but it does not seem to be working. I'm wondering if anyone can tell me if I'm missing some ...
Platto asked 6/2, 2014 at 18:56
1
Solved
Have I understood this right, if statements are more dependent on branch prediction and v-table look-up is more dependent on branch target prediction? Regarding v-tables, there is no "branch predic...
Smearcase asked 6/2, 2014 at 16:45
1
Solved
In reference to this question, the answer specify that the unsorted array takes more time because it fails the branch prediction test. but if we make a minor change in the program:
import java.uti...
Suffice asked 29/1, 2014 at 13:23
3
Solved
In the following pseudo-code:
if (rdtscp supported by hardware) {
Invoke "rdtscp" instruction
} else {
Invoke "rdtsc" instruction
}
Let's say the CPU does not support the rdtscp instruction an...
Soutane asked 7/1, 2014 at 18:18
1
My orginial idea was to give an elegant code example, that would demonstrate the impact of instruction cache limitations. I wrote the following piece of code, that creates a large amount of identic...
Paralytic asked 4/9, 2013 at 1:56
© 2022 - 2024 — McMap. All rights reserved.