- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for the confusion. You're correct. The loops are vectorized in both code samples - I confirmed on my test bench.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page