Created
June 8, 2016 00:44
-
-
Save lambday/774e12056299f461a4c64837298bea95 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) (841.955000 ms) | |
[ RUNS ] Average time: 84195.500 us | |
Fastest: 78455.000 us (-5740.500 us / -6.818 %) | |
Slowest: 123583.000 us (+39387.500 us / +46.781 %) | |
Average performance: 11.87712 runs/s | |
Best performance: 12.74616 runs/s (+0.86904 runs/s / +7.31693 %) | |
Worst performance: 8.09173 runs/s (-3.78539 runs/s / -31.87129 %) | |
[ITERATIONS] Average time: 84.195 us | |
Fastest: 78.455 us (-5.740 us / -6.818 %) | |
Slowest: 123.583 us (+39.388 us / +46.781 %) | |
Average performance: 11877.11932 iterations/s | |
Best performance: 12746.16022 iterations/s (+869.04090 iterations/s / +7.31693 %) | |
Worst performance: 8091.72783 iterations/s (-3785.39150 iterations/s / -31.87129 %) | |
[ RUN ] SGVector.linalg(data.A, data.B, data.backend) (10 runs, 1000 iterations per run) | |
[ DONE ] SGVector.linalg(data.A, data.B, data.backend) (792.074000 ms) | |
[ RUNS ] Average time: 79207.400 us | |
Fastest: 78522.000 us (-685.400 us / -0.865 %) | |
Slowest: 81070.000 us (+1862.600 us / +2.352 %) | |
Average performance: 12.62508 runs/s | |
Best performance: 12.73528 runs/s (+0.11020 runs/s / +0.87288 %) | |
Worst performance: 12.33502 runs/s (-0.29006 runs/s / -2.29752 %) | |
[ITERATIONS] Average time: 79.207 us | |
Fastest: 78.522 us (-0.685 us / -0.865 %) | |
Slowest: 81.070 us (+1.863 us / +2.352 %) | |
Average performance: 12625.08301 iterations/s | |
Best performance: 12735.28438 iterations/s (+110.20137 iterations/s / +0.87288 %) | |
Worst performance: 12335.01912 iterations/s (-290.06389 iterations/s / -2.29752 %) | |
[==========] 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
#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