mirror of
https://github.com/boostorg/mpi.git
synced 2026-02-24 16:12:16 +00:00
Try to make sure user's operators are stateless, and do not use their state if any.
refs #68
This commit is contained in:
@@ -51,7 +51,7 @@ namespace detail {
|
||||
T* out_values, Op op, mpl::false_ /*is_mpi_op*/,
|
||||
mpl::true_ /*is_mpi_datatype*/)
|
||||
{
|
||||
user_op<Op, T> mpi_op(op);
|
||||
user_op<Op, T> mpi_op;
|
||||
BOOST_MPI_CHECK_RESULT(MPI_Allreduce,
|
||||
(const_cast<T*>(in_values), out_values, n,
|
||||
boost::mpi::get_mpi_datatype<T>(*in_values),
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace detail {
|
||||
T* out_values, Op op, int root, mpl::false_ /*is_mpi_op*/,
|
||||
mpl::true_/*is_mpi_datatype*/)
|
||||
{
|
||||
user_op<Op, T> mpi_op(op);
|
||||
user_op<Op, T> mpi_op;
|
||||
BOOST_MPI_CHECK_RESULT(MPI_Reduce,
|
||||
(const_cast<T*>(in_values), out_values, n,
|
||||
boost::mpi::get_mpi_datatype<T>(*in_values),
|
||||
@@ -96,7 +96,7 @@ namespace detail {
|
||||
reduce_impl(const communicator& comm, const T* in_values, int n, Op op,
|
||||
int root, mpl::false_/*is_mpi_op*/, mpl::true_/*is_mpi_datatype*/)
|
||||
{
|
||||
user_op<Op, T> mpi_op(op);
|
||||
user_op<Op, T> mpi_op;
|
||||
BOOST_MPI_CHECK_RESULT(MPI_Reduce,
|
||||
(const_cast<T*>(in_values), 0, n,
|
||||
boost::mpi::get_mpi_datatype<T>(*in_values),
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace detail {
|
||||
scan_impl(const communicator& comm, const T* in_values, int n, T* out_values,
|
||||
Op op, mpl::false_ /*is_mpi_op*/, mpl::true_ /*is_mpi_datatype*/)
|
||||
{
|
||||
user_op<Op, T> mpi_op(op);
|
||||
user_op<Op, T> mpi_op;
|
||||
BOOST_MPI_CHECK_RESULT(MPI_Scan,
|
||||
(const_cast<T*>(in_values), out_values, n,
|
||||
boost::mpi::get_mpi_datatype<T>(*in_values),
|
||||
|
||||
@@ -292,14 +292,12 @@ namespace detail {
|
||||
class user_op
|
||||
{
|
||||
public:
|
||||
explicit user_op(Op& op)
|
||||
user_op()
|
||||
{
|
||||
BOOST_MPI_CHECK_RESULT(MPI_Op_create,
|
||||
(&user_op<Op, T>::perform,
|
||||
is_commutative<Op, T>::value,
|
||||
&mpi_op));
|
||||
|
||||
op_ptr = &op;
|
||||
}
|
||||
|
||||
~user_op()
|
||||
@@ -321,18 +319,16 @@ namespace detail {
|
||||
|
||||
private:
|
||||
MPI_Op mpi_op;
|
||||
static Op* op_ptr;
|
||||
|
||||
static void BOOST_MPI_CALLING_CONVENTION perform(void* vinvec, void* voutvec, int* plen, MPI_Datatype*)
|
||||
{
|
||||
T* invec = static_cast<T*>(vinvec);
|
||||
T* outvec = static_cast<T*>(voutvec);
|
||||
std::transform(invec, invec + *plen, outvec, outvec, *op_ptr);
|
||||
Op op;
|
||||
std::transform(invec, invec + *plen, outvec, outvec, op);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Op, typename T> Op* user_op<Op, T>::op_ptr = 0;
|
||||
|
||||
} // end namespace detail
|
||||
|
||||
} } // end namespace boost::mpi
|
||||
|
||||
Reference in New Issue
Block a user