Skip to content

Commit

Permalink
Explicitly avoid temporary in isend.
Browse files Browse the repository at this point in the history
  • Loading branch information
aminiussi committed Oct 26, 2016
1 parent 8e3e9cd commit e3b0d08
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
7 changes: 6 additions & 1 deletion include/boost/mpi/detail/binary_buffer_oprimitive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ class BOOST_MPI_DECL binary_buffer_oprimitive
{
return size_ = buffer_.size();
}


const std::size_t* size_ptr() const
{
return &size();
}

void save_binary(void const *address, std::size_t count)
{
save_impl(address,count);
Expand Down
5 changes: 5 additions & 0 deletions include/boost/mpi/detail/packed_oprimitive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class BOOST_MPI_DECL packed_oprimitive
return size_ = buffer_.size();
}

const std::size_t* size_ptr() const
{
return &size();
}

void save_binary(void const *address, std::size_t count)
{
save_impl(address,MPI_BYTE,count);
Expand Down
28 changes: 14 additions & 14 deletions src/point_to_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ void
packed_archive_send(MPI_Comm comm, int dest, int tag,
const packed_oarchive& ar)
{
std::size_t size = ar.size();
std::size_t const& size = ar.size();
BOOST_MPI_CHECK_RESULT(MPI_Send,
(static_cast<void*>(&size), 1,
get_mpi_datatype<std::size_t>(ar.size()),
(&size, 1,
get_mpi_datatype(size),
dest, tag, comm));
BOOST_MPI_CHECK_RESULT(MPI_Send,
(const_cast<void*>(ar.address()), ar.size(),
(const_cast<void*>(ar.address()), size,
MPI_PACKED,
dest, tag, comm));
}
Expand All @@ -45,13 +45,13 @@ packed_archive_isend(MPI_Comm comm, int dest, int tag,
MPI_Request* out_requests, int num_out_requests)
{
assert(num_out_requests >= 2);
const void* size = &ar.size();
std::size_t const& size = ar.size();
BOOST_MPI_CHECK_RESULT(MPI_Isend,
(const_cast<void*>(size), 1,
get_mpi_datatype<std::size_t>(ar.size()),
(&size, 1,
get_mpi_datatype(size),
dest, tag, comm, out_requests));
BOOST_MPI_CHECK_RESULT(MPI_Isend,
(const_cast<void*>(ar.address()), ar.size(),
(const_cast<void*>(ar.address()), size,
MPI_PACKED,
dest, tag, comm, out_requests + 1));

Expand All @@ -65,13 +65,13 @@ packed_archive_isend(MPI_Comm comm, int dest, int tag,
{
assert(num_out_requests >= 2);

const void* size = &ar.size();
std::size_t const& size = ar.size();
BOOST_MPI_CHECK_RESULT(MPI_Isend,
(const_cast<void*>(size), 1,
get_mpi_datatype<std::size_t>(ar.size()),
(&size, 1,
get_mpi_datatype(size),
dest, tag, comm, out_requests));
BOOST_MPI_CHECK_RESULT(MPI_Isend,
(const_cast<void*>(ar.address()), ar.size(),
(const_cast<void*>(ar.address()), size,
MPI_PACKED,
dest, tag, comm, out_requests + 1));

Expand All @@ -84,13 +84,13 @@ packed_archive_recv(MPI_Comm comm, int source, int tag, packed_iarchive& ar,
{
std::size_t count;
BOOST_MPI_CHECK_RESULT(MPI_Recv,
(&count, 1, get_mpi_datatype<std::size_t>(count),
(&count, 1, get_mpi_datatype(count),
source, tag, comm, &status));

// Prepare input buffer and receive the message
ar.resize(count);
BOOST_MPI_CHECK_RESULT(MPI_Recv,
(ar.address(), ar.size(), MPI_PACKED,
(ar.address(), count, MPI_PACKED,
status.MPI_SOURCE, status.MPI_TAG,
comm, &status));
}
Expand Down

0 comments on commit e3b0d08

Please sign in to comment.