Skip to content

Commit

Permalink
Fix various missing bigcount functions
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Tronge <jtronge@lanl.gov>
  • Loading branch information
jtronge committed Aug 15, 2024
1 parent c09c91e commit ab496c4
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 35 deletions.
34 changes: 28 additions & 6 deletions ompi/include/mpi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,8 @@ OMPI_DECLSPEC int MPI_File_write_ordered_begin_c(MPI_File fh, const void *buf,
OMPI_DECLSPEC int MPI_File_write_ordered_end(MPI_File fh, const void *buf, MPI_Status *status);
OMPI_DECLSPEC int MPI_File_get_type_extent(MPI_File fh, MPI_Datatype datatype,
MPI_Aint *extent);
OMPI_DECLSPEC int MPI_File_get_type_extent_c(MPI_File fh, MPI_Datatype datatype,
MPI_Count *extent);
OMPI_DECLSPEC int MPI_File_set_atomicity(MPI_File fh, int flag);
OMPI_DECLSPEC int MPI_File_get_atomicity(MPI_File fh, int *flag);
OMPI_DECLSPEC int MPI_File_sync(MPI_File fh);
Expand Down Expand Up @@ -2067,6 +2069,7 @@ OMPI_DECLSPEC int MPI_Neighbor_alltoallw_init_c(const void *sendbuf, const MPI_
OMPI_DECLSPEC MPI_Fint MPI_Op_c2f(MPI_Op op);
OMPI_DECLSPEC int MPI_Op_commutative(MPI_Op op, int *commute);
OMPI_DECLSPEC int MPI_Op_create(MPI_User_function *function, int commute, MPI_Op *op);
OMPI_DECLSPEC int MPI_Op_create_c(MPI_User_function_c *function, int commute, MPI_Op *op);
OMPI_DECLSPEC int MPI_Open_port(MPI_Info info, char *port_name);
OMPI_DECLSPEC MPI_Op MPI_Op_f2c(MPI_Fint op);
OMPI_DECLSPEC int MPI_Op_free(MPI_Op *op);
Expand All @@ -2079,7 +2082,7 @@ OMPI_DECLSPEC int MPI_Pack_external_c(const char datarep[], const void *inbuf,
OMPI_DECLSPEC int MPI_Pack_external_size(const char datarep[], int incount,
MPI_Datatype datatype, MPI_Aint *size);
OMPI_DECLSPEC int MPI_Pack_external_size_c(const char datarep[], MPI_Count incount,
MPI_Datatype datatype, MPI_Aint *size);
MPI_Datatype datatype, MPI_Count *size);
OMPI_DECLSPEC int MPI_Pack(const void *inbuf, int incount, MPI_Datatype datatype,
void *outbuf, int outsize, int *position, MPI_Comm comm);
OMPI_DECLSPEC int MPI_Pack_c(const void *inbuf, MPI_Count incount, MPI_Datatype datatype,
Expand Down Expand Up @@ -2414,6 +2417,8 @@ OMPI_DECLSPEC int MPI_Type_get_envelope_c(MPI_Datatype type, MPI_Count *num_int
MPI_Count *num_datatypes, int *combiner);
OMPI_DECLSPEC int MPI_Type_get_extent(MPI_Datatype type, MPI_Aint *lb,
MPI_Aint *extent);
OMPI_DECLSPEC int MPI_Type_get_extent_c(MPI_Datatype type, MPI_Count *lb,
MPI_Count *extent);
OMPI_DECLSPEC int MPI_Type_get_extent_x(MPI_Datatype type, MPI_Count *lb,
MPI_Count *extent);
OMPI_DECLSPEC int MPI_Type_get_name(MPI_Datatype type, char *type_name,
Expand Down Expand Up @@ -2449,8 +2454,8 @@ OMPI_DECLSPEC int MPI_Unpublish_name(const char *service_name, MPI_Info info, c
OMPI_DECLSPEC int MPI_Unpack_external (const char datarep[], const void *inbuf, MPI_Aint insize,
MPI_Aint *position, void *outbuf, int outcount,
MPI_Datatype datatype);
OMPI_DECLSPEC int MPI_Unpack_external_c (const char datarep[], const void *inbuf, MPI_Aint insize,
MPI_Aint *position, void *outbuf, MPI_Count outcount,
OMPI_DECLSPEC int MPI_Unpack_external_c (const char datarep[], const void *inbuf, MPI_Count insize,
MPI_Count *position, void *outbuf, MPI_Count outcount,
MPI_Datatype datatype);
OMPI_DECLSPEC int MPI_Waitall(int count, MPI_Request array_of_requests[],
MPI_Status *array_of_statuses);
Expand All @@ -2462,14 +2467,20 @@ OMPI_DECLSPEC int MPI_Waitsome(int incount, MPI_Request array_of_requests[],
MPI_Status array_of_statuses[]);
OMPI_DECLSPEC int MPI_Win_allocate(MPI_Aint size, int disp_unit, MPI_Info info,
MPI_Comm comm, void *baseptr, MPI_Win *win);
OMPI_DECLSPEC int MPI_Win_allocate_c(MPI_Aint size, MPI_Aint disp_unit, MPI_Info info,
MPI_Comm comm, void *baseptr, MPI_Win *win);
OMPI_DECLSPEC int MPI_Win_allocate_shared(MPI_Aint size, int disp_unit, MPI_Info info,
MPI_Comm comm, void *baseptr, MPI_Win *win);
OMPI_DECLSPEC int MPI_Win_allocate_shared_c(MPI_Aint size, MPI_Aint disp_unit, MPI_Info info,
MPI_Comm comm, void *baseptr, MPI_Win *win);
OMPI_DECLSPEC int MPI_Win_attach(MPI_Win win, void *base, MPI_Aint size);
OMPI_DECLSPEC MPI_Fint MPI_Win_c2f(MPI_Win win);
OMPI_DECLSPEC int MPI_Win_call_errhandler(MPI_Win win, int errorcode);
OMPI_DECLSPEC int MPI_Win_complete(MPI_Win win);
OMPI_DECLSPEC int MPI_Win_create(void *base, MPI_Aint size, int disp_unit,
MPI_Info info, MPI_Comm comm, MPI_Win *win);
OMPI_DECLSPEC int MPI_Win_create_c(void *base, MPI_Aint size, MPI_Aint disp_unit,
MPI_Info info, MPI_Comm comm, MPI_Win *win);
OMPI_DECLSPEC int MPI_Win_create_dynamic(MPI_Info info, MPI_Comm comm, MPI_Win *win);
OMPI_DECLSPEC int MPI_Win_create_errhandler(MPI_Win_errhandler_function *function,
MPI_Errhandler *errhandler);
Expand Down Expand Up @@ -2913,6 +2924,8 @@ OMPI_DECLSPEC int PMPI_File_write_ordered_begin_c(MPI_File fh, const void *buf,
OMPI_DECLSPEC int PMPI_File_write_ordered_end(MPI_File fh, const void *buf, MPI_Status *status);
OMPI_DECLSPEC int PMPI_File_get_type_extent(MPI_File fh, MPI_Datatype datatype,
MPI_Aint *extent);
OMPI_DECLSPEC int PMPI_File_get_type_extent_c(MPI_File fh, MPI_Datatype datatype,
MPI_Count *extent);
OMPI_DECLSPEC int PMPI_File_set_atomicity(MPI_File fh, int flag);
OMPI_DECLSPEC int PMPI_File_get_atomicity(MPI_File fh, int *flag);
OMPI_DECLSPEC int PMPI_File_sync(MPI_File fh);
Expand Down Expand Up @@ -3187,6 +3200,7 @@ OMPI_DECLSPEC int PMPI_Neighbor_alltoallw_init_c(const void *sendbuf, const MPI
OMPI_DECLSPEC MPI_Fint PMPI_Op_c2f(MPI_Op op);
OMPI_DECLSPEC int PMPI_Op_commutative(MPI_Op op, int *commute);
OMPI_DECLSPEC int PMPI_Op_create(MPI_User_function *function, int commute, MPI_Op *op);
OMPI_DECLSPEC int PMPI_Op_create_c(MPI_User_function_c *function, int commute, MPI_Op *op);
OMPI_DECLSPEC int PMPI_Open_port(MPI_Info info, char *port_name);
OMPI_DECLSPEC MPI_Op PMPI_Op_f2c(MPI_Fint op);
OMPI_DECLSPEC int PMPI_Op_free(MPI_Op *op);
Expand All @@ -3199,7 +3213,7 @@ OMPI_DECLSPEC int PMPI_Pack_external_c(const char datarep[], const void *inbuf,
OMPI_DECLSPEC int PMPI_Pack_external_size(const char datarep[], int incount,
MPI_Datatype datatype, MPI_Aint *size);
OMPI_DECLSPEC int PMPI_Pack_external_size_c(const char datarep[], MPI_Count incount,
MPI_Datatype datatype, MPI_Aint *size);
MPI_Datatype datatype, MPI_Count *size);
OMPI_DECLSPEC int PMPI_Pack(const void *inbuf, int incount, MPI_Datatype datatype,
void *outbuf, int outsize, int *position, MPI_Comm comm);
OMPI_DECLSPEC int PMPI_Pack_c(const void *inbuf, MPI_Count incount, MPI_Datatype datatype,
Expand Down Expand Up @@ -3534,6 +3548,8 @@ OMPI_DECLSPEC int PMPI_Type_get_envelope_c(MPI_Datatype type, MPI_Count *num_in
MPI_Count *num_datatypes, int *combiner);
OMPI_DECLSPEC int PMPI_Type_get_extent(MPI_Datatype type, MPI_Aint *lb,
MPI_Aint *extent);
OMPI_DECLSPEC int PMPI_Type_get_extent_c(MPI_Datatype type, MPI_Count *lb,
MPI_Count *extent);
OMPI_DECLSPEC int PMPI_Type_get_extent_x(MPI_Datatype type, MPI_Count *lb,
MPI_Count *extent);
OMPI_DECLSPEC int PMPI_Type_get_name(MPI_Datatype type, char *type_name,
Expand Down Expand Up @@ -3569,8 +3585,8 @@ OMPI_DECLSPEC int PMPI_Unpublish_name(const char *service_name, MPI_Info info,
OMPI_DECLSPEC int PMPI_Unpack_external (const char datarep[], const void *inbuf, MPI_Aint insize,
MPI_Aint *position, void *outbuf, int outcount,
MPI_Datatype datatype);
OMPI_DECLSPEC int PMPI_Unpack_external_c (const char datarep[], const void *inbuf, MPI_Aint insize,
MPI_Aint *position, void *outbuf, MPI_Count outcount,
OMPI_DECLSPEC int PMPI_Unpack_external_c (const char datarep[], const void *inbuf, MPI_Count insize,
MPI_Count *position, void *outbuf, MPI_Count outcount,
MPI_Datatype datatype);
OMPI_DECLSPEC int PMPI_Waitall(int count, MPI_Request array_of_requests[],
MPI_Status *array_of_statuses);
Expand All @@ -3582,14 +3598,20 @@ OMPI_DECLSPEC int PMPI_Waitsome(int incount, MPI_Request array_of_requests[],
MPI_Status array_of_statuses[]);
OMPI_DECLSPEC int PMPI_Win_allocate(MPI_Aint size, int disp_unit, MPI_Info info,
MPI_Comm comm, void *baseptr, MPI_Win *win);
OMPI_DECLSPEC int PMPI_Win_allocate_c(MPI_Aint size, MPI_Aint disp_unit, MPI_Info info,
MPI_Comm comm, void *baseptr, MPI_Win *win);
OMPI_DECLSPEC int PMPI_Win_allocate_shared(MPI_Aint size, int disp_unit, MPI_Info info,
MPI_Comm comm, void *baseptr, MPI_Win *win);
OMPI_DECLSPEC int PMPI_Win_allocate_shared_c(MPI_Aint size, MPI_Aint disp_unit, MPI_Info info,
MPI_Comm comm, void *baseptr, MPI_Win *win);
OMPI_DECLSPEC int PMPI_Win_attach(MPI_Win win, void *base, MPI_Aint size);
OMPI_DECLSPEC MPI_Fint PMPI_Win_c2f(MPI_Win win);
OMPI_DECLSPEC int PMPI_Win_call_errhandler(MPI_Win win, int errorcode);
OMPI_DECLSPEC int PMPI_Win_complete(MPI_Win win);
OMPI_DECLSPEC int PMPI_Win_create(void *base, MPI_Aint size, int disp_unit,
MPI_Info info, MPI_Comm comm, MPI_Win *win);
OMPI_DECLSPEC int PMPI_Win_create_c(void *base, MPI_Aint size, MPI_Aint disp_unit,
MPI_Info info, MPI_Comm comm, MPI_Win *win);
OMPI_DECLSPEC int PMPI_Win_create_dynamic(MPI_Info info, MPI_Comm comm, MPI_Win *win);
OMPI_DECLSPEC int PMPI_Win_create_errhandler(MPI_Win_errhandler_function *function,
MPI_Errhandler *errhandler);
Expand Down
43 changes: 41 additions & 2 deletions ompi/mpi/bindings/ompi_bindings/c_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,19 @@ def type_text(self, enable_count=False):
return 'MPI_Count'


@Type.add_type('DISP')
class TypeDisp(Type):

@property
def is_count(self):
return True

def type_text(self, enable_count=False):
return 'MPI_Aint' if enable_count else 'int'


@Type.add_type('DISP_ARRAY')
class TypeDisplArray(Type):
class TypeDispArray(Type):

@property
def is_count(self):
Expand Down Expand Up @@ -199,6 +210,7 @@ def parameter(self, enable_count=False, **kwargs):
else:
return f'int {self.name}[]'


@Type.add_type('COUNT_OUT')
class TypeCountOut(Type):

Expand All @@ -209,6 +221,29 @@ def is_count(self):
def type_text(self, enable_count=False):
return 'MPI_Count *' if enable_count else 'int *'


@Type.add_type('AINT_COUNT')
class TypeAintCountOut(Type):

@property
def is_count(self):
return True

def type_text(self, enable_count=False):
return 'MPI_Count' if enable_count else 'MPI_Aint'


@Type.add_type('AINT_COUNT_OUT')
class TypeAintCountOut(Type):

@property
def is_count(self):
return True

def type_text(self, enable_count=False):
return 'MPI_Count *' if enable_count else 'MPI_Aint *'


@Type.add_type('INT_ARRAY')
class TypeIntArray(Type):

Expand Down Expand Up @@ -867,8 +902,12 @@ class TypeDeleteFunctionStandard(Type):
@Type.add_type('USER_FUNCTION', abi_type=['ompi'])
class TypeUserFunction(Type):

@property
def is_count(self):
return True

def type_text(self, enable_count=False):
return 'MPI_User_function *'
return 'MPI_User_function_c *' if enable_count else 'MPI_User_function *'


@Type.add_type('USER_FUNCTION', abi_type=['standard'])
Expand Down
15 changes: 13 additions & 2 deletions ompi/mpi/bindings/ompi_bindings/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,18 @@ def abi_internal_name(extname):
return f'{extname}_ABI_INTERNAL'


BIGCOUNT_TYPE_NAMES = [
'COUNT',
'COUNT_ARRAY',
'DISP',
'DISP_ARRAY',
'COUNT_OUT',
'AINT_COUNT',
'AINT_COUNT_OUT',
'USER_FUNCTION',
]


def prototype_has_bigcount(prototype):
"""Should this prototype have a bigcount version?"""
return any(param.type_name in ('COUNT', 'COUNT_ARRAY', 'DISP', 'DISP_ARRAY', 'COUNT_OUT')
for param in prototype.params)
return any(param.type_name in BIGCOUNT_TYPE_NAMES for param in prototype.params)
7 changes: 5 additions & 2 deletions ompi/mpi/c/file_get_type_extent.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
/* TODO: Does this need a bigcount variant? */

PROTOTYPE ERROR_CLASS file_get_type_extent(FILE fh, DATATYPE datatype,
AINT_OUT extent)
AINT_COUNT_OUT extent)
{
int rc;
MPI_Aint tmp_extent = 0;

MEMCHECKER(
memchecker_datatype(datatype);
Expand All @@ -59,8 +60,10 @@ PROTOTYPE ERROR_CLASS file_get_type_extent(FILE fh, DATATYPE datatype,

switch (fh->f_io_version) {
case MCA_IO_BASE_V_3_0_0:
/* TODO:BIGCOUNT: Need to update below code with bigcount variant */
rc = fh->f_io_selected_module.v3_0_0.
io_module_file_get_type_extent(fh, datatype, extent);
io_module_file_get_type_extent(fh, datatype, &tmp_extent);
*extent = tmp_extent;
break;

default:
Expand Down
1 change: 1 addition & 0 deletions ompi/mpi/c/op_create.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ PROTOTYPE ERROR_CLASS op_create(USER_FUNCTION function, INT commute, OP_OUT op)

/* Create and cache the op. Sets a refcount of 1. */

/* TODO:BIGCOUNT: Update internally to handle bigcount variant of user function */
*op = ompi_op_create_user(OPAL_INT_TO_BOOL(commute),
(ompi_op_fortran_handler_fn_t *) function);
if (NULL == *op) {
Expand Down
11 changes: 7 additions & 4 deletions ompi/mpi/c/pack_external_size.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@

/* TODO: Does this need a bigcount variant? */

PROTOTYPE ERROR_CLASS pack_external_size(STRING datarep, INT incount,
DATATYPE datatype, AINT_OUT size)
PROTOTYPE ERROR_CLASS pack_external_size(STRING datarep, COUNT incount,
DATATYPE datatype, AINT_COUNT_OUT size)
{
int rc = MPI_SUCCESS;
MPI_Aint tmp_size = 0;

MEMCHECKER(
memchecker_datatype(datatype);
Expand All @@ -52,8 +53,10 @@ PROTOTYPE ERROR_CLASS pack_external_size(STRING datarep, INT incount,
}
}

rc = ompi_datatype_pack_external_size(datarep, incount,
datatype, size);
/* TODO:BIGCOUNT: Update when the ompi_datatype code is updated for bigcount */
rc = ompi_datatype_pack_external_size(datarep, (int) incount,
datatype, &tmp_size);
*size = tmp_size;

OMPI_ERRHANDLER_NOHANDLE_RETURN(rc, rc, FUNC_NAME);
}
9 changes: 7 additions & 2 deletions ompi/mpi/c/type_get_extent.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
#include "ompi/datatype/ompi_datatype.h"
#include "ompi/memchecker.h"

PROTOTYPE ERROR_CLASS type_get_extent(DATATYPE type, AINT_OUT lb, AINT_OUT extent)
PROTOTYPE ERROR_CLASS type_get_extent(DATATYPE type, AINT_COUNT_OUT lb, AINT_COUNT_OUT extent)
{
int rc;
ptrdiff_t tmp_lb = 0;
ptrdiff_t tmp_extent = 0;

MEMCHECKER(
memchecker_datatype(type);
Expand All @@ -46,6 +48,9 @@ PROTOTYPE ERROR_CLASS type_get_extent(DATATYPE type, AINT_OUT lb, AINT_OUT exten
}
}

rc = ompi_datatype_get_extent( type, lb, extent );
/* TODO:BIGCOUNT: Does ompi_datatype_get_extent() need a bigcount variant? */
rc = ompi_datatype_get_extent( type, &tmp_lb, &tmp_extent );
*lb = tmp_lb;
*extent = tmp_extent;
OMPI_ERRHANDLER_NOHANDLE_RETURN(rc, rc, FUNC_NAME );
}
14 changes: 8 additions & 6 deletions ompi/mpi/c/unpack_external.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
#include "opal/datatype/opal_convertor.h"
#include "ompi/memchecker.h"

/* TODO: Does this need a bigcount variant? */

PROTOTYPE ERROR_CLASS unpack_external (STRING datarep, BUFFER inbuf, AINT insize,
AINT_OUT position, BUFFER_OUT outbuf, INT outcount,
PROTOTYPE ERROR_CLASS unpack_external (STRING datarep, BUFFER inbuf, AINT_COUNT insize,
AINT_COUNT_OUT position, BUFFER_OUT outbuf, COUNT outcount,
DATATYPE datatype)
{
int rc = MPI_SUCCESS;
MPI_Aint tmp_position = 0;

MEMCHECKER(
memchecker_datatype(datatype);
Expand All @@ -57,9 +56,12 @@ PROTOTYPE ERROR_CLASS unpack_external (STRING datarep, BUFFER inbuf, AINT insize
OMPI_ERRHANDLER_NOHANDLE_CHECK(rc, rc, FUNC_NAME);
}

rc = ompi_datatype_unpack_external(datarep, inbuf, insize,
position, outbuf, outcount,
/* TODO:BIGCOUNT: Update once ompi_datatype_unpack_external() is updated with a bigcount variant */

rc = ompi_datatype_unpack_external(datarep, inbuf, (MPI_Aint) insize,
&tmp_position, outbuf, (int) outcount,
datatype);
*position = tmp_position;

OMPI_ERRHANDLER_NOHANDLE_RETURN(rc, rc, FUNC_NAME);
}
7 changes: 3 additions & 4 deletions ompi/mpi/c/win_allocate.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
#include "ompi/win/win.h"
#include "ompi/memchecker.h"

/* TODO: Does this need a bigcount variant? */

PROTOTYPE ERROR_CLASS win_allocate(AINT size, INT disp_unit, INFO info,
PROTOTYPE ERROR_CLASS win_allocate(AINT size, DISP disp_unit, INFO info,
COMM comm, BUFFER_OUT baseptr, WIN_OUT win)
{
int ret = MPI_SUCCESS;
Expand Down Expand Up @@ -68,7 +66,8 @@ PROTOTYPE ERROR_CLASS win_allocate(AINT size, INT disp_unit, INFO info,
}

/* create window and return */
ret = ompi_win_allocate((size_t)size, disp_unit, &(info->super),
/* TODO:BIGCOUNT: Update ompi_win_allocate to take ptrdiff_t/MPI_Aint disp units */
ret = ompi_win_allocate((size_t)size, (int)disp_unit, &(info->super),
comm, baseptr, win);
if (OMPI_SUCCESS != ret) {
*win = MPI_WIN_NULL;
Expand Down
7 changes: 3 additions & 4 deletions ompi/mpi/c/win_allocate_shared.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
#include "ompi/win/win.h"
#include "ompi/memchecker.h"

/* TODO: Does this need a bigcount variant? */

PROTOTYPE ERROR_CLASS win_allocate_shared(AINT size, INT disp_unit, INFO info,
PROTOTYPE ERROR_CLASS win_allocate_shared(AINT size, DISP disp_unit, INFO info,
COMM comm, BUFFER_OUT baseptr, WIN_OUT win)
{
int ret = MPI_SUCCESS;
Expand Down Expand Up @@ -69,7 +67,8 @@ PROTOTYPE ERROR_CLASS win_allocate_shared(AINT size, INT disp_unit, INFO info,
}

/* create window and return */
ret = ompi_win_allocate_shared((size_t)size, disp_unit, &(info->super),
/* TODO:BIGCOUNT: Update internal code to use ptrdiff_t for disp_unit */
ret = ompi_win_allocate_shared((size_t)size, (int)disp_unit, &(info->super),
comm, baseptr, win);
if (OMPI_SUCCESS != ret) {
*win = MPI_WIN_NULL;
Expand Down
Loading

0 comments on commit ab496c4

Please sign in to comment.