main.cpp 954 Bytes
Newer Older
1
2
3
4
/*!
 * Copyright (c) 2016 Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See LICENSE file in the project root for license information.
 */
5
#include <LightGBM/application.h>
Guolin Ke's avatar
Guolin Ke committed
6

7
#include <iostream>
8
#include <string>
9

10
11
12
#ifdef USE_MPI
  #include "network/linkers.h"
#endif
13

Guolin Ke's avatar
Guolin Ke committed
14
int main(int argc, char** argv) {
15
  bool success = false;
16
17
18
  try {
    LightGBM::Application app(argc, argv);
    app.Run();
19
20
21
22
23
24

#ifdef USE_MPI
    LightGBM::Linkers::MpiFinalizeIfIsParallel();
#endif

    success = true;
25
26
27
28
29
30
31
32
33
34
35
  }
  catch (const std::exception& ex) {
    std::cerr << "Met Exceptions:" << std::endl;
    std::cerr << ex.what() << std::endl;
  }
  catch (const std::string& ex) {
    std::cerr << "Met Exceptions:" << std::endl;
    std::cerr << ex << std::endl;
  }
  catch (...) {
    std::cerr << "Unknown Exceptions" << std::endl;
36
37
38
39
40
41
42
  }

  if (!success) {
#ifdef USE_MPI
    LightGBM::Linkers::MpiAbortIfIsParallel();
#endif

43
44
    exit(-1);
  }
45
}