Re: [eigen] strange SSE2 impact on Vector::array and Array |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] strange SSE2 impact on Vector::array and Array
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Sun, 18 Dec 2011 10:23:58 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=P9PncscA2EzuZQinELP+rqO7ZKCRa5Cr7Ietqv9oXIw=; b=Et2NGkGUk6qLiaTq+8LvF5QHL51JFF/gKKCBXdb54YZDLmESQ9+MCerXLfWEECzbdT 8038bP7+fUIqfsHBrWJktBseOq2SrYdo3sS09h8JWYQLWuSIZgnBXPUsxIP3+KWfqEy+ oMJJUtvwB/GdNjROMLI2O+4UzCwjzL0FWb1+o=
Array and Vector should really give you the same perf, the difference
you get is probably only due to your system load. However, SSE should
give you a significant speed up.
Here is a small bench that you cn try:
#include <Eigen/Core>
#include <bench/BenchTimer.h>
#include <iostream>
using namespace Eigen;
EIGEN_DONT_INLINE void foo_arr(ArrayXd& a, ArrayXd& b)
{
a += b;
}
EIGEN_DONT_INLINE void foo_vec(VectorXd& a, VectorXd& b)
{
a += b;
}
int main()
{
BenchTimer t1, t2;
const int n=10000,m=10000;
{
ArrayXd a(ArrayXd::Random(n)),b(ArrayXd::Random(n));
BENCH(t1, 20, m, foo_arr(a,b));
}
{
VectorXd a(VectorXd::Random(n)),b(VectorXd::Random(n));
BENCH(t2, 20, m, foo_vec(a,b));
}
std::cout << t1.best() << " " << t2.best() << std::endl;
}
Here I get:
without SSE: 0.122551 0.121282
with SSE: 0.0742666 0.0743076
gael
2011/12/17 Not Sure <kuerzn@xxxxxxxxxxxxxx>:
> void main(){
>
> const int n=100000,m=10000;
> {
> ArrayXd a(ArrayXd::Random(n)),b(ArrayXd::Random(n));
> for(int i=0;i<m;i++)
> a += b;
> }
> {
> VectorXd a(VectorXd::Random(n)),b(VectorXd::Random(n));
> for(int i=0;i<m;i++)
> a.array() += b.array();
> }
> }