Skip to content
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

Support mpi_abi.h #1

Open
wants to merge 963 commits into
base: main
Choose a base branch
from
Open

Support mpi_abi.h #1

wants to merge 963 commits into from

Conversation

hzhou
Copy link

@hzhou hzhou commented Feb 17, 2023

Pull Request Description

Reference: pmodels#6390

Synopsis

$ ./autogen.sh
$ ./configure --prefix=[path] --eanble-mpi-abi
$ make install
$ [set path]
$ mpicc_abi -o cpi examples/cpi.c

$ mpirun -n 2 ./cpi

$ ldd ./cpi

$ nm [path/to/]libmpi_abi.so | less

Checklist

  • Do not break MPICH ABI
  • handle object constants
  • status objects
  • convert integer constants
  • make install
  • mpicc_abi -o cpi_abi examples/cpi.c && mpirun -n 2 ./cpi_abi
  • Pass mpich testsuite

Provide cptr version of MPI_Alloc_mem. This is needed by the generic
interface in mpi.mod.
Provide specific interface so MPI_Alloc_mem could return baseptr as
TYPE(C_PTR), as specified in the standard.
We need PMPI_Wtime and PMPI_Wtick since otherwise the compiler doesn't
know the function return type. We need PMPI interfaces for other
functions for the same reason that we need MPI interfaces.
It was a bug previously but it did not trigger test failures due to not
using generic interfaces. Now we it triggers compile error that we
switched all functions to generic interfaces.
Add test for MPI_Alloc_mem and return Type(C_PTR).
binding/f90: Add `c_ptr` interface for `MPI_Alloc_mem`

Approved-by: Ken Raffenetti
Move MPIR_Request_completion_processing inside MPIR_Test and MPIR_Wait.
The call frees potential resource and transfers the status. Do it inside
MPIR_Test and MPIR_Wait makes the code more consistent and cleaner.
For MPI_{Test,Wait}_{all,any,some}, free the completed requests and set
to MPI_REQUEST_NULL in the binding layer. This prepares for
MPI_Get_status_{all,any,some} that are added in MPI 4.1.

We also convert all request pointers for MPI_Testall and MPI_Waitall.
MPI_Waitall will need to convert all pointers anyway, so there shouldn't
be performance difference -- if any, should be better. MPI_Testall has
no impact for count < 64, the batch size. The impact of large testall
request arrays will be negligible compared to the overhead of running
progress.
This allows gforker and remshell to handle longer pmi commands and
commodate longer kvs values. This is needed to handle larger port names
such as the case for ch4:ucx.
Allow users to request support for MPI memory allocation kinds via this
command line option. The string will be propagated to the proxies and
returned via PMI job attribute query (key="PMI_mpi_memory_alloc_kinds").
pm: increase PMI max length to 4096

Approved-by: Ken Raffenetti
* Try avoid print handle as int
* MPI_MESSAGE_NULL may not be MPI_REQUEST_NULL
* MPI_Comm may not be the same as MPI_Win
* Cast to (long long) to print MPI_Count
We should not assume handles to be of integer type.
Custom clean up code (ref. MPI_Comm_spawn_multiple) are loaded in
func['code-clean_up']. We need avoid overwriting this attribute or we
will lose the custom cleanup code then function is being processed
twice.
Newer gcc warns when non-null array constants such as MPI_UNWEIGHTED is
passed to paramber typed as "int param[]". Make the parameter type
simply a pointer avoids such warnings.
Remove the assumption that MPI_PROC_NULL is -1 and MPI_ANY_SOURCE is -2.
The constants may be defined as negative integers, as in the current ABI
draft.
MPID_MAX_PORT_NAME is 1024, and it is the same as abi MPI_MAX_PORT_NAME.
Alternatively, we can raise MPID_MAX_PORT_NAME to higher value.
Then internal code need deal with both the types from ABI header and the
actual types used by MPICH. Generate mpi_abi_internal.h from mpi_abi.h
by renaming all MPI_ typenames into ABI_ prefix. Generate mpi_abi_util.c
to initialize an internal table for builtin datatypes and ops
conversions.

Generates:
    src/binding/abi/mpi_abi_internal.h
    src/binding/abi/mpi_abi_util.c
Various conversion functions.
Use --enable-mpi-abi configure option to enable build and installing
libmpi_abi.so.
Dump c_binding_abi.c, to be linked into libmpi_abi.so.
If MPI_ABI is defined, make mpi.h to effectively the same as mpi_abi.h.
This allows applications to use mpicc_abi to compile their code without
any changes.
When BUILD_MPI_ABI is defined, include mpi_abi_internal.h, and exclude
the portion that defines constants and typedefs that are already defined
in mpi_abi_internal.h. We essentially swapping the ABI for all internal
code.

Note that we need to always define the MPICH specific parts or some
internal code won't build.

MPICH_SUPPRESS_PROTOTYPES is no longer used, so we removed it.
Internal all handles object may not be part of the ABI. Add check macro
to replace it on entry.
The ABI signature of callback functions can be different. We need
convert the handle input upon calling callbacks.
MPI-5 ABI may define various DUP_FN as constants. We can easily swap
them during input.
MPI_COMBINER_HVECTOR_INTEGER, MPI_COMBINER_HINDEXED_INTEGER, and
MPI_COMBINER_STRUCT_INTEGER are removed in the current MPI standards and
thus can be missing from the abi header. Add macro-guard to prevent
compile failures.
* Pass --enable-mpi-abi to romio configure
* Build libromio_abi.so and libpromio_abi.so when enabled
* Include mpi_abi.h instead of mpi.h when BUILD_MPI_ABI is defined
* internally adio.h will include mpio.h without abi, and
  romio_abi_internal.h with abi. I.e. mpio.h is skipped ifdef
  BUILD_MPI_ABI.
Three routines are defined in ROMIO, potentially using ABI header. We
need handler conversion to use inside MPICH.

Only include mpir_ext.h in the code that needs it. With BUILD_MPI_ABI,
we need alter the function parameter types for conversions.

Since we no longer include mpir_ext.h in the binding files, we need
explicitly declare them. We can treat them as void pointers to avoid the
distinction between ABI and non-ABI versions.
ROMIO directly uses the MPI ABI header since it sits on top of the MPI
layer. As such, we need add ABI handle conversions for functions defined
in MPICH and called by ROMIO.

Define them all in src/glue/romio/glue_romio.c.
Update builtin handle constants based on upstream huffman coding scheme.  Ref:
https://github.com/mpiwg-abi/specification-text-draft/blob/main/print-handle-constants.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants