We have a (Numeric 3 float) vector class that I would love to align to 16-bytes in order to allow SIMD oerations. Using declspec to 16-byte align it causes a slew of C2719 errors (parameter’: formal parameter with __declspec(align(‘#’)) won’t be aligned). If I can’t pass around a vector aligned, what’s the point? Even using a const reference to the vector is causing the compiler error which really annoys me.
Is there a way to do what I want here – get 16-byte class alignment while allowing struct passing without having to do some silly trickery to __m128 types?
You’re not likely to get much of a benefit from using SIMD unless you’re operating on a bunch of these 3-dimensional vector structures at a time, in which case you would probably pass them in an array, which you could align as you need to. The other case where you might obtain some benefit from SIMD is if you’re doing a lot of computations on each vector and you can parallelize the operations on the three channels. In that case, then doing some manual manipulation at the beginning of a function to coax it into a
__m128type might still afford you some benefit.