Skip to content

Commit 81e3492

Browse files
hppritchaedgargabriel
authored andcommitted
c-bindings: add support for const request args
Three new functions were added to the MPI API as part of the 4.1 standard. These used an array of const MPI_Request s which the bindings code didn't support. This commit also fixes back the mpi.h prototypes to include the constants and required changes to the new template files. Signed-off-by: Howard Pritchard <[email protected]>
1 parent f636bc5 commit 81e3492

File tree

5 files changed

+37
-14
lines changed

5 files changed

+37
-14
lines changed

ompi/include/mpi.h.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,13 +2227,13 @@ OMPI_DECLSPEC int MPI_Request_free(MPI_Request *request);
22272227
OMPI_DECLSPEC int MPI_Request_get_status(MPI_Request request, int *flag,
22282228
MPI_Status *status);
22292229
/* should be 'const MPI_Request array_of_requests[]' */
2230-
OMPI_DECLSPEC int MPI_Request_get_status_all(int count, MPI_Request array_of_requests[], int *flag,
2230+
OMPI_DECLSPEC int MPI_Request_get_status_all(int count, const MPI_Request array_of_requests[], int *flag,
22312231
MPI_Status array_of_statuses[]);
22322232
/* should be 'const MPI_Request array_of_requests[]' */
2233-
OMPI_DECLSPEC int MPI_Request_get_status_any(int count, MPI_Request array_of_requests[], int *index,
2233+
OMPI_DECLSPEC int MPI_Request_get_status_any(int count, const MPI_Request array_of_requests[], int *index,
22342234
int *flag, MPI_Status *status);
22352235
/* should be 'const MPI_Request array_of_requests[]' */
2236-
OMPI_DECLSPEC int MPI_Request_get_status_some(int incount, MPI_Request array_of_requests[], int *outcount,
2236+
OMPI_DECLSPEC int MPI_Request_get_status_some(int incount, const MPI_Request array_of_requests[], int *outcount,
22372237
int array_of_indices[], MPI_Status array_of_statuses[]);
22382238
OMPI_DECLSPEC int MPI_Rget(void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
22392239
int target_rank, MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype,
@@ -3395,13 +3395,13 @@ OMPI_DECLSPEC int PMPI_Request_free(MPI_Request *request);
33953395
OMPI_DECLSPEC int PMPI_Request_get_status(MPI_Request request, int *flag,
33963396
MPI_Status *status);
33973397
/* should be 'const MPI_Request array_of_requests[]' */
3398-
OMPI_DECLSPEC int PMPI_Request_get_status_all(int count, MPI_Request array_of_requests[], int *flag,
3398+
OMPI_DECLSPEC int PMPI_Request_get_status_all(int count, const MPI_Request array_of_requests[], int *flag,
33993399
MPI_Status array_of_statuses[]);
34003400
/* should be 'const MPI_Request array_of_requests[]' */
3401-
OMPI_DECLSPEC int PMPI_Request_get_status_any(int count, MPI_Request array_of_requests[], int *index,
3401+
OMPI_DECLSPEC int PMPI_Request_get_status_any(int count, const MPI_Request array_of_requests[], int *index,
34023402
int *flag, MPI_Status *status);
34033403
/* should be 'const MPI_Request array_of_requests[]' */
3404-
OMPI_DECLSPEC int PMPI_Request_get_status_some(int incount, MPI_Request array_of_requests[], int *outcount,
3404+
OMPI_DECLSPEC int PMPI_Request_get_status_some(int incount, const MPI_Request array_of_requests[], int *outcount,
34053405
int array_of_indices[], MPI_Status array_of_statuses[]);
34063406
OMPI_DECLSPEC int PMPI_Rget(void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
34073407
int target_rank, MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype,

ompi/mpi/bindings/ompi_bindings/c_type.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,38 @@ def type_text(self, enable_count=False):
556556
def argument(self):
557557
return f'(MPI_Request) {self.name}'
558558

559+
@Type.add_type('REQUEST_CONST', abi_type=['ompi'])
560+
class TypeConstRequest(TypeRequest):
561+
562+
def type_text(self, enable_count=False):
563+
return f'const MPI_Request *'
564+
565+
def parameter(self, enable_count=False, **kwargs):
566+
if self.count_param is None:
567+
return f'const MPI_Request {self.name}'
568+
else:
569+
return f'const MPI_Request {self.name}[]'
570+
571+
#
572+
# TODO ABI NEEDS WORK
573+
#
574+
@Type.add_type('REQUEST_CONST', abi_type=['standard'])
575+
class TypeConstRequestStandard(TypeRequestStandard):
576+
577+
def type_text(self, enable_count=False):
578+
name = self.mangle_name('MPI_Request')
579+
return f'const {name}'
580+
581+
@property
582+
def argument(self):
583+
return f'(MPI_Request) {self.name}'
559584

560585
@Type.add_type('REQUEST_INOUT', abi_type=['ompi'])
561586
class TypeRequestInOut(Type):
562587

563588
def type_text(self, enable_count=False):
564589
return 'MPI_Request *'
565590

566-
567591
@Type.add_type('REQUEST_INOUT', abi_type=['standard'])
568592
class TypeRequestInOutStandard(Type):
569593

@@ -593,7 +617,6 @@ def parameter(self, enable_count=False, **kwargs):
593617
else:
594618
return f'{type_name} {self.name}[]'
595619

596-
597620
@Type.add_type('STATUS', abi_type=['ompi'])
598621
class TypeStatus(Type):
599622

ompi/mpi/c/request_get_status_all.c.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* not be freed (unlike the test function). A subsequent call to test, wait
3838
* or free should be executed on the request.
3939
*/
40-
PROTOTYPE ERROR_CLASS request_get_status_all(INT count, REQUEST_INOUT requests:count, INT_OUT flag,
40+
PROTOTYPE ERROR_CLASS request_get_status_all(INT count, REQUEST_CONST requests:count, INT_OUT flag,
4141
STATUS_OUT statuses:count)
4242
{
4343
MEMCHECKER(
@@ -54,7 +54,7 @@ PROTOTYPE ERROR_CLASS request_get_status_all(INT count, REQUEST_INOUT requests:c
5454
if (NULL == requests) {
5555
rc = MPI_ERR_REQUEST;
5656
} else {
57-
if(!ompi_request_check_same_instance(requests, count) ) {
57+
if(!ompi_request_check_same_instance((MPI_Request *)requests, count) ) {
5858
rc = MPI_ERR_REQUEST;
5959
}
6060
}

ompi/mpi/c/request_get_status_any.c.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* not be freed (unlike the test function). A subsequent call to test, wait
3838
* or free should be executed on the request.
3939
*/
40-
PROTOTYPE ERROR_CLASS request_get_status_any(INT count, REQUEST_INOUT requests:count, INT_OUT indx,
40+
PROTOTYPE ERROR_CLASS request_get_status_any(INT count, REQUEST_CONST requests:count, INT_OUT indx,
4141
INT_OUT flag, STATUS_OUT status)
4242
{
4343

@@ -55,7 +55,7 @@ PROTOTYPE ERROR_CLASS request_get_status_any(INT count, REQUEST_INOUT requests:c
5555
if (NULL == requests) {
5656
rc = MPI_ERR_REQUEST;
5757
} else {
58-
if(!ompi_request_check_same_instance(requests, count) ) {
58+
if(!ompi_request_check_same_instance((MPI_Request *)requests, count) ) {
5959
rc = MPI_ERR_REQUEST;
6060
}
6161
}

ompi/mpi/c/request_get_status_some.c.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* not be freed (unlike the test function). A subsequent call to test, wait
3838
* or free should be executed on the request.
3939
*/
40-
PROTOTYPE ERROR_CLASS request_get_status_some(INT incount, REQUEST_INOUT requests:count, INT_OUT outcount,
40+
PROTOTYPE ERROR_CLASS request_get_status_some(INT incount, REQUEST_CONST requests:count, INT_OUT outcount,
4141
INT_OUT indices, STATUS_OUT statuses:count)
4242
{
4343

@@ -55,7 +55,7 @@ PROTOTYPE ERROR_CLASS request_get_status_some(INT incount, REQUEST_INOUT request
5555
if (NULL == requests) {
5656
rc = MPI_ERR_REQUEST;
5757
} else {
58-
if(!ompi_request_check_same_instance(requests, incount) ) {
58+
if(!ompi_request_check_same_instance((MPI_Request *)requests, incount) ) {
5959
rc = MPI_ERR_REQUEST;
6060
}
6161
}

0 commit comments

Comments
 (0)