Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

loop was not vectorized: vectorization possible but seems inefficient.

srimks
New Contributor II
381 Views
Hi All.

Somewhat sceptic, the way ICC-v11.0 gave vectorizations message for below code with L# which is part of CPP multi files -

---
169: appleobj *nonapple = new appleobj[524288];
---

the ICC-v11.0 vectorizations message is -

--
test.cc(169): (col. 27) remark: loop was not vectorized: vectorization possible but seems inefficient.--

The above code can be understood as doing following things in btw -

typedef struct apple {
int a1;
int a2;
int t1;
int t2;
int s1_type;
double kite1;
double kite2;

orange_param() : a1(0), a2(0) {}

} appleobj;
..
..
..in between many sections of code exist......
..

int main() {

appleobj *nonapple = new appleobj[524288];
----

Sorry, for not letting in between things of code be known, but atleast the Compiler should not hit with above vectorization message when pointing to simple dynamic-allocation.

Above means that - Compiler is checking if VECTORIZATIONS can be done during dynamic-allocation, undoubtedly not possible?

Please clarify.

~BR
0 Kudos
4 Replies
jimdempseyatthecove
Honored Contributor III
381 Views

BR,

You shouldn't be so quick to discount what the compiler can or cannot do with the constructors of an array of objects.

As a test, comment out all in appleobj except for a1 and a2. (you may have to make a dummy test program)

See what happens on the new, and also look at the dissassembly window.

I have been rather impressed by some of the optimizations taking place

Jim Dempsey

0 Kudos
levicki
Valued Contributor I
381 Views
srimks,

Assuming that the above code isn't a contrived example, your structure members aren't ordered in a most effective manner possible.

You should therefore consider learning some basics about memory layout and proper alignment of variables before criticizing the compiler for its (usually justified) tradeoff decisions when it comes to vectorization.

Judging by the number of your posts dealing with vectorization lately I simply cannot resist the impression that you are using the number of "LOOP WAS VECTORIZED" statements in the compiler output as a measure of your code performance which can't be further from the truth.

It is as if you are trying to vectorize every single loop, regardless of the real performance impact of such quest. Just keep in mind that vectorized != faster.

I am telling you this because I was like you in the beginning and after writing dozen of vectorized loops in assembler where I thought it would make a difference only to find out (by measuring performance) that it doesn't, I started trusting the compiler judgement when it comes to "vectorization possible but seems inefficient" message.

0 Kudos
srimks
New Contributor II
381 Views
Quoting - Igor Levicki
srimks,

Assuming that the above code isn't a contrived example, your structure members aren't ordered in a most effective manner possible.

You should therefore consider learning some basics about memory layout and proper alignment of variables before criticizing the compiler for its (usually justified) tradeoff decisions when it comes to vectorization.

Judging by the number of your posts dealing with vectorization lately I simply cannot resist the impression that you are using the number of "LOOP WAS VECTORIZED" statements in the compiler output as a measure of your code performance which can't be further from the truth.

It is as if you are trying to vectorize every single loop, regardless of the real performance impact of such quest. Just keep in mind that vectorized != faster.

I am telling you this because I was like you in the beginning and after writing dozen of vectorized loops in assembler where I thought it would make a difference only to find out (by measuring performance) that it doesn't, I started trusting the compiler judgement when it comes to "vectorization possible but seems inefficient" message.

Igor.

Really appreciate what you suggested and it's true.

Performing vectorization for single CPP/C file is easy but vectorizing CPP code of multi CPP files is challenging as it has numerous issues.

I am currently handling multi CPP file package could of of atleast 8,000-10,000 lines of code, so concluding anything about Compiler vectorizations would be too early which somehow I didn't. But, I prefer trying to understand all behaviours related to possible constructs related to "LOOP NOT VECTORIZED" because....."

I think replacing section of code with proper assembler code would be final step to explore vectorizations.

I am happy to have persons like - Jim, Igor(U) & Tim around with their instant respones.

~BR
0 Kudos
TimP
Honored Contributor III
381 Views
There's no substitute for profiling your code to find out where aggressive optimizations may or may not be worth while.
0 Kudos
Reply