Skip to content

Commit 8a7407f

Browse files
committed
checkpoint
Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 29b1a2f commit 8a7407f

19 files changed

+358
-182
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ docs/man
535535

536536
# Generated C Bindings
537537
ompi/mpi/c/*_generated*.c
538-
ompi/mpi/c/ompi_*.c
539538
ompi/mpi/c/standard_*.c
540539
ompi/mpi/c/abi.h
541540
ompi/mpi/c/standard_abi

ompi/mpi/bindings/ompi_bindings/c.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,11 @@ def generate_status_convert_fn(self):
218218
abi_type = self.mangle_name(type_)
219219
self.dump(f'{consts.INLINE_ATTRS} void {ConvertFuncs.STATUS}({type_} *out, {abi_type} *inp)')
220220
self.dump('{')
221+
self.dump(' void *ptr = &out->_ucount;')
221222
self.dump(' out->MPI_SOURCE = inp->MPI_SOURCE;')
222223
self.dump(' out->MPI_TAG = inp->MPI_TAG;')
224+
self.dump(' out->_cancelled = inp->MPI_Internal[0];')
225+
self.dump(' memcpy(ptr, &inp->MPI_Internal[1],sizeof(out->_ucount));')
223226
self.dump(f' out->MPI_ERROR = {ConvertFuncs.ERROR_CLASS}(inp->MPI_ERROR);')
224227
# Ignoring the private fields for now
225228
self.dump('}')
@@ -229,8 +232,11 @@ def generate_status_convert_fn_intern_to_abi(self):
229232
abi_type = self.mangle_name(type_)
230233
self.dump(f'{consts.INLINE_ATTRS} void {ConvertOMPIToStandard.STATUS}({abi_type} *out, {type_} *inp)')
231234
self.dump('{')
235+
self.dump(' void *ptr = &out->MPI_Internal[1];')
232236
self.dump(' out->MPI_SOURCE = inp->MPI_SOURCE;')
233237
self.dump(' out->MPI_TAG = inp->MPI_TAG;')
238+
self.dump(' out->MPI_Internal[0] =inp->_cancelled;')
239+
self.dump(' memcpy(ptr, &inp->_ucount,sizeof(inp->_ucount));')
234240
# self.dump(f' out->MPI_ERROR = {ConvertOMPIToStandard.ERROR_CLASS}(inp->MPI_ERROR);')
235241
# Ignoring the private fields for now
236242
self.dump('}')
@@ -309,7 +315,7 @@ def dump_header(self):
309315
int MPI_SOURCE;
310316
int MPI_TAG;
311317
int MPI_ERROR;
312-
int mpi_abi_private[5];
318+
int MPI_Internal[5];
313319
};""")
314320
self.dump(f'typedef struct MPI_Status_ABI {self.mangle_name("MPI_Status")};')
315321
self.dump()

ompi/mpi/bindings/ompi_bindings/c_type.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,66 @@ def parameter(self, enable_count=False, **kwargs):
757757
else:
758758
return f'{type_name} {self.name}[]'
759759

760+
@Type.add_type('STATUS_INOUT', abi_type=['ompi'])
761+
class TypeStatusInOut(Type):
762+
763+
def type_text(self, enable_count=False):
764+
return 'MPI_Status *'
765+
766+
def parameter(self, enable_count=False, **kwargs):
767+
if self.count_param is None:
768+
return f'MPI_Status *{self.name}'
769+
else:
770+
return f'MPI_Status {self.name}[]'
771+
772+
#
773+
# so far there are no vectors of statuses for inout in the the standard
774+
#
775+
@Type.add_type('STATUS_INOUT', abi_type=['standard'])
776+
class TypeStausInOutStandard(StandardABIType):
777+
778+
def if_should_set_status(self):
779+
"""Generate the condition to check if the status(es) should be set."""
780+
condition = ' && '.join(f'{self.mangle_name(const)} != {self.name}'
781+
for const in IGNORED_STATUS_HANDLES)
782+
return 'if (%s) {' % (condition,)
783+
784+
@property
785+
def status_argument(self):
786+
return f'{self.name}_arg'
787+
788+
@property
789+
def init_code(self):
790+
mangle_type = self.mangle_name('MPI_Status')
791+
code = [f'MPI_Status *{self.status_argument} = NULL;']
792+
code.append(f'MPI_Status {self.tmpname};')
793+
code.append(f'{ConvertFuncs.STATUS}(&{self.tmpname}, ({mangle_type} *){self.name});')
794+
code.append(self.if_should_set_status())
795+
code.append(f'{self.status_argument} = &{self.tmpname};')
796+
code.append('} else {')
797+
code.append(f'{self.status_argument} = MPI_STATUS_IGNORE;')
798+
code.append('}')
799+
return code
800+
801+
@property
802+
def final_code(self):
803+
code = [self.if_should_set_status()]
804+
code.append(f'{ConvertOMPIToStandard.STATUS}({self.name}, &{self.tmpname});')
805+
code.append('}')
806+
return code
807+
808+
@property
809+
def argument(self):
810+
return self.status_argument
811+
812+
def type_text(self, enable_count=False):
813+
type_name = self.mangle_name('MPI_Status')
814+
return f'{type_name} *'
815+
816+
def parameter(self, enable_count=False, **kwargs):
817+
type_name = self.mangle_name('MPI_Status')
818+
return f'{type_name} *{self.name}'
819+
760820

761821
@Type.add_type('F08_STATUS')
762822
class TypeF08Status(Type):

ompi/mpi/c/Makefile.am

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,6 @@ prototype_sources = \
293293
isendrecv_replace.c.in \
294294
issend.c.in \
295295
is_thread_main.c.in \
296-
keyval_create.c.in \
297-
keyval_free.c.in \
298296
lookup_name.c.in \
299297
message_c2f.c.in \
300298
message_f2c.c.in \
@@ -490,7 +488,9 @@ libmpi_c_la_SOURCES = \
490488
libmpi_c_la_SOURCES += \
491489
abi_details.c \
492490
abi_supported.c \
493-
abi_version.c
491+
abi_version.c \
492+
ompi_isendrecv.c \
493+
ompi_sendrecv.c
494494

495495
libmpi_c_la_LIBADD = libmpi_c_profile.la
496496
if BUILD_MPI_BINDINGS_LAYER
@@ -533,6 +533,8 @@ deprecated_interface_profile_sources = \
533533
errhandler_create.c \
534534
errhandler_get.c \
535535
errhandler_set.c \
536+
keyval_create.c \
537+
keyval_free.c \
536538
type_extent.c \
537539
type_hindexed.c \
538540
type_hvector.c \

ompi/mpi/c/bindings.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ BEGIN_C_DECLS
116116
} while (0)
117117

118118

119+
int ompi_sendrecv(const void * sendbuf, size_t sendcount, MPI_Datatype sendtype, int dest, int sendtag,
120+
void * recvbuf, size_t recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status);
121+
int ompi_isendrecv(const void * sendbuf, size_t sendcount, MPI_Datatype sendtype, int dest, int sendtag,
122+
void * recvbuf, size_t recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Request * request);
123+
119124
END_C_DECLS
120125

121126
#endif /* OMPI_C_BINDINGS_H */

ompi/mpi/c/isendrecv.c.in

Lines changed: 1 addition & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -37,60 +37,12 @@
3737
#include "ompi/runtime/ompi_spc.h"
3838

3939

40-
struct ompi_isendrecv_context_t {
41-
opal_object_t super;
42-
int nreqs;
43-
int source;
44-
ompi_request_t *subreq[2];
45-
};
46-
47-
typedef struct ompi_isendrecv_context_t ompi_isendrecv_context_t;
48-
#if OMPI_BUILD_MPI_PROFILING
49-
OBJ_CLASS_INSTANCE(ompi_isendrecv_context_t, opal_object_t, NULL, NULL);
50-
#else
51-
OBJ_CLASS_DECLARATION(ompi_isendrecv_context_t);
52-
#endif /* OMPI_BUILD_MPI_PROFILING */
53-
54-
static int ompi_isendrecv_complete_func (ompi_comm_request_t *request)
55-
{
56-
ompi_isendrecv_context_t *context =
57-
(ompi_isendrecv_context_t *) request->context;
58-
59-
/*
60-
* Copy the status from the receive side of the sendrecv request?
61-
* But what if the send failed?
62-
*
63-
* Probably need to bring up in the MPI forum.
64-
*/
65-
66-
if (MPI_PROC_NULL != context->source) {
67-
OMPI_COPY_STATUS(&request->super.req_status,
68-
context->subreq[0]->req_status, false);
69-
} else {
70-
OMPI_COPY_STATUS(&request->super.req_status,
71-
ompi_request_empty.req_status, false);
72-
}
73-
74-
if(NULL != context->subreq[0]) {
75-
ompi_request_free(&context->subreq[0]);
76-
}
77-
if(NULL != context->subreq[1]) {
78-
ompi_request_free(&context->subreq[1]);
79-
}
80-
81-
return OMPI_SUCCESS;
82-
}
83-
8440
PROTOTYPE ERROR_CLASS isendrecv(BUFFER sendbuf, COUNT sendcount, DATATYPE sendtype,
8541
INT dest, INT sendtag, BUFFER_OUT recvbuf, COUNT recvcount,
8642
DATATYPE recvtype, INT source, INT recvtag,
8743
COMM comm, REQUEST_INOUT request)
8844
{
89-
ompi_isendrecv_context_t *context = NULL;
90-
ompi_comm_request_t *crequest;
9145
int rc = MPI_SUCCESS;
92-
int nreqs = 0;
93-
uint32_t flags;
9446

9547
SPC_RECORD(OMPI_SPC_ISENDRECV, 1);
9648

@@ -125,64 +77,9 @@ PROTOTYPE ERROR_CLASS isendrecv(BUFFER sendbuf, COUNT sendcount, DATATYPE sendty
12577
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
12678
}
12779

128-
crequest = ompi_comm_request_get ();
129-
if (NULL == crequest) {
130-
return OMPI_ERR_OUT_OF_RESOURCE;
131-
}
132-
133-
context = OBJ_NEW(ompi_isendrecv_context_t);
134-
if (NULL == context) {
135-
ompi_comm_request_return (crequest);
136-
return OMPI_ERR_OUT_OF_RESOURCE;
137-
}
138-
139-
crequest->context = &context->super;
140-
context->subreq[0] = MPI_REQUEST_NULL;
141-
context->subreq[1] = MPI_REQUEST_NULL;
142-
context->source = source;
143-
144-
if (source != MPI_PROC_NULL) { /* post recv */
145-
rc = MCA_PML_CALL(irecv(recvbuf, recvcount, recvtype,
146-
source, recvtag, comm, &context->subreq[nreqs++]));
147-
if (MPI_SUCCESS != rc) {
148-
OBJ_RELEASE(context);
149-
ompi_comm_request_return (crequest);
150-
}
151-
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
152-
}
153-
154-
if (dest != MPI_PROC_NULL) { /* send */
155-
rc = MCA_PML_CALL(isend(sendbuf, sendcount, sendtype, dest,
156-
sendtag, MCA_PML_BASE_SEND_STANDARD, comm, &context->subreq[nreqs++]));
157-
if (MPI_SUCCESS != rc) {
158-
OBJ_RELEASE(context);
159-
ompi_comm_request_return (crequest);
160-
}
161-
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
162-
}
163-
164-
/*
165-
* schedule the operation
166-
*/
167-
168-
context->nreqs = nreqs;
169-
assert(nreqs <= 2);
170-
171-
flags = OMPI_COMM_REQ_FLAG_RETAIN_SUBREQ;
172-
173-
rc = ompi_comm_request_schedule_append_w_flags(crequest, ompi_isendrecv_complete_func,
174-
context->subreq, nreqs, flags);
175-
if (MPI_SUCCESS != rc) {
176-
OBJ_RELEASE(context);
177-
ompi_comm_request_return (crequest);
178-
}
80+
rc = ompi_isendrecv(sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, recvtype, source, recvtag, comm, request);
17981

18082
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
18183

182-
/* kick off the request */
183-
184-
ompi_comm_request_start (crequest);
185-
*request = &crequest->super;
186-
18784
return rc;
18885
}

ompi/mpi/c/isendrecv_replace.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ PROTOTYPE ERROR_CLASS isendrecv_replace(BUFFER_OUT buf, COUNT count, DATATYPE da
148148

149149
/* simple case */
150150
if ( source == MPI_PROC_NULL || dest == MPI_PROC_NULL || count == 0 ) {
151-
rc = PMPI_Isendrecv(buf, count, datatype, dest, sendtag, buf, count, datatype, source, recvtag, comm, request);
151+
rc = ompi_isendrecv(buf, count, datatype, dest, sendtag, buf, count, datatype, source, recvtag, comm, request);
152152
return rc;
153153
}
154154

ompi/mpi/c/keyval_create.c.in renamed to ompi/mpi/c/keyval_create.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND. */
12
/*
23
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -31,22 +32,26 @@
3132
#include "ompi/attribute/attribute.h"
3233
#include "ompi/communicator/communicator.h"
3334

34-
PROTOTYPE ERROR_CLASS keyval_create(COPY_FUNCTION copy_attr_fn,
35-
DELETE_FUNCTION delete_attr_fn,
36-
INT_OUT keyval, BUFFER_OUT extra_state)
35+
#if OMPI_BUILD_MPI_PROFILING
36+
#if OPAL_HAVE_WEAK_SYMBOLS
37+
#pragma weak MPI_Keyval_create = PMPI_Keyval_create
38+
#endif
39+
#define MPI_Keyval_create PMPI_Keyval_create
40+
#endif
41+
int MPI_Keyval_create(MPI_Copy_function * copy_attr_fn, MPI_Delete_function * delete_attr_fn, int *keyval, void * extra_state)
3742
{
3843
int ret;
3944
ompi_attribute_fn_ptr_union_t copy_fn;
4045
ompi_attribute_fn_ptr_union_t del_fn;
4146

4247
if (MPI_PARAM_CHECK) {
43-
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
48+
OMPI_ERR_INIT_FINALIZE("MPI_Keyval_create");
4449
if (NULL == keyval) {
4550
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_KEYVAL,
46-
FUNC_NAME);
51+
"MPI_Keyval_create");
4752
} else if ((NULL == copy_attr_fn) || (NULL == delete_attr_fn)) {
4853
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG,
49-
FUNC_NAME);
54+
"MPI_Keyval_create");
5055
}
5156
}
5257

@@ -55,5 +60,5 @@ PROTOTYPE ERROR_CLASS keyval_create(COPY_FUNCTION copy_attr_fn,
5560

5661
ret = ompi_attr_create_keyval(COMM_ATTR, copy_fn,
5762
del_fn, keyval, extra_state, 0, NULL);
58-
OMPI_ERRHANDLER_NOHANDLE_RETURN(ret, MPI_ERR_OTHER, FUNC_NAME);
63+
OMPI_ERRHANDLER_NOHANDLE_RETURN(ret, MPI_ERR_OTHER, "MPI_Keyval_create");
5964
}

ompi/mpi/c/keyval_free.c.in renamed to ompi/mpi/c/keyval_free.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND. */
12
/*
23
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -28,18 +29,24 @@
2829
#include "ompi/attribute/attribute.h"
2930
#include "ompi/communicator/communicator.h"
3031

31-
PROTOTYPE ERROR_CLASS keyval_free(INT_OUT keyval)
32+
#if OMPI_BUILD_MPI_PROFILING
33+
#if OPAL_HAVE_WEAK_SYMBOLS
34+
#pragma weak MPI_Keyval_free = PMPI_Keyval_free
35+
#endif
36+
#define MPI_Keyval_free PMPI_Keyval_free
37+
#endif
38+
int MPI_Keyval_free(int *keyval)
3239
{
3340
int ret;
3441

3542
/* Check for valid key pointer */
3643
if (MPI_PARAM_CHECK) {
3744
if (NULL == keyval) {
3845
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_KEYVAL,
39-
FUNC_NAME);
46+
"MPI_Keyval_free");
4047
}
4148
}
4249

4350
ret = ompi_attr_free_keyval(COMM_ATTR, keyval, 0);
44-
OMPI_ERRHANDLER_NOHANDLE_RETURN(ret, MPI_ERR_OTHER, FUNC_NAME);
51+
OMPI_ERRHANDLER_NOHANDLE_RETURN(ret, MPI_ERR_OTHER, "MPI_Keyval_free");
4552
}

0 commit comments

Comments
 (0)