We have a vector class (Numeric 3 float) that I would like to align with 16 bytes to allow SIMD operations. Using declspec to align 16 bytes causes many C2719 errors (parameter ': formal parameter with __declspec (align (' # ')) will not be aligned). If I can't get around a vector aligned, what's the point? Even using a const reference to a vector causes a compiler error, which really annoys me.
Is there a way to do what I want here is to get 16 byte alignment, allowing the structure to be passed without having to do any silly tricks up to __m128 types?
You are unlikely to get much benefit from using SIMD unless you are working on a bunch of these three-dimensional vector structures at a time, in which case you are likely to pass them into an array that you can align as needed. Another case where you can get some benefit from SIMD is that you do a lot of calculations for each vector, and you can parallelize the operations across three channels. In this case, doing some manual manipulation at the beginning of the type binding function __m128may still give you some benefit.
__m128
If I cannot pass a vector aligned, what is the point?
__declspec(align(#)) . ++ 11 , ; alignas, , __declspec(align(#)). , alignas .
__declspec(align(#))
alignas
, Microsoft , , , Clang, Windows.
, , ++ , , , . , , , ,
, ? 16-- . - ?
__declspec (passinreg), Xbox360, Visual Studio Windows .
: http://connect.microsoft.com/VisualStudio/feedback/details/381542/supporting-declspec-passinreg-in-windows
VectorParameter typedef'ed const Vector const Vector& , .
VectorParameter
const Vector
const Vector&
, V++ , , , -. 1) , __declspec (align (X)) , . . 2) SIMD . 20%, quat multiply quat rotate SIMD. , . , float [4]. -, FPS, . , , , . 3) , _mm_store_ps _mm_load_ps /O 2. , SIMD , , , .