Community
cancel
Showing results for 
Search instead for 
Did you mean: 
T_C
Beginner
127 Views

What do "near branches", "macro branches" and "taken speculatively" refer to?

I am looking at the list of branch events for Ivy Bridge and when finding their descriptions I come across the following terms:

"near branches"

"macro branches"

"taken speculative" 

What are the first two and what does the third mean? I thought the idea is to "predict" a branch, so I am unsure what the "speculative" means here?

The events in question are:

BR_MISP_RETIRED.NEAR_TAKEN

BR_MISP_RETIRED.ALL_BRANCHES

BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL

0 Kudos
12 Replies
Peter_W_Intel
Employee
127 Views

BR_MISP_RETIRED.ALL_BRANCHES - count all mispredicted macro branch instruction retired. Here "macro branch" means include all branch instructions and you can understand "macro" which is on instruction level.

BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL - count mispredicted indirect call branch instruction retired. Usually "indirect call", means there is no call address provided in compiling time, it depends on previous instructions' operation, for example "call address" will be stored in register, or address in memory. So if "call address" is known early - CPU can speculatively do "call"

BR_MISP_RETIRED.NEAR_TAKEN - count near call misprediction for instructions retired, "near call" means target address is in same segment of caller, just do 1: push EIP+1 to CS for return use 2. put EIP+offset as new EIP 3. execute EIP. Sometime, CPU can speculatively run "near call" early if call address is presented. 

 

Bernard
Black Belt
127 Views

>>>"taken speculative">>> IIRC "taken speculative" means that CPU was able to predict correctly speculatively executed code branch.
Bernard
Black Belt
127 Views

"near branches" Near branches are related to near conditional jump inside the same segment.
T_C
Beginner
127 Views

iliyapolak wrote:

"near branches"

Near branches are related to near conditional jump inside the same segment.

Hi there, thanks for replying.

What do you mean by "related to" exactly?

T_C
Beginner
127 Views

Peter Wang (Intel) wrote:

BR_MISP_RETIRED.ALL_BRANCHES - count all mispredicted macro branch instruction retired. Here "macro branch" means include all branch instructions and you can understand "macro" which is on instruction level.

Hi. Could you clarify what you mean by "macro on an instruction level" please? I could only find this, which didn't seem relevant to our context:

http://en.wikipedia.org/wiki/Macro_instruction

Peter Wang (Intel) wrote:
BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL - count mispredicted indirect call branch instruction retired. Usually "indirect call", means there is no call address provided in compiling time, it depends on previous instructions' operation, for example "call address" will be stored in register, or address in memory. So if "call address" is known early - CPU can speculatively do "call"

Are you saying "speculative" refers to the CPU speculatively executing the code for the branch it predicts?

What is the correct term for instructions executed for a mispredicted branch? They are not "retired" right, because they weren't required? Is there an official term to describe those instructions which are speculatively executed and discarded?

Bernard
Black Belt
127 Views

T C wrote:

Quote:

iliyapolak wrote:

"near branches"

Near branches are related to near conditional jump inside the same segment.

 

Hi there, thanks for replying.

What do you mean by "related to" exactly?

Near branches are unconditional or conditional jumps inside the same segment. For example unconditional branch inside cs segment: jmp near <some label>  or jmp dword cs:[eax+10h].

Peter_W_Intel
Employee
127 Views

T C wrote:

Quote:

Peter Wang (Intel) wrote:

BR_MISP_RETIRED.ALL_BRANCHES - count all mispredicted macro branch instruction retired. Here "macro branch" means include all branch instructions and you can understand "macro" which is on instruction level.

Hi. Could you clarify what you mean by "macro on an instruction level" please? I could only find this, which didn't seem relevant to our context:

http://en.wikipedia.org/wiki/Macro_instruction

Quote:

Peter Wang (Intel) wrote:BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL - count mispredicted indirect call branch instruction retired. Usually "indirect call", means there is no call address provided in compiling time, it depends on previous instructions' operation, for example "call address" will be stored in register, or address in memory. So if "call address" is known early - CPU can speculatively do "call"

Are you saying "speculative" refers to the CPU speculatively executing the code for the branch it predicts?

What is the correct term for instructions executed for a mispredicted branch? They are not "retired" right, because they weren't required? Is there an official term to describe those instructions which are speculatively executed and discarded?

Could you clarify what you mean by "macro on an instruction level" please?

I don't know exact term that you provide doc, but I meant that Macro Instruction (I said here) will be decoded by CPU, it is approximated to "machine code".

Are you saying "speculative" refers to the CPU speculatively executing the code for the branch it predicts?

Exactly. BTB (Branch Target Buffer) stores fetched branch code, which will be executed speculatively - it may/ may not be retired.

> Is there an official term to describe those instructions which are speculatively executed and discarded?

I recommend you to know all terms from this article

Bernard
Black Belt
127 Views

iliyapolak wrote:

Quote:

T C wrote:

Quote:

iliyapolak wrote:

"near branches"

Near branches are related to near conditional jump inside the same segment.

An example of far jump can be this in pseudocode: jmp far ds: // where code is jumping from ss:

 

Hi there, thanks for replying.

What do you mean by "related to" exactly?

Near branches are unconditional or conditional jumps inside the same segment. For example unconditional branch inside cs segment: jmp near <some label>  or jmp dword cs:[eax+10h].

Bernard
Black Belt
127 Views

It seems that my previous post does not contain my answer. >>>Near branches are unconditional or conditional jumps inside the same segment. For example unconditional branch inside cs segment: jmp near or jmp dword cs:[eax+10h].>>> An example of far jump in x86 pseudocode: jmp far ds.:
Bernard
Black Belt
127 Views

>>>I don't know exact term that you provide doc, but I meant that Macro Instruction (I said here) will be decoded by CPU, it is approximated to "machine code".>>>

AFAIK "macro instruction" is  a machine code instruction (x86-64 assembly opcodes).

T_C
Beginner
127 Views

Thanks guys!

Bernard
Black Belt
127 Views

>>>An example of far jump in x86 pseudocode:

jmp far ds.:>>>

 

jmp far ds:<some label>

Reply