diff --git a/toolkit/Makefile b/toolkit/Makefile index fc73737b7..4d96e6bab 100644 --- a/toolkit/Makefile +++ b/toolkit/Makefile @@ -1,7 +1,7 @@ export CC = gcc export CXX = g++ export MPICXX = mpicxx -export LDFLAGS= -pthread -lm +export LDFLAGS= -pthread -lm -L../lib export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fPIC -I../src # specify tensor path @@ -12,31 +12,27 @@ MPIOBJ = engine_mpi.o OBJ = $(RABIT_OBJ) kmeans.o MPIBIN = kmeans.mpi -.PHONY: clean all +.PHONY: clean all lib -all: $(BIN) $(MPIBIN) +all: $(BIN) $(MPIBIN) + +lib: + cd ..;make;cd - -allreduce_base.o: ../src/allreduce_base.cc ../src/*.h -engine.o: ../src/engine.cc ../src/*.h -allreduce_robust.o: ../src/allreduce_robust.cc ../src/*.h -engine_mpi.o: ../src/engine_mpi.cc kmeans.o: kmeans.cpp ../src/*.h # we can link against MPI version to get use MPI -kmeans: kmeans.o $(RABIT_OBJ) -kmeans.mpi: kmeans.o $(MPIOBJ) - +kmeans: kmeans.o lib +kmeans.mpi: kmeans.o lib + $(BIN) : - $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.cpp %.o %.c %.cc, $^) + $(CXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c %.cc, $^) $(LDFLAGS) -lrabit $(OBJ) : $(CXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c %.cc, $^) ) $(MPIBIN) : - $(MPICXX) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.cpp %.o %.c %.cc, $^) - -$(MPIOBJ) : - $(MPICXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c %.cc, $^) ) + $(MPICXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS) -lrabit_mpi clean: $(RM) $(OBJ) $(BIN) $(MPIBIN) *~ ../src/*~ diff --git a/toolkit/kmeans.cpp b/toolkit/kmeans.cpp index c8884417c..24f784923 100644 --- a/toolkit/kmeans.cpp +++ b/toolkit/kmeans.cpp @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) { Model model; int iter = rabit::LoadCheckPoint(&model); if (iter == 0) { - rabit::Allreduce(&data.feat_dim, sizeof(data.feat_dim)); + rabit::Allreduce(&data.feat_dim, 1); model.InitModel(num_cluster, data.feat_dim); InitCentroids(data, &model.centroids); model.Normalize(); @@ -121,7 +121,9 @@ int main(int argc, char *argv[]) { } temp[k][num_feat] += 1.0f; } + // call allreduce rabit::Allreduce(&temp.data[0], temp.data.size()); + // set number for (int k = 0; k < num_cluster; ++k) { float cnt = temp[k][num_feat]; for (unsigned i = 0; i < num_feat; ++i) {