DASH  0.3.0
BenchmarkParams.h
1 #ifndef DASH__UTIL__BENCHMARK_PARAMS_H__
2 #define DASH__UTIL__BENCHMARK_PARAMS_H__
3 
4 #include <dash/util/Locality.h>
5 #include <dash/Team.h>
6 
7 #include <iostream>
8 #include <sstream>
9 #include <iomanip>
10 #include <vector>
11 #include <string>
12 
13 
14 namespace dash {
15 namespace util {
16 
18  std::string flag;
19  std::string description;
20  std::string value_type;
21  bool required;
22 };
23 
25 {
26 public:
27  typedef std::vector< std::pair< std::string, std::string > >
28  env_flags_type;
29 
30  typedef struct dash_config_params_t {
31  env_flags_type env_mpi_config;
32  env_flags_type env_dash_config;
33  env_flags_type env_dart_config;
34  bool env_mpi_shared_win;
35  bool env_papi;
36  bool env_hwloc;
37  bool env_numalib;
38  bool env_mkl;
39  bool env_blas;
40  bool env_lapack;
41  bool env_scalapack;
42  bool env_plasma;
44 
45 public:
46  BenchmarkParams(const std::string & benchmark_name);
47 
48  inline void set_output_width(int width)
49  {
50  _header_width = width;
51  }
52 
53  void parse_args(int argc, char * argv[]);
54 
55  const config_params_type & config() const {
56  return _config;
57  }
58 
59  int output_width() const {
60  return _header_width;
61  }
62 
63  void print_header();
64 
65  void print_pinning();
66 
67  void print_section_start(const std::string & section_name) const;
68  void print_section_end() const;
69 
70  void print(
71  std::stringstream & lines,
72  const std::string& prefix = "") const
73  {
74  std::ostringstream oss;
75  std::string line;
76  while(std::getline(lines, line)) {
77  oss << "-- " << prefix << " " << line << '\n';
78  }
79  std::cout << oss.str();
80  }
81 
82  template <typename T>
83  void print_param(
84  const std::string & name,
85  T value) const
86  {
87  if (dash::Team::GlobalUnitID() != 0) {
88  return;
89  }
90  int value_w = _header_width - 6 - name.length();
91  std::ostringstream oss;
92  oss << "-- "
93  << std::left << name << " "
94  << std::right << std::setw(value_w) << value
95  << '\n';
96  std::cout << oss.str();
97  }
98 
99  template <typename T>
100  void print_param(
101  const std::string & flag,
102  const std::string & description,
103  T value) const
104  {
105  if (dash::Team::GlobalUnitID() != 0) {
106  return;
107  }
108  int flag_w = 7;
109  int value_w = 10;
110  int desc_w = _header_width - value_w - flag_w - 6;
111  std::ostringstream oss;
112  oss << "-- "
113  << std::left << std::setw(flag_w) << flag << " "
114  << std::right << std::setw(value_w) << value
115  << std::right << std::setw(desc_w) << description
116  << '\n';
117  std::cout << oss.str();
118  }
119 
120 private:
121  global_unit_t _myid;
122  int _header_width = 82;
123  config_params_type _config;
124  std::string _name;
125 };
126 
127 } // namespae util
128 } // namespace dash
129 
130 #endif // DASH__UTIL__BENCHMARK_PARAMS_H__
This class is a simple memory pool which holds allocates elements of size ValueType.
Definition: AllOf.h:8
struct dash::unit_id< dash::global_unit, dart_global_unit_t > global_unit_t
Unit ID to use for global IDs.
Definition: Types.h:332
static global_unit_t GlobalUnitID()
The invariant unit ID in dash::Team::All().
Definition: Team.h:221