mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Add support for dumping blocking sizes tables
This commit is contained in:
parent
f2c3e2b10f
commit
d73ccd717e
@ -28,6 +28,9 @@ const int default_precision = 4;
|
||||
// see --only-cubic-sizes
|
||||
bool only_cubic_sizes = false;
|
||||
|
||||
// see --dump-tables
|
||||
bool dump_tables = false;
|
||||
|
||||
uint8_t log2_pot(size_t x) {
|
||||
size_t l = 0;
|
||||
while (x >>= 1) l++;
|
||||
@ -318,14 +321,74 @@ float efficiency_of_subset(
|
||||
efficiency_this_product_size = max(efficiency_this_product_size, efficiency_this_entry);
|
||||
}
|
||||
efficiency = min(efficiency, efficiency_this_product_size);
|
||||
first_entry_index_with_this_product_size = entry_index;
|
||||
product_size = first_file.entries[entry_index].product_size;
|
||||
if (entry_index < num_entries) {
|
||||
first_entry_index_with_this_product_size = entry_index;
|
||||
product_size = first_file.entries[entry_index].product_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return efficiency;
|
||||
}
|
||||
|
||||
void dump_table_for_subset(
|
||||
const vector<preprocessed_inputfile_t>& preprocessed_inputfiles,
|
||||
const vector<size_t>& subset)
|
||||
{
|
||||
const preprocessed_inputfile_t& first_file = preprocessed_inputfiles[subset[0]];
|
||||
const size_t num_entries = first_file.entries.size();
|
||||
size_t entry_index = 0;
|
||||
size_t first_entry_index_with_this_product_size = 0;
|
||||
uint16_t product_size = first_file.entries[0].product_size;
|
||||
size_t i = 0;
|
||||
size_triple_t min_product_size(first_file.entries.front().product_size);
|
||||
size_triple_t max_product_size(first_file.entries.back().product_size);
|
||||
if (!min_product_size.is_cubic() || !max_product_size.is_cubic()) {
|
||||
abort();
|
||||
}
|
||||
if (only_cubic_sizes) {
|
||||
cout << "/* Warning: generated with --only-cubic-sizes ! */" << endl;
|
||||
}
|
||||
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[] = {";
|
||||
while (entry_index < num_entries) {
|
||||
++entry_index;
|
||||
if (entry_index == num_entries ||
|
||||
first_file.entries[entry_index].product_size != product_size)
|
||||
{
|
||||
float best_efficiency_this_product_size = 0.0f;
|
||||
uint16_t best_block_size_this_product_size = 0;
|
||||
for (size_t e = first_entry_index_with_this_product_size; e < entry_index; e++) {
|
||||
float efficiency_this_entry = 1.0f;
|
||||
for (auto i = subset.begin(); i != subset.end(); ++i) {
|
||||
efficiency_this_entry = min(efficiency_this_entry, preprocessed_inputfiles[*i].entries[e].efficiency);
|
||||
}
|
||||
if (efficiency_this_entry > best_efficiency_this_product_size) {
|
||||
best_efficiency_this_product_size = efficiency_this_entry;
|
||||
best_block_size_this_product_size = first_file.entries[e].block_size;
|
||||
}
|
||||
}
|
||||
if ((i++) % 8) {
|
||||
cout << ", ";
|
||||
} else {
|
||||
cout << endl << " ";
|
||||
}
|
||||
cout << "0x" << hex << best_block_size_this_product_size << dec;
|
||||
if (entry_index < num_entries) {
|
||||
first_entry_index_with_this_product_size = entry_index;
|
||||
product_size = first_file.entries[entry_index].product_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << endl << " };" << endl;
|
||||
cout << " return data;" << endl;
|
||||
cout << " }" << endl;
|
||||
cout << "};" << endl;
|
||||
}
|
||||
|
||||
float efficiency_of_partition(
|
||||
const vector<preprocessed_inputfile_t>& preprocessed_inputfiles,
|
||||
const vector<vector<size_t>>& partition)
|
||||
@ -507,6 +570,10 @@ void print_partition(
|
||||
for (auto file = subset->begin(); file != subset->end(); ++file) {
|
||||
cout << " " << preprocessed_inputfiles[*file].filename << endl;
|
||||
}
|
||||
if (dump_tables) {
|
||||
cout << " Table:" << endl;
|
||||
dump_table_for_subset(preprocessed_inputfiles, *subset);
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
@ -772,6 +839,10 @@ int main(int argc, char* argv[])
|
||||
only_cubic_sizes = true;
|
||||
arg_handled = true;
|
||||
}
|
||||
if (!strcmp(argv[i], "--dump-tables")) {
|
||||
dump_tables = true;
|
||||
arg_handled = true;
|
||||
}
|
||||
if (!arg_handled) {
|
||||
cerr << "Unrecognized option: " << argv[i] << endl;
|
||||
show_usage_and_exit(argc, argv, available_actions);
|
||||
|
@ -446,7 +446,7 @@ void try_run_some_benchmarks(
|
||||
unsigned int seconds_to_sleep_if_lower_clock_speed = 1;
|
||||
|
||||
while (current_clock_speed < (1 - clock_speed_tolerance) * max_clock_speed) {
|
||||
if (seconds_to_sleep_if_lower_clock_speed > 30) {
|
||||
if (seconds_to_sleep_if_lower_clock_speed > 32) {
|
||||
cerr << "Sleeping longer probably won't make a difference." << endl;
|
||||
cerr << "Serializing benchmarks to " << session_filename << endl;
|
||||
serialize_benchmarks(session_filename, benchmarks, first_benchmark_to_run);
|
||||
@ -456,7 +456,7 @@ void try_run_some_benchmarks(
|
||||
rerun_last_tests = true;
|
||||
cerr << "Sleeping "
|
||||
<< seconds_to_sleep_if_lower_clock_speed
|
||||
<< " s..." << endl;
|
||||
<< " s... \r" << endl;
|
||||
sleep(seconds_to_sleep_if_lower_clock_speed);
|
||||
current_clock_speed = measure_clock_speed();
|
||||
seconds_to_sleep_if_lower_clock_speed *= 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user