diff --git a/src/common/Executor.cpp b/src/common/Executor.cpp index e54bc9214..e62307e04 100644 --- a/src/common/Executor.cpp +++ b/src/common/Executor.cpp @@ -612,40 +612,94 @@ 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(); + const Svector& excluded_tuning_names = run_params.getExcludeTuningInput(); + // Constuct set of all possible tunings + set all_tunings; for (VariantID vid : variant_ids) { - std::unordered_map 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()); - } + all_tunings.insert(tuning_name); } } - 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; + } + // Check for invalid tuning input + Svector invalid; + for (string const& tuning_name: selected_tuning_names) { + if (all_tunings.find(tuning_name) == all_tunings.end()) { + invalid.push_back(tuning_name); } - // reorder to put "default" first - auto default_order_iter = tuning_names_order_map.find(KernelBase::getDefaultTuningName()); - if (default_order_iter != tuning_names_order_map.end()) { - size_t default_idx = default_order_iter->second; - std::string default_name = std::move(tuning_names[vid][default_idx]); - tuning_names[vid].erase(tuning_names[vid].begin()+default_idx); - tuning_names[vid].emplace(tuning_names[vid].begin(), std::move(default_name)); + } + run_params.setInvalidTuningInput(invalid); + // Check for invalid exclude tuning input + invalid.clear(); + for (string const& tuning_name: excluded_tuning_names) { + if (all_tunings.find(tuning_name) == all_tunings.end()) { + invalid.push_back(tuning_name); } } - - // - // If we've gotten to this point, we have good input to run. - // - if ( run_params.getInputState() != RunParams::DryRun && - run_params.getInputState() != RunParams::CheckRun ) { - run_params.setInputState(RunParams::PerfRun); + run_params.setInvalidExcludeTuningInput(invalid); + // Validate invalid input + if ( !(run_params.getInvalidTuningInput().empty()) || + !(run_params.getInvalidExcludeTuningInput().empty())) { + run_params.setInputState(RunParams::BadInput); } + if (run_params.getInputState() != RunParams::BadInput) { // If tunings input is valid + for (VariantID vid : variant_ids) { + std::unordered_map 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()) { + if ((selected_tuning_names.empty() || find(selected_tuning_names.begin(), selected_tuning_names.end(), tuning_name) != selected_tuning_names.end()) // If argument is not provided or name is selected + && + find(excluded_tuning_names.begin(), excluded_tuning_names.end(), tuning_name) == excluded_tuning_names.end()) { // name does not exist in exclusion list + tuning_names_order_map.emplace( + tuning_name, tuning_names_order_map.size()); // Add tuning name to map + } + } + } + } + + 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; + } + // reorder to put "default" first + auto default_order_iter = tuning_names_order_map.find(KernelBase::getDefaultTuningName()); + if (default_order_iter != tuning_names_order_map.end()) { + size_t default_idx = default_order_iter->second; + std::string default_name = std::move(tuning_names[vid][default_idx]); + tuning_names[vid].erase(tuning_names[vid].begin()+default_idx); + tuning_names[vid].emplace(tuning_names[vid].begin(), std::move(default_name)); + } + } + + // Add tunings to Adiak metadata + #if defined(RAJA_PERFSUITE_USE_CALIPER) + std::set tunings_set; + for (VariantID vid : variant_ids) { + for (std::string const& tuning_name : tuning_names[vid]) { + tunings_set.emplace(tuning_name); + } + } + adiak::value("tunings", tunings_set); + #endif + + // + // If we've gotten to this point, we have good input to run. + // + if ( run_params.getInputState() != RunParams::DryRun && + run_params.getInputState() != RunParams::CheckRun ) { + run_params.setInputState(RunParams::PerfRun); + } + + } // tuning input looks good + } // kernel and variant input both look good } // if kernel input looks good @@ -919,22 +973,26 @@ void Executor::runKernel(KernelBase* kernel, bool print_kernel_name) if ( run_params.showProgress() ) { if ( kernel->hasVariantDefined(vid) ) { - getCout() << " Running "; + getCout() << "\tRunning "; } else { - getCout() << " No "; + getCout() << "\tNo "; } getCout() << getVariantName(vid) << " variant" << endl; } for (size_t tune_idx = 0; tune_idx < kernel->getNumVariantTunings(vid); ++tune_idx) { - - if ( run_params.showProgress() ) { - getCout() << " Running " - << kernel->getVariantTuningName(vid, tune_idx) << " tuning"; + std::string const& tuning_name = kernel->getVariantTuningName(vid, tune_idx); + if (find(tuning_names[vid].begin(), tuning_names[vid].end(), tuning_name) != tuning_names[vid].end()) { // Check if valid tuning + if ( run_params.showProgress() ) { + getCout() << "\t\tRunning " << tuning_name << " tuning"; + } + kernel->execute(vid, tune_idx); // Execute kernel + if ( run_params.showProgress() ) { + getCout() << " -- " << kernel->getLastTime() << " sec." << endl; + } } - kernel->execute(vid, tune_idx); - if ( run_params.showProgress() ) { - getCout() << " -- " << kernel->getLastTime() << " sec." << endl; + else { + getCout() << "\t\tSkipping " << tuning_name << " tuning" << endl; } } } // loop over variants diff --git a/src/common/RunParams.cpp b/src/common/RunParams.cpp index e85ee5c86..df30b5c38 100644 --- a/src/common/RunParams.cpp +++ b/src/common/RunParams.cpp @@ -47,6 +47,10 @@ RunParams::RunParams(int argc, char** argv) invalid_variant_input(), exclude_variant_input(), invalid_exclude_variant_input(), + tuning_input(), + invalid_tuning_input(), + exclude_tuning_input(), + invalid_exclude_tuning_input(), feature_input(), invalid_feature_input(), exclude_feature_input(), @@ -156,6 +160,24 @@ 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 exclude_tuning_input = "; + for (size_t j = 0; j < exclude_tuning_input.size(); ++j) { + str << "\n\t" << exclude_tuning_input[j]; + } + str << "\n invalid_exclude_tuning_input = "; + for (size_t j = 0; j < invalid_exclude_tuning_input.size(); ++j) { + str << "\n\t" << invalid_exclude_tuning_input[j]; + } + str << "\n feature_input = "; for (size_t j = 0; j < feature_input.size(); ++j) { str << "\n\t" << feature_input[j]; @@ -534,6 +556,37 @@ void RunParams::parseCommandLineOptions(int argc, char** argv) } } } + } else if ( std::string(argv[i]) == std::string("--tunings") || + std::string(argv[i]) == std::string("-t") ) { + + 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("--exclude-tunings") || + std::string(argv[i]) == std::string("-et") ) { + + bool done = false; + i++; + while ( i < argc && !done ) { + opt = std::string(argv[i]); + if ( opt.at(0) == '-' ) { + i--; + done = true; + } else { + exclude_tuning_input.push_back(opt); + ++i; + } + } } else if ( std::string(argv[i]) == std::string("--features") || std::string(argv[i]) == std::string("-f") ) { @@ -751,6 +804,21 @@ void RunParams::printHelpMessage(std::ostream& str) const << "\t\t --exclude-variants RAJA_CUDA (exclude all RAJA_CUDA kernel variants)\n" << "\t\t -ev Base_Seq RAJA_CUDA (exclude Base_Seq and RAJA_CUDA variants)\n\n"; + str << "\t --tunings, -t [Default is run all]\n" + << "\t (names of tunings to run)\n" + << "\t Note: knowing which tunings are available requires knowledge about the variants,\n" + << "\t since available tunings depend on the given variant (and potentially other args).\n"; + str << "\t\t Examples...\n" + << "\t\t --tunings default (run all default tunings)\n" + << "\t\t -t default block_128 (run default and block_128 tunings)\n\n"; + + str << "\t --exclude-tunings, -et [Default is exclude none]\n" + << "\t (names of tunings to exclude)\n" + << "\t See --tunings for more information.\n"; + str << "\t\t Examples...\n" + << "\t\t --exclude-tunings library (exclude all library tunings)\n" + << "\t\t -et default library (exclude default and library tunings)\n\n"; + str << "\t --seq-data-space, -sds [Default is Host]\n" << "\t (names of data space to use)\n"; str << "\t\t Examples...\n" diff --git a/src/common/RunParams.hpp b/src/common/RunParams.hpp index 2c81a4f70..3a8119c44 100644 --- a/src/common/RunParams.hpp +++ b/src/common/RunParams.hpp @@ -179,6 +179,20 @@ class RunParams { const std::vector& getInvalidExcludeVariantInput() const { return invalid_exclude_variant_input; } + const std::vector& getTuningInput() const + { return tuning_input; } + void setInvalidTuningInput( std::vector& svec ) + { invalid_tuning_input = svec; } + const std::vector& getInvalidTuningInput() const + { return invalid_tuning_input; } + + const std::vector& getExcludeTuningInput() const + { return exclude_tuning_input; } + void setInvalidExcludeTuningInput( std::vector& svec ) + { invalid_exclude_tuning_input = svec; } + const std::vector& getInvalidExcludeTuningInput() const + { return invalid_exclude_tuning_input; } + const std::vector& getFeatureInput() const { return feature_input; } void setInvalidFeatureInput( std::vector& svec ) @@ -274,6 +288,10 @@ class RunParams { std::vector invalid_variant_input; std::vector exclude_variant_input; std::vector invalid_exclude_variant_input; + std::vector tuning_input; + std::vector invalid_tuning_input; + std::vector exclude_tuning_input; + std::vector invalid_exclude_tuning_input; std::vector feature_input; std::vector invalid_feature_input; std::vector exclude_feature_input;