start testing allreduce
This commit is contained in:
@@ -11,19 +11,24 @@ else
|
||||
endif
|
||||
|
||||
# specify tensor path
|
||||
BIN = test_group_data test_quantile test_sock
|
||||
|
||||
BIN = test_group_data test_quantile test_allreduce
|
||||
OBJ = sync_tcp.o
|
||||
.PHONY: clean all
|
||||
|
||||
all: $(BIN) $(MPIBIN)
|
||||
|
||||
sync_tcp.o: ../src/sync/sync_tcp.cpp ../src/utils/*.h
|
||||
|
||||
test_group_data: test_group_data.cpp ../src/utils/*.h
|
||||
test_quantile: test_quantile.cpp ../src/utils/*.h
|
||||
test_sock: test_sock.cpp ../src/utils/*.h
|
||||
test_allreduce: test_allreduce.cpp ../src/utils/*.h ../src/sync/sync.h sync_tcp.o
|
||||
|
||||
$(BIN) :
|
||||
$(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.cpp %.o %.c, $^)
|
||||
|
||||
$(OBJ) :
|
||||
$(CXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c, $^) )
|
||||
|
||||
$(MPIBIN) :
|
||||
$(MPICXX) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.cpp %.o %.c, $^)
|
||||
|
||||
|
||||
22
test/test_allreduce.cpp
Normal file
22
test/test_allreduce.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <sync/sync.h>
|
||||
|
||||
using namespace xgboost;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
sync::Init(argc, argv);
|
||||
int rank = sync::GetRank();
|
||||
std::string name = sync::GetProcessorName().c_str();
|
||||
printf("start %s rank=%d\n", name.c_str(), rank);
|
||||
|
||||
std::vector<float> ndata(16);
|
||||
for (size_t i = 0; i < ndata.size(); ++i) {
|
||||
ndata[i] = i + rank;
|
||||
}
|
||||
sync::AllReduce(&ndata[0], ndata.size(), sync::kMax);
|
||||
sync::Finalize();
|
||||
for (size_t i = 0; i < ndata.size(); ++i) {
|
||||
printf("%lu: %f\n", i, ndata[i]);
|
||||
}
|
||||
printf("all end\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user