Can this loop be vectorized?

Discussion in 'C++' started by Wolfgang Thomsen, Nov 28, 2008.

  1. 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 = 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
     
    Wolfgang Thomsen, Nov 28, 2008
    #1
    1. Advertising

  2. Or why don't you type:

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

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

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

    }
     
    ÏÑíÏ ÚÈÏ Çááå, Nov 28, 2008
    #2
    1. Advertising

  3. 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 = b[tmp];

    }
    Please try this..
    But for knowing
    I tryed your code on turbo c++ 4.5 . It was running..
     
    ÏÑíÏ ÚÈÏ Çááå, Nov 28, 2008
    #3
  4. Wolfgang Thomsen

    red floyd Guest

    دريد عبد الله 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 = 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.
     
    red floyd, Nov 28, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ago
    Replies:
    3
    Views:
    339
  2. Luna Moon
    Replies:
    16
    Views:
    1,395
    Giovanni Gherdovich
    Aug 8, 2008
  3. Bearophile

    Vectorized laziness inside

    Bearophile, Sep 10, 2009, in forum: Python
    Replies:
    0
    Views:
    331
    Bearophile
    Sep 10, 2009
  4. Bearophile

    Vectorized laziness 2

    Bearophile, Dec 20, 2009, in forum: Python
    Replies:
    0
    Views:
    230
    Bearophile
    Dec 20, 2009
  5. Isaac Won
    Replies:
    9
    Views:
    419
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page