Re: [eigen] [Fwd: eigen cwise] unexpected performance regression with eigen's cwise() |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] [Fwd: eigen cwise] unexpected performance regression with eigen's cwise()
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 19 Aug 2009 14:25:22 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=yjw9KT3OiqWZX1iSvz3laYyiT/tnYxC9FjI4OQ5WZao=; b=sfKjUu6nrv2S7107jCFgRwtvwyTriev4Bri2XqlLFca1zviDVJIN9WjT5IgQxID+7r T1GDB9kAyDHv9ARhfhUsCq8Y3raSCZgZKTJbUWmZ2gM+oudXHV8vsoxqjJn/bOZ1olP7 urhYON0cRWEzyCtNAUXcoVm/iyvmKcPJy8pf0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=hAMZFrC640UGFltQQvjJSPRd5FHYdqlAhG4NU7gxx2OB24A7BH6b5/fCeU2zKkeqtu bpHSFYYyRofCp9Eup8sB3AjiXqvTboCXpPkIM6RECgr0a5ZFiZm+44DoSFeo+37vzIVx pMccRLkxqemp0PdAKVS4NB2rLpvFSp3lTgEas=
First, here's a fixed version, the code was doing illegal accesses due
to mixing up i and j.
Here with gcc-4.4.1 on x86 linux, I can't see a significant speed difference.
=== 14:20:44 ~$ g++ -DEIGEN_CWISEOP temp.cpp -o temp -O3 -msse2
-DNDEBUG -I eigen2 && ./temp
Time: 2.64
=== 14:21:12 ~$ g++ -DCUSTOM_CWISEOP temp.cpp -o temp -O3 -msse2
-DNDEBUG -I eigen2 && ./temp
Time: 2.62
maybe tell your friend to try with gcc 4.4 ?
Benoit
2009/8/19 Rohit Garg <rpg.314@xxxxxxxxx>:
> 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<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<SIZE-2;i++)
for (int j=0;j<ITER;j++)
#ifdef CUSTOM_CWISEOP
blah[i]=cwiseop(blah[i+1],blah[i+2]);
#endif
#ifdef EIGEN_CWISEOP
blah[i]=blah[i+1].cwise()*blah[i+2];
#endif
}
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;
}