Skip to content

Commit

Permalink
romio: add MPI_Register_datarep_c
Browse files Browse the repository at this point in the history
MPI_Register_datarep and MPI_Register_datarep_c differ in the types of
conversion function. Since we don't actually support non-NULL conversion
functions, the only difference is in the parameter types.
  • Loading branch information
hzhou committed May 13, 2021
1 parent 3cf108e commit 44eb541
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 4 deletions.
19 changes: 17 additions & 2 deletions src/mpi/romio/adio/include/adioi.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,18 @@ struct ADIOI_Hints_struct {
typedef struct ADIOI_Datarep {
char *name;
void *state;
int is_large;
MPI_Datarep_extent_function *extent_fn;
MPI_Datarep_conversion_function *read_conv_fn;
MPI_Datarep_conversion_function *write_conv_fn;
union {
struct {
MPI_Datarep_conversion_function *read_conv_fn;
MPI_Datarep_conversion_function *write_conv_fn;
} small;
struct {
MPI_Datarep_conversion_function_c *read_conv_fn;
MPI_Datarep_conversion_function_c *write_conv_fn;
} large;
} u;
struct ADIOI_Datarep *next; /* pointer to next datarep */
} ADIOI_Datarep;

Expand Down Expand Up @@ -843,6 +852,12 @@ int MPIOI_File_write_shared(MPI_File fh, const void *buf, int count,
int MPIOI_File_iwrite_shared(MPI_File fh, const void *buf, int count,
MPI_Datatype datatype, MPIO_Request * request);

typedef void (*MPIOI_VOID_FN) (void *);
int MPIOI_Register_datarep(const char *datarep,
MPIOI_VOID_FN * read_conversion_fn,
MPIOI_VOID_FN * write_conversion_fn,
MPI_Datarep_extent_function * dtype_file_extent_fn,
void *extra_state, int is_large);

/* Unix-style file locking */

Expand Down
86 changes: 84 additions & 2 deletions src/mpi/romio/mpi-io/register_datarep.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,82 @@ Input Parameters:
.N fortran
@*/

int MPI_Register_datarep(ROMIO_CONST char *datarep,
MPI_Datarep_conversion_function * read_conversion_fn,
MPI_Datarep_conversion_function * write_conversion_fn,
MPI_Datarep_extent_function * dtype_file_extent_fn, void *extra_state)
{
int is_large = false;
return MPIOI_Register_datarep(datarep, (MPIOI_VOID_FN *) read_conversion_fn,
(MPIOI_VOID_FN *) write_conversion_fn,
dtype_file_extent_fn, extra_state, is_large);
}

/* large count function */

#ifdef HAVE_WEAK_SYMBOLS

#if defined(HAVE_PRAGMA_WEAK)
#pragma weak MPI_Register_datarep_c = PMPI_Register_datarep_c
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
#pragma _HP_SECONDARY_DEF PMPI_Register_datarep_c MPI_Register_datarep_c
#elif defined(HAVE_PRAGMA_CRI_DUP)
#pragma _CRI duplicate MPI_Register_datarep_c as PMPI_Register_datarep_c
/* end of weak pragmas */
#elif defined(HAVE_WEAK_ATTRIBUTE)
int MPI_Register_datarep_c(const char *datarep,
MPI_Datarep_conversion_function_c * read_conversion_fn,
MPI_Datarep_conversion_function_c * write_conversion_fn,
MPI_Datarep_extent_function * dtype_file_extent_fn, void *extra_state)
__attribute__ ((weak, alias("PMPI_Register_datarep_c")));
#endif

#endif

/*@
MPI_Register_datarep_c - Register functions for user-defined data
representations
Input Parameters:
+ datarep - data representation name (string)
. read_conversion_fn - function invoked to convert from file representation to
native representation (function)
. write_conversion_fn - function invoked to convert from native representation to
file representation (function)
. dtype_file_extent_fn - function invoked to get the exted of a datatype as represented
in the file (function)
- extra_state - pointer to extra state that is passed to each of the
three functions
Notes:
This function allows the user to provide routines to convert data from
an external representation, used within a file, and the native representation,
used within the CPU. There is one predefined data representation,
'external32'. Please consult the MPI-2 standard for details on this
function.
.N fortran
@*/

int MPI_Register_datarep_c(ROMIO_CONST char *datarep,
MPI_Datarep_conversion_function_c * read_conversion_fn,
MPI_Datarep_conversion_function_c * write_conversion_fn,
MPI_Datarep_extent_function * dtype_file_extent_fn, void *extra_state)
{
int is_large = true;
return MPIOI_Register_datarep(datarep, (MPIOI_VOID_FN *) read_conversion_fn,
(MPIOI_VOID_FN *) write_conversion_fn,
dtype_file_extent_fn, extra_state, is_large);
}

#ifdef MPIO_BUILD_PROFILING
int MPIOI_Register_datarep(const char *datarep,
MPIOI_VOID_FN * read_conversion_fn,
MPIOI_VOID_FN * write_conversion_fn,
MPI_Datarep_extent_function * dtype_file_extent_fn,
void *extra_state, int is_large)
{
int error_code;
ADIOI_Datarep *adio_datarep;
Expand Down Expand Up @@ -117,8 +189,17 @@ int MPI_Register_datarep(ROMIO_CONST char *datarep,
adio_datarep = ADIOI_Malloc(sizeof(ADIOI_Datarep));
adio_datarep->name = ADIOI_Strdup(datarep);
adio_datarep->state = extra_state;
adio_datarep->read_conv_fn = read_conversion_fn;
adio_datarep->write_conv_fn = write_conversion_fn;
adio_datarep->is_large = is_large;
if (is_large) {
adio_datarep->u.large.read_conv_fn =
(MPI_Datarep_conversion_function_c *) read_conversion_fn;
adio_datarep->u.large.write_conv_fn =
(MPI_Datarep_conversion_function_c *) write_conversion_fn;
} else {
adio_datarep->u.small.read_conv_fn = (MPI_Datarep_conversion_function *) read_conversion_fn;
adio_datarep->u.small.write_conv_fn =
(MPI_Datarep_conversion_function *) write_conversion_fn;
}
adio_datarep->extent_fn = dtype_file_extent_fn;
adio_datarep->next = ADIOI_Datarep_head;

Expand All @@ -131,3 +212,4 @@ int MPI_Register_datarep(ROMIO_CONST char *datarep,

return error_code;
}
#endif

0 comments on commit 44eb541

Please sign in to comment.