Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
Announcements
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
7783 Discussions

How are we supposed to migrate from #pragma simd?

roger567
New Contributor I
917 Views

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?

0 Kudos
1 Solution
AbhishekD_Intel
Moderator
917 Views

Hi,

You can follow this link which will help to understand including SIMD in your codes.

I hope it will solve your problem.

-Abhishek

View solution in original post

7 Replies
AbhishekD_Intel
Moderator
917 Views

Hi,

Can you please send us the details of the compiler which you are using?

-Abhishek

roger567
New Contributor I
917 Views

Hi Abhishek,

I am using:

Microsoft Visual Studio Community 2017 Version 15.9.18
VisualStudio.15.Release/15.9.18+28307.960

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 19.0.6.15

AbhishekD_Intel
Moderator
918 Views

Hi,

You can follow this link which will help to understand including SIMD in your codes.

I hope it will solve your problem.

-Abhishek

jimdempseyatthecove
Black Belt
917 Views

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.

https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-restrict-qrestrict

Additionally, see: https://en.wikipedia.org/wiki/Restrict and https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html

You may need to use __restrict, __restrict__, __declspec(restrict)

 

Jim Dempsey

Vladimir_P_1234567890
917 Views

you can try to use "#pragma omp simd" instead of "#pragma simd".

Vladimir 

roger567
New Contributor I
917 Views

Thanks guys,

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.

Thanks again

Roger

AbhishekD_Intel
Moderator
917 Views

Thanks, Roger for your confirmation can we close this thread?

You are always welcome to post a new thread if you have any issues.

-Abhishek

Reply