mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
updated geometry benchmark to handle additional cases
This commit is contained in:
parent
98798e904b
commit
22e6741da9
@ -1,8 +1,11 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
#include <bench/BenchTimer.h>
|
||||
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
|
||||
#ifndef REPEAT
|
||||
#define REPEAT 1000000
|
||||
@ -11,7 +14,8 @@ using namespace Eigen;
|
||||
enum func_opt
|
||||
{
|
||||
TV,
|
||||
TMATRIXV
|
||||
TMATV,
|
||||
TMATVMAT,
|
||||
};
|
||||
|
||||
|
||||
@ -29,7 +33,7 @@ struct func<res, arg1, arg2, TV>
|
||||
};
|
||||
|
||||
template <class res, class arg1, class arg2>
|
||||
struct func<res, arg1, arg2, TMATRIXV>
|
||||
struct func<res, arg1, arg2, TMATV>
|
||||
{
|
||||
static __attribute__ ((noinline)) res run( arg1& a1, arg2& a2 )
|
||||
{
|
||||
@ -38,6 +42,15 @@ struct func<res, arg1, arg2, TMATRIXV>
|
||||
}
|
||||
};
|
||||
|
||||
template <class res, class arg1, class arg2>
|
||||
struct func<res, arg1, arg2, TMATVMAT>
|
||||
{
|
||||
static __attribute__ ((noinline)) res run( arg1& a1, arg2& a2 )
|
||||
{
|
||||
asm ("");
|
||||
return res(a1.matrix() * a2.matrix());
|
||||
}
|
||||
};
|
||||
|
||||
template <class func, class arg1, class arg2>
|
||||
struct test_transform
|
||||
@ -58,13 +71,13 @@ struct test_transform
|
||||
a2 = func::run( a1, a2 );
|
||||
timer.stop();
|
||||
}
|
||||
std::cout << timer.value() << "s " << (double(REPEAT)/timer.value())/(1024.*1024.*1024.) << " GFlops\n";
|
||||
cout << setprecision(4) << fixed << timer.value() << "s " << endl;;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#define run_test( op, scalar, mode, option, vsize ) \
|
||||
std::cout << #op << " " << #scalar << " " << #mode << " " << #option << " " << #vsize " "; \
|
||||
#define run_vec( op, scalar, mode, option, vsize ) \
|
||||
std::cout << #scalar << "\t " << #mode << "\t " << #option << " " << #vsize " "; \
|
||||
{\
|
||||
typedef Transform<scalar, 3, mode, option> Trans;\
|
||||
typedef Matrix<scalar, vsize, 1, option> Vec;\
|
||||
@ -72,13 +85,50 @@ struct test_transform
|
||||
test_transform< Func, Trans, Vec >::run();\
|
||||
}
|
||||
|
||||
#define run_trans( op, scalar, mode, option ) \
|
||||
std::cout << #scalar << "\t " << #mode << "\t " << #option << " "; \
|
||||
{\
|
||||
typedef Transform<scalar, 3, mode, option> Trans;\
|
||||
typedef func<Trans,Trans,Trans,op> Func;\
|
||||
test_transform< Func, Trans, Trans >::run();\
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
run_test(TV, float, Isometry, AutoAlign, 3);
|
||||
run_test(TV, float, Isometry, DontAlign, 3);
|
||||
run_test(TV, float, Isometry, AutoAlign, 4);
|
||||
run_test(TV, float, Isometry, DontAlign, 4);
|
||||
cout << "vec = trans * vec" << endl;
|
||||
run_vec(TV, float, Isometry, AutoAlign, 3);
|
||||
run_vec(TV, float, Isometry, DontAlign, 3);
|
||||
run_vec(TV, float, Isometry, AutoAlign, 4);
|
||||
run_vec(TV, float, Isometry, DontAlign, 4);
|
||||
run_vec(TV, float, Projective, AutoAlign, 4);
|
||||
run_vec(TV, float, Projective, DontAlign, 4);
|
||||
run_vec(TV, double, Isometry, AutoAlign, 3);
|
||||
run_vec(TV, double, Isometry, DontAlign, 3);
|
||||
run_vec(TV, double, Isometry, AutoAlign, 4);
|
||||
run_vec(TV, double, Isometry, DontAlign, 4);
|
||||
run_vec(TV, double, Projective, AutoAlign, 4);
|
||||
run_vec(TV, double, Projective, DontAlign, 4);
|
||||
|
||||
run_test(TMATRIXV, float, Isometry, AutoAlign, 4);
|
||||
run_test(TMATRIXV, float, Isometry, DontAlign, 4);
|
||||
cout << "vec = trans.matrix() * vec" << endl;
|
||||
run_vec(TMATV, float, Isometry, AutoAlign, 4);
|
||||
run_vec(TMATV, float, Isometry, DontAlign, 4);
|
||||
run_vec(TMATV, double, Isometry, AutoAlign, 4);
|
||||
run_vec(TMATV, double, Isometry, DontAlign, 4);
|
||||
|
||||
cout << "trans = trans1 * trans" << endl;
|
||||
run_trans(TV, float, Isometry, AutoAlign);
|
||||
run_trans(TV, float, Isometry, DontAlign);
|
||||
run_trans(TV, double, Isometry, AutoAlign);
|
||||
run_trans(TV, double, Isometry, DontAlign);
|
||||
run_trans(TV, float, Projective, AutoAlign);
|
||||
run_trans(TV, float, Projective, DontAlign);
|
||||
run_trans(TV, double, Projective, AutoAlign);
|
||||
run_trans(TV, double, Projective, DontAlign);
|
||||
|
||||
cout << "trans = trans1.matrix() * trans.matrix()" << endl;
|
||||
run_trans(TMATVMAT, float, Isometry, AutoAlign);
|
||||
run_trans(TMATVMAT, float, Isometry, DontAlign);
|
||||
run_trans(TMATVMAT, double, Isometry, AutoAlign);
|
||||
run_trans(TMATVMAT, double, Isometry, DontAlign);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user