aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/analyze-blocking-sizes.cpp
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <benoitjacob@google.com>2015-03-15 18:05:53 -0400
committerGravatar Benoit Jacob <benoitjacob@google.com>2015-03-15 18:05:53 -0400
commitca5c12587b6e51be7f401c2878800d5d49f615d8 (patch)
treeaa5eb4cdf55f2163a4e94c6d3a9d66d26f7c6036 /bench/analyze-blocking-sizes.cpp
parente56aabf205a1e8f581dd8a46d7d46ce79c45e158 (diff)
Polish lookup tables generation
Diffstat (limited to 'bench/analyze-blocking-sizes.cpp')
-rw-r--r--bench/analyze-blocking-sizes.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/bench/analyze-blocking-sizes.cpp b/bench/analyze-blocking-sizes.cpp
index c133df599..3d57f4bb3 100644
--- a/bench/analyze-blocking-sizes.cpp
+++ b/bench/analyze-blocking-sizes.cpp
@@ -347,13 +347,16 @@ void dump_table_for_subset(
abort();
}
if (only_cubic_sizes) {
- cout << "/* Warning: generated with --only-cubic-sizes ! */" << endl;
+ cerr << "Can't generate tables with --only-cubic-sizes." << endl;
+ abort();
}
- cout << "struct optimal_block_sizes_table {" << endl;
- cout << " static const size_t min_size = " << min_product_size.k << ";" << endl;
- cout << " static const size_t max_size = " << max_product_size.k << ";" << endl;
- cout << " static const uint16_t* table() {" << endl;
- cout << " static const uint16_t data[] = {";
+ cout << "struct LookupTable {" << endl;
+ cout << " static const size_t BaseSize = " << min_product_size.k << ";" << endl;
+ const size_t NumSizes = log2_pot(max_product_size.k / min_product_size.k) + 1;
+ const size_t TableSize = NumSizes * NumSizes * NumSizes;
+ cout << " static const size_t NumSizes = " << NumSizes << ";" << endl;
+ cout << " static const uint16_t* Data() {" << endl;
+ cout << " static const uint16_t data[" << TableSize << "] = {";
while (entry_index < num_entries) {
++entry_index;
if (entry_index == num_entries ||
@@ -371,18 +374,23 @@ void dump_table_for_subset(
best_block_size_this_product_size = first_file.entries[e].block_size;
}
}
- if ((i++) % 8) {
- cout << ", ";
+ if ((i++) % NumSizes) {
+ cout << " ";
} else {
cout << endl << " ";
}
cout << "0x" << hex << best_block_size_this_product_size << dec;
if (entry_index < num_entries) {
+ cout << ",";
first_entry_index_with_this_product_size = entry_index;
product_size = first_file.entries[entry_index].product_size;
}
}
}
+ if (i != TableSize) {
+ cerr << endl << "Wrote " << i << " table entries, expected " << TableSize << endl;
+ abort();
+ }
cout << endl << " };" << endl;
cout << " return data;" << endl;
cout << " }" << endl;
@@ -855,6 +863,11 @@ int main(int argc, char* argv[])
input_filenames.emplace_back(argv[i]);
}
+ if (dump_tables && only_cubic_sizes) {
+ cerr << "Incompatible options: --only-cubic-sizes and --dump-tables." << endl;
+ show_usage_and_exit(argc, argv, available_actions);
+ }
+
if (!action) {
show_usage_and_exit(argc, argv, available_actions);
}