inputfile_t Struct Reference

Public Types

enum class  type_t { unknown , all_pot_sizes , default_sizes }
 

Public Member Functions

 inputfile_t (const string &fname)
 

Public Attributes

string filename
 
vector< inputfile_entry_tentries
 
type_t type
 

Member Enumeration Documentation

◆ type_t

enum inputfile_t::type_t
strong
Enumerator
unknown 
all_pot_sizes 
default_sizes 
68 { unknown, all_pot_sizes, default_sizes };

Constructor & Destructor Documentation

◆ inputfile_t()

inputfile_t::inputfile_t ( const string &  fname)
inline
74  : filename(fname), type(type_t::unknown) {
75  ifstream stream(filename);
76  if (!stream.is_open()) {
77  cerr << "couldn't open input file: " << filename << endl;
78  exit(1);
79  }
80  string line;
81  while (getline(stream, line)) {
82  if (line.empty()) continue;
83  if (line.find("BEGIN MEASUREMENTS ALL POT SIZES") == 0) {
84  if (type != type_t::unknown) {
85  cerr << "Input file " << filename << " contains redundant BEGIN MEASUREMENTS lines";
86  exit(1);
87  }
89  continue;
90  }
91  if (line.find("BEGIN MEASUREMENTS DEFAULT SIZES") == 0) {
92  if (type != type_t::unknown) {
93  cerr << "Input file " << filename << " contains redundant BEGIN MEASUREMENTS lines";
94  exit(1);
95  }
97  continue;
98  }
99 
100  if (type == type_t::unknown) {
101  continue;
102  }
103  switch (type) {
104  case type_t::all_pot_sizes: {
105  unsigned int product_size, block_size;
106  float gflops;
107  int sscanf_result = sscanf(line.c_str(), "%x %x %f", &product_size, &block_size, &gflops);
108  if (3 != sscanf_result || !product_size || product_size > 0xfff || !block_size || block_size > 0xfff ||
109  !isfinite(gflops)) {
110  cerr << "ill-formed input file: " << filename << endl;
111  cerr << "offending line:" << endl << line << endl;
112  exit(1);
113  }
114  if (only_cubic_sizes && !size_triple_t(product_size).is_cubic()) {
115  continue;
116  }
117  inputfile_entry_t entry;
118  entry.product_size = uint16_t(product_size);
119  entry.pot_block_size = uint16_t(block_size);
120  entry.gflops = gflops;
121  entries.push_back(entry);
122  break;
123  }
124  case type_t::default_sizes: {
125  unsigned int product_size;
126  float gflops;
127  int bk, bm, bn;
128  int sscanf_result = sscanf(line.c_str(), "%x default(%d, %d, %d) %f", &product_size, &bk, &bm, &bn, &gflops);
129  if (5 != sscanf_result || !product_size || product_size > 0xfff || !isfinite(gflops)) {
130  cerr << "ill-formed input file: " << filename << endl;
131  cerr << "offending line:" << endl << line << endl;
132  exit(1);
133  }
134  if (only_cubic_sizes && !size_triple_t(product_size).is_cubic()) {
135  continue;
136  }
137  inputfile_entry_t entry;
138  entry.product_size = uint16_t(product_size);
139  entry.pot_block_size = 0;
140  entry.nonpot_block_size = size_triple_t(bk, bm, bn);
141  entry.gflops = gflops;
142  entries.push_back(entry);
143  break;
144  }
145 
146  default:
147  break;
148  }
149  }
150  stream.close();
151  if (type == type_t::unknown) {
152  cerr << "Unrecognized input file " << filename << endl;
153  exit(1);
154  }
155  if (entries.empty()) {
156  cerr << "didn't find any measurements in input file: " << filename << endl;
157  exit(1);
158  }
159  }
bool only_cubic_sizes
Definition: analyze-blocking-sizes.cpp:29
#define isfinite(X)
Definition: main.h:111
std::uint16_t uint16_t
Definition: Meta.h:38
line
Definition: calibrate.py:103
Definition: analyze-blocking-sizes.cpp:60
uint16_t product_size
Definition: analyze-blocking-sizes.cpp:61
size_triple_t nonpot_block_size
Definition: analyze-blocking-sizes.cpp:63
uint16_t pot_block_size
Definition: analyze-blocking-sizes.cpp:62
float gflops
Definition: analyze-blocking-sizes.cpp:64
string filename
Definition: analyze-blocking-sizes.cpp:70
type_t type
Definition: analyze-blocking-sizes.cpp:72
vector< inputfile_entry_t > entries
Definition: analyze-blocking-sizes.cpp:71
Definition: analyze-blocking-sizes.cpp:45

References MergeRestartFiles::filename, inputfile_entry_t::gflops, isfinite, calibrate::line, inputfile_entry_t::nonpot_block_size, only_cubic_sizes, inputfile_entry_t::pot_block_size, inputfile_entry_t::product_size, and compute_granudrum_aor::type.

Member Data Documentation

◆ entries

◆ filename

string inputfile_t::filename

◆ type


The documentation for this struct was generated from the following file: