Community
cancel
Showing results for 
Search instead for 
Did you mean: 
piedpiper
Beginner
114 Views

ICC 17 and Auto Vectorization

Jump to solution

Hello,

 

I have just recently begun experimenting with ICC 17 and its auto-vectorization features.   I was wondering if anyone could explain why the following code ('blah') can be auto-vectorized by ICC while ('blahblah') cannot ?  The difference being that variables a,b,c are declared on the stack in 'blahblah'.

const int numElems = 256;


void blah(double a[], double b[], double c[])
{
   int i = 0;

   // This vectorizes
   for (i = 0; i < numElems; i++)
   {
     a = b * c;
   }
}

void blahblah()
{
   double a[numElems];
   double b[numElems];
   double c[numElems];

   int i = 0;

   // This does not vectorize
   for (i = 0; i < numElems; i++)
   {
     a = b * c;
   }
}

Thanks in advance for any help.

 

 

0 Kudos
1 Solution
Judith_W_Intel
Employee
114 Views

 

What makes you think the loop was not vectorized? I see the following in the optimization report:

sptxl15-274> cat t.c

const int numElems = 256;

void blahblah()
{
   double a[numElems];
   double b[numElems];
   double c[numElems];

   int i = 0;

   // This does not vectorize
   for (i = 0; i < numElems; i++)
   {
     a = b * c;
   }

}
sptxl15-275> icc -qopt-report=5 -c t.c
icc: remark #10397: optimization reports are generated in *.optrpt files in the output location
sptxl15-276> grep "LOOP" *.optrpt | grep VECTOR
   remark #15300: LOOP WAS VECTORIZED
sptxl15-277>

Are you using any special command line switches?

Judy

View solution in original post

2 Replies
Judith_W_Intel
Employee
115 Views

 

What makes you think the loop was not vectorized? I see the following in the optimization report:

sptxl15-274> cat t.c

const int numElems = 256;

void blahblah()
{
   double a[numElems];
   double b[numElems];
   double c[numElems];

   int i = 0;

   // This does not vectorize
   for (i = 0; i < numElems; i++)
   {
     a = b * c;
   }

}
sptxl15-275> icc -qopt-report=5 -c t.c
icc: remark #10397: optimization reports are generated in *.optrpt files in the output location
sptxl15-276> grep "LOOP" *.optrpt | grep VECTOR
   remark #15300: LOOP WAS VECTORIZED
sptxl15-277>

Are you using any special command line switches?

Judy

View solution in original post

piedpiper
Beginner
114 Views

Sorry for the confusion.  You're correct.   The loops are vectorized in both code samples - I confirmed on my test bench.

Reply