-
Notifications
You must be signed in to change notification settings - Fork 235
Expand file tree
/
Copy pathmain.cc
More file actions
46 lines (43 loc) · 1.33 KB
/
main.cc
File metadata and controls
46 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "ps.h"
#include "app/linear_method/async_sgd.h"
#include "app/linear_method/darlin.h"
#include "app/linear_method/model_evaluation.h"
namespace PS {
App* App::Create(const string& conf_str) {
using namespace LM;
// parse config
Config conf;
CHECK(google::protobuf::TextFormat::ParseFromString(conf_str, &conf))
<< " failed to parse conf: " << conf.ShortDebugString();
// create app
auto my_role = MyNode().role();
App* app = nullptr;
if (conf.has_darlin()) {
if (my_role == Node::SCHEDULER) {
app = new DarlinScheduler(conf);
} else if (my_role == Node::WORKER) {
app = new DarlinWorker(conf);
} else if (my_role == Node::SERVER) {
app = new DarlinServer(conf);
}
} else if (conf.has_async_sgd()) {
typedef float Real;
if (my_role == Node::SCHEDULER) {
app = new AsyncSGDScheduler(conf);
} else if (my_role == Node::WORKER) {
app = new AsyncSGDWorker<Real>(conf);
} else if (my_role == Node::SERVER) {
app = new AsyncSGDServer<Real>(conf);
}
} else if (conf.has_validation_data()) {
app = new ModelEvaluation(conf);
}
CHECK(app) << "fail to create " << conf.ShortDebugString()
<< " at " << MyNode().ShortDebugString();
return app;
}
} // namespace PS
int main(int argc, char *argv[]) {
PS::RunSystem(argc, argv);
return 0;
}