Constified the compute reduction functions.
These should and have to be used with a const object.
This commit is contained in:
parent
0aebabf41e
commit
f544ccf308
@ -142,7 +142,7 @@ public:
|
|||||||
communicator.free();
|
communicator.free();
|
||||||
}
|
}
|
||||||
template<class T>
|
template<class T>
|
||||||
void updateOwnerMask(const T& container)
|
void updateOwnerMask(const T& container) const
|
||||||
{
|
{
|
||||||
if( ! indexSet_ )
|
if( ! indexSet_ )
|
||||||
{
|
{
|
||||||
@ -180,7 +180,7 @@ public:
|
|||||||
/// \param value The initial value or a tuple of them.
|
/// \param value The initial value or a tuple of them.
|
||||||
template<typename Container, typename BinaryOperator, typename T>
|
template<typename Container, typename BinaryOperator, typename T>
|
||||||
void computeReduction(const Container& container, BinaryOperator binaryOperator,
|
void computeReduction(const Container& container, BinaryOperator binaryOperator,
|
||||||
T& value)
|
T& value) const
|
||||||
{
|
{
|
||||||
computeReduction(container, binaryOperator, value, is_tuple<Container>());
|
computeReduction(container, binaryOperator, value, is_tuple<Container>());
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ private:
|
|||||||
/// This is a helper function to prepare for calling computeTupleReduction.
|
/// This is a helper function to prepare for calling computeTupleReduction.
|
||||||
template<typename Container, typename BinaryOperator, typename T>
|
template<typename Container, typename BinaryOperator, typename T>
|
||||||
void computeReduction(const Container& container, BinaryOperator binaryOperator,
|
void computeReduction(const Container& container, BinaryOperator binaryOperator,
|
||||||
T& value, std::integral_constant<bool,true>)
|
T& value, std::integral_constant<bool,true>) const
|
||||||
{
|
{
|
||||||
computeTupleReduction(container, binaryOperator, value);
|
computeTupleReduction(container, binaryOperator, value);
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ private:
|
|||||||
/// This is a helper function to prepare for calling computeTupleReduction.
|
/// This is a helper function to prepare for calling computeTupleReduction.
|
||||||
template<typename Container, typename BinaryOperator, typename T>
|
template<typename Container, typename BinaryOperator, typename T>
|
||||||
void computeReduction(const Container& container, BinaryOperator binaryOperator,
|
void computeReduction(const Container& container, BinaryOperator binaryOperator,
|
||||||
T& value, std::integral_constant<bool,false>)
|
T& value, std::integral_constant<bool,false>) const
|
||||||
{
|
{
|
||||||
std::tuple<const Container&> containers=std::tuple<const Container&>(container);
|
std::tuple<const Container&> containers=std::tuple<const Container&>(container);
|
||||||
auto values=std::make_tuple(value);
|
auto values=std::make_tuple(value);
|
||||||
@ -211,7 +211,7 @@ private:
|
|||||||
template<typename... Containers, typename... BinaryOperators, typename... ReturnValues>
|
template<typename... Containers, typename... BinaryOperators, typename... ReturnValues>
|
||||||
void computeTupleReduction(const std::tuple<Containers...>& containers,
|
void computeTupleReduction(const std::tuple<Containers...>& containers,
|
||||||
std::tuple<BinaryOperators...>& operators,
|
std::tuple<BinaryOperators...>& operators,
|
||||||
std::tuple<ReturnValues...>& values)
|
std::tuple<ReturnValues...>& values) const
|
||||||
{
|
{
|
||||||
static_assert(std::tuple_size<std::tuple<Containers...> >::value==
|
static_assert(std::tuple_size<std::tuple<Containers...> >::value==
|
||||||
std::tuple_size<std::tuple<BinaryOperators...> >::value,
|
std::tuple_size<std::tuple<BinaryOperators...> >::value,
|
||||||
@ -243,14 +243,14 @@ private:
|
|||||||
typename std::enable_if<I == sizeof...(BinaryOperators), void>::type
|
typename std::enable_if<I == sizeof...(BinaryOperators), void>::type
|
||||||
computeGlobalReduction(const std::tuple<ReturnValues...>&,
|
computeGlobalReduction(const std::tuple<ReturnValues...>&,
|
||||||
std::tuple<BinaryOperators...>&,
|
std::tuple<BinaryOperators...>&,
|
||||||
std::tuple<ReturnValues...>&)
|
std::tuple<ReturnValues...>&) const
|
||||||
{}
|
{}
|
||||||
/// \brief TMP for computing the the global reduction after receiving the local ones.
|
/// \brief TMP for computing the the global reduction after receiving the local ones.
|
||||||
template<int I=0, typename... BinaryOperators, typename... ReturnValues>
|
template<int I=0, typename... BinaryOperators, typename... ReturnValues>
|
||||||
typename std::enable_if<I !=sizeof...(BinaryOperators), void>::type
|
typename std::enable_if<I !=sizeof...(BinaryOperators), void>::type
|
||||||
computeGlobalReduction(const std::tuple<ReturnValues...>& receivedValues,
|
computeGlobalReduction(const std::tuple<ReturnValues...>& receivedValues,
|
||||||
std::tuple<BinaryOperators...>& operators,
|
std::tuple<BinaryOperators...>& operators,
|
||||||
std::tuple<ReturnValues...>& values)
|
std::tuple<ReturnValues...>& values) const
|
||||||
{
|
{
|
||||||
auto& val=std::get<I>(values);
|
auto& val=std::get<I>(values);
|
||||||
val = std::get<I>(operators).localOperator()(val, std::get<I>(receivedValues));
|
val = std::get<I>(operators).localOperator()(val, std::get<I>(receivedValues));
|
||||||
@ -263,14 +263,14 @@ private:
|
|||||||
typename std::enable_if<I==sizeof...(Containers), void>::type
|
typename std::enable_if<I==sizeof...(Containers), void>::type
|
||||||
computeLocalReduction(const std::tuple<Containers...>&,
|
computeLocalReduction(const std::tuple<Containers...>&,
|
||||||
std::tuple<BinaryOperators...>&,
|
std::tuple<BinaryOperators...>&,
|
||||||
std::tuple<ReturnValues...>&)
|
std::tuple<ReturnValues...>&) const
|
||||||
{}
|
{}
|
||||||
/// \brief TMP for computing the the local reduction on the DOF that the process owns.
|
/// \brief TMP for computing the the local reduction on the DOF that the process owns.
|
||||||
template<int I=0, typename... Containers, typename... BinaryOperators, typename... ReturnValues>
|
template<int I=0, typename... Containers, typename... BinaryOperators, typename... ReturnValues>
|
||||||
typename std::enable_if<I!=sizeof...(Containers), void>::type
|
typename std::enable_if<I!=sizeof...(Containers), void>::type
|
||||||
computeLocalReduction(const std::tuple<Containers...>& containers,
|
computeLocalReduction(const std::tuple<Containers...>& containers,
|
||||||
std::tuple<BinaryOperators...>& operators,
|
std::tuple<BinaryOperators...>& operators,
|
||||||
std::tuple<ReturnValues...>& values)
|
std::tuple<ReturnValues...>& values) const
|
||||||
{
|
{
|
||||||
const auto& container = std::get<I>(containers);
|
const auto& container = std::get<I>(containers);
|
||||||
if( container.size() )
|
if( container.size() )
|
||||||
|
Loading…
Reference in New Issue
Block a user