help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vectorization in gcc 4.1.1


From: BobR
Subject: Re: Vectorization in gcc 4.1.1
Date: Wed, 04 Jul 2007 05:51:59 GMT

rameshk <ramesh.kadambi@gmail.com> wrote in message...
> Hi,
> I was trying to get gcc to vectorize a simple loop:
>
> #include <vector>
// > int test(double *x , int size);
>
> int test(double *x, int size){
>         int ret = 1;
>         std::vector<double>     v;
>         v.resize(size);
>         double  *a = &v[0];

   std::cout<<"sizeof(double)="<<sizeof(double)<<std::endl;
   std::vector<double> vD( 10 );
   std::cout<<"sizeof(vD)="<<sizeof(vD)<<std::endl;
/* - out -
sizeof(double)=8
sizeof(vD)=12
*/

>         for(int i = 0;i < size; ++i )
>         {
>                 a[i ] = 1/x[i];      // ka-boom
>         }
>
> }

int test( double *x, int size ){
     int ret = 1;
     // std::vector<double> v( size );
     // for( std::size_t a(0); a < v.size(); ++a ){  v.at( i ) = 1/x[i]; }
// for(a)

     std::vector<double> v( x, x + size );

     // .... do something with 'v'
     return ret;
     }

--
Bob R
POVrookie




reply via email to

[Prev in Thread] Current Thread [Next in Thread]