Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
acdemiralp committed Oct 20, 2023
2 parents 0a14eb8 + ae58c4c commit 420b0f4
Show file tree
Hide file tree
Showing 37 changed files with 132 additions and 134 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ set (CMAKE_CXX_STANDARD 20)
include (set_max_warning_level)
set_max_warning_level ()

# Necessary to suppress the ... changes the meaning of symbol ...
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
endif ()

################################################## Options ##################################################
option(MPI_BUILD_TESTS "Build tests." OFF)
option(MPI_USE_EXCEPTIONS "Use exceptions." OFF)
Expand Down
2 changes: 1 addition & 1 deletion include/mpi/core/communicators/cartesian_communicator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class cartesian_communicator : public topological_communicator
std::array<std::int32_t, 2> shift (const std::int32_t dimension, const std::int32_t displacement = 1) const
{
std::array<std::int32_t, 2> result {};
MPI_CHECK_ERROR_CODE(MPI_Cart_shift, (native_, dimension, displacement, &result[0], &result[1]))
MPI_CHECK_ERROR_CODE(MPI_Cart_shift, (native_, dimension, displacement, result.data(), &result[1]))
return result;
}
};
Expand Down
14 changes: 7 additions & 7 deletions include/mpi/core/communicators/communicator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ class communicator
}

[[nodiscard]]
group group () const
mpi::group group () const
{
mpi::group result(MPI_GROUP_NULL, true);
MPI_CHECK_ERROR_CODE(MPI_Comm_group, (native_, &result.native_))
return result;
}
[[nodiscard]]
topology topology () const
mpi::topology topology () const
{
std::int32_t result;
MPI_CHECK_ERROR_CODE(MPI_Topo_test, (native_, &result))
Expand Down Expand Up @@ -276,7 +276,7 @@ class communicator
{
std::string result(MPI_MAX_OBJECT_NAME, '\n');
std::int32_t length(0);
MPI_CHECK_ERROR_CODE(MPI_Comm_get_name, (native_, &result[0], &length))
MPI_CHECK_ERROR_CODE(MPI_Comm_get_name, (native_, result.data(), &length))
result.resize(static_cast<std::size_t>(length));
return result;
}
Expand All @@ -286,7 +286,7 @@ class communicator
}

[[nodiscard]]
information information () const
mpi::information information () const
{
mpi::information result(MPI_INFO_NULL, true);
MPI_CHECK_ERROR_CODE(MPI_Comm_get_info, (native_, &result.native_))
Expand Down Expand Up @@ -553,7 +553,7 @@ class communicator
request partitioned_send (const std::int32_t partitions, const void* data, const count size, const data_type& data_type, const std::int32_t destination, const std::int32_t tag = 0, const mpi::information& info = mpi::information()) const
{
request result(MPI_REQUEST_NULL, true, true);
MPI_CHECK_ERROR_CODE(MPI_Psend_init, (data, partitions, size, data_type.native(), destination, tag, native_, info.native(), &result.native_))
MPI_CHECK_ERROR_CODE(MPI_Psend_init, (const_cast<void*>(data), partitions, size, data_type.native(), destination, tag, native_, info.native(), &result.native_)) // Note: Several implementations require the const_cast.
return result;
}
template <typename type> [[nodiscard]]
Expand Down Expand Up @@ -1083,7 +1083,7 @@ class communicator
received_type& received,
const bool resize = false) const
{
std::int32_t local_size (container_adapter<sent_type>::size(sent));
const std::int32_t local_size (container_adapter<sent_type>::size(sent));
std::vector<std::int32_t> received_sizes(size());
all_gather(local_size, received_sizes);

Expand All @@ -1108,7 +1108,7 @@ class communicator
{
using adapter = container_adapter<type>;

std::int32_t local_size (adapter::size(data));
const std::int32_t local_size (adapter::size(data));
std::vector<std::int32_t> received_sizes(size());
all_gather(local_size, received_sizes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class distributed_graph_communicator : public topological_communicator
}

[[nodiscard]]
neighbor_counts neighbor_counts () const
mpi::neighbor_counts neighbor_counts () const
{
mpi::neighbor_counts result {};
MPI_CHECK_ERROR_CODE(MPI_Dist_graph_neighbors_count, (native_, &result.source_count, &result.destination_count, reinterpret_cast<std::int32_t*>(&result.weighted)))
Expand Down
4 changes: 2 additions & 2 deletions include/mpi/core/communicators/graph_communicator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class graph_communicator : public topological_communicator
std::array<std::int32_t, 2> counts () const
{
std::array<std::int32_t, 2> result {};
MPI_CHECK_ERROR_CODE(MPI_Graphdims_get, (native_, &result[0], &result[1]))
MPI_CHECK_ERROR_CODE(MPI_Graphdims_get, (native_, result.data(), &result[1]))
return result;
}
[[nodiscard]]
graph graph () const
mpi::graph graph () const
{
const auto count = counts();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class topological_communicator : public communicator
received_type& received,
const bool resize = false) const
{
std::int32_t local_size (container_adapter<sent_type>::size(sent));
const std::int32_t local_size (container_adapter<sent_type>::size(sent));
std::vector<std::int32_t> received_sizes(incoming_neighbor_count());
neighbor_all_gather(local_size, received_sizes);

Expand Down
2 changes: 1 addition & 1 deletion include/mpi/core/environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ inline std::string processor_name ()
{
std::string result(MPI_MAX_PROCESSOR_NAME, '\n');
std::int32_t size (0);
MPI_CHECK_ERROR_CODE(MPI_Get_processor_name, (&result[0], &size))
MPI_CHECK_ERROR_CODE(MPI_Get_processor_name, (result.data(), &size))
result.resize(static_cast<std::size_t>(size));
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion include/mpi/core/error/error_class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class error_class
{
std::string result(MPI_MAX_ERROR_STRING, '\n');
std::int32_t length(0);
MPI_Error_string(native_, &result[0], &length);
MPI_Error_string(native_, result.data(), &length);
result.resize(static_cast<std::size_t>(length));
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions include/mpi/core/information.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class information
return {std::nullopt};

std::string result(size, '\n');
MPI_CHECK_ERROR_CODE(MPI_Info_get, (native_, key.c_str(), size, &result[0], &exists))
MPI_CHECK_ERROR_CODE(MPI_Info_get, (native_, key.c_str(), size, result.data(), &exists))

return result;
}
Expand All @@ -167,7 +167,7 @@ class information
std::string key_at (const std::int32_t index) const
{
std::string result(MPI_MAX_INFO_KEY, '\n');
MPI_CHECK_ERROR_CODE(MPI_Info_get_nthkey, (native_, index, &result[0]))
MPI_CHECK_ERROR_CODE(MPI_Info_get_nthkey, (native_, index, result.data()))
return result;
}
[[nodiscard]]
Expand Down
2 changes: 1 addition & 1 deletion include/mpi/core/port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class port
explicit port (const information& info = information())
: managed_(true), name_(MPI_MAX_PORT_NAME, '\n')
{
MPI_CHECK_ERROR_CODE(MPI_Open_port, (info.native(), &name_[0]))
MPI_CHECK_ERROR_CODE(MPI_Open_port, (info.native(), name_.data()))
}
explicit port (std::string name, const bool managed = false)
: managed_(managed), name_(std::move(name))
Expand Down
2 changes: 1 addition & 1 deletion include/mpi/core/request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class request
}
void set_partition_ready(const std::vector<std::int32_t>& partitions) const
{
MPI_CHECK_ERROR_CODE(MPI_Pready_list , (static_cast<std::int32_t>(partitions.size()), partitions.data(), native_))
MPI_CHECK_ERROR_CODE(MPI_Pready_list , (static_cast<std::int32_t>(partitions.size()), const_cast<std::int32_t*>(partitions.data()), native_)) // Note: Several implementations require the const_cast.
}
void set_partition_ready(const std::int32_t lower, const std::int32_t upper) const
{
Expand Down
2 changes: 1 addition & 1 deletion include/mpi/core/service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class service
inline port lookup_service(const std::string& name, const information& info = information())
{
std::string result(MPI_MAX_PORT_NAME, '\n');
MPI_CHECK_ERROR_CODE(MPI_Lookup_name, (name.c_str(), info.native(), &result[0]))
MPI_CHECK_ERROR_CODE(MPI_Lookup_name, (name.c_str(), info.native(), result.data()))
return port(result); // Unmanaged construction.
}
}
12 changes: 6 additions & 6 deletions include/mpi/core/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace mpi
class session
{
public:
session (const information& information, const session_error_handler& error_handler)
session (const mpi::information& information, const session_error_handler& error_handler)
: managed_(true)
{
MPI_CHECK_ERROR_CODE(MPI_Session_init, (information.native(), error_handler.native(), &native_))
Expand Down Expand Up @@ -56,14 +56,14 @@ class session
}

[[nodiscard]]
std::int32_t process_set_count ( const information& information = mpi::information()) const
std::int32_t process_set_count ( const mpi::information& information = mpi::information()) const
{
std::int32_t result;
MPI_CHECK_ERROR_CODE(MPI_Session_get_num_psets, (native_, information.native(), &result))
return result;
}
[[nodiscard]]
std::string process_set_name (const std::int32_t index, const information& information = mpi::information()) const
std::string process_set_name (const std::int32_t index, const mpi::information& information = mpi::information()) const
{
std::int32_t size (0);
MPI_CHECK_ERROR_CODE(MPI_Session_get_nth_pset, (native_, information.native(), index, &size, nullptr ))
Expand All @@ -73,7 +73,7 @@ class session
return result;
}
[[nodiscard]]
information process_set_information(const std::string& name) const
mpi::information process_set_information(const std::string& name) const
{
mpi::information result(MPI_INFO_NULL, true);
MPI_CHECK_ERROR_CODE(MPI_Session_get_pset_info, (native_, name.c_str(), &result.native_))
Expand All @@ -88,7 +88,7 @@ class session
return std::stoi(*info["mpi_size"]);
}
[[nodiscard]]
std::vector<process_set> process_sets (const information& information = mpi::information()) const
std::vector<process_set> process_sets (const mpi::information& information = mpi::information()) const
{
std::vector<process_set> result(process_set_count(information));
for (std::size_t i = 0; i < result.size(); ++i)
Expand All @@ -100,7 +100,7 @@ class session
}

[[nodiscard]]
information information () const
mpi::information information () const
{
mpi::information result(MPI_INFO_NULL, true);
MPI_CHECK_ERROR_CODE(MPI_Session_get_info, (native_, &result.native_))
Expand Down
5 changes: 4 additions & 1 deletion include/mpi/core/status.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ namespace mpi
class communicator;
class message;
class request;
class io::file;
namespace io
{
class file;
}

class status
{
Expand Down
8 changes: 4 additions & 4 deletions include/mpi/core/structs/data_type_information.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class data_type;

struct data_type_information
{
std::vector<std::int32_t> integers ;
std::vector<aint> addresses ;
std::vector<data_type> data_types;
combiner combiner ;
std::vector<std::int32_t> integers ;
std::vector<aint> addresses ;
std::vector<data_type> data_types ;
mpi::combiner combiner {};
};
}
2 changes: 1 addition & 1 deletion include/mpi/core/structs/spawn_information.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ struct spawn_information
std::string command ;
std::vector<std::string> arguments ;
std::int32_t process_count;
information information ;
mpi::information information ;
};
}
8 changes: 4 additions & 4 deletions include/mpi/core/type/data_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class data_type
std::array<aint , 2> extent () const
{
std::array<aint, 2> result {};
MPI_CHECK_ERROR_CODE(MPI_Type_get_extent, (native_, &result[0], &result[1]))
MPI_CHECK_ERROR_CODE(MPI_Type_get_extent, (native_, result.data(), &result[1]))
MPI_CHECK_UNDEFINED (MPI_Type_get_extent, result[0])
MPI_CHECK_UNDEFINED (MPI_Type_get_extent, result[1])
return result;
Expand All @@ -184,7 +184,7 @@ class data_type
std::array<count, 2> extent_x () const
{
std::array<count, 2> result {};
MPI_CHECK_ERROR_CODE(MPI_Type_get_extent_x, (native_, &result[0], &result[1]))
MPI_CHECK_ERROR_CODE(MPI_Type_get_extent_x, (native_, result.data(), &result[1]))
MPI_CHECK_UNDEFINED (MPI_Type_get_extent_x, result[0])
MPI_CHECK_UNDEFINED (MPI_Type_get_extent_x, result[1])
return result;
Expand All @@ -193,7 +193,7 @@ class data_type
std::array<aint , 2> true_extent () const
{
std::array<aint, 2> result {};
MPI_CHECK_ERROR_CODE(MPI_Type_get_true_extent, (native_, &result[0], &result[1]))
MPI_CHECK_ERROR_CODE(MPI_Type_get_true_extent, (native_, result.data(), &result[1]))
MPI_CHECK_UNDEFINED (MPI_Type_get_true_extent, result[0])
MPI_CHECK_UNDEFINED (MPI_Type_get_true_extent, result[1])
return result;
Expand All @@ -202,7 +202,7 @@ class data_type
std::array<count, 2> true_extent_x () const
{
std::array<count, 2> result {};
MPI_CHECK_ERROR_CODE(MPI_Type_get_true_extent_x, (native_, &result[0], &result[1]))
MPI_CHECK_ERROR_CODE(MPI_Type_get_true_extent_x, (native_, result.data(), &result[1]))
MPI_CHECK_UNDEFINED (MPI_Type_get_true_extent_x, result[0])
MPI_CHECK_UNDEFINED (MPI_Type_get_true_extent_x, result[1])
return result;
Expand Down
20 changes: 10 additions & 10 deletions include/mpi/core/utility/container_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ class container_adapter<type, std::enable_if_t<std::conjunction_v<std::negation<
public:
using value_type = type;

static const data_type& data_type()
static const mpi::data_type& data_type()
{
return type_traits<value_type>::get_data_type();
}
static value_type* data ( type& container)
static value_type* data ( type& container)
{
return &container;
}
static const value_type* data (const type& container)
static const value_type* data (const type& container)
{
return &container;
}
static std::size_t size (const type& container)
static std::size_t size (const type& container)
{
return 1;
}

static void resize ( type& container, const std::size_t size)
static void resize ( type& container, const std::size_t size)
{
// Do nothing. Compliant types are not resizable.
}
Expand All @@ -51,30 +51,30 @@ class container_adapter<type, std::enable_if_t<is_compliant_contiguous_sequentia
public:
using value_type = typename type::value_type;

static const data_type& data_type()
static const mpi::data_type& data_type()
{
return type_traits<value_type>::get_data_type();
}
static value_type* data ( type& container)
static value_type* data ( type& container)
{
if constexpr (std::is_same_v<type, std::valarray<value_type>>)
return &container[0]; // std::valarray does not have a .data() function.
else
return container.data();
}
static const value_type* data (const type& container)
static const value_type* data (const type& container)
{
if constexpr (std::is_same_v<type, std::valarray<value_type>>)
return &container[0]; // std::valarray does not have a .data() function.
else
return container.data();
}
static std::size_t size (const type& container)
static std::size_t size (const type& container)
{
return container.size();
}

static void resize ( type& container, const std::size_t size)
static void resize ( type& container, const std::size_t size)
{
// Spans are not resizable.
if constexpr (!is_span_v<type>)
Expand Down
4 changes: 2 additions & 2 deletions include/mpi/core/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ constexpr std::int32_t sub_version = MPI_SUBVERSION;
inline std::array<std::int32_t, 2> get_version ()
{
std::array<std::int32_t, 2> result {};
MPI_CHECK_ERROR_CODE(MPI_Get_version, (&result[0], &result[1]))
MPI_CHECK_ERROR_CODE(MPI_Get_version, (result.data(), &result[1]))
return result;
}
inline std::string get_library_version()
{
std::string result(MPI_MAX_LIBRARY_VERSION_STRING, '\n');
std::int32_t size (0);
MPI_CHECK_ERROR_CODE(MPI_Get_library_version, (&result[0], &size))
MPI_CHECK_ERROR_CODE(MPI_Get_library_version, (result.data(), &size))
result.resize(static_cast<std::size_t>(size));
return result;
}
Expand Down
Loading

0 comments on commit 420b0f4

Please sign in to comment.