If I try
double* ptr1; double* ptr2; __assume_aligned(ptr1, 64); __assume_aligned(ptr2, 64); #pragma simd for (int i=0; i<n; ++i) ptr1 = ptr2;
it will vectorise the loop with aligned access, but gives a warning that #pragma simd is deprecated.
If I swap "simd" for "vector aligned", it does not vectorise and the optimisation report says "use the simd directive".
The documentation for #pragma simd (https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-simd) doesn't mention deprecation or any alternatives.
Is there any documentation/articles that tells us how we are supposed to do this these days?
I am using:
Microsoft Visual Studio Community 2017 Version 15.9.18
Intel® Parallel Studio XE 2019 Update 5 Composer Edition for C++ Windows* Package ID: w_comp_lib_2019.5.281
Intel® Parallel Studio XE 2019 Update 5 Composer Edition for C++ Windows* Integration for Microsoft* Visual Studio* 2017, Version 18.104.22.168
At issue here is the pointers you have declared may overlap with respect the SIMD vector width. Use of #pragma simd stated "you don't care if they overlap, vectoreize regardless of possibility of overlapping". What you need is a means of assuring the compiler that these pointers will not point to memory that will overlap when used by a vector read from one, operator, vector write to the other. For this, there is the restrict keyword.
double* restrict ptr1; // *** or __restrict depending on compiler vendor and/or option double* restrict ptr2; // *** or __restrict depending on compiler vendor and/or option __assume_aligned(ptr1, 64); __assume_aligned(ptr2, 64); for (int i=0; i<n; ++i) ptr1 = ptr2;
Note, the availability of the restrict keyword may depend upon the choice of C++ standard selection or other compiler option.
You may need to use __restrict, __restrict__, __declspec(restrict)
The documentation link was what I was looking for - searching the Intel web-site produced great articles from 2013 and prior, but I had no idea what was currently recommended practice.
Jim's restrict option makes the most sense to me, but it drives Intellisense and Resharper crazy, even though it compiles and works.
So I will switch to Vladimir's omp simd for now and hope VS catches up with restrict.