-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaults.cc
98 lines (79 loc) · 1.77 KB
/
defaults.cc
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
#include <boost/program_options.hpp>
#include "defaults.hh"
#include "laplace.hh"
defaults::defaults(void)
: verbosity(false)
, synch_ops(false)
, dtype(cl::device::CPU)
{
}
/* copy constructor defaults::defaults(const defaults &) intentionally not
* defined
*/
defaults::~defaults(void)
{
}
/* assignment operator defaults::operator=(const defaults &) intentionally not
* defined.
*/
bool defaults::verbose(void) const
{
return verbosity;
}
bool defaults::synch(void) const
{
return synch_ops;
}
cl::device::type defaults::dev_type(void) const
{
return dtype;
}
defaults::area defaults::lattice_size(void) const
{
area ret;
ret.dim[0] = 224;
ret.dim[1] = 224;
return ret;
}
defaults::area defaults::local_size(void) const
{
area ret;
ret.dim[0] = 16;
ret.dim[1] = 16;
return ret;
}
defaults &defaults::get(void)
{
static defaults defs;
return defs;
}
void defaults::process_arguments(int argc, char **argv)
{
namespace po = boost::program_options;
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message")
("verbose,v", "enable verbose output")
("synch", "enable synchronous operations")
("device,d", po::value<cl::device::type>(&get().dtype),
"select device type (CPU, GPU)")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if(vm.count("help")) {
std::cerr << desc << std::endl;
throw help_activated();
}
if(vm.count("verbose")) {
std::cerr << "Enabling verbose output." << std::endl;
get().verbosity = true;
}
if(vm.count("synch")) {
if(get().verbosity) {
std::cerr << "Enabling synchronous operation." << std::endl;
}
get().synch_ops = true;
}
}