top | item 46969568

(no title)

20k | 19 days ago

The magic here with the word-ese is that a floating point expression may be contracted. In C, you write things like:

    float a = /*expression*/

    float b = /*expression*/

    float c = a * b;
Contraction can only happen within the expressions on the right hand side, not mutually between a and b. This makes inlining, and even variable substitution not legally permitted by the C spec to be equivalent to the actually written out inlined version. Ie you can't transform:

    float a = v1 * v2;

    float b = v3 * v4;

    float c = a + b;
Into

    float c = (v1 * v2) + (v3 * v4);
As they aren't semantically equivalent, and compilers do follow these rules. The same applies for inline functions. Its one of the reasons why macros can sometimes perform better than force-inline functions

In practice, the big 3 compilers all perform floating point contraction according to the spec, and this is a major issue if you want to get good gpgpu performance because this extends to OpenCL and C-style languages in general (like CUDA)

discuss

order

No comments yet.