DP3
IDGConfiguration.h
Go to the documentation of this file.
1 // Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy)
2 // SPDX-License-Identifier: GPL-3.0-or-later
3 
4 #ifndef DP3_BASE_IDG_CONFIGURATION_H_
5 #define DP3_BASE_IDG_CONFIGURATION_H_
6 
7 #include <idg-api.h>
8 
9 #include <boost/algorithm/string.hpp>
10 #include <boost/program_options.hpp>
11 
12 #include <fstream>
13 
15  public:
16  static void Read(idg::api::Type& proxyType, int& bufferSize,
17  idg::api::options_type& options) {
18  namespace po = boost::program_options;
19  po::options_description desc("Options");
20  desc.add_options()("proxy", "idg proxy")(
21  "max_nr_w_layers", po::value<int>(), "")("buffersize", po::value<int>(),
22  "");
23 
24  po::variables_map vm;
25  std::ifstream ifs("idg.conf");
26  if (ifs.fail()) {
27  // Logger::Debug << "could not open config file\n";
28  } else {
29  try {
30  po::store(po::parse_config_file(ifs, desc), vm);
31  } catch (po::error&) {
32  }
33  }
34  if (vm.count("proxy")) {
35  std::string proxy(vm["proxy"].as<std::string>());
36  boost::to_lower(proxy);
37  if (proxy == "cpu-optimized") proxyType = idg::api::Type::CPU_OPTIMIZED;
38  if (proxy == "cpu-reference") proxyType = idg::api::Type::CPU_REFERENCE;
39  if (proxy == "cuda-generic") proxyType = idg::api::Type::CUDA_GENERIC;
40  if (proxy == "hybrid-cuda-cpu-optimized")
41  proxyType = idg::api::Type::HYBRID_CUDA_CPU_OPTIMIZED;
42  }
43  if (vm.count("buffersize")) {
44  bufferSize = vm["buffersize"].as<int>();
45  }
46  if (vm.count("max_nr_w_layers")) {
47  options["max_nr_w_layers"] = vm["max_nr_w_layers"].as<int>();
48  }
49  }
50 };
51 
52 #endif
Definition: IDGConfiguration.h:14
static void Read(idg::api::Type &proxyType, int &bufferSize, idg::api::options_type &options)
Definition: IDGConfiguration.h:16