2
0
mirror of https://github.com/boostorg/mpi.git synced 2026-01-19 04:22:10 +00:00

put status code in status files

This commit is contained in:
Alain O Miniussi
2020-06-23 10:48:47 +02:00
parent e60a9c009d
commit e1aea365fb
5 changed files with 46 additions and 48 deletions

View File

@@ -46,15 +46,16 @@ lib boost_mpi
intercommunicator.cpp
mpi_datatype_cache.cpp
mpi_datatype_oarchive.cpp
offsets.cpp
packed_iarchive.cpp
packed_oarchive.cpp
packed_skeleton_iarchive.cpp
packed_skeleton_oarchive.cpp
point_to_point.cpp
request.cpp
status.cpp
text_skeleton_oarchive.cpp
timer.cpp
offsets.cpp
: # Requirements
<library>../../serialization/build//boost_serialization
<library>/mpi//mpi [ mpi.extra-requirements ]

View File

@@ -1256,38 +1256,6 @@ communicator::irecv<content>(int source, int tag,
return irecv<const content>(source, tag, c);
}
// Count elements in a message
template<typename T>
inline optional<int> status::count() const
{
return count_impl<T>(is_mpi_datatype<T>());
}
template<typename T>
optional<int> status::count_impl(mpl::true_) const
{
if (m_count != -1)
return m_count;
int return_value;
BOOST_MPI_CHECK_RESULT(MPI_Get_count,
(&m_status, get_mpi_datatype<T>(T()), &return_value));
if (return_value == MPI_UNDEFINED)
return optional<int>();
else
/* Cache the result. */
return m_count = return_value;
}
template<typename T>
inline optional<int> status::count_impl(mpl::false_) const
{
if (m_count == -1)
return optional<int>();
else
return m_count;
}
// We're sending a type that has an associated MPI datatype, so we
// map directly to that datatype.
template<typename T>

View File

@@ -13,6 +13,7 @@
#define BOOST_MPI_STATUS_HPP
#include <boost/mpi/config.hpp>
#include <boost/mpi/datatype.hpp>
#include <boost/optional.hpp>
#include <boost/mpl/bool.hpp>
@@ -69,7 +70,7 @@ class BOOST_MPI_DECL status
* @returns the number of @c T elements in the message, if it can be
* determined.
*/
template<typename T> optional<int> count() const;
template<typename T> optional<int> count() const { return count_impl<T>(is_mpi_datatype<T>()); }
/**
* References the underlying @c MPI_Status
@@ -102,6 +103,30 @@ class BOOST_MPI_DECL status
friend class request;
};
template<typename T>
optional<int> status::count_impl(mpl::true_) const
{
if (m_count != -1)
return m_count;
int return_value;
BOOST_MPI_CHECK_RESULT(MPI_Get_count,
(&m_status, get_mpi_datatype<T>(T()), &return_value));
if (return_value == MPI_UNDEFINED)
return optional<int>();
else
/* Cache the result. */
return m_count = return_value;
}
template<typename T>
inline optional<int> status::count_impl(mpl::false_) const
{
if (m_count == -1)
return optional<int>();
else
return m_count;
}
} } // end namespace boost::mpi

View File

@@ -13,20 +13,6 @@
namespace boost { namespace mpi {
/***************************************************************************
* status *
***************************************************************************/
bool status::cancelled() const
{
int flag = 0;
BOOST_MPI_CHECK_RESULT(MPI_Test_cancelled, (&m_status, &flag));
return flag != 0;
}
/***************************************************************************
* communicator *
***************************************************************************/
communicator::communicator()
{
comm_ptr.reset(new MPI_Comm(MPI_COMM_WORLD));

18
src/status.cpp Normal file
View File

@@ -0,0 +1,18 @@
// Copyright (C) 2005, 2006 Douglas Gregor.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/mpi/status.hpp>
namespace boost { namespace mpi {
bool status::cancelled() const
{
int flag = 0;
BOOST_MPI_CHECK_RESULT(MPI_Test_cancelled, (&m_status, &flag));
return flag != 0;
}
}}