Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Can this loop be vectorized? (http://www.velocityreviews.com/forums/t646440-can-this-loop-be-vectorized.html)

 Wolfgang Thomsen 11-28-2008 06:01 PM

Can this loop be vectorized?

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

 دريد عبد الله 11-28-2008 06:21 PM

Re: Can this loop be vectorized?

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]];

}

 دريد عبد الله 11-28-2008 06:27 PM

Re: Can this loop be vectorized?

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];

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

 red floyd 11-28-2008 07:22 PM

Re: Can this loop be vectorized?

ط¯ط±ظٹط¯ ط¹ط¨ط¯ ط§ظ„ظ„ظ‡ 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];
>
> }
> 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.

 All times are GMT. The time now is 02:03 PM.