16 #include "Teuchos_CommHelpers.hpp"
17 #include "Teuchos_RawParameterListHelpers.hpp"
44 namespace KokkosTuningParams {
68 std::ostringstream oss;
70 const std::string name = oss.str();
76 topValidParamList->set<
Teuchos::ParameterList>(
"kokkos tuning: muelu parameter mapping", validParamList,
"Sublist for Kokkos tuning of MueLu");
78 return topValidParamList;
84 if (
comm_.
is_null())
throw std::runtime_error(
"MueLu::KokkosTuningInterface::Setup(): Communicator cannot be null");
93 namespace KTE = Kokkos::Tools::Experimental;
102 std::ostringstream oss;
104 const std::string name = oss.str();
108 std::string muelu_param = sublist.
get<std::string>(
"muelu parameter");
111 if (sublist.
isType<
int>(
"initial guess")) {
113 int guess = sublist.
get<
int>(
"initial guess");
118 KTE::VariableInfo out_info;
119 out_info.type = KTE::ValueType::kokkos_value_int64;
120 out_info.category = KTE::StatisticalCategory::kokkos_value_interval;
121 out_info.valueQuantity = KTE::CandidateValueType::kokkos_value_range;
125 out_info.candidates = KTE::make_candidate_range((int64_t)range[0], (int64_t)range[1], (int64_t)range[2],
false,
false);
126 size_t var_id = KTE::declare_output_type(muelu_param, out_info);
127 out_variables.push_back(KTE::make_variable_value(var_id, int64_t(guess)));
130 }
else if (sublist.
isType<
double>(
"initial guess")) {
132 double guess = sublist.
get<
double>(
"initial guess");
137 KTE::VariableInfo out_info;
138 out_info.type = KTE::ValueType::kokkos_value_double;
139 out_info.category = KTE::StatisticalCategory::kokkos_value_interval;
140 out_info.valueQuantity = KTE::CandidateValueType::kokkos_value_range;
144 out_info.candidates = KTE::make_candidate_range(range[0], range[1], range[2],
false,
false);
145 size_t var_id = KTE::declare_output_type(muelu_param, out_info);
146 out_variables.push_back(KTE::make_variable_value(var_id, guess));
173 for (
int i = 0; i < (int)inputs.
size(); i++) {
175 KTE::VariableInfo in_info;
176 in_info.type = KTE::ValueType::kokkos_value_string;
177 size_t var_id = KTE::declare_input_type(inputs[i].c_str(), in_info);
178 in_variables.push_back(KTE::make_variable_value(var_id, inputs[i].c_str()));
184 std::vector<std::string> tokens;
187 size_t end = base_string.find(delimiter);
189 while (end != std::string::npos) {
190 tokens.push_back(base_string.substr(start, end - start));
191 start = end + delimiter.length();
192 end = base_string.find(delimiter, start);
196 tokens.push_back(base_string.substr(start, end));
203 namespace KTE = Kokkos::Tools::Experimental;
206 if (
comm_->getRank() == 0) {
231 for (
int i = 0; i < (int)
out_names.size(); i++) {
238 for (
int j = 0; j < (int)treeWalk.size() - 1; j++) {
239 activeList = &(activeList->
sublist(treeWalk[j]));
242 std::string activeName = treeWalk[treeWalk.size() - 1];
254 Teuchos::updateParametersAndBroadcast(outArg(tunedParams), outArg(mueluParams), *
comm_, 0, overwrite);
259 size_t PL_kokkos_context_id = mueluParams.
get<
Teuchos::ParameterList>(
"kokkos tuning: muelu parameter mapping").get<size_t>(
"kokkos context id");
Teuchos::ParameterList params_
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
std::vector< Kokkos::Tools::Experimental::VariableValue > in_variables
std::vector< std::string > out_typenames
T & get(const std::string &name, T def_value)
std::vector< Kokkos::Tools::Experimental::VariableValue > out_variables
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
One-liner description of what is happening.
Teuchos::RCP< const Teuchos::Comm< int > > comm_
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
void UnpackMueLuMapping()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool isSublist(const std::string &name) const
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
void SetMueLuParameters(size_t kokkos_context_id, Teuchos::ParameterList &mueluParams, bool overwrite=true) const
Teuchos::RCP< const Teuchos::ParameterList > GetValidParameterList() const
bool isType(const std::string &name) const
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
KokkosTuningInterface(const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
std::vector< std::string > SplitString(const std::string &base_string, const std::string &delimiter) const
Exception throws to report errors in the internal logical of the program.
Description of what is happening (more verbose)
const int MAX_VALID_PARAMS
std::vector< std::string > out_names