-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogramoptions.hpp
70 lines (61 loc) · 2.38 KB
/
programoptions.hpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include <iostream>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include "common.hpp"
namespace mp {
struct Options
{
ParticipantType participant;
CommunicatorType commType;
PublishingType pubType;
boost::filesystem::path publishDirectory;
double peers;
double rounds;
bool debug;
std::string runName;
bool split;
explicit Options(boost::program_options::variables_map opt) {
participant = opt["participant"].as<std::string>() == "A" ? A : B;
peers = opt["peers"].as<double>();
publishDirectory = boost::filesystem::path(opt["publishDirectory"].as<std::string>());
commType = opt["commType"].as<std::string>() == "single" ? single : many;
pubType = opt["publishingType"].as<std::string>() == "file" ? file : server;
rounds = opt["rounds"].as<double>();
debug = opt["debug"].as<bool>();
runName = opt["runName"].as<std::string>();
split = opt["split"].as<bool>();
}
};
Options getOptions(int argc, char *argv[])
{
namespace po = boost::program_options;
po::options_description desc("mpiports: Benchmal MPI perfomance");
desc.add_options()
("help,h", "produce help")
("participant,p", po::value<std::string>()->required(), "Participant Name, A or B")
("peers", po::value<double>()->default_value(4), "Peers to connect, if value < 1 it is interpreted as a ratio, if > 1, it is an absolute number")
("publishDirectory,d", po::value<std::string>()->default_value("./publish"), "Directory to publish connection information to")
("commType,c", po::value<std::string>()->required(), "Intercom type: 'single' or 'many'")
("publishingType,m", po::value<std::string>()->default_value("file"), "Publishing type: 'file' or 'server'")
("rounds,r", po::value<double>()->default_value(1), "Number of data exchange rounds")
("debug", po::bool_switch(), "Enable debug output")
("runName", po::value<std::string>()->default_value(""), "runName, forward to EventTimings")
("split", po::bool_switch(), "Use MPI_Comm_split");
po::variables_map vm;
try {
po::store(parse_command_line(argc, argv, desc), vm);
if (vm.count("help")) {
std::cout << desc << std::endl << std::endl;
std::exit(-1);
}
po::notify(vm);
}
catch(po::error& e) {
std::cout << "ERROR: " << e.what() << "\n\n";
std::cout << desc << std::endl;
std::exit(-1);
}
return Options(vm);
}
}