1 #ifndef INCLUDE_UTILS_CLUSTER_H_
2 #define INCLUDE_UTILS_CLUSTER_H_
3 #include <glog/logging.h>
8 #include "proto/cluster.pb.h"
9 #include "utils/cluster_rt.h"
11 using std::shared_ptr;
24 static shared_ptr<Cluster> Get();
27 const int nserver_groups()
const{
return cluster_.nserver_groups(); }
28 const int nworker_groups()
const {
return cluster_.nworker_groups(); }
29 int nworkers_per_group()
const {
return cluster_.nworkers_per_group();}
30 int nservers_per_group()
const {
return cluster_.nservers_per_group();}
31 int nworkers_per_procs()
const{
return cluster_.nworkers_per_procs();}
32 int nservers_per_procs()
const{
return cluster_.nservers_per_procs();}
33 int nworker_groups_per_server_group()
const {
34 return cluster_.nworker_groups()/cluster_.nserver_groups();
41 if(server_worker_separate()){
42 CHECK_LT(procs_id_, nprocs());
43 return procs_id_>=nworker_procs();
45 return procs_id_<nserver_procs();
51 if(server_worker_separate()){
52 return procs_id_<nworker_procs();
54 return procs_id_<nprocs();
60 bool server_worker_separate()
const {
61 return cluster_.server_worker_separate();
63 int nworker_procs()
const {
64 return nworker_groups()*nworkers_per_group()/nworkers_per_procs();
66 int nserver_procs()
const {
67 return nserver_groups()*nservers_per_group()/nservers_per_procs();
70 return cluster_.nprocs();
73 const string endpoint()
const {
80 CHECK_LT(procs_id, nprocs());
81 CHECK_GE(procs_id, 0);
82 return endpoints_.at(procs_id);
84 const string workspace() {
return cluster_.workspace();}
85 const string vis_folder(){
86 return cluster_.workspace()+
"/visualization";
88 const string log_folder(){
89 if(cluster_.has_log_dir()){
90 return cluster_.workspace()+
"log";
95 const int stub_timeout()
const {
96 return cluster_.stub_timeout();
98 const int worker_timeout()
const {
99 return cluster_.worker_timeout();
101 const int server_timeout()
const {
102 return cluster_.server_timeout();
122 std::vector<std::string> endpoints_;
125 shared_ptr<ClusterRuntime> cluster_rt_;
127 static shared_ptr<Cluster> instance_;
132 #endif // INCLUDE_UTILS_CLUSTER_H_
bool has_worker() const
Definition: cluster.h:50
Definition: cluster.pb.h:41
shared_ptr< ClusterRuntime > runtime() const
bandwidth MB/s float bandwidth() const { return cluster_.bandwidth(); }
Definition: cluster.h:112
int procs_id() const
Definition: cluster.h:59
Cluster is a singleton object, which provides cluster configuations, e.g., the topology of the cluste...
Definition: cluster.h:22
const string endpoint(int procs_id) const
Definition: cluster.h:79
bool has_server() const
Definition: cluster.h:40