[eigen] [Fwd: eigen cwise] unexpected performance regression with eigen's cwise()

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


A freind of mine who is using eigen for his code, hit this unexpected
speed bump. I have no idea why.

gcc 4.3.3
Opteron 144, 1.8 ghz
OS: ubuntu, 9.04, 32 bit
eigen: unstable


---------- Forwarded message ----------
From:  <sriramkashyap@xxxxxxxxx>
Date: Wed, Aug 19, 2009 at 10:16 AM
Subject: eigen cwise
To: Rohit Garg <rpg.314@xxxxxxxxx>


Results for 3 runs of the attached code (50000 cwise muls, done 50000 times):

compile flags; -msse -msse2 -msse3 -DEIGEN_NO_DEBUG -O3

My cwise: 7.56, 7.84, 7.7
Eigen cwise: 8.3, 8.17, 8.39



-- 
Rohit Garg

http://rpg-314.blogspot.com/

Senior Undergraduate
Department of Physics
Indian Institute of Technology
Bombay
#include<iostream>
#include<Eigen/Core>
#include<Eigen/AlignedVector3>
#include<ctime>

using namespace Eigen;
using namespace std;
#define SIZE 50000
#define ITER 50000
Vector3f blah[SIZE];

void initBlah(){
	for (int i=0;i<SIZE;i++){
		blah[i]=Vector3f((i%100)/2.0f,(i%100)/3.0f,(i%100)/4.0f);
	}
}

Vector3f cwiseop(const Vector3f& a, const Vector3f& b){
	return Vector3f(a.x()*b.x(),a.y()*b.y(),a.z()*b.z());
}

void doMul(){
	for (int i=0;i<ITER;i++)
		for (int j=0;j<SIZE-2;j++)
			blah[i]=cwiseop(blah[i+1],blah[i+2]);
//				blah[i]=blah[i+1].cwise()*blah[i+2];
}

int main(){
	initBlah();
	clock_t start = std::clock();
	doMul();
	clock_t end = std::clock();
	cout<<"Time: "<<((double)end-(double)start)/CLOCKS_PER_SEC<<endl;
	return 0;
}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/