diff --git a/toolkit/Makefile b/toolkit/Makefile index a194ccd08..01a3cd83a 100644 --- a/toolkit/Makefile +++ b/toolkit/Makefile @@ -2,16 +2,16 @@ export CC = gcc export CXX = g++ export MPICXX = mpicxx export LDFLAGS= -pthread -lm -L../lib -export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fPIC -I../include -std=c++11 +export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fPIC -I../include # specify tensor path -BIN = kmeans +BIN = kmeans.rabit # objectives that makes up rabit library OBJ = kmeans.o MPIBIN = kmeans.mpi .PHONY: clean all lib -all: $(BIN) $(MPIBIN) +all: $(BIN) lib: cd ..;make;cd - @@ -19,7 +19,7 @@ lib: kmeans.o: kmeans.cpp ../src/*.h # we can link against MPI version to get use MPI -kmeans: kmeans.o lib +kmeans.rabit: kmeans.o lib kmeans.mpi: kmeans.o lib $(BIN) : diff --git a/toolkit/kmeans.cpp b/toolkit/kmeans.cpp index 11f191625..e6be48fc0 100644 --- a/toolkit/kmeans.cpp +++ b/toolkit/kmeans.cpp @@ -115,7 +115,10 @@ int main(int argc, char *argv[]) { Matrix temp; for (int r = iter; r < max_iter; ++r) { temp.Init(num_cluster, num_feat + 1, 0.0f); - auto lazy_get_centroid = [&]() { +#if __cplusplus >= 201103L + auto lazy_get_centroid = [&]() +#endif + { // lambda function used to calculate the data if necessary // this function may not be called when the result can be directly recovered const size_t ndata = data.NumRow(); @@ -131,7 +134,11 @@ int main(int argc, char *argv[]) { } }; // call allreduce +#if __cplusplus >= 201103L rabit::Allreduce(&temp.data[0], temp.data.size(), lazy_get_centroid); +#else + rabit::Allreduce(&temp.data[0], temp.data.size()); +#endif // set number for (int k = 0; k < num_cluster; ++k) { float cnt = temp[k][num_feat]; diff --git a/toolkit/kmeans_hadoop.sh b/toolkit/kmeans_hadoop.sh index bcd9adb3a..d9a86bddd 100755 --- a/toolkit/kmeans_hadoop.sh +++ b/toolkit/kmeans_hadoop.sh @@ -6,4 +6,4 @@ then fi #set path to hadoop streaming jar here STREAMING_JAR= -python ../rabit_hadoop.py -hs $STREAMING_JAR -s $1 -i $2 -m kmeans --args "stdin "$3" "$4" stdout" -o $5 +python ../rabit_hadoop.py -hs $STREAMING_JAR -s $1 -i $2 -m kmeans.rabit --args "stdin "$3" "$4" stdout" -o $5