Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions include/mpicpp-lite/impl/Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

namespace mpicpp_lite {

namespace op {
MPI_Op create(MPI_User_function * user_fn, bool commute);
}

enum class ThreadSupport : int {
SINGLE = MPI_THREAD_SINGLE,
FUNNELED = MPI_THREAD_FUNNELED,
Expand Down Expand Up @@ -51,9 +55,12 @@ class Environment {
private:
/// User-registered datatypes
static inline std::vector<MPI_Datatype> user_datatypes_;
/// user-defined operations
static inline std::vector<MPI_Op> user_operations_;

template <typename T>
friend MPI_Datatype register_mpi_datatype();
friend MPI_Op op::create(MPI_User_function * user_fn, bool commute);
};

inline Environment::Environment() : initialized_(false)
Expand Down Expand Up @@ -150,6 +157,10 @@ Environment::destroy()
for (auto & dt : user_datatypes_)
MPI_CHECK(MPI_Type_free(&dt));
user_datatypes_.clear();

for (auto & op : user_operations_)
MPI_CHECK(MPI_Op_free(&op));
user_operations_.clear();
}

} // namespace mpicpp_lite
2 changes: 2 additions & 0 deletions include/mpicpp-lite/impl/Operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "mpi.h"
#include "Error.h"
#include "Environment.h"
#include <algorithm>
#include <type_traits>
#include <concepts>
Expand Down Expand Up @@ -315,6 +316,7 @@ create(MPI_User_function * user_fn, bool commute)
{
MPI_Op op;
MPI_CHECK(MPI_Op_create(user_fn, commute, &op));
Environment::user_operations_.push_back(op);
return op;
}

Expand Down
Loading