FIAS . Impressum . Privacy

std::vector vs Vc::Memory

Tijskens Engelbert [please enable javascript to see the address]
Tue Mar 4 18:57:25 CET 2014


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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://compeng.uni-frankfurt.de/pipermail/vc/attachments/20140304/256cce62/attachment.html>


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