I've been puzzled by the speed of MTL, please help me!
"YY LI" <[email protected]>
| Newsgroups | gmane.comp.lib.mtl.devel |
|---|---|
| Message-ID | <[email protected]> |
Dear sirs:
I've done some test on the speed of mtl, comparing to my c code.
unfortunately, my mtl code runs more slowly than my c code. I'm sure I have
misused the mtl library, but, I cannot overcome it. please give some guide.
my tests is about the speed of "Multiply matrix A times vector x", my
compiler is visual c++ 6.0, I've compiled the code to be release version, so
I think I've enable the option of optimisition.
I present some of my code below:
1)the mtl code:
typedef matrix< double,
rectangle<>,
dense<>,
row_major>::type Matrix;
typedef dense1D<double> Vector;
const int M=1000;
const int N=1000;
void mtl_mult_vec()
{
Matrix A(M, N);
Vector B(N), C(M);
for(int i=0;i<M;i++)
for(int j=0;j<N;j++)
{
A(i,j) = i*N+j;
}
for(i=0;i<N;i++)
{
B[i] = i;
}
//I'm desired in the running time of "mult"
mult(A, B, C);
}
2)my c code
const int M=1000;
const int N=1000;
double A[M][N], B[N], C[M];
void c_mult_vec()
{
for(int i=0;i<M;i++)
for(int j=0;j<N;j++)
{
A[i][j] = i*N+j;
}
for(i=0;i<N;i++)
{
B[i] = i;
}
//I'm desired in the running time of the code following.
for(i=0;i<M;i++)
for(int k=0;k<N;k++)
C[i]+=A[i][k]*B[k];
}
according to my test, the running time of the two senarios is as following:
mtl 438ms
c code 63ms
I don't know why the speed of mtl is so slow, please give me some advice.
sincerely yours
hartor
2003.6.4
_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus
_______________________________________________
This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/