I'm writing a program using Qt5, and I need to allocate a QVector <float> having its data() pointer 32-byte aligned.
Is there anyway I could do this without modifying the Qt library itself?
My code looks something like this:
QVector <float> vec;
vec.resize(n);
float *wricker_ptr = wricker.data(); // this should be 32-byte aligned
for (int i=0; i<n; i++)
{
wricker_ptr[i] = /* some computed value */;
}
I'm using Intel's C++ Compiler.
Two solutions come to mind:
std::vector and a suitable allocator. QVector's data payload is allocated with alignof(T).¹QVector<__m256i> or similar and reinterpret_cast in and out.¹ not entirely true, see http://thread.gmane.org/gmane.comp.lib.qt.devel/22326/focus=22596
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With