Created
June 8, 2016 00:41
-
-
Save lambday/492b40fed33e45670dd8794c9bff2bf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[lambday@lambday.iitb.ac.in oxphos]$ ./benchmark | |
[==========] Running 2 benchmarks. | |
[ RUN ] SGVector.explict(data.A, data.B) (10 runs, 1000 iterations per run) | |
[ DONE ] SGVector.explict(data.A, data.B) (809.396000 ms) | |
[ RUNS ] Average time: 80939.600 us | |
Fastest: 78482.000 us (-2457.600 us / -3.036 %) | |
Slowest: 97388.000 us (+16448.400 us / +20.322 %) | |
Average performance: 12.35489 runs/s | |
Best performance: 12.74178 runs/s (+0.38688 runs/s / +3.13142 %) | |
Worst performance: 10.26821 runs/s (-2.08669 runs/s / -16.88956 %) | |
[ITERATIONS] Average time: 80.940 us | |
Fastest: 78.482 us (-2.458 us / -3.036 %) | |
Slowest: 97.388 us (+16.448 us / +20.322 %) | |
Average performance: 12354.89180 iterations/s | |
Best performance: 12741.77518 iterations/s (+386.88339 iterations/s / +3.13142 %) | |
Worst performance: 10268.20553 iterations/s (-2086.68627 iterations/s / -16.88956 %) | |
[ RUN ] SGVector.linalg(data.A, data.B, data.backend) (10 runs, 1000 iterations per run) | |
[ DONE ] SGVector.linalg(data.A, data.B, data.backend) (9735.243000 ms) | |
[ RUNS ] Average time: 973524.300 us | |
Fastest: 955443.000 us (-18081.300 us / -1.857 %) | |
Slowest: 1010392.000 us (+36867.700 us / +3.787 %) | |
Average performance: 1.02720 runs/s | |
Best performance: 1.04663 runs/s (+0.01944 runs/s / +1.89245 %) | |
Worst performance: 0.98971 runs/s (-0.03748 runs/s / -3.64885 %) | |
[ITERATIONS] Average time: 973.524 us | |
Fastest: 955.443 us (-18.081 us / -1.857 %) | |
Slowest: 1010.392 us (+36.868 us / +3.787 %) | |
Average performance: 1027.19573 iterations/s | |
Best performance: 1046.63491 iterations/s (+19.43919 iterations/s / +1.89245 %) | |
Worst performance: 989.71488 iterations/s (-37.48084 iterations/s / -3.64885 %) | |
[==========] Ran 2 benchmarks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dot.h> | |
#include <shogun/lib/SGVector.h> | |
#include <shogun/mathematics/eigen3.h> | |
using Eigen::Map; | |
using Eigen::Matrix; | |
using Eigen::Dynamic; | |
namespace shogun | |
{ | |
namespace linalg | |
{ | |
template <typename T> | |
inline T CPUBackend::dot(const SGVector<T>& a, const SGVector<T>& b) const | |
{ | |
typedef Matrix<T, Dynamic, 1> VectorXt; | |
Map<VectorXt> vec_a(a.vector, a.vlen); | |
Map<VectorXt> vec_b(b.vector, b.vlen); | |
return vec_a.dot(vec_b); | |
} | |
template float64_t CPUBackend::dot<float64_t>(const SGVector<float64_t>&, const SGVector<float64_t>&) const; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef DOT_H__ | |
#define DOT_H__ | |
//#include <shogun/lib/SGVector.h> | |
//#include <shogun/mathematics/eigen3.h> | |
// | |
//using Eigen::Map; | |
//using Eigen::Matrix; | |
//using Eigen::Dynamic; | |
namespace shogun | |
{ | |
template <class> class SGVector; | |
namespace linalg | |
{ | |
struct CPUBackend | |
{ | |
template <typename T> | |
inline T dot(const SGVector<T>& a, const SGVector<T>& b) const; | |
//{ | |
// typedef Matrix<T, Dynamic, 1> VectorXt; | |
// Map<VectorXt> vec_a(a.vector, a.vlen); | |
// Map<VectorXt> vec_b(b.vector, b.vlen); | |
// return vec_a.dot(vec_b); | |
//} | |
}; | |
} | |
} | |
#endif // DOT_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <shogun/lib/common.h> | |
#include <shogun/lib/SGVector.h> | |
#include <shogun/mathematics/eigen3.h> | |
#include <dot.h> | |
#include <hayai/hayai.hpp> | |
using namespace shogun; | |
using namespace linalg; | |
using Eigen::Map; | |
using Eigen::Matrix; | |
using Eigen::Dynamic; | |
typedef float64_t value_type; | |
template <typename T> | |
struct Data | |
{ | |
explicit Data(size_t _size) : size(_size) | |
{ | |
A=SGVector<T>(size); | |
B=SGVector<T>(size); | |
A.range_fill(1); | |
B.range_fill(size); | |
} | |
CPUBackend backend; | |
SGVector<T> A; | |
SGVector<T> B; | |
const size_t size; | |
}; | |
BENCHMARK_P(SGVector, explict, 10, 1000, (const SGVector<value_type> &A, const SGVector<value_type> &B)) | |
{ | |
typedef Matrix<value_type, Dynamic, 1> VectorXt; | |
Map<VectorXt> vec_A(A.vector, A.vlen); | |
Map<VectorXt> vec_B(B.vector, B.vlen); | |
auto C = vec_A.dot(vec_B); | |
} | |
BENCHMARK_P(SGVector, linalg, 10, 1000, (const SGVector<value_type> &A, const SGVector<value_type> &B, const CPUBackend& backend)) | |
{ | |
auto C = backend.dot(A, B); | |
} | |
Data<value_type> data(1000000); | |
BENCHMARK_P_INSTANCE(SGVector, explict, (data.A, data.B)); | |
BENCHMARK_P_INSTANCE(SGVector, linalg, (data.A, data.B, data.backend)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment