Skip to content

Commit

Permalink
Support building with MPI 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Nov 28, 2023
1 parent ba3aea7 commit a97f1c8
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 32 deletions.
1 change: 0 additions & 1 deletion mpiwrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ add_library(mpiwrapper
mpiwrapper.h
mpiwrapper.c
mpiwrapper-mpi3.c
mpiwrapper-mpi40.c
mpiwrapper.F90
mpiwrapper_functions.F90
)
Expand Down
30 changes: 0 additions & 30 deletions mpiwrapper/mpiwrapper-mpi40.c

This file was deleted.

78 changes: 77 additions & 1 deletion mpiwrapper/mpiwrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
#define MPI_User_function_c MPI_User_function
#endif


////////////////////////////////////////////////////////////////////////////////

// Consistency checks
Expand Down Expand Up @@ -1580,15 +1579,23 @@ int MPIABI_Buffer_detach_c(void *buffer_addr, MPIABI_Count *size) {
}

int MPIABI_Buffer_flush(void) {
#if MPI_VERSION_NUMBER >= 410
int ierr = MPI_Buffer_flush();
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Buffer_iflush(MPIABI_Request *request) {
#if MPI_VERSION_NUMBER >= 410
MPI_Request mpi_request;
int ierr = MPI_Buffer_iflush(&mpi_request);
*request = mpi2abi_request(mpi_request);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Cancel(MPIABI_Request *request) {
Expand All @@ -1600,6 +1607,7 @@ int MPIABI_Cancel(MPIABI_Request *request) {
}

int MPIABI_Comm_attach_buffer(MPIABI_Comm comm, void *buffer, int size) {
#if MPI_VERSION_NUMBER >= 410
if (buffer == MPIABI_BUFFER_AUTOMATIC)
buffer = MPI_BUFFER_AUTOMATIC;
int ierr = MPI_Comm_attach_buffer(abi2mpi_comm(comm), buffer, size);
Expand All @@ -1608,40 +1616,60 @@ int MPIABI_Comm_attach_buffer(MPIABI_Comm comm, void *buffer, int size) {

int MPIABI_Comm_attach_buffer_c(MPIABI_Comm comm, void *buffer,
MPIABI_Count size) {
#if MPI_VERSION_NUMBER >= 410
if (buffer == MPIABI_BUFFER_AUTOMATIC)
buffer = MPI_BUFFER_AUTOMATIC;
int ierr = MPI_Comm_attach_buffer_c(abi2mpi_comm(comm), buffer, size);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Comm_detach_buffer(MPIABI_Comm comm, void *buffer_addr, int *size) {
#if MPI_VERSION_NUMBER >= 410
int ierr = MPI_Comm_detach_buffer(abi2mpi_comm(comm), buffer_addr, size);
if (*(void **)buffer_addr == MPI_BUFFER_AUTOMATIC)
*(void **)buffer_addr = MPIABI_BUFFER_AUTOMATIC;
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Comm_detach_buffer_c(MPIABI_Comm comm, void *buffer_addr,
MPIABI_Count *size) {
#if MPI_VERSION_NUMBER >= 410
MPI_Count mpi_size;
int ierr =
MPI_Comm_detach_buffer_c(abi2mpi_comm(comm), buffer_addr, &mpi_size);
if (*(void **)buffer_addr == MPI_BUFFER_AUTOMATIC)
*(void **)buffer_addr = MPIABI_BUFFER_AUTOMATIC;
*size = mpi_size;
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Comm_flush_buffer(MPIABI_Comm comm) {
#if MPI_VERSION_NUMBER >= 410
int ierr = MPI_Comm_flush_buffer(abi2mpi_comm(comm));
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Comm_iflush_buffer(MPIABI_Comm comm, MPIABI_Request *request) {
#if MPI_VERSION_NUMBER >= 410
MPI_Request mpi_request;
int ierr = MPI_Comm_iflush_buffer(abi2mpi_comm(comm), &mpi_request);
*request = mpi2abi_request(mpi_request);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Get_count(const MPIABI_Status *status, MPIABI_Datatype datatype,
Expand Down Expand Up @@ -1970,6 +1998,7 @@ int MPIABI_Request_get_status_all(int count,
const MPIABI_Request array_of_requests[],
int *flag,
MPIABI_Status array_of_statuses[]) {
#if MPI_VERSION_NUMBER >= 410
MPI_Request array_of_mpi_requests[count];
for (int n = 0; n < count; ++n)
array_of_mpi_requests[n] = abi2mpi_request(array_of_requests[n]);
Expand All @@ -1982,12 +2011,16 @@ int MPIABI_Request_get_status_all(int count,
array_of_statuses[n] =
mpi2abi_status(((MPI_Status *)array_of_statuses)[n]);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Request_get_status_any(int count,
const MPIABI_Request array_of_requests[],
int *index, int *flag,
MPIABI_Status *status) {
#if MPI_VERSION_NUMBER >= 410
MPI_Request array_of_mpi_requests[count];
for (int n = 0; n < count; ++n)
array_of_mpi_requests[n] = abi2mpi_request(array_of_requests[n]);
Expand All @@ -1997,12 +2030,16 @@ int MPIABI_Request_get_status_any(int count,
if (*flag)
mpi2abi_statusptr(mpi_status);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Request_get_status_some(int incount,
const MPIABI_Request array_of_requests[],
int *outcount, int array_of_indices[],
MPIABI_Status array_of_statuses[]) {
#if MPI_VERSION_NUMBER >= 410
MPI_Request array_of_mpi_requests[incount];
for (int n = 0; n < incount; ++n)
array_of_mpi_requests[n] = abi2mpi_request(array_of_requests[n]);
Expand All @@ -2016,6 +2053,9 @@ int MPIABI_Request_get_status_some(int incount,
array_of_statuses[n] =
mpi2abi_status(((MPI_Status *)array_of_statuses)[n]);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Rsend(const void *buf, int count, MPIABI_Datatype datatype, int dest,
Expand Down Expand Up @@ -2147,52 +2187,76 @@ int MPIABI_Sendrecv_replace_c(void *buf, MPIABI_Count count,

int MPIABI_Session_attach_buffer(MPIABI_Session session, void *buffer,
int size) {
#if MPI_VERSION_NUMBER >= 410
if (buffer == MPIABI_BUFFER_AUTOMATIC)
buffer = MPI_BUFFER_AUTOMATIC;
int ierr = MPI_Session_attach_buffer(abi2mpi_session(session), buffer, size);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Session_attach_buffer_c(MPIABI_Session session, void *buffer,
MPIABI_Count size) {
#if MPI_VERSION_NUMBER >= 410
if (buffer == MPIABI_BUFFER_AUTOMATIC)
buffer = MPI_BUFFER_AUTOMATIC;
int ierr =
MPI_Session_attach_buffer_c(abi2mpi_session(session), buffer, size);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Session_detach_buffer(MPIABI_Session session, void *buffer_addr,
int *size) {
#if MPI_VERSION_NUMBER >= 410
int ierr =
MPI_Session_detach_buffer(abi2mpi_session(session), buffer_addr, size);
if (*(void **)buffer_addr == MPI_BUFFER_AUTOMATIC)
*(void **)buffer_addr = MPIABI_BUFFER_AUTOMATIC;
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Session_detach_buffer_c(MPIABI_Session session, void *buffer_addr,
MPIABI_Count *size) {
#if MPI_VERSION_NUMBER >= 410
MPI_Count mpi_size;
int ierr = MPI_Session_detach_buffer_c(abi2mpi_session(session), buffer_addr,
&mpi_size);
if (*(void **)buffer_addr == MPI_BUFFER_AUTOMATIC)
*(void **)buffer_addr = MPIABI_BUFFER_AUTOMATIC;
*size = mpi_size;
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Session_flush_buffer(MPIABI_Session session) {
#if MPI_VERSION_NUMBER >= 410
int ierr = MPI_Session_flush_buffer(abi2mpi_session(session));
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Session_iflush_buffer(MPIABI_Session session,
MPIABI_Request *request) {
#if MPI_VERSION_NUMBER >= 410
MPI_Request mpi_request;
int ierr = MPI_Session_iflush_buffer(abi2mpi_session(session), &mpi_request);
*request = mpi2abi_request(mpi_request);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Ssend(const void *buf, int count, MPIABI_Datatype datatype, int dest,
Expand Down Expand Up @@ -2251,24 +2315,36 @@ int MPIABI_Startall(int count, MPIABI_Request array_of_requests[]) {
}

int MPIABI_Status_get_error(MPIABI_Status *status, int *err) {
#if MPI_VERSION_NUMBER >= 410
MPI_Status mpi_status = abi2mpi_status(*status);
int ierr = MPI_Status_get_error(&mpi_status, err);
*err = mpi2abi_errorcode(*err);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Status_get_source(MPIABI_Status *status, int *source) {
#if MPI_VERSION_NUMBER >= 410
MPI_Status mpi_status = abi2mpi_status(*status);
int ierr = MPI_Status_get_source(&mpi_status, source);
*source = mpi2abi_proc(*source);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Status_get_tag(MPIABI_Status *status, int *tag) {
#if MPI_VERSION_NUMBER >= 410
MPI_Status mpi_status = abi2mpi_status(*status);
int ierr = MPI_Status_get_tag(&mpi_status, tag);
*tag = mpi2abi_tag(*tag);
return mpi2abi_errorcode(ierr);
#else
assert(0);
#endif
}

int MPIABI_Test(MPIABI_Request *request, int *flag, MPIABI_Status *status) {
Expand Down

0 comments on commit a97f1c8

Please sign in to comment.