|
-
July 14th, 2004, 02:10 AM
#1
Pipelining using Ifs
If I am not wrong if is killing the pipelinging in the CPU. And since P4 machines has a lot of pipe-stages it will probably kill a lot of performance if you use a lot of them. But does anyone know if the CPU guesses that the If in VC++ is not true, or true, or if it depends on what the if does?
It would be so nice if you know you have an if (like an exception or something) and you know it will more or less never be called could give the compiler a sign and tell it to guess this if will not be true, so start on the next line after the if.
Hope for some serious techincal answers here...
ØØ
-
July 14th, 2004, 12:49 PM
#2
Hi NoteMe,
Its been a while since my architecture class, but Intel's branch prediction algorithm is over 90% efficient (I think its actually higher than that, but I don't have a reference).
If you are concerned about writing code that addresses this issue, see http://www.intel.com/cd/ids/develope...779.htm?page=3. I usually don't worry about it. Visual C++ is an optimizing compiler. It generally does a fine job of code generation.
Jeff
-
July 14th, 2004, 12:56 PM
#3
Thanks for the warning. I am not thinking so much about it either. But I just got the idea, and I think it was a sweet idea to have an otional keyword you could apply to help the compiler choose if the if is often true or not. Thanks for the reading BTW. I will check it out right away.
ØØ
-
July 15th, 2004, 05:20 AM
#4
OK. Read it and thought a bit about it. Looks like there is an instruction for P4 machines, but there is probably an other instruction for AMD, and maybe other instructions for older versions. And it only provides ASM code of course. So I guess there is no C++ command for it, maybe not even in VC++. So that means if I want to use it I have to write the function in ASM, and that is not an option. Then I am back to the stone age before I know it. But at least I have learned that things like for loops should never be longer then 16 iterations and stuff like that. I can at least use that for bottlenecks.
Thanks so far.
Øyvind Østlund
Last edited by NoteMe; April 27th, 2006 at 08:06 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|