5.10.2008

Low Level Performance : FCMP (2)

First, this is an amazing day for you and I. This post breaks a 3 year streak of only posting 8 times! (Yes, look to the right to check for yourself.) You're welcome. Now bring me some pie..


Secondly, let me address a little "*" that should have been assigned in my last post. FCMP logic causes problems in Out-of-order architectures like the PowerPC inside the 360. As posted before, it's caused by the fact that the branching hardware occurs before the FPU logic on the power pc, so in order to get the result for execution, the pipeline must be flushed and the branch must be processed before everything can resume.

One other problem exists on PPC platforms that ALSO comes from incorrect use of FCMP, and that's Load-Hit-Stores. I'll make a separate post about them, and how to fix them later, but I just wanted to point out for now that the prior solutions work to remove any FCMP problems from your performance bottlenecks, but if done wrong, CAN introduce LHS penalties.

A LHS penalty can occur when switching between processing units. That is, the simple process of typecasting a Float, to an INT causes a LHS. Why? Well, short story is that the separate int/float/vmx processing units on the 360 don't have direct read/write access to each other, so they have to write the value to main memory before loading it into their registers.

So, here's the fine print in my last post. Those solutions only work (well) if the floating point value hasn't already been loaded into the floating point registers. IE the value still resides in memory.

If the float information is still in memory, the processor will just load it up as the compiler tells it, to the proper address space. As talked about before, we can reinterpret the bits of a float to an int, which effectivly loads the same memory space into the int registers for our work. IF the float had already been in the floating point register (ie, y=mx+b; if(FastFloatCompare(y,0))) then you would techincally remove the FCMP penalty, but have the full wrath of the LHS problems, which could be 2x as long.

I'll mention something about LHS, and my thoughts on a few industry happenings later.. Right now : BEER.

~Main

0 comments: