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 "tunings" Command Line Option #333

Closed
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions src/common/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,18 +612,29 @@ void Executor::setupSuite()
//
// Make a single ordering of tuning names for each variant across kernels.
//

// Determine which tunings to execute from input.
const Svector& selected_tuning_names = run_params.getTuningInput();
for (VariantID vid : variant_ids) {
std::unordered_map<std::string, size_t> tuning_names_order_map;
for (const KernelBase* kernel : kernels) {
for (std::string const& tuning_name :
kernel->getVariantTuningNames(vid)) {
if (tuning_names_order_map.find(tuning_name) ==
tuning_names_order_map.end()) {
tuning_names_order_map.emplace(
tuning_name, tuning_names_order_map.size());
if (selected_tuning_names.size() == 0 || find(selected_tuning_names.begin(), selected_tuning_names.end(), tuning_name) != selected_tuning_names.end()) {
michaelmckinsey1 marked this conversation as resolved.
Show resolved Hide resolved
tuning_names_order_map.emplace(
tuning_name, tuning_names_order_map.size());
}
}
}
}
// Add tunings to metadata
std::vector<std::string> final_tunings;
for (const auto &key: tuning_names_order_map) {
final_tunings.push_back(key.first);
}
adiak::value("tunings", final_tunings);
tuning_names[vid].resize(tuning_names_order_map.size());
for (auto const& tuning_name_idx_pair : tuning_names_order_map) {
tuning_names[vid][tuning_name_idx_pair.second] = tuning_name_idx_pair.first;
Expand Down
7 changes: 6 additions & 1 deletion src/common/KernelBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ class KernelBase

void setVariantDefined(VariantID vid);
void addVariantTuningName(VariantID vid, std::string name)
{ variant_tuning_names[vid].emplace_back(std::move(name)); }
{ // Sub-select tuning from command line argument
const std::vector<std::string>& selected_tuning_names = run_params.getTuningInput();
if (selected_tuning_names.size() == 0 || std::find(selected_tuning_names.begin(), selected_tuning_names.end(), name) != selected_tuning_names.end()) {
variant_tuning_names[vid].emplace_back(std::move(name));
}
}
michaelmckinsey1 marked this conversation as resolved.
Show resolved Hide resolved

virtual void setSeqTuningDefinitions(VariantID vid)
{ addVariantTuningName(vid, getDefaultTuningName()); }
Expand Down
26 changes: 26 additions & 0 deletions src/common/RunParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ RunParams::RunParams(int argc, char** argv)
invalid_variant_input(),
exclude_variant_input(),
invalid_exclude_variant_input(),
tuning_input(),
invalid_tuning_input(),
feature_input(),
invalid_feature_input(),
exclude_feature_input(),
Expand Down Expand Up @@ -156,6 +158,15 @@ void RunParams::print(std::ostream& str) const
str << "\n\t" << invalid_exclude_variant_input[j];
}

str << "\n tuning_input = ";
for (size_t j = 0; j < tuning_input.size(); ++j) {
str << "\n\t" << tuning_input[j];
}
str << "\n invalid_tuning_input = ";
for (size_t j = 0; j < invalid_tuning_input.size(); ++j) {
str << "\n\t" << invalid_tuning_input[j];
}

str << "\n feature_input = ";
for (size_t j = 0; j < feature_input.size(); ++j) {
str << "\n\t" << feature_input[j];
Expand Down Expand Up @@ -534,6 +545,21 @@ void RunParams::parseCommandLineOptions(int argc, char** argv)
}
}
}
} else if ( std::string(argv[i]) == std::string("--tunings") ||
std::string(argv[i]) == std::string("-t") ) {
michaelmckinsey1 marked this conversation as resolved.
Show resolved Hide resolved

bool done = false;
i++;
while ( i < argc && !done ) {
opt = std::string(argv[i]);
if ( opt.at(0) == '-' ) {
i--;
done = true;
} else {
tuning_input.push_back(opt);
++i;
}
}

} else if ( std::string(argv[i]) == std::string("--features") ||
std::string(argv[i]) == std::string("-f") ) {
Expand Down
9 changes: 9 additions & 0 deletions src/common/RunParams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ class RunParams {
const std::vector<std::string>& getInvalidExcludeVariantInput() const
{ return invalid_exclude_variant_input; }

const std::vector<std::string>& getTuningInput() const
{ return tuning_input; }
void setInvalidTuningInput( std::vector<std::string>& svec )
{ invalid_tuning_input = svec; }
const std::vector<std::string>& getInvalidTuningInput() const
{ return invalid_tuning_input; }

const std::vector<std::string>& getFeatureInput() const
{ return feature_input; }
void setInvalidFeatureInput( std::vector<std::string>& svec )
Expand Down Expand Up @@ -274,6 +281,8 @@ class RunParams {
std::vector<std::string> invalid_variant_input;
std::vector<std::string> exclude_variant_input;
std::vector<std::string> invalid_exclude_variant_input;
std::vector<std::string> tuning_input;
std::vector<std::string> invalid_tuning_input;
std::vector<std::string> feature_input;
std::vector<std::string> invalid_feature_input;
std::vector<std::string> exclude_feature_input;
Expand Down