[eigen] About performance with 3-double vectors and self written library |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] About performance with 3-double vectors and self written library
- From: William Oquendo <woquendo@xxxxxxxxx>
- Date: Tue, 2 Mar 2010 12:30:15 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:content-type; bh=IppDAZFoTxKcj0iYPzIBCG01NQktHCOQbAXtiTVku7o=; b=nd47mvWBX3YqPUGEfGddos5zWiVldEL9nbsD/UpfGCBXDh3y+xgV3iokIUekgCFIhW 6T7Bz73VV2+iQUwrIuR/hWXtmNuJGOv/FaGuZXlNLWzsuru7lyDQTY9nceKR54+XfJPH hMPTaOUGd6PSvs+MVyid6WOPSjD+KMFVsGLAs=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=VEBBXWeDXB9Zk17jeG00gOYDSGjtToVMW1NgfnCRNp2Yd9XF97FBhwLZLpG/slQlar HLhxrYpgJO2CIxv18nOF8m5JNf+ZxhWnOqlPwsXVxBPjnXs8vN86W+ojPgwvY6EfPt90 eufquR8aBCrEmHSvOyzUoB/lJhoI5YNc9ViwQ=
Dear all,
I have written a small 3 dimensional - double - vector library, and I was expecting that eigen performance was better than my library.. Unfortunately, that is not the case. I have run a test and, for g++ 4.2 I got aprox 12 secons with eigen and aprox 6 seconds with my library. With g++ 4.5, I got 5.5 aprox for eigen and 7 aprox for my library.
I wluld like to know if I am using eigen the wrong way and that is the cause of this c++4.2 performance penalty (I do not have access to g++ 4.5 on the production servers) or this is just an special case.
I am attaching the code and copying it here:
#include "vector3d.hh"
#include <eigen2/Eigen/Core>
#include <eigen2/Eigen/Geometry>
USING_PART_OF_NAMESPACE_EIGEN
#include <iostream>
using namespace std;
typedef Vector3D vec_t; // my library
//typedef Vector3d vec_t; // Eigen
const double STEPS = 1.0e4;
int main(void)
{
double i;
vec_t v1, v2;
vec_t v3 = v2;
vec_t v5;
///*
for(double j = 0; j < STEPS; j++) {
v3 = v2;
// copy constructor
for(i = 0; i < STEPS; i++) {
vec_t v4 = v3;
}
// copy
for(i = 0; i < STEPS; i++) {
v3 = vec_t(i/0.34, i, i*i);
}
// accessing one element
for(i = 0; i < STEPS; i++) {
v3[1] = i;
}
// long airhmetic operations
v1 = vec_t(1,2.2,3.4);
v2 = vec_t(-2, 3, 3);
for(i = 0; i < STEPS; i++) {
v3 = vec_t(i/0.34, i, i*i);
v5 = v1+v2-v3;
}
// scalar product
double result;
for(i = 0; i < STEPS; i++) {
result = v3.dot(v5);
}
// cross product
for(i = 0; i < STEPS; i++) {
v5 = v1.cross(v2);
}
// complex operation
for(i = 0; i < 10*STEPS; i++) {
v5 = v1 + 2.0*v2 - v3/4.0 + (v3.cross(v2));
}
// normalize
for(i = 0; i < STEPS; i++) {
v3 = v5.normalized();
}
for(i = 0; i < STEPS; i++) {
v5.normalize();
}
}
//*/
clog << v1 << endl;
clog << v2 << endl;
clog << v3 << endl;
clog << v5 << endl;
return 0;
}
Best regards / Cordialmente,
--
William Oquendo
Phd Candidate
Simulation Of Physical Systems Group
National University of Colombia
Linux User # 321481
*********************
Este correo puede carecer de tildes o eñes ya que el teclado no contiene estos caracteres. Presento excusas por eso.
*********************
Attachment:
test.cpp
Description: Binary data
Attachment:
vector3d.hh
Description: Binary data