Skip to content

Commit

Permalink
Fixed control/performance variable and event object handles on system…
Browse files Browse the repository at this point in the history
…s where the handles are not int32s.
  • Loading branch information
acdemiralp committed Oct 20, 2023
1 parent 73a9cea commit 14f7fa4
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 51 deletions.
77 changes: 59 additions & 18 deletions include/mpi/tool/control_variable_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,74 @@ class control_variable_handle
explicit control_variable_handle (const control_variable& variable)
: managed_(true)
{
if (variable.bind_type == bind_type::file)
if (variable.bind_type == bind_type::communicator)
{
MPI_Comm handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))
object_ = communicator(handle); // Unmanaged construction.
}
else if (variable.bind_type == bind_type::data_type)
{
MPI_Datatype handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))
object_ = data_type(handle);
}
else if (variable.bind_type == bind_type::error_handler)
{
MPI_Errhandler handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))
object_ = error_handler(handle);
}
else if (variable.bind_type == bind_type::file)
{
MPI_File handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))

// Unmanaged construction.
object_ = io::file(handle);
}
else
else if (variable.bind_type == bind_type::group)
{
std::int32_t handle; // Abusing the fact that all native MPI object handles are std::int32_ts.
MPI_Group handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))

// Unmanaged construction.
if (variable.bind_type == bind_type::communicator ) object_ = communicator (handle);
else if (variable.bind_type == bind_type::data_type ) object_ = data_type (handle);
else if (variable.bind_type == bind_type::error_handler) object_ = error_handler(handle);
else if (variable.bind_type == bind_type::group ) object_ = group (handle);
else if (variable.bind_type == bind_type::information ) object_ = information (handle);
else if (variable.bind_type == bind_type::message ) object_ = message (handle);
else if (variable.bind_type == bind_type::op ) object_ = op (handle);
else if (variable.bind_type == bind_type::request ) object_ = request (handle);
else if (variable.bind_type == bind_type::window ) object_ = window (handle);
object_ = group(handle);
}
else if (variable.bind_type == bind_type::information)
{
MPI_Info handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))
object_ = information(handle);
}
else if (variable.bind_type == bind_type::message)
{
MPI_Message handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))
object_ = message(handle);
}
else if (variable.bind_type == bind_type::op)
{
MPI_Op handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))
object_ = op(handle);
}
else if (variable.bind_type == bind_type::request)
{
MPI_Request handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))
object_ = request(handle);
}
else if (variable.bind_type == bind_type::window)
{
MPI_Win handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))
object_ = window(handle);
}
#ifdef MPI_USE_LATEST
else if (variable.bind_type == bind_type::session ) object_ = session (handle);
#endif
else if (variable.bind_type == bind_type::session)
{
MPI_Session handle;
MPI_CHECK_ERROR_CODE(MPI_T_cvar_handle_alloc, (variable.index, &handle, &native_, &count_))
object_ = session(handle);
}
#endif
}
explicit control_variable_handle (const MPI_T_cvar_handle& native, const bool managed = false, const std::int32_t count = 1, std::optional<object_variant> object = std::nullopt)
: managed_(managed), native_(native), count_(count), object_(std::move(object))
Expand Down
75 changes: 58 additions & 17 deletions include/mpi/tool/event_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,71 @@ class event_handle
explicit event_handle (const event& event, const information& information = mpi::information())
: managed_(true), copy_buffer_size_(event.displacements.back() + event.data_types.back().size())
{
if (event.bind_type == bind_type::file)
if (variable.bind_type == bind_type::communicator)
{
MPI_Comm handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))
object_ = communicator(handle); // Unmanaged construction.
}
else if (variable.bind_type == bind_type::data_type)
{
MPI_Datatype handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))
object_ = data_type(handle);
}
else if (variable.bind_type == bind_type::error_handler)
{
MPI_Errhandler handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))
object_ = error_handler(handle);
}
else if (variable.bind_type == bind_type::file)
{
MPI_File handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))

// Unmanaged construction.
object_ = io::file(handle);
}
else
else if (variable.bind_type == bind_type::group)
{
std::int32_t handle; // Abusing the fact that all native MPI object handles are std::int32_ts.
MPI_Group handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))

// Unmanaged construction.
if (event.bind_type == bind_type::communicator ) object_ = communicator (handle);
else if (event.bind_type == bind_type::data_type ) object_ = data_type (handle);
else if (event.bind_type == bind_type::error_handler) object_ = error_handler (handle);
else if (event.bind_type == bind_type::group ) object_ = group (handle);
else if (event.bind_type == bind_type::information ) object_ = mpi::information(handle);
else if (event.bind_type == bind_type::message ) object_ = message (handle);
else if (event.bind_type == bind_type::op ) object_ = op (handle);
else if (event.bind_type == bind_type::request ) object_ = request (handle);
else if (event.bind_type == bind_type::window ) object_ = window (handle);
else if (event.bind_type == bind_type::session ) object_ = session (handle);
object_ = group(handle);
}
else if (variable.bind_type == bind_type::information)
{
MPI_Info handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))
object_ = information(handle);
}
else if (variable.bind_type == bind_type::message)
{
MPI_Message handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))
object_ = message(handle);
}
else if (variable.bind_type == bind_type::op)
{
MPI_Op handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))
object_ = op(handle);
}
else if (variable.bind_type == bind_type::request)
{
MPI_Request handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))
object_ = request(handle);
}
else if (variable.bind_type == bind_type::window)
{
MPI_Win handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))
object_ = window(handle);
}
else if (variable.bind_type == bind_type::session)
{
MPI_Session handle;
MPI_CHECK_ERROR_CODE(MPI_T_event_handle_alloc, (event.index, &handle, information.native(), &native_))
object_ = session(handle);
}
}
explicit event_handle (const MPI_T_event_registration native, const bool managed = false, std::optional<object_variant> object = std::nullopt)
Expand Down
76 changes: 60 additions & 16 deletions include/mpi/tool/performance_variable_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,74 @@ class performance_variable_handle
explicit performance_variable_handle (const performance_variable& variable, const session& session)
: managed_(true), session_(session)
{
if (variable.bind_type == bind_type::file)
if (variable.bind_type == bind_type::communicator)
{
MPI_Comm handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))
object_ = communicator(handle); // Unmanaged construction.
}
else if (variable.bind_type == bind_type::data_type)
{
MPI_Datatype handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))
object_ = data_type(handle);
}
else if (variable.bind_type == bind_type::error_handler)
{
MPI_Errhandler handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))
object_ = error_handler(handle);
}
else if (variable.bind_type == bind_type::file)
{
MPI_File handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))
object_ = io::file(handle);
}
else
else if (variable.bind_type == bind_type::group)
{
std::int32_t handle; // Abusing the fact that all native MPI object handles are std::int32_ts.
MPI_Group handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))

// Unmanaged construction.
if (variable.bind_type == bind_type::communicator ) object_ = communicator (handle);
else if (variable.bind_type == bind_type::data_type ) object_ = data_type (handle);
else if (variable.bind_type == bind_type::error_handler) object_ = error_handler(handle);
else if (variable.bind_type == bind_type::group ) object_ = group (handle);
else if (variable.bind_type == bind_type::information ) object_ = information (handle);
else if (variable.bind_type == bind_type::message ) object_ = message (handle);
else if (variable.bind_type == bind_type::op ) object_ = op (handle);
else if (variable.bind_type == bind_type::request ) object_ = request (handle);
else if (variable.bind_type == bind_type::window ) object_ = window (handle);
object_ = group(handle);
}
else if (variable.bind_type == bind_type::information)
{
MPI_Info handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))
object_ = information(handle);
}
else if (variable.bind_type == bind_type::message)
{
MPI_Message handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))
object_ = message(handle);
}
else if (variable.bind_type == bind_type::op)
{
MPI_Op handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))
object_ = op(handle);
}
else if (variable.bind_type == bind_type::request)
{
MPI_Request handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))
object_ = request(handle);
}
else if (variable.bind_type == bind_type::window)
{
MPI_Win handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))
object_ = window(handle);
}
#ifdef MPI_USE_LATEST
else if (variable.bind_type == bind_type::session ) object_ = session (handle);
#endif
else if (variable.bind_type == bind_type::session)
{
MPI_Session handle;
MPI_CHECK_ERROR_CODE(MPI_T_pvar_handle_alloc, (session_.native(), variable.index, &handle, &native_, &count_))
object_ = session(handle);
}
#endif
}
explicit performance_variable_handle (const MPI_T_pvar_handle& native , const session& session, const bool managed = false, const std::int32_t count = 1, std::optional<object_variant> object = std::nullopt)
: managed_(managed), native_(native), count_(count), object_(std::move(object)), session_(session)
Expand Down

0 comments on commit 14f7fa4

Please sign in to comment.