43 #ifndef DOMI_UTILS_HPP
44 #define DOMI_UTILS_HPP
47 #include "Domi_ConfigDefs.hpp"
50 #include "Teuchos_Array.hpp"
51 #include "Teuchos_ArrayView.hpp"
52 #include "Teuchos_ParameterList.hpp"
76 typedef Teuchos::Ordinal size_type;
90 typedef Ordinal dim_type;
95 typedef Ordinal difference_type;
103 typedef Teuchos::Tuple< int, 2 > padding_type;
125 LAST_INDEX_FASTEST = 0,
127 FIRST_INDEX_FASTEST = 1,
173 template<
class SIZE_TYPE,
class DIM_TYPE >
174 Teuchos::Array< SIZE_TYPE >
175 computeStrides(
const Teuchos::Array< DIM_TYPE > & dimensions,
178 int n = dimensions.size();
179 Teuchos::Array< SIZE_TYPE > strides(n);
180 if (n == 0)
return strides;
182 if (layout == FIRST_INDEX_FASTEST)
185 for (
int axis = 1; axis < n; ++axis)
186 strides[axis] = strides[axis-1] * dimensions[axis-1];
191 for (
int axis = n-2; axis >= 0; --axis)
192 strides[axis] = strides[axis+1] * dimensions[axis+1];
207 template<
class SIZE_TYPE,
class DIM_TYPE >
208 Teuchos::Array< SIZE_TYPE >
209 computeStrides(
const Teuchos::ArrayView< DIM_TYPE > & dimensions,
219 Teuchos::Array< DIM_TYPE > nonConstDims(0);
220 nonConstDims.insert(nonConstDims.begin(),
223 return computeStrides< SIZE_TYPE, DIM_TYPE >(nonConstDims, layout);
234 template<
class DIM_TYPE >
235 size_type computeSize(
const Teuchos::ArrayView< DIM_TYPE > & dimensions)
237 size_type result = 1;
238 for (
int axis = 0; axis < dimensions.size(); ++axis)
239 result *= dimensions[axis];
251 template<
class DIM_TYPE >
252 size_type computeSize(
const Teuchos::Array< DIM_TYPE > & dimensions)
260 Teuchos::Array< DIM_TYPE > nonConstDims(0);
261 nonConstDims.insert(nonConstDims.begin(),
264 return computeSize(nonConstDims());
277 template<
class SIZE_TYPE,
class DIM_TYPE >
278 SIZE_TYPE computeSize(
const Teuchos::ArrayView< DIM_TYPE > & dimensions,
279 const Teuchos::ArrayView< SIZE_TYPE > & strides)
282 typename remove_const< SIZE_TYPE >::type result = 1;
283 for (
int axis = 0; axis < dimensions.size(); ++axis)
284 result += (dimensions[axis]-1) * strides[axis];
295 Teuchos::Array< int >
305 int indexOfMax(
const Teuchos::ArrayView< const float > & seq);
323 Teuchos::Array< int >
324 decomposeProcs(
int nprocs,
325 const Teuchos::ArrayView< dim_type > & dimensions);
352 Teuchos::Array< int >
353 regularizeCommDims(
int numProcs,
355 const Teuchos::ArrayView< const int > & commDims);
377 Teuchos::Array< int >
378 regularizeCommDims(
int numProcs,
379 Teuchos::ParameterList & plist);
391 Teuchos::Array< int >
392 computeCommIndexes(
int rank,
393 const Teuchos::ArrayView< int > & commStrides);
406 Teuchos::Array< int >
407 createArrayOfInts(
int numDims,
408 const Teuchos::ArrayView< const int > & source);
417 Teuchos::Array< int >
418 splitStringOfIntsWithCommas(std::string data);
427 template<
class T > MPI_Datatype mpiType();
440 int mpiOrder(Layout layout);
446 #endif // DOMI_MDARRAY_UTILS_HPP
Provide capability to declare a variable as non-const, even if template parameter is const...
Definition: Domi_Utils.hpp:144
T type
Typedef for the non-const version of the template parameter.
Definition: Domi_Utils.hpp:160
T type
Typedef for the template parameter.
Definition: Domi_Utils.hpp:148