Changes

Jump to: navigation, search

SIMD/Uses/Conversion

786 bytes added, 20:07, 12 April 2014
SSE2 conversion options
i = (int) d > 0 ? (d + 0.5) : (d - 0.5);
 
This works, but is not particularly fast: For every value a conditional statement is executed, making the code very "branchy", which is generally disliked by pipelined processor designs. No matter what branch is taken, preceding the type conversion there's an additional arithmetic operation to apply the fitting offset.
 
SIMD instruction sets like SSE2 have specialized data conversion operations -- including, e.g., conversion of floating point values to integer values with rounding. In the case of SSE2, both scalar and vector values can be converted (i.e., a single value at a time or a vector of values). In the latter case, the conversion does not only avoid costly branches and additional arithmetic operations, but also gives several converted values with a single operation.
51
edits

Navigation menu