-
Notifications
You must be signed in to change notification settings - Fork 988
Emit MPI Standard ABI handles in MPI_T event payloads #14306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,17 +71,31 @@ int ompi_errhandler_invoke(ompi_errhandler_t *errhandler, void *mpi_object, | |
| } | ||
| payload.err_code = (int32_t) err_code; | ||
| payload.object_type = object_bind; | ||
| /* XXX ABI: the MPI_Errhandler handle and the invoking object's handle | ||
| must match the registering MPI_T tool's ABI (ompi_mpit_callback_abi). */ | ||
| /* The MPI_Errhandler handle and the invoking object's handle must match | ||
| the registering MPI_T tool's ABI (ompi_mpit_callback_abi). So must | ||
| the err_code and object_type integer values, whose encodings differ | ||
| between the two ABIs. */ | ||
| if (OMPI_MPIT_ABI_OMPI == ompi_mpit_callback_abi) { | ||
| payload.errhandler_handle = (uint64_t) (uintptr_t) errhandler; | ||
| payload.object_handle = (uint64_t) (uintptr_t) mpi_object; | ||
| } else { | ||
| /* TODO ABI (#13280): set the MPI Standard ABI handle values -- the | ||
| MPI_Errhandler, and mpi_object converted per object_type | ||
| (MPI_Comm / MPI_Win / MPI_File / MPI_Session). */ | ||
| payload.errhandler_handle = 0; | ||
| payload.object_handle = 0; | ||
| /* MPI Standard ABI: publish integer handles and Standard-ABI | ||
| integer values. The errhandler is converted as an | ||
| MPI_Errhandler; the invoking object is converted per its binding | ||
| kind (MPI_Comm / MPI_Win / MPI_File / MPI_Session). An object | ||
| with no binding (e.g. a predefined handler routed before | ||
| MPI_INIT) has object_bind == NO_OBJECT and a 0 object_handle, | ||
| matching the Open MPI ABI's "0 when not available" behavior. The | ||
| err_code and object_type integer values are remapped to their | ||
| Standard-ABI encodings. */ | ||
| payload.err_code = ompi_mpit_abi_error((int32_t) err_code); | ||
| payload.object_type = ompi_mpit_abi_bind(object_bind); | ||
| payload.errhandler_handle | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Standard-ABI branch converts the two handle elements of the errhandler_invoked payload but leaves the other two elements —
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be addressed by commit b26d9a1 |
||
| = ompi_mpit_abi_handle(errhandler, MPI_T_BIND_MPI_ERRHANDLER); | ||
| payload.object_handle | ||
| = (MPI_T_BIND_NO_OBJECT == object_bind) | ||
| ? 0 | ||
| : ompi_mpit_abi_handle(mpi_object, object_bind); | ||
| } | ||
| mca_base_event_raise(ompi_event_errhandler_invoked, NULL, &payload); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ | ||
| /* | ||
| * Copyright (c) 2026 Triad National Security, LLC. All rights | ||
| * reserved. | ||
| * $COPYRIGHT$ | ||
| * | ||
| * Additional copyrights may follow | ||
| * | ||
| * $HEADER$ | ||
| * | ||
| * MPI Standard ABI handle converter for MPI_T event payloads. | ||
| * | ||
| * The MPI_T event producers in libopen_mpi publish MPI object handles | ||
| * (communicator, window, session, error handler, file) in their event | ||
| * payloads. Under the MPI Standard ABI a tool expects those handles as the | ||
| * Standard-ABI integer handle, not the internal object pointer. The | ||
| * intern->ABI converters (ompi_convert_comm_ompi_to_standard(), etc.) are | ||
| * generated into abi_converters.h and compiled only into libmpi_abi (the upper | ||
| * layer), so the raise sites in libopen_mpi cannot call them directly (the | ||
| * OPAL->OMPI layering forbids an upward link dependency). | ||
| * | ||
| * This translation unit lives in libmpi_abi and provides the converter. The | ||
| * Standard-ABI init entry points (MPI_Init / MPI_Init_thread / MPI_Session_init) | ||
| * install it downward with ompi_mpit_register_abi_handle_convert(), mirroring | ||
| * ompi_mpi_instance_register_mpiext_init(). | ||
| */ | ||
|
|
||
| #include "ompi_config.h" | ||
|
|
||
| #include <stddef.h> | ||
| #include <stdint.h> | ||
|
|
||
| #include "ompi/communicator/communicator.h" | ||
| #include "ompi/win/win.h" | ||
| #include "ompi/file/file.h" | ||
| #include "ompi/instance/instance.h" | ||
| #include "ompi/errhandler/errhandler.h" | ||
|
|
||
| #include "ompi/mpi/c/abi.h" | ||
| #include "ompi/mpi/c/abi_converters.h" | ||
| #include "ompi/mpi/c/mpit_abi_handle_convert.h" | ||
|
|
||
| #include "ompi/runtime/ompi_mpit_events.h" | ||
|
|
||
| uint64_t ompi_mpit_abi_handle_convert_impl(void *object, int handle_kind) | ||
| { | ||
| if (NULL == object) { | ||
| return 0; | ||
| } | ||
|
|
||
| /* handle_kind is a public MPI_T_BIND_* binding constant naming the class of | ||
| the object; convert the internal object pointer to the Standard-ABI | ||
| integer handle with the matching generated intern->ABI converter, then | ||
| widen to uint64_t. Each converter returns a mangled *_ABI_INTERNAL | ||
| handle (a pointer-width value carrying either a small reserved-handle | ||
| index or the object pointer), so route it through uintptr_t. */ | ||
| switch (handle_kind) { | ||
| case MPI_T_BIND_MPI_COMM: | ||
| return (uint64_t) (uintptr_t) | ||
| ompi_convert_comm_ompi_to_standard((ompi_communicator_t *) object); | ||
| case MPI_T_BIND_MPI_WIN: | ||
| return (uint64_t) (uintptr_t) | ||
| ompi_convert_win_ompi_to_standard((ompi_win_t *) object); | ||
| case MPI_T_BIND_MPI_SESSION: | ||
| return (uint64_t) (uintptr_t) | ||
| ompi_convert_session_ompi_to_standard((ompi_instance_t *) object); | ||
| case MPI_T_BIND_MPI_ERRHANDLER: | ||
| return (uint64_t) (uintptr_t) | ||
| ompi_convert_intern_errorhandler_abi_errorhandler( | ||
| (ompi_errhandler_t *) object); | ||
| case MPI_T_BIND_MPI_FILE: | ||
| return (uint64_t) (uintptr_t) | ||
| ompi_convert_file_ompi_to_standard((ompi_file_t *) object); | ||
| default: | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
| int32_t ompi_mpit_abi_error_convert_impl(int32_t err_code) | ||
| { | ||
| /* Map an internal MPI error code to its MPI Standard ABI value. */ | ||
| return (int32_t) ompi_convert_intern_error_abi_error((int) err_code); | ||
| } | ||
|
|
||
| int32_t ompi_mpit_abi_bind_convert_impl(int32_t object_bind) | ||
| { | ||
| /* Map an internal MPI_T_BIND_* value to its MPI Standard ABI value. */ | ||
| return (int32_t) ompi_convert_t_bind_ompi_to_standard((int) object_bind); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ | ||
| /* | ||
| * Copyright (c) 2026 Triad National Security, LLC. All rights | ||
| * reserved. | ||
| * $COPYRIGHT$ | ||
| * | ||
| * Additional copyrights may follow | ||
| * | ||
| * $HEADER$ | ||
| * | ||
| * Declaration of the MPI Standard ABI handle converter for MPI_T event | ||
| * payloads. The implementation lives in mpit_abi_handle_convert.c and is | ||
| * compiled only into libmpi_abi. The Standard-ABI init entry points install | ||
| * it downward via ompi_mpit_register_abi_handle_convert() so the libopen_mpi | ||
| * producer raise sites can reach it without an upward link dependency. | ||
| */ | ||
|
|
||
| #ifndef OMPI_MPI_C_MPIT_ABI_HANDLE_CONVERT_H | ||
| #define OMPI_MPI_C_MPIT_ABI_HANDLE_CONVERT_H | ||
|
|
||
| #include "ompi_config.h" | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| BEGIN_C_DECLS | ||
|
|
||
| /* Convert an internal MPI object handle (pointer) to its MPI Standard ABI | ||
| integer handle, widened to uint64_t. `handle_kind` is a public MPI_T_BIND_* | ||
| binding constant (MPI_T_BIND_MPI_COMM / _WIN / _SESSION / _ERRHANDLER / | ||
| _FILE). This is the ompi_mpit_abi_handle_convert_fn_t installed via | ||
| ompi_mpit_register_abi_handle_convert(). */ | ||
| OMPI_DECLSPEC uint64_t ompi_mpit_abi_handle_convert_impl(void *object, | ||
| int handle_kind); | ||
|
|
||
| /* Convert an internal MPI error code to its MPI Standard ABI value. This is | ||
| the ompi_mpit_abi_value_convert_fn_t installed via | ||
| ompi_mpit_register_abi_error_convert(). */ | ||
| OMPI_DECLSPEC int32_t ompi_mpit_abi_error_convert_impl(int32_t err_code); | ||
|
|
||
| /* Convert an internal MPI_T_BIND_* binding kind to its MPI Standard ABI value. | ||
| This is the ompi_mpit_abi_value_convert_fn_t installed via | ||
| ompi_mpit_register_abi_bind_convert(). */ | ||
| OMPI_DECLSPEC int32_t ompi_mpit_abi_bind_convert_impl(int32_t object_bind); | ||
|
|
||
| END_C_DECLS | ||
|
|
||
| #endif /* OMPI_MPI_C_MPIT_ABI_HANDLE_CONVERT_H */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
communicator_name_setevent is object-bound: a tool can only receive this (now correctly converted) payload after binding a registration to a specific communicator viaMPI_T_event_handle_alloc'sobj_handle. That binding-side conversion is still missing:ompi/mpi/tool/event_handle_alloc.c.inpassesobj_handlestraight tomca_base_event_handle_allocwith no Standard-ABI-to-internal conversion (and the spec's sec. 6.1 bullet retained in this diff still says "The Standard ABI must convert"). Under the Standard ABI, binding works for user-created communicators only by accident (their ABI handle happens to equal the internal pointer) and silently never matches for predefined handles such asMPI_COMM_WORLD, whose Standard-ABI handle is a small reserved integer. If the binding side is deliberately deferred to a follow-up, the spec's sec. 10 test-coverage claim of "end to end" Standard-ABI coverage overstates what is exercised; either close the gap or note it explicitly as remaining work inspecs/mpi-t-events/spec.md.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be addressed by commit b26d9a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry this event_handle_alloc.c.in changes will be deferred to a separate PR. Comment about deferring solution concerning event_register_callback.c.in is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed by PR #14358