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

Cannot vectorize array notations

Jump to solution
Hi all,
I have vectorization problems and I really need your help.
Here are the vectorization reports for each array notation in the code bellow:
-Array Notation(1) : Vectorized
-Array Notation(2) : Subscript too complex
-Array Notation(3) : Existence of vector dependence
-Array Notation(4) : Subscript too complex
-Array Notatino(5) : Subscript too complex
-Array Notation(6) : Existence of vector dependence
I tried using "restrict" on the pointers(i.e. int* restric p_p_data_), but didn't work.
Is there any problem I'm missing?
Thanks in advance!
[CPU Info]
-Core2 Quad Q9400
[OS Info]
-WinXP Pro SP3
[Compiler Info]
-Composer XE 2011 Update7, Package ID:w_ccompxe_2011.7.258
[cpp]class SomeClass { SomeClass(); ~SomeClass(); void Init(); void PreProcess(); void Process(); __declspec (vector) int GetDiff(int sub, int add) { return (add - sub); }; const byte* add_point_; const byte* subtract_point_; std::vector y_data_; std::vector x_data_; std::vector processed_data_; int* p_y_data_; int* p_x_data_; int* p_p_data_; }; void Init() { x_data_.resize(5000); y_data_.resize(5000); processed_data_.resize(5000); p_x_data_ = &x_data_.front(); p_y_data_ = &y_data_.front(); p_p_data_ = &processed_data_.front(); return; } void PreProcess() { int x_size = 5000; add_point_ = image_->base_address(); subtract_point_ = add_point_; // Array Notation(1) p_y_data_[0:x_size] = add_point_[0:x_size]; for (int y = 0; y < 4; y++) { // Array Notation(2) p_y_data_[0:x_size] += add_point_[0:x_size]; } return; } void Process() { int x_size = 5000; // Array Notation(3) p_y_data_[0:x_size] += GetDiff(subtract_point_[0:x_size], add_point_[0:x_size]); // Array Notation(4) p_x_data_[0:x_size] = p_y_data_[0:x_size]; x_size--; for (int x = 1; x < 4; x++) { // Array Notation(5) p_x_data_[0:x_size] += p_y_data_; x_size--; } x_size -= 4; // Array Notation(6) p_p_data_[0:x_size] = GetDiff(p_x_data_[0:x_size], p_x_data_[settings_->df.block_width:x_size]); return; }[/cpp]
0 Kudos

Accepted Solutions
Black Belt
47 Views
ansi-alias is needed so as to assert that the (non-integer) data contained in a doesn't alias with the book-keeping data. I suppose it would be particularly inadvisable to expect a compiler to accept code which violates the standard in such a case, but Windows applications do frequently have such expectations.
restrict would be used to assert non-aliasing among data regions defined separately outside the local scope and accessed by pointers (C style); by extension, it might apply to reference. As restrict still is not formally defined for C++, you are correct that it may not necessarily be meaningful in class context.

View solution in original post

0 Kudos
6 Replies
47 Views
What compiler are you use?
0 Kudos
Black Belt
47 Views
Your compiler options would need to include -ansi-alias -restrict , and you have left your restrict out of your source code (restrict or __restrict may work, but not __restrict__ with the relatively old compiler). It's hard to guess what you have done; an actual example with your compile command would go a long way. If you are depending on the new gcc compatibility, that is an option for ICL 13.0.
0 Kudos
Beginner
47 Views
Hi Maycon Oliveira!
Thank you for your reply.
I'm using intel composer xe on Visual Studio 2005.
0 Kudos
Beginner
47 Views
Hi Timp!
Thank you for your reply.
Vectocization worked with "Qansi-alias" compiler option.
But, I thought that the "restrict" qualifier and the "Qrestrict" compiler option were enough to remove the vector dependency of pointers.
Using "Qansi-alias" I have to worry about pointers aliasing on other part of the total source code...
I also tried "restrict" instead of "__restrict" but didn't work.
Maybe, "restict" shouldn't be used on members of a class?
0 Kudos
Black Belt
48 Views
ansi-alias is needed so as to assert that the (non-integer) data contained in a doesn't alias with the book-keeping data. I suppose it would be particularly inadvisable to expect a compiler to accept code which violates the standard in such a case, but Windows applications do frequently have such expectations.
restrict would be used to assert non-aliasing among data regions defined separately outside the local scope and accessed by pointers (C style); by extension, it might apply to reference. As restrict still is not formally defined for C++, you are correct that it may not necessarily be meaningful in class context.

View solution in original post

0 Kudos
Beginner
47 Views
Declaring restrict pointers inside my function worked and finally vectorization sucessed!
Thank you so much for your help!!!
0 Kudos