Skip to content

Commit

Permalink
api: add handle to/from int conversion apis
Browse files Browse the repository at this point in the history
As proposed in the MPI 4.2 ABI proposal --
mpi-forum/mpi-standard#978.
  • Loading branch information
hzhou committed Dec 19, 2024
1 parent 4dcfba2 commit 1c06af1
Show file tree
Hide file tree
Showing 3 changed files with 250 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/binding/abi/mpi_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,29 @@ MPI_Session MPI_Session_f2c(MPI_Fint session);
MPI_Fint MPI_Win_c2f(MPI_Win win);
MPI_Win MPI_Win_f2c(MPI_Fint win);

int MPI_Comm_toint(MPI_Comm comm);
MPI_Comm MPI_Comm_fromint(int comm);
int MPI_Errhandler_toint(MPI_Errhandler errhandler);
MPI_Errhandler MPI_Errhandler_fromint(int errhandler);
int MPI_Type_toint(MPI_Datatype datatype);
MPI_Datatype MPI_Type_fromint(int datatype);
int MPI_File_toint(MPI_File file);
MPI_File MPI_File_fromint(int file);
int MPI_Group_toint(MPI_Group group);
MPI_Group MPI_Group_fromint(int group);
int MPI_Info_toint(MPI_Info info);
MPI_Info MPI_Info_fromint(int info);
int MPI_Message_toint(MPI_Message message);
MPI_Message MPI_Message_fromint(int message);
int MPI_Op_toint(MPI_Op op);
MPI_Op MPI_Op_fromint(int op);
int MPI_Request_toint(MPI_Request request);
MPI_Request MPI_Request_fromint(int request);
int MPI_Session_toint(MPI_Session session);
MPI_Session MPI_Session_fromint(int session);
int MPI_Win_toint(MPI_Win win);
MPI_Win MPI_Win_fromint(int win);

/* MPI_T functions */
int MPI_T_category_changed(int *update_number);
int MPI_T_category_get_categories(int cat_index, int len, int indices[]);
Expand Down Expand Up @@ -1881,6 +1904,29 @@ MPI_Session PMPI_Session_f2c(MPI_Fint session);
MPI_Fint PMPI_Win_c2f(MPI_Win win);
MPI_Win PMPI_Win_f2c(MPI_Fint win);

int PMPI_Comm_toint(MPI_Comm comm);
MPI_Comm PMPI_Comm_fromint(int comm);
int PMPI_Errhandler_toint(MPI_Errhandler errhandler);
MPI_Errhandler PMPI_Errhandler_fromint(int errhandler);
int PMPI_Type_toint(MPI_Datatype datatype);
MPI_Datatype PMPI_Type_fromint(int datatype);
int PMPI_File_toint(MPI_File file);
MPI_File PMPI_File_fromint(int file);
int PMPI_Group_toint(MPI_Group group);
MPI_Group PMPI_Group_fromint(int group);
int PMPI_Info_toint(MPI_Info info);
MPI_Info PMPI_Info_fromint(int info);
int PMPI_Message_toint(MPI_Message message);
MPI_Message PMPI_Message_fromint(int message);
int PMPI_Op_toint(MPI_Op op);
MPI_Op PMPI_Op_fromint(int op);
int PMPI_Request_toint(MPI_Request request);
MPI_Request PMPI_Request_fromint(int request);
int PMPI_Session_toint(MPI_Session session);
MPI_Session PMPI_Session_fromint(int session);
int PMPI_Win_toint(MPI_Win win);
MPI_Win PMPI_Win_fromint(int win);

/* PMPI_T functions */
int PMPI_T_category_changed(int *update_number);
int PMPI_T_category_get_categories(int cat_index, int len, int indices[]);
Expand Down
201 changes: 201 additions & 0 deletions src/binding/c/abi_api.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
# vim: set ft=c:

MPI_Comm_toint:
.return: INTEGER
comm: COMMUNICATOR
.desc: converts MPI_Comm to an integer handle
.impl: direct
.skip: Fortran, Errors
{
return (int) comm;
}

MPI_Comm_fromint:
.return: COMMUNICATOR
comm: INTEGER
.desc: converts an integer handle to MPI_Comm
.impl: direct
.skip: Fortran, Errors
{
return (MPI_Comm) comm;
}

MPI_Errhandler_toint:
.return: INTEGER
errhandler: ERRHANDLER
.desc: converts MPI_Errhandler to an integer handle
.impl: direct
.skip: Fortran, Errors
{
return (int) errhandler;
}

MPI_Errhandler_fromint:
.return: ERRHANDLER
errhandler: INTEGER
.desc: converts an integer handle to MPI_Errhandler
.impl: direct
.skip: Fortran, Errors
{
return (MPI_Errhandler) errhandler;
}

MPI_Group_toint:
.return: INTEGER
group: GROUP
.desc: converts MPI_Group to an integer handle
.impl: direct
.skip: Fortran, Errors
{
return (int) group;
}

MPI_Group_fromint:
.return: GROUP
group: INTEGER
.desc: converts an integer handle to MPI_Group
.impl: direct
.skip: Fortran, Errors
{
return (MPI_Group) group;
}

MPI_Info_toint:
.return: INTEGER
info: INFO
.desc: converts MPI_Info to an integer handle
.impl: direct
.skip: Fortran, Errors
{
return (int) info;
}

MPI_Info_fromint:
.return: INFO
info: INTEGER
.desc: converts an integer handle to MPI_Info
.impl: direct
.skip: Fortran, Errors
{
return (MPI_Info) info;
}

MPI_Message_toint:
.return: INTEGER
message: MESSAGE
.desc: converts MPI_Message to an integer handle
.impl: direct
.skip: Fortran, Errors
{
return (int) message;
}

MPI_Message_fromint:
.return: MESSAGE
message: INTEGER
.desc: converts an integer handle to MPI_Message
.impl: direct
.skip: Fortran, Errors
{
return (MPI_Message) message;
}

MPI_Op_toint:
.return: INTEGER
op: OPERATION
.desc: converts MPI_Op to an integer handle
.impl: direct
.skip: Fortran, Errors
{
return (int) op;
}

MPI_Op_fromint:
.return: OPERATION
op: INTEGER
.desc: converts an integer handle to MPI_Op
.impl: direct
.skip: Fortran, Errors
{
return (MPI_Op) op;
}

MPI_Request_toint:
.return: INTEGER
request: REQUEST
.desc: converts MPI_Request to an integer handle
.impl: direct
.skip: Fortran, Errors
{
return (int) request;
}

MPI_Request_fromint:
.return: REQUEST
request: INTEGER
.desc: converts an integer handle to MPI_Request
.impl: direct
.skip: Fortran, Errors
{
return (MPI_Request) request;
}

MPI_Session_toint:
.request: INTEGER
session: SESSION
.desc: converts MPI_Session to an integer handle
.impl: direct
.skip: Fortran, Errors
{
return (int) session;
}

MPI_Session_fromint:
.return: SESSION
session: INTEGER
.desc: converts an integer handle to MPI_Session
.impl: direct
.skip: Fortran, Errors
{
return (MPI_Session) session;
}

MPI_Type_toint:
.return: INTEGER
datatype: DATATYPE
.desc: converts MPI_Type to an integer handle
.impl: direct
.skip: Fortran, Errors
{
return (int) datatype;
}

MPI_Type_fromint:
.return: DATATYPE
datatype: INTEGER
.desc: converts an integer handle to MPI_Type
.impl: direct
.skip: Fortran, Errors
{
return (MPI_Datatype) datatype;
}

MPI_Win_toint:
.return: INTEGER
win: WINDOW
.desc: converts MPI_Win to an integer handle
.impl: direct
.skip: Fortran, Errors
{
return (int) win;
}

MPI_Win_fromint:
.return: WINDOW
win: INTEGER
.desc: converts an integer handle to MPI_Win
.impl: direct
.skip: Fortran, Errors
{
return (MPI_Win) win;
}
3 changes: 3 additions & 0 deletions src/binding/custom_mapping.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ LIS_KIND_MAP:
STREAM: handle
IOVEC: None
ASYNC_THING: None
INTEGER: integer

SMALL_F90_KIND_MAP:
GPU_TYPE: INTEGER
Expand Down Expand Up @@ -42,10 +43,12 @@ SMALL_C_KIND_MAP:
STREAM: MPIX_Stream
IOVEC: MPIX_Iov
ASYNC_THING: MPIX_Async_thing
INTEGER: int

BIG_C_KIND_MAP:
GPU_TYPE: int
GREQUEST_CLASS: MPIX_Grequest_class
STREAM: MPIX_Stream
IOVEC: MPIX_Iov
ASYNC_THING: MPIX_Async_thing
INTEGER: int

0 comments on commit 1c06af1

Please sign in to comment.