FIAS . Impressum . Privacy

std::vector vs Vc::Memory

Matthias Kretz kretz@compeng.uni-frankfurt.de[please enable javascript to see the address]
Wed Mar 5 09:28:16 CET 2014


Oh, BTW, in case you missed it: there's also a benchmarks repository for Vc on 
code.compeng.uni-frankfurt.de. I do a bad job of maintaining it, but there's 
some useful and interesting benchmark code there.

On Wednesday 05 March 2014 09:23:12 Sandro Wenzel wrote:
> Dear Tijskens,
> 
> I was intrigued by your observations  and tried to reproduce them but I
> failed. Actually, I feel like Matthias that measuring such short
> minimalistic code section is really tough.
> 
> Would you be able  to share your benchmark code and the way you compile it
> such that I can have a more thorough look?
> 
> Best
> 
> Sandro
> 
> 
> 
> 2014-03-04 18:57 GMT+01:00 Tijskens Engelbert <
> 
> Engelbert.Tijskens@uantwerpen.be[please enable javascript to see the address]>:
> >  Dear all,
> >  
> >  I am trying to figure out how to use std::vector<float> efficiently in
> > 
> > combination with Vc. (to have dynamic arrays and performance)
> > 
> >      std::vector<float> x(1024);
> >     
> >     for( int i=0; i<ne; ++i ) {//initialize
> >     
> >         x[i]=1.0;
> >     
> >     }
> > 
> > // scalar loop using std::vector
> > 
> >     for( int i=0; i<ne; ++i ) {
> >     
> >         x[i] -= 1.0;
> >     
> >     }
> > 
> > // vector loop using std::vector
> > 
> >     for( int i=0; i<ne; i+=Vc::float_v::Size )
> >     {
> >     
> >         Vc::float_v vx( &x[i] );
> >         vx -= 1.0;
> >         vx.store( &x[i] );
> >     
> >     }
> > 
> > // vector loop using Vc::Memory instead of std::vector
> > 
> >     Vc::Memory<Vc::float_v,ne> Vx;
> >     for( int i=0; i<ne; ++i ) {//initialize
> >     
> >         Vx[i] = 1.0;
> >     
> >     }
> >     Vc::float_v one(1.);
> >     ET_TIME_THIS
> >     
> >      ( "Vc::Memory<Vc::float_v,ne>  vector",
> >      
> >         for( int i=0; i<nv; ++i ) {
> >         
> >             Vx.vector(i) -= one;
> >         
> >         }
> > 
> > When i time these loops i get the following results
> > 
> >  scalar loop using std::vector : 2162 cycles/repetition, 9.4e-07
> > 
> > seconds/repetition, 1   x speedup, 2.3  GHz, 100 repetitions.
> > vector loop using std::vector :  357 cycles/repetition, 1.6e-07
> > seconds/repetition, 6.04x speedup, 2.24 GHz, 100 repetitions.
> > vector loop using Vc::Memory  :  288 cycles/repetition, 1.2e-07
> > seconds/repetition, 7.49x speedup, 2.4  GHz, 100 repetitions.
> > 
> >  is there a way to improve the vector loop using std::vector? By the way
> > 
> > if i write the second loop as
> > 
> >  // vector loop using std::vector
> >  
> >     for( int i=0; i<ne; i+=Vc::float_v::Size )
> >     {
> >     
> >         Vc::float_v vx( &x[i] );
> >         Vx.vector(i) -= one;
> >         vx.store( &x[i] );
> >     
> >     }
> >  
> >  things get even worse, the speedup being only 4.2x roughly.
> > 
> > _______________________________________________
> > Vc mailing list
> > Vc@compeng.uni-frankfurt.de[please enable javascript to see the address]
> > https://compeng.uni-frankfurt.de/mailman/listinfo/vc

-- 
─────────────────────────────────────────────────────────────
 Dipl.-Phys. Matthias Kretz

 Web:   http://compeng.uni-frankfurt.de/?mkretz

 SIMD easy and portable: http://compeng.uni-frankfurt.de/?vc
─────────────────────────────────────────────────────────────
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://compeng.uni-frankfurt.de/pipermail/vc/attachments/20140305/e366e9c3/attachment.pgp>


More information about the Vc mailing list
FIAS . Impressum . Privacy