Skip to content

Commit 177e600

Browse files
committed
some fixes to comm attributes wrappers
also see about fixing an issue with some of the ompi mca components when using --enable-mca-dso. Signed-off-by: Howard Pritchard <[email protected]>
1 parent df6aff9 commit 177e600

File tree

6 files changed

+197
-9
lines changed

6 files changed

+197
-9
lines changed

ompi/mpi/Makefile.am

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,14 @@ EXTRA_DIST += \
3131
mpi/bindings/ompi_bindings/fortran.py \
3232
mpi/bindings/ompi_bindings/fortran_type.py \
3333
mpi/bindings/ompi_bindings/util.py
34+
35+
#
36+
# attr_fn.c needs to be slurped into libopen_mpi
37+
# as it defines the OMPI native variants of
38+
# built-in copy/del attribute functions are these
39+
# are used in some component plugins
40+
#
41+
42+
libopen_mpi_la_SOURCES += \
43+
mpi/c/attr_fn.c
44+

ompi/mpi/bindings/ompi_bindings/c_type.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,11 +1376,20 @@ def argument(self):
13761376
def init_code(self):
13771377
code = []
13781378
code = ['ompi_abi_wrapper_helper_t *helper = NULL;']
1379+
code.append('MPI_Comm_copy_attr_function_ABI_INTERNAL *copy_fn;')
13791380
code.append('helper = ( ompi_abi_wrapper_helper_t *)malloc(sizeof(ompi_abi_wrapper_helper_t));')
13801381
code.append('if (NULL == helper) return MPI_ERR_NO_MEM;')
13811382
code.append('helper->user_extra_state = extra_state;')
1382-
code.append('helper->user_copy_fn = comm_copy_attr_fn;')
1383-
code.append('helper->user_delete_fn = comm_delete_attr_fn;')
1383+
code.append(f'if ({self.name} == MPI_COMM_NULL_COPY_FN_ABI_INTERNAL)' + '{')
1384+
code.append('copy_fn = ABI_C_MPI_COMM_NULL_COPY_FN;')
1385+
code.append('} else if (' + f'{self.name}' + ' == MPI_COMM_DUP_FN_ABI_INTERNAL) {')
1386+
code.append('copy_fn = ABI_C_MPI_COMM_DUP_FN;')
1387+
code.append('} else {')
1388+
code.append(f'copy_fn = {self.name};')
1389+
code.append('}')
1390+
code.append('helper->user_copy_fn = copy_fn;')
1391+
code.append('helper->user_extra_state = extra_state;')
1392+
code.append('extra_state = helper->user_extra_state;')
13841393
return code
13851394

13861395
# TODO: This should be generalized to be reused with type and win
@@ -1425,6 +1434,22 @@ def type_text(self, enable_count=False):
14251434
def argument(self):
14261435
return f'(MPI_Comm_delete_attr_function *) {self.name}'
14271436

1437+
#
1438+
# note the code generated here relies on that generated for
1439+
# COMM_COPY_ATTR_FUNCTION above
1440+
#
1441+
@property
1442+
def init_code(self):
1443+
code = []
1444+
code.append('MPI_Comm_delete_attr_function_ABI_INTERNAL *delete_fn;')
1445+
code.append(f'if ({self.name} == MPI_COMM_NULL_DELETE_FN_ABI_INTERNAL)' + '{')
1446+
code.append('delete_fn = ABI_C_MPI_COMM_NULL_DELETE_FN;')
1447+
code.append('} else {')
1448+
code.append(f'delete_fn = {self.name};')
1449+
code.append('}')
1450+
code.append('helper->user_delete_fn = delete_fn;')
1451+
return code
1452+
14281453
@Type.add_type('GREQUEST_QUERY_FUNCTION', abi_type=['ompi'])
14291454
class TypeGrequestQueryFunction(Type):
14301455

ompi/mpi/c/Makefile.am

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,8 @@ EXTRA_DIST = $(prototype_sources) \
518518
abi_converters.h \
519519
abi_get_info.c.in
520520

521-
# attr_fn.c contains attribute manipulation functions which do not
522-
# profiling implications, and so are always built.
523-
libmpi_c_la_SOURCES = \
524-
attr_fn.c
525-
526521
# functions that do not require profiling implementations.
527-
libmpi_c_la_SOURCES += \
522+
libmpi_c_la_SOURCES = \
528523
ompi_isendrecv.c \
529524
ompi_sendrecv.c \
530525
ompi_abi_fortran.c

ompi/mpi/c/Makefile_abi.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ endif
3939
BUILT_SOURCES = abi.h standard_abi/mpi.h
4040

4141
libmpi_c_abi_la_SOURCES = \
42-
attr_fn.c \
42+
attr_fn_abi.c \
4343
ompi_isendrecv.c \
4444
ompi_sendrecv.c \
4545
ompi_abi_fortran.c

ompi/mpi/c/abi_converters.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,26 @@ __opal_attribute_always_inline__ static inline int ompi_convert_abi_source_inter
10171017
}
10181018
}
10191019

1020+
/*
1021+
* prototypes for ABI built-in attribute callback functions
1022+
*/
1023+
1024+
OMPI_DECLSPEC int ABI_C_MPI_COMM_NULL_DELETE_FN( MPI_Comm_ABI_INTERNAL comm,
1025+
int comm_keyval,
1026+
void* attribute_val_out,
1027+
void* extra_state );
1028+
OMPI_DECLSPEC int ABI_C_MPI_COMM_NULL_COPY_FN( MPI_Comm_ABI_INTERNAL comm,
1029+
int comm_keyval,
1030+
void* extra_state,
1031+
void* attribute_val_in,
1032+
void* attribute_val_out,
1033+
int* flag );
1034+
OMPI_DECLSPEC int ABI_C_MPI_COMM_DUP_FN( MPI_Comm_ABI_INTERNAL comm, int comm_keyval,
1035+
void* extra_state,
1036+
void* attribute_val_in,
1037+
void* attribute_val_out,
1038+
int* flag );
1039+
10201040
#if defined(c_plusplus) || defined(__cplusplus)
10211041
}
10221042
#endif

ompi/mpi/c/attr_fn_abi.c

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/*
2+
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3+
* University Research and Technology
4+
* Corporation. All rights reserved.
5+
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* of Tennessee Research Foundation. All rights
7+
* reserved.
8+
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
* University of Stuttgart. All rights reserved.
10+
* Copyright (c) 2004-2005 The Regents of the University of California.
11+
* All rights reserved.
12+
* Copyright (c) 2018 Research Organization for Information Science
13+
* and Technology (RIST). All rights reserved.
14+
* $COPYRIGHT$
15+
*
16+
* Additional copyrights may follow
17+
*
18+
* $HEADER$
19+
*/
20+
21+
22+
#include "ompi_config.h"
23+
24+
#include "ompi/mpi/c/bindings.h"
25+
#include "ompi/mpi/c/abi.h"
26+
#include "ompi/mpi/c/abi_converters.h"
27+
28+
/*
29+
* Comment to circumvent error-msg of weak-check:
30+
* We do not need #pragma weak in here, as these functions
31+
* do not have a function for the profiling interface.
32+
*/
33+
34+
/*
35+
* Note that these are the back-end functions for MPI_DUP_FN (and
36+
* friends). They have an ABI_C_* prefix because of weird reasons
37+
* listed in a lengthy comment in mpi.h.
38+
*
39+
* Specifically:
40+
*
41+
* MPI_NULL_DELETE_FN -> ABI_C_MPI_NULL_DELETE_FN
42+
* MPI_NULL_COPY_FN -> ABI_C_MPI_NULL_COPY_FN
43+
* MPI_DUP_FN -> ABI_C_MPI_DUP_FN
44+
*
45+
* MPI_TYPE_NULL_DELETE_FN -> ABI_C_MPI_TYPE_NULL_DELETE_FN
46+
* MPI_TYPE_NULL_COPY_FN -> ABI_C_MPI_TYPE_NULL_COPY_FN
47+
* MPI_TYPE_DUP_FN -> ABI_C_MPI_TYPE_DUP_FN
48+
*
49+
* MPI_COMM_NULL_DELETE_FN -> ABI_C_MPI_COMM_NULL_DELETE_FN
50+
* MPI_COMM_NULL_COPY_FN -> ABI_C_MPI_COMM_NULL_COPY_FN
51+
* MPI_COMM_DUP_FN -> ABI_C_MPI_COMM_DUP_FN
52+
*
53+
* MPI_WIN_NULL_DELETE_FN -> ABI_C_MPI_WIN_NULL_DELETE_FN
54+
* MPI_WIN_NULL_COPY_FN -> ABI_C_MPI_WIN_NULL_COPY_FN
55+
* MPI_WIN_DUP_FN -> ABI_C_MPI_WIN_DUP_FN
56+
*/
57+
58+
#if 0
59+
int ABI_C_MPI_TYPE_NULL_DELETE_FN( MPI_Datataype_ABI_INTERNAL datatype, int type_keyval,
60+
void* attribute_val_out,
61+
void* extra_state )
62+
{
63+
/* Why not all MPI functions are like this ?? */
64+
return MPI_SUCCESS;
65+
}
66+
67+
int ABI_C_MPI_TYPE_NULL_COPY_FN( MPI_Datataype_ABI_INTERNAL datatype, int type_keyval,
68+
void* extra_state,
69+
void* attribute_val_in,
70+
void* attribute_val_out,
71+
int* flag )
72+
{
73+
*flag = 0;
74+
return MPI_SUCCESS;
75+
}
76+
77+
int ABI_C_MPI_TYPE_DUP_FN( MPI_Datataype_ABI_INTERNAL datatype, int type_keyval,
78+
void* extra_state,
79+
void* attribute_val_in, void* attribute_val_out,
80+
int* flag )
81+
{
82+
*flag = 1;
83+
*(void**)attribute_val_out = attribute_val_in;
84+
return MPI_SUCCESS;
85+
}
86+
87+
int ABI_C_MPI_WIN_NULL_DELETE_FN( MPI_Win_ABI_INTERNAL window, int win_keyval,
88+
void* attribute_val_out,
89+
void* extra_state )
90+
{
91+
return MPI_SUCCESS;
92+
}
93+
94+
int ABI_C_MPI_WIN_NULL_COPY_FN( MPI_Win_ABI_INTERNAL window, int win_keyval,
95+
void* extra_state,
96+
void* attribute_val_in,
97+
void* attribute_val_out, int* flag )
98+
{
99+
*flag= 0;
100+
return MPI_SUCCESS;
101+
}
102+
103+
int ABI_C_MPI_WIN_DUP_FN( MPI_Win_ABI_INTERNAL window, int win_keyval, void* extra_state,
104+
void* attribute_val_in, void* attribute_val_out,
105+
int* flag )
106+
{
107+
*flag = 1;
108+
*(void**)attribute_val_out = attribute_val_in;
109+
return MPI_SUCCESS;
110+
}
111+
112+
#endif
113+
114+
int ABI_C_MPI_COMM_NULL_DELETE_FN( MPI_Comm_ABI_INTERNAL comm, int comm_keyval,
115+
void* attribute_val_out,
116+
void* extra_state )
117+
{
118+
return MPI_SUCCESS;
119+
}
120+
121+
int ABI_C_MPI_COMM_NULL_COPY_FN( MPI_Comm_ABI_INTERNAL comm, int comm_keyval,
122+
void* extra_state,
123+
void* attribute_val_in,
124+
void* attribute_val_out, int* flag )
125+
{
126+
*flag= 0;
127+
return MPI_SUCCESS;
128+
}
129+
130+
int ABI_C_MPI_COMM_DUP_FN( MPI_Comm_ABI_INTERNAL comm, int comm_keyval, void* extra_state,
131+
void* attribute_val_in, void* attribute_val_out,
132+
int* flag )
133+
{
134+
*flag = 1;
135+
*(void**)attribute_val_out = attribute_val_in;
136+
return MPI_SUCCESS;
137+
}

0 commit comments

Comments
 (0)