xgboost_distributed - yanshengli/xgboost GitHub Wiki
关于xgboost的分布式、并行化处理 目前xgboost支持多种并行处理架构,包括流行的hadoop、MPI、本地多进程、多线程等,主要依赖于并行处理框架rabit 其计算模式主要有:AllReduct,BroadCast。
#include <rabit.h>
using namespace rabit;
const int N = 3;
int main(int argc, char *argv[]) {
int a[N];
rabit::Init(argc, argv);
for (int i = 0; i < N; ++i) {
a[i] = rabit::GetRank() + i;
}
printf("@node[%d] before-allreduce: a={%d, %d, %d}\n",
rabit::GetRank(), a[0], a[1], a[2]);
// allreduce take max of each elements in all processes
Allreduce<op::Max>(&a[0], N);
printf("@node[%d] after-allreduce-max: a={%d, %d, %d}\n",
rabit::GetRank(), a[0], a[1], a[2]);
// second allreduce that sums everything up
Allreduce<op::Sum>(&a[0], N);
printf("@node[%d] after-allreduce-sum: a={%d, %d, %d}\n",
rabit::GetRank(), a[0], a[1], a[2]);
rabit::Finalize();
return 0;
}
运行形式如下:../tracker/rabit_demo.py -n 2 basic.rabit,前面是运行本地架构,后面是消息模式