Skip to content

Commit

Permalink
Add headers collecting compatibility for removals and deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
dalcinl committed Mar 21, 2024
1 parent 7a13cd8 commit 49e07bd
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 0 deletions.
76 changes: 76 additions & 0 deletions mpi-api-deprecated.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#pragma once

#if !defined(MPI_ABI_static_inline)
# if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus)
# define MPI_ABI_static_inline static inline
# else
# define MPI_ABI_static_inline static __inline
# endif
#endif

/* MPI deprecated types and constants */

#define MPI_Copy_function MPI_Comm_copy_attr_function
#define MPI_Delete_function MPI_Comm_delete_attr_function
#define MPI_DUP_FN MPI_COMM_DUP_FN
#define MPI_NULL_COPY_FN MPI_COMM_NULL_COPY_FN
#define MPI_NULL_DELETE_FN MPI_COMM_NULL_DELETE_FN

#define MPI_HOST MPI_KEYVAL_INVALID
#define MPI_T_ERR_INVALID_ITEM MPI_T_ERR_INVALID_INDEX

/* MPI deprecated functions */

#define MPI_Attr_delete MPI_Comm_delete_attr
#define MPI_Attr_get MPI_Comm_get_attr
#define MPI_Attr_put MPI_Comm_set_attr

#define MPI_Keyval_create MPI_Comm_create_keyval
#define MPI_Keyval_free MPI_Comm_free_keyval

#define MPI_Get_elements_x MPI_Get_elements_c
#define MPI_Status_set_elements_x MPI_Status_set_elements_c

#define MPI_Type_get_extent_x MPI_Type_get_extent_c
#define MPI_Type_get_true_extent_x MPI_Type_get_true_extent_c
#define MPI_Type_size_x MPI_Type_size_c

MPI_ABI_static_inline int MPI_Info_get(MPI_Info MPI_info, const char *MPI_key, int MPI_valuelen, char *MPI_value, int *MPI_flag) {
int MPI_buflen = MPI_valuelen + 1;
return MPI_Info_get_string(MPI_info, MPI_key, &MPI_buflen, MPI_value, MPI_flag);
}

MPI_ABI_static_inline int MPI_Info_get_valuelen(MPI_Info MPI_info, const char *MPI_key, int *MPI_valuelen, int *MPI_flag) {
int MPI_ierr; int MPI_buflen = 0; char MPI_value[1] = {0};
MPI_ierr = MPI_Info_get_string(MPI_info, MPI_key, MPI_valuelen ? &MPI_buflen : MPI_valuelen, MPI_value, MPI_flag);
if (MPI_ierr == MPI_SUCCESS && MPI_valuelen) *MPI_valuelen = MPI_buflen - 1;
return MPI_ierr;
}

/* PMPI deprecated functions */

#define PMPI_Attr_delete PMPI_Comm_delete_attr
#define PMPI_Attr_get PMPI_Comm_get_attr
#define PMPI_Attr_put PMPI_Comm_set_attr

#define PMPI_Keyval_create PMPI_Comm_create_keyval
#define PMPI_Keyval_free PMPI_Comm_free_keyval

#define PMPI_Get_elements_x PMPI_Get_elements_c
#define PMPI_Status_set_elements_x PMPI_Status_set_elements_c

#define PMPI_Type_get_extent_x PMPI_Type_get_extent_c
#define PMPI_Type_get_true_extent_x PMPI_Type_get_true_extent_c
#define PMPI_Type_size_x PMPI_Type_size_c

MPI_ABI_static_inline int PMPI_Info_get(MPI_Info MPI_info, const char *MPI_key, int MPI_valuelen, char *MPI_value, int *MPI_flag) {
int MPI_buflen = MPI_valuelen + 1;
return PMPI_Info_get_string(MPI_info, MPI_key, &MPI_buflen, MPI_value, MPI_flag);
}

MPI_ABI_static_inline int PMPI_Info_get_valuelen(MPI_Info MPI_info, const char *MPI_key, int *MPI_valuelen, int *MPI_flag) {
int MPI_ierr; int MPI_buflen = 0; char MPI_value[1] = {0};
MPI_ierr = PMPI_Info_get_string(MPI_info, MPI_key, MPI_valuelen ? &MPI_buflen : MPI_valuelen, MPI_value, MPI_flag);
if (MPI_ierr == MPI_SUCCESS && MPI_valuelen) *MPI_valuelen = MPI_buflen - 1;
return MPI_ierr;
}
80 changes: 80 additions & 0 deletions mpi-api-removed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#pragma once

#if !defined(MPI_ABI_static_inline)
# if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus)
# define MPI_ABI_static_inline static inline
# else
# define MPI_ABI_static_inline static __inline
# endif
#endif

/* MPI removed types and constants */

#define MPI_Handler_function MPI_Comm_errhandler_function

#define MPI_LB MPI_DATATYPE_NULL
#define MPI_UB MPI_DATATYPE_NULL

/* MPI removed functions */

#define MPI_Address MPI_Get_address

#define MPI_Errhandler_create MPI_Comm_create_Errhandler
#define MPI_Errhandler_get MPI_Comm_get_errhandler
#define MPI_Errhandler_set MPI_Comm_set_errhandler

#define MPI_Type_hindexed MPI_Type_create_hindexed
#define MPI_Type_hvector MPI_Type_create_hvector
#define MPI_Type_struct MPI_Type_create_struct

MPI_static_inline int MPI_Type_extent(MPI_Datatype MPI_datatype, MPI_Aint *MPI_extent)
{
MPI_Aint MPI_lb;
return MPI_Type_get_extent(MPI_datatype, &MPI_lb, MPI_extent);
}

MPI_static_inline int MPI_Type_lb(MPI_Datatype MPI_datatype, MPI_Aint *MPI_lb)
{
MPI_Aint MPI_extent;
return MPI_Type_get_extent(MPI_datatype, MPI_lb, &MPI_extent);
}

MPI_static_inline int MPI_Type_ub(MPI_Datatype MPI_datatype, MPI_Aint *MPI_ub)
{
MPI_Aint MPI_lb;
MPI_ierr = MPI_Type_get_extent(MPI_datatype, &MPI_lb, MPI_ub);
if (MPI_ierr == MPI_SUCCESS && MPI_ub) *MPI_ub += MPI_lb;
return MPI_ierr;
}

/* PMPI removed functions */

#define PMPI_Address PMPI_Get_Address

#define PMPI_Errhandler_create PMPI_Comm_create_Errhandler
#define PMPI_Errhandler_get PMPI_Comm_get_errhandler
#define PMPI_Errhandler_set PMPI_Comm_set_errhandler

#define PMPI_Type_hindexed PMPI_Type_create_hindexed
#define PMPI_Type_hvector PMPI_Type_create_hvector
#define PMPI_Type_struct PMPI_Type_create_struct

MPI_static_inline int PMPI_Type_extent(MPI_Datatype MPI_datatype, MPI_Aint *MPI_extent)
{
MPI_Aint MPI_lb;
return PMPI_Type_get_extent(MPI_datatype, &MPI_lb, MPI_extent);
}

MPI_static_inline int PMPI_Type_lb(MPI_Datatype MPI_datatype, MPI_Aint *MPI_lb)
{
MPI_Aint MPI_extent;
return PMPI_Type_get_extent(MPI_datatype, MPI_lb, &MPI_extent);
}

MPI_static_inline int PMPI_Type_ub(MPI_Datatype MPI_datatype, MPI_Aint *MPI_ub)
{
MPI_Aint MPI_lb;
MPI_ierr = PMPI_Type_get_extent(MPI_datatype, &MPI_lb, MPI_ub);
if (MPI_ierr == MPI_SUCCESS && MPI_ub) *MPI_ub += MPI_lb;
return MPI_ierr;
}

0 comments on commit 49e07bd

Please sign in to comment.