Boost logo

Boost Users :

From: Marco Segurini (yg-boost-users_at_[hidden])
Date: 2003-07-01 10:25:10


Hi,

I am very new in using Boost library.
I start replacing row memory array with 'multi_array' class template but the
performace slow down a lot.

Running this test program...

//begin------------------
#include "windows.h"
#include <iostream>
#include "boost\multi_array.hpp"

using namespace std;
using namespace boost;

int main()
{
    const size_t DimX = 2000;
    const size_t DimY = 1500;
    const size_t DimZ = 1;
    multi_array<int,3> V3(extents[DimZ][DimY][DimX]);

    int iVal;
    unsigned long time1 = GetTickCount();
    for (size_t Z=0; Z<DimZ; ++Z)
        for (size_t Y=0; Y<DimY; ++Y)
            for (size_t X=0; X<DimX; ++X)
                iVal = V3[Z][Y][X];
    unsigned long time2 = GetTickCount();
    cout << "Multi_array: " << time2-time1 << endl;

    int * pInt = V3.data();
    time1 = GetTickCount();
    for (size_t Z=0; Z<DimZ; ++Z)
        for (size_t Y=0; Y<DimY; ++Y)
            for (size_t X=0; X<DimX; ++X)
                iVal = pInt[(Z*DimY+Y)*DimX+X];
    time2 = GetTickCount();
    cout << "Pointer....: " << time2-time1 << endl;

    return 0;
}

//end------------------

... the output (using vc++ in release mode with no optimization) is

Multi_array: 1663
Pointer....:70

So, where am I wrong?

Thanks.
Marco.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net