mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-29 16:22:03 +08:00
add ublas vector of vector in sparse setter bench
This commit is contained in:
parent
61b85b1436
commit
22792c696f
@ -100,5 +100,6 @@ void eiToCSparse(const EigenSparseMatrix& src, cs* &dst)
|
|||||||
#include <boost/numeric/ublas/triangular.hpp>
|
#include <boost/numeric/ublas/triangular.hpp>
|
||||||
#include <boost/numeric/ublas/vector_sparse.hpp>
|
#include <boost/numeric/ublas/vector_sparse.hpp>
|
||||||
#include <boost/numeric/ublas/matrix_sparse.hpp>
|
#include <boost/numeric/ublas/matrix_sparse.hpp>
|
||||||
|
#include <boost/numeric/ublas/vector_of_vector.hpp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,19 +4,22 @@
|
|||||||
// -DNOGMM -DNOMTL -DCSPARSE
|
// -DNOGMM -DNOMTL -DCSPARSE
|
||||||
// -I /home/gael/Coding/LinearAlgebra/CSparse/Include/ /home/gael/Coding/LinearAlgebra/CSparse/Lib/libcsparse.a
|
// -I /home/gael/Coding/LinearAlgebra/CSparse/Include/ /home/gael/Coding/LinearAlgebra/CSparse/Lib/libcsparse.a
|
||||||
#ifndef SIZE
|
#ifndef SIZE
|
||||||
#define SIZE 300000
|
#define SIZE 1000000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NBPERROW
|
#ifndef NBPERROW
|
||||||
#define NBPERROW 12
|
#define NBPERROW 24
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef REPEAT
|
#ifndef REPEAT
|
||||||
#define REPEAT 1
|
#define REPEAT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NOGOOGLE
|
||||||
#define EIGEN_GOOGLEHASH_SUPPORT
|
#define EIGEN_GOOGLEHASH_SUPPORT
|
||||||
#include <google/sparse_hash_map>
|
#include <google/sparse_hash_map>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "BenchSparseUtil.h"
|
#include "BenchSparseUtil.h"
|
||||||
|
|
||||||
|
|
||||||
@ -37,6 +40,7 @@ EIGEN_DONT_INLINE Scalar* setrand_eigen_google_sparse(const Coordinates& coords,
|
|||||||
EIGEN_DONT_INLINE Scalar* setrand_ublas_mapped(const Coordinates& coords, const Values& vals);
|
EIGEN_DONT_INLINE Scalar* setrand_ublas_mapped(const Coordinates& coords, const Values& vals);
|
||||||
EIGEN_DONT_INLINE Scalar* setrand_ublas_coord(const Coordinates& coords, const Values& vals);
|
EIGEN_DONT_INLINE Scalar* setrand_ublas_coord(const Coordinates& coords, const Values& vals);
|
||||||
EIGEN_DONT_INLINE Scalar* setrand_ublas_compressed(const Coordinates& coords, const Values& vals);
|
EIGEN_DONT_INLINE Scalar* setrand_ublas_compressed(const Coordinates& coords, const Values& vals);
|
||||||
|
EIGEN_DONT_INLINE Scalar* setrand_ublas_genvec(const Coordinates& coords, const Values& vals);
|
||||||
EIGEN_DONT_INLINE Scalar* setrand_mtl(const Coordinates& coords, const Values& vals);
|
EIGEN_DONT_INLINE Scalar* setrand_mtl(const Coordinates& coords, const Values& vals);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -74,8 +78,9 @@ int main(int argc, char *argv[])
|
|||||||
for (int k=0; k<REPEAT; ++k)
|
for (int k=0; k<REPEAT; ++k)
|
||||||
setrand_eigen_gnu_hash(coords,values);
|
setrand_eigen_gnu_hash(coords,values);
|
||||||
timer.stop();
|
timer.stop();
|
||||||
std::cout << "Eigen gnu hashmap\t" << timer.value() << "\n";
|
std::cout << "Eigen std::map\t" << timer.value() << "\n";
|
||||||
}
|
}
|
||||||
|
#ifndef NOGOOGLE
|
||||||
{
|
{
|
||||||
timer.reset();
|
timer.reset();
|
||||||
timer.start();
|
timer.start();
|
||||||
@ -92,6 +97,7 @@ int main(int argc, char *argv[])
|
|||||||
timer.stop();
|
timer.stop();
|
||||||
std::cout << "Eigen google sparse\t" << timer.value() << "\n";
|
std::cout << "Eigen google sparse\t" << timer.value() << "\n";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NOUBLAS
|
#ifndef NOUBLAS
|
||||||
{
|
{
|
||||||
@ -103,6 +109,14 @@ int main(int argc, char *argv[])
|
|||||||
std::cout << "ublas mapped\t" << timer.value() << "\n";
|
std::cout << "ublas mapped\t" << timer.value() << "\n";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
timer.reset();
|
||||||
|
timer.start();
|
||||||
|
for (int k=0; k<REPEAT; ++k)
|
||||||
|
setrand_ublas_genvec(coords,values);
|
||||||
|
timer.stop();
|
||||||
|
std::cout << "ublas vecofvec\t" << timer.value() << "\n";
|
||||||
|
}
|
||||||
|
/*{
|
||||||
timer.reset();
|
timer.reset();
|
||||||
timer.start();
|
timer.start();
|
||||||
for (int k=0; k<REPEAT; ++k)
|
for (int k=0; k<REPEAT; ++k)
|
||||||
@ -117,7 +131,7 @@ int main(int argc, char *argv[])
|
|||||||
setrand_ublas_coord(coords,values);
|
setrand_ublas_coord(coords,values);
|
||||||
timer.stop();
|
timer.stop();
|
||||||
std::cout << "ublas coord\t" << timer.value() << "\n";
|
std::cout << "ublas coord\t" << timer.value() << "\n";
|
||||||
}
|
}*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -151,6 +165,7 @@ EIGEN_DONT_INLINE Scalar* setrand_eigen_gnu_hash(const Coordinates& coords, cons
|
|||||||
return 0;//&mat.coeffRef(coords[0].x(), coords[0].y());
|
return 0;//&mat.coeffRef(coords[0].x(), coords[0].y());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NOGOOGLE
|
||||||
EIGEN_DONT_INLINE Scalar* setrand_eigen_google_dense(const Coordinates& coords, const Values& vals)
|
EIGEN_DONT_INLINE Scalar* setrand_eigen_google_dense(const Coordinates& coords, const Values& vals)
|
||||||
{
|
{
|
||||||
using namespace Eigen;
|
using namespace Eigen;
|
||||||
@ -176,6 +191,8 @@ EIGEN_DONT_INLINE Scalar* setrand_eigen_google_sparse(const Coordinates& coords,
|
|||||||
}
|
}
|
||||||
return 0;//&mat.coeffRef(coords[0].x(), coords[0].y());
|
return 0;//&mat.coeffRef(coords[0].x(), coords[0].y());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NOUBLAS
|
#ifndef NOUBLAS
|
||||||
EIGEN_DONT_INLINE Scalar* setrand_ublas_mapped(const Coordinates& coords, const Values& vals)
|
EIGEN_DONT_INLINE Scalar* setrand_ublas_mapped(const Coordinates& coords, const Values& vals)
|
||||||
{
|
{
|
||||||
@ -191,7 +208,7 @@ EIGEN_DONT_INLINE Scalar* setrand_ublas_mapped(const Coordinates& coords, const
|
|||||||
compressed_matrix<Scalar> mat(aux);
|
compressed_matrix<Scalar> mat(aux);
|
||||||
return 0;// &mat(coords[0].x(), coords[0].y());
|
return 0;// &mat(coords[0].x(), coords[0].y());
|
||||||
}
|
}
|
||||||
EIGEN_DONT_INLINE Scalar* setrand_ublas_coord(const Coordinates& coords, const Values& vals)
|
/*EIGEN_DONT_INLINE Scalar* setrand_ublas_coord(const Coordinates& coords, const Values& vals)
|
||||||
{
|
{
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
using namespace boost::numeric;
|
using namespace boost::numeric;
|
||||||
@ -215,6 +232,21 @@ EIGEN_DONT_INLINE Scalar* setrand_ublas_compressed(const Coordinates& coords, co
|
|||||||
mat(coords[i].x(), coords[i].y()) = vals[i];
|
mat(coords[i].x(), coords[i].y()) = vals[i];
|
||||||
}
|
}
|
||||||
return 0;//&mat(coords[0].x(), coords[0].y());
|
return 0;//&mat(coords[0].x(), coords[0].y());
|
||||||
|
}*/
|
||||||
|
EIGEN_DONT_INLINE Scalar* setrand_ublas_genvec(const Coordinates& coords, const Values& vals)
|
||||||
|
{
|
||||||
|
using namespace boost;
|
||||||
|
using namespace boost::numeric;
|
||||||
|
using namespace boost::numeric::ublas;
|
||||||
|
|
||||||
|
// ublas::vector<coordinate_vector<Scalar> > foo;
|
||||||
|
generalized_vector_of_vector<Scalar, row_major, ublas::vector<coordinate_vector<Scalar> > > aux(SIZE,SIZE);
|
||||||
|
for (int i=0; i<coords.size(); ++i)
|
||||||
|
{
|
||||||
|
aux(coords[i].x(), coords[i].y()) = vals[i];
|
||||||
|
}
|
||||||
|
compressed_matrix<Scalar,row_major> mat(aux);
|
||||||
|
return 0;//&mat(coords[0].x(), coords[0].y());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user