[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

Can this loop be vectorized?

Wolfgang Thomsen

11/28/2008 6:02:00 PM

Hello,

is there a way to convince the Intel compiler to (auto-)vectorize the
following?

double a[N], b[N];
int c[2N];

for(int i=0; i<N; i++) {
a[i] = b[c[i*2]];
}

It does not vectorize presumably because c[] is a different data type than
a[] and b[].


Any help greatly appreciated!
Wolf
4 Answers

???? ??? ????

11/28/2008 6:21:00 PM

0

Or why don't you type:

double a[N], b[N];
int c[2N];

for(int i=0; i<N; i++) {

a[i] = b[c[i*2]];

}

Jeff Schwab

11/28/2008 6:26:00 PM

0

درÙ?د عبد اÙ?Ù?Ù? wrote:
> Or why don't you type:
>
> double a[N], b[N];
> int c[2N];
>
> for(int i=0; i<N; i++) {
>
> a[i] = b[c[i*2]];
>
> }

Are my eyes failing in my old age, or is that identical to the OP's code
except for the addition of two blank lines? What is that supposed to
accomplish?

???? ??? ????

11/28/2008 6:28:00 PM

0

Sory For Mistake
Tyy To Type:

double a[N], b[N];
int c[2N];

for(int i=0; i<N; i++) {
tmp = c[i*2]; // All now are integers
a[i] = b[tmp];

}
Please try this..
But for knowing
I tryed your code on turbo c++ 4.5 . It was running..

red floyd

11/28/2008 7:23:00 PM

0

درÙ?د عبد اÙ?Ù?Ù? wrote:
> Sory For Mistake
> Tyy To Type:
>
> double a[N], b[N];
> int c[2N];
>
> for(int i=0; i<N; i++) {
> tmp = c[i*2]; // All now are integers
> a[i] = b[tmp];
>
> }
> Please try this..
> But for knowing
> I tryed your code on turbo c++ 4.5 . It was running..
>

That wasn't what OP was asking. To the OP, you're better off asking in
a group dedicated to your compiler -- ISO/IEC 14882:2003 doesn't discuss
vectorization at all.