branch prediction and C#???

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

In my engineering class we're discussing microprocessor branch predictors.
Is it possible to write a Windows application (anything whatsoever) that
would allow me see how branch prediction is done in C# or if it implements
some type of Branch Target Buffer?

Any help would be appreciated.

Thanks.
 
would allow me see how branch prediction is done in C# or if it implements
some type of Branch Target Buffer?

C# is a programming language, not a microprocessor. And the C# compiler
doesn't do any kind of compile time branch prediction.
 
news.microsoft.com said:
In my engineering class we're discussing microprocessor branch predictors.
Is it possible to write a Windows application (anything whatsoever) that
would allow me see how branch prediction is done in C# or if it implements
some type of Branch Target Buffer?

It's a while since I worked on CPUs, but surely branch prediction would still be
a hardware function existing down at the instruction pipeline level? C# is a
programming language running on top of a managed framework which itself is
running on top of an OS - this is many levels above what you are asking about.

In assembly language on bare hardware, one *might* write a diagnostic to confirm
the presence/absence of specific types of branch prediction - IF one knows
enough about the hardware internals of the specific processor one is probing.
But even that low-level diagnostic is more likely to be effective if it can be
written in the processor's native microcode. Or so I would think . . .

HTH,
-rick-
 
Correct me if I'm wrong, but if branch prediction in the CPU is working
correctly, you shouldn't be able to tell from the outside that it's
even happening. Branch prediction is a speed optimization within the
CPU that should be transparent from the level even of assembly language
programming, no?
 
Bruce said:
Correct me if I'm wrong, but if branch prediction in the CPU is working
correctly, you shouldn't be able to tell from the outside that it's
even happening. Branch prediction is a speed optimization within the
CPU that should be transparent from the level even of assembly language
programming, no?

Yes, of course you should be able to tell - else why bother building the extra
hardware? - but certainly not from the application level. It would have to be a
very CPU-specific low-level diagnostic program, running on bare hardware, and
likely using indirect methods such as carefully tailored timed loops. A more
direct sort of test *might* be possible if one has access to the machine's
native microcode (if it has one). In general, to write this kind of probe it is
most helpful to have access to the CPU manufacturer's internal design
documents for the CPU at hand.

Regards,
-rick-
 
Back
Top