Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max_bb_count to exegesis converter #35

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion gematria/datasets/convert_bhive_to_llvm_exegesis_input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <fstream>
#include <iostream>
#include <limits>
#include <memory>
#include <sstream>
#include <string>
Expand Down Expand Up @@ -44,6 +45,8 @@ ABSL_FLAG(std::string, bhive_csv, "", "Filename of the input BHive CSV file");
ABSL_FLAG(
std::string, output_dir, "",
"Directory containing output files that can be executed by llvm-exegesis");
ABSL_FLAG(unsigned, max_bb_count, std::numeric_limits<unsigned>::max(),
"The maximum number of basic blocks to process");

int main(int argc, char* argv[]) {
absl::ParseCommandLine(argc, argv);
Expand Down Expand Up @@ -102,7 +105,10 @@ int main(int argc, char* argv[]) {
gematria::BHiveImporter bhive_importer(&canonicalizer);

std::ifstream bhive_csv_file(bhive_filename);
const unsigned max_bb_count = absl::GetFlag(FLAGS_max_bb_count);
for (std::string line; std::getline(bhive_csv_file, line);) {
if (file_counter >= max_bb_count) break;

auto comma_index = line.find(',');
if (comma_index == std::string::npos) {
std::cerr << "Invalid CSV file: no comma in line '" << line << "'\n";
Expand Down Expand Up @@ -173,4 +179,4 @@ int main(int argc, char* argv[]) {

file_counter++;
}
}
}
Loading