How to align cv :: Mat for AVX-512 / AVX2 architectures?
Disclamer: I'm new to simd so if this dirty peasant asks some bad questions.
In my opinion, AVX-512 architectures can handle up to 16 floating point variables, while AVX2 "only" 4.
To take advantage of this, the data must be aligned. As I found out here , it can be done with:
For AVX-512:
alignas(32) float a[8];
For AVX2:
alignas(16) float a[8];
Ok, so my first question is , since 16 is a factor of 32, why don't we always use alignas(32)
also for AVX2 architectures? Maybe (maybe) I'm missing something.
Then I have this function:
bool interpolate(const Mat &im, Mat &res, /*...*/){/*...*/}
which are allocated with
cv::Mat im(r, c, CV_32FC1); //similarly res
The Intel compiler report tells me that the two matrices are not aligned. So my second question is , how can I highlight them so that they match 16/32 ? I could allocate the aligned pointer and pass it to the constructor with cv::Mat
something like:
float *aligned_ptr = /*allocate r*c 16/32 aligned floating points*/
cv::Mat m (r, c, CV_32FC1, /* use aligned_ptr somehow*/);
source to share
No one has answered this question yet
See similar questions:
or similar: