enable support for lambda preprocessing function, and c++11

This commit is contained in:
tqchen
2014-12-19 02:00:43 -08:00
parent 58331067f8
commit 1754fdbf4e
10 changed files with 124 additions and 23 deletions

View File

@@ -2,7 +2,7 @@ export CC = gcc
export CXX = g++
export MPICXX = mpicxx
export LDFLAGS= -pthread -lm -lrt
export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fPIC -I../src
export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fPIC -I../src -std=c++11
# specify tensor path
BIN = speed_test test_model_recover test_local_recover

View File

@@ -50,14 +50,17 @@ class Model : public rabit::utils::ISerializable {
inline void TestMax(Model *model, Model *local, int ntrial, int iter) {
int rank = rabit::GetRank();
int nproc = rabit::GetWorldSize();
const int z = iter + 111;
const int z = iter + 111;
std::vector<float> ndata(model->data.size());
for (size_t i = 0; i < ndata.size(); ++i) {
ndata[i] = (i * (rank+1)) % z + local->data[i];
}
test::CallBegin("Allreduce::Max", ntrial, iter);
rabit::Allreduce<op::Max>(&ndata[0], ndata.size());
rabit::Allreduce<op::Max>(&ndata[0], ndata.size(),
[&]() {
// use lambda expression to prepare the data
for (size_t i = 0; i < ndata.size(); ++i) {
ndata[i] = (i * (rank+1)) % z + local->data[i];
}
});
test::CallEnd("Allreduce::Max", ntrial, iter);
for (size_t i = 0; i < ndata.size(); ++i) {