@@ -89,9 +89,6 @@ void KokkosTuningInterface::UnpackMueLuMapping() {
89
89
const Teuchos::ParameterList& pL = params_.get <Teuchos::ParameterList>(" kokkos tuning: muelu parameter mapping" );
90
90
namespace KTE = Kokkos::Tools::Experimental;
91
91
92
- // FIXME: Remove
93
- std::cout<<" *** Params for Kokkos Tuning ***" <<pL<<" ********************************" <<std::endl;
94
-
95
92
/* *******************************/
96
93
/* Process the output variables */
97
94
/* *******************************/
@@ -114,20 +111,16 @@ void KokkosTuningInterface::UnpackMueLuMapping() {
114
111
const Teuchos::Array<int > & range = sublist.get <Teuchos::Array<int > >(" discrete range" );
115
112
TEUCHOS_TEST_FOR_EXCEPTION (range.size () !=3 , Exceptions::RuntimeError, " MueLu::KokkosTuningInterface: 'discrete range' needs to be (low, high, step)" );
116
113
117
- // Copy the range to int64_t because Kokkos
118
- std::vector<int64_t > range64 (range.size ());
119
- for (int j=0 ;j<(int )range.size (); j++)
120
- range64[j] = range[j];
121
- int64_ranges.push_back (range64);
122
-
123
-
124
114
// Set the VariableInfo
125
115
KTE::VariableInfo out_info;
126
- out_info.type = Kokkos::Tools::Experimental::ValueType::kokkos_value_int64;
127
- out_info.category = Kokkos::Tools::Experimental::StatisticalCategory::kokkos_value_ordinal;
128
- out_info.valueQuantity = Kokkos::Tools::Experimental::CandidateValueType::kokkos_value_set;
129
- out_info.candidates = Kokkos::Tools::Experimental::make_candidate_set (3 ,int64_ranges[int64_ranges.size ()-1 ].data ());
130
- size_t var_id = Kokkos::Tools::Experimental::declare_output_type (muelu_param,out_info);
116
+ out_info.type = KTE::ValueType::kokkos_value_int64;
117
+ out_info.category = KTE::StatisticalCategory::kokkos_value_interval;
118
+ out_info.valueQuantity = KTE::CandidateValueType::kokkos_value_range;
119
+
120
+ // Unlike the ordinal lists, the ranges get copied into Kokkos
121
+ // TODO: Add support for open/closed ranges
122
+ out_info.candidates = KTE::make_candidate_range ((int64_t )range[0 ],(int64_t )range[1 ],(int64_t )range[2 ],false ,false );
123
+ size_t var_id = KTE::declare_output_type (muelu_param,out_info);
131
124
out_variables.push_back (KTE::make_variable_value (var_id,int64_t (guess)));
132
125
133
126
out_typenames.push_back (" int" );
@@ -138,32 +131,23 @@ void KokkosTuningInterface::UnpackMueLuMapping() {
138
131
const Teuchos::Array<double > & range = sublist.get <Teuchos::Array<double > >(" continuous range" );
139
132
TEUCHOS_TEST_FOR_EXCEPTION (range.size () !=3 , Exceptions::RuntimeError, " MueLu::KokkosTuningInterface: 'continuous range' needs to be (low, high, step)" );
140
133
141
-
142
- // Copy the range because Kokkos
143
- std::vector<double > rangeD (range.size ());
144
- for (int j=0 ;j<(int )range.size (); j++)
145
- rangeD[j] = range[j];
146
- double_ranges.push_back (rangeD);
147
-
148
-
149
134
// Set the VariableInfo
150
135
KTE::VariableInfo out_info;
151
- out_info.type = Kokkos::Tools::Experimental::ValueType::kokkos_value_double;
152
- out_info.category = Kokkos::Tools::Experimental::StatisticalCategory::kokkos_value_ordinal;
153
- out_info.valueQuantity = Kokkos::Tools::Experimental::CandidateValueType::kokkos_value_set;
154
- // FIXME: This is a memory error waiting to happen
155
- out_info.candidates = Kokkos::Tools::Experimental::make_candidate_set (3 ,double_ranges[double_ranges.size ()-1 ].data ());
156
- size_t var_id = Kokkos::Tools::Experimental::declare_output_type (muelu_param,out_info);
136
+ out_info.type = KTE::ValueType::kokkos_value_double;
137
+ out_info.category = KTE::StatisticalCategory::kokkos_value_interval;
138
+ out_info.valueQuantity = KTE::CandidateValueType::kokkos_value_range;
139
+
140
+ // Unlike the ordinal lists, the ranges get copied into Kokkos
141
+ // TODO: Add support for open/closed ranges
142
+ out_info.candidates = KTE::make_candidate_range (range[0 ],range[1 ],range[2 ],false ,false );
143
+ size_t var_id = KTE::declare_output_type (muelu_param,out_info);
157
144
out_variables.push_back (KTE::make_variable_value (var_id,guess));
158
145
159
146
out_typenames.push_back (" double" );
160
147
}
161
- /* else if(sublist.isType<std::string>("initial guess")) {
162
- // Categorical
163
-
164
- }*/
148
+ // TODO: Add support for categorical and set parameters
165
149
else {
166
- TEUCHOS_TEST_FOR_EXCEPTION (true , Exceptions::RuntimeError, " MueLu::KokkosTuningInterface: Only handles int and double parameters " );
150
+ TEUCHOS_TEST_FOR_EXCEPTION (true , Exceptions::RuntimeError, " MueLu::KokkosTuningInterface: We currently only handle int and double ranges. " );
167
151
}
168
152
169
153
// Stash the parameter name
@@ -183,8 +167,13 @@ void KokkosTuningInterface::UnpackMueLuMapping() {
183
167
in_variables.clear ();
184
168
185
169
const Teuchos::Array<std::string> & inputs = pL.get <Teuchos::Array<std::string> >(" input variables" );
170
+
186
171
for (int i=0 ; i< (int )inputs.size (); i++) {
187
- in_variables.push_back (KTE::make_variable_value (i,inputs[i].c_str ()));
172
+ // NOTE: The string name is copied in here (unlike double/int) so we don't need to cache.
173
+ KTE::VariableInfo in_info;
174
+ in_info.type = KTE::ValueType::kokkos_value_string;
175
+ size_t var_id = KTE::declare_input_type (inputs[i].c_str (),in_info);
176
+ in_variables.push_back (KTE::make_variable_value (var_id,inputs[i].c_str ()));
188
177
}
189
178
190
179
@@ -219,6 +208,12 @@ void KokkosTuningInterface::SetMueLuParameters(size_t kokkos_context_id, Teuchos
219
208
// Only Rank 0 calls KokkosTuning
220
209
GetOStream (Runtime0) << " MueLu::KokkosTuningInterface: Tuning " << out_variables.size () << " parameters" <<std::endl;
221
210
211
+ // Set input variable
212
+ if (IsPrint (Runtime1))
213
+ GetOStream (Runtime1) <<" Adding " <<in_variables.size ()<<" input variables" <<std::endl;
214
+
215
+ KTE::set_input_values (kokkos_context_id, in_variables.size (), in_variables.data ());
216
+
222
217
// Start the tuning
223
218
KTE::request_output_values (kokkos_context_id, out_variables.size (), out_variables.data ());
224
219
@@ -241,8 +236,6 @@ void KokkosTuningInterface::SetMueLuParameters(size_t kokkos_context_id, Teuchos
241
236
Teuchos::ParameterList *activeList = &tunedParams;
242
237
std::vector<std::string> treeWalk = SplitString (out_names[i]," ||" );
243
238
244
- for (int j=0 ; j<(int ) treeWalk.size (); j++)
245
-
246
239
// Walk down all but the last guy
247
240
for (int j=0 ;j<(int ) treeWalk.size ()-1 ; j++) {
248
241
activeList = &(activeList->sublist (treeWalk[j]));
@@ -259,14 +252,8 @@ void KokkosTuningInterface::SetMueLuParameters(size_t kokkos_context_id, Teuchos
259
252
}
260
253
}
261
254
}
262
- #if 0
263
- std::cout<<"*** FINAL TUNED PARAMS ***"<<std::endl;
264
- std::cout<<tunedParams<<std::endl;
265
- std::cout<<"*************************"<<std::endl;
266
- #endif
267
255
268
256
Teuchos::updateParametersAndBroadcast (outArg (tunedParams), outArg (mueluParams), *comm_, 0 , overwrite);
269
-
270
257
}
271
258
272
259
0 commit comments