-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replaced SGVector::add with linalg::add; moved SGVector::operator+=(S…
…GVector) to .cpp file; added benchmark for SGVector::operator+=(SGVector)
- Loading branch information
nginn
committed
Dec 2, 2015
1 parent
a6c2269
commit fc0e3f5
Showing
9 changed files
with
63 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <shogun/lib/SGVector.h> | ||
#include <shogun/lib/SGSparseVector.h> | ||
#include <shogun/mathematics/linalg/linalg.h> | ||
#include <algorithm> | ||
#include <hayai/hayai.hpp> | ||
#include <iostream> | ||
|
||
using namespace shogun; | ||
|
||
/** | ||
* Instructions : | ||
* 1. Install benchmarking toolkit "hayai" (https://github.com/nickbruun/hayai) | ||
* 2. Compile against libhayai_main, e.g. | ||
* g++ -O3 -std=c++11 sgvector_add_operator_benchmark.cpp -I/usr/include/eigen3 -I/usr/local/include/viennacl -lshogun -lhayai_main -lOpenCL -o benchmark | ||
* 3. ./benchmark | ||
*/ | ||
|
||
/** Generate data only once */ | ||
struct Data | ||
{ | ||
Data() | ||
{ | ||
init(); | ||
} | ||
|
||
void init() | ||
{ | ||
m_vec = SGVector<float32_t>(num_elems); | ||
std::iota(m_vec.data(), m_vec.data()+m_vec.size(), 1); | ||
} | ||
|
||
SGVector<float32_t> m_vec; | ||
static constexpr index_t num_elems=1000; | ||
}; | ||
|
||
Data data; | ||
|
||
|
||
BENCHMARK(SGVector, addoperator_SGVector, 10, 100000000) | ||
{ | ||
SGVector<float32_t> test_vec = SGVector<float32_t>(data.num_elems); | ||
std::iota(test_vec.data(), test_vec.data()+test_vec.size(), 1); | ||
data.m_vec += test_vec; | ||
} | ||
|
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
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
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
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
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
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
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
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
fc0e3f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lambday can you comment?