Skip to content

Commit 519519b

Browse files
authored
Merge pull request #10070 from bwbarrett/cleanup/attribute-copy-args
attributes: Remove internal copy arg
2 parents 6e6195d + 1bcc6b1 commit 519519b

File tree

11 files changed

+46
-40
lines changed

11 files changed

+46
-40
lines changed

contrib/check_unnecessary_headers.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# Copyright (c) 2004-2005 The Regents of the University of California.
1212
# All rights reserved.
1313
# Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
14+
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
15+
# All Rights reserved.
1416
#
1517
#
1618
# Some grep/sed mojo may be of interest to others...
@@ -175,7 +177,7 @@ SEARCH_HEADER[29]=""
175177
delete_unnessary_header .
176178

177179
####################################
178-
SEARCH_HEADER[0]="ompi/attribute/attribute.h ATTR_HASH_SIZE OMPI_KEYVAL_PREDEFINED OMPI_KEYVAL_F77 ompi_attribute_type_t ompi_mpi1_fortran_copy_attr_function ompi_mpi1_fortran_delete_attr_function ompi_mpi2_fortran_copy_attr_function ompi_mpi2_fortran_delete_attr_function MPI_Comm_internal_copy_attr_function MPI_Type_internal_copy_attr_function MPI_Win_internal_copy_attr_function ompi_attribute_keyval_destructor_fn_t ompi_attribute_fn_ptr_union_t ompi_attribute_fortran_ptr_t ompi_attribute_keyval_t ompi_attr_hash_init ompi_attr_init ompi_attr_finalize ompi_attr_create_keyval ompi_attr_free_keyval ompi_attr_set_c ompi_attr_set_fortran_mpi1 ompi_attr_set_fortran_mpi2 ompi_attr_get_c ompi_attr_get_fortran_mpi1 ompi_attr_get_fortran_mpi2 ompi_attr_delete ompi_attr_copy_all ompi_attr_delete_all ompi_attr_create_predefined ompi_attr_free_predefined"
180+
SEARCH_HEADER[0]="ompi/attribute/attribute.h ATTR_HASH_SIZE OMPI_KEYVAL_PREDEFINED OMPI_KEYVAL_F77 ompi_attribute_type_t ompi_mpi1_fortran_copy_attr_function ompi_mpi1_fortran_delete_attr_function ompi_mpi2_fortran_copy_attr_function ompi_mpi2_fortran_delete_attr_function ompi_attribute_keyval_destructor_fn_t ompi_attribute_fn_ptr_union_t ompi_attribute_fortran_ptr_t ompi_attribute_keyval_t ompi_attr_hash_init ompi_attr_init ompi_attr_finalize ompi_attr_create_keyval ompi_attr_free_keyval ompi_attr_set_c ompi_attr_set_fortran_mpi1 ompi_attr_set_fortran_mpi2 ompi_attr_get_c ompi_attr_get_fortran_mpi1 ompi_attr_get_fortran_mpi2 ompi_attr_delete ompi_attr_copy_all ompi_attr_delete_all ompi_attr_create_predefined ompi_attr_free_predefined"
179181
SEARCH_HEADER[1]="ompi/class/ompi_free_list.h ompi_free_list_item_init_fn_t ompi_free_list_t ompi_free_list_item_t ompi_free_list_init_ex ompi_free_list_init ompi_free_list_init_ex_new ompi_free_list_init_new ompi_free_list_grow ompi_free_list_resize ompi_free_list_pos_t OMPI_FREE_LIST_POS_BEGINNING ompi_free_list_parse OMPI_FREE_LIST_GET OMPI_FREE_LIST_WAIT __ompi_free_list_wait OMPI_FREE_LIST_RETURN"
180182
SEARCH_HEADER[2]="ompi/class/ompi_rb_tree.h ompi_rb_tree_nodecolor_t ompi_rb_tree_node_t ompi_rb_tree_comp_fn_t ompi_rb_tree_t ompi_rb_tree_condition_fn_t ompi_rb_tree_action_fn_t ompi_rb_tree_construct ompi_rb_tree_destruct ompi_rb_tree_init ompi_rb_tree_insert ompi_rb_tree_find_with ompi_rb_tree_find ompi_rb_tree_delete ompi_rb_tree_destroy ompi_rb_tree_traverse ompi_rb_tree_size"
181183
SEARCH_HEADER[3]="ompi/class/ompi_seq_tracker.h ompi_seq_tracker_range_t ompi_seq_tracker_t ompi_seq_tracker_check_duplicate ompi_seq_tracker_insert ompi_seq_tracker_copy"

ompi/attribute/attribute.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
1919
* reserved.
20+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
21+
* All Rights reserved.
2022
* $COPYRIGHT$
2123
*
2224
* Additional copyrights may follow
@@ -331,7 +333,7 @@ do { \
331333
/* See the big, long comment above from DELETE_ATTR_CALLBACKS -- most of
332334
that text applies here, too. */
333335

334-
#define COPY_ATTR_CALLBACKS(type, old_object, keyval_obj, in_attr, new_object, out_attr, err) \
336+
#define COPY_ATTR_CALLBACKS(type, old_object, keyval_obj, in_attr, out_attr, err) \
335337
do { \
336338
OPAL_THREAD_UNLOCK(&attribute_lock); \
337339
if (0 != (keyval_obj->attr_flag & OMPI_KEYVAL_F77)) { \
@@ -380,7 +382,7 @@ do { \
380382
in = translate_to_c(in_attr); \
381383
if ((err = (*((keyval_obj->copy_attr_fn).attr_##type##_copy_fn)) \
382384
((ompi_##type##_t *)old_object, key, keyval_obj->extra_state.c_ptr, \
383-
in, &out, &flag, (ompi_##type##_t *)(new_object))) == MPI_SUCCESS) { \
385+
in, &out, &flag)) == MPI_SUCCESS) { \
384386
out_attr->av_value = out; \
385387
} \
386388
} \
@@ -1036,19 +1038,19 @@ int ompi_attr_copy_all(ompi_attribute_type_t type, void *old_object,
10361038
case COMM_ATTR:
10371039
/* Now call the copy_attr_fn */
10381040
COPY_ATTR_CALLBACKS(communicator, old_object, hash_value,
1039-
old_attr, new_object, new_attr, err);
1041+
old_attr, new_attr, err);
10401042
break;
10411043

10421044
case TYPE_ATTR:
10431045
/* Now call the copy_attr_fn */
10441046
COPY_ATTR_CALLBACKS(datatype, old_object, hash_value,
1045-
old_attr, new_object, new_attr, err);
1047+
old_attr, new_attr, err);
10461048
break;
10471049

10481050
case WIN_ATTR:
10491051
/* Now call the copy_attr_fn */
10501052
COPY_ATTR_CALLBACKS(win, old_object, hash_value,
1051-
old_attr, new_object, new_attr, err);
1053+
old_attr, new_attr, err);
10521054
break;
10531055

10541056
default:

ompi/attribute/attribute.h

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* and Technology (RIST). All rights reserved.
1616
* Copyright (c) 2018-2019 Triad National Security, LLC. All rights
1717
* reserved.
18+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
19+
* All Rights reserved.
1820
* $COPYRIGHT$
1921
*
2022
* Additional copyrights may follow
@@ -83,18 +85,6 @@ typedef void (*ompi_aint_copy_attr_function)(MPI_Fint *oldobj, MPI_Fint *keyval,
8385
ompi_fortran_logical_t *flag, MPI_Fint *ierr);
8486
typedef void (*ompi_aint_delete_attr_function)(MPI_Fint *obj, MPI_Fint *keyval, void *attr_in,
8587
void *extra_state, MPI_Fint *ierr);
86-
/*
87-
* Internally the copy function for all kinds of MPI objects has one more
88-
* argument, the pointer to the new object. Therefore, we can do on the
89-
* flight modifications of the new communicator based on attributes stored
90-
* on the main communicator.
91-
*/
92-
typedef int (*MPI_Comm_internal_copy_attr_function)(MPI_Comm, int, void *, void *, void *, int *,
93-
MPI_Comm);
94-
typedef int (*MPI_Type_internal_copy_attr_function)(MPI_Datatype, int, void *, void *, void *,
95-
int *, MPI_Datatype);
96-
typedef int (*MPI_Win_internal_copy_attr_function)(MPI_Win, int, void *, void *, void *, int *,
97-
MPI_Win);
9888

9989
typedef void (ompi_attribute_keyval_destructor_fn_t)(int);
10090

@@ -107,19 +97,17 @@ union ompi_attribute_fn_ptr_union_t {
10797
MPI_Type_delete_attr_function *attr_datatype_delete_fn;
10898
MPI_Win_delete_attr_function *attr_win_delete_fn;
10999

110-
MPI_Comm_internal_copy_attr_function attr_communicator_copy_fn;
111-
MPI_Type_internal_copy_attr_function attr_datatype_copy_fn;
112-
MPI_Win_internal_copy_attr_function attr_win_copy_fn;
100+
MPI_Comm_copy_attr_function *attr_communicator_copy_fn;
101+
MPI_Type_copy_attr_function *attr_datatype_copy_fn;
102+
MPI_Win_copy_attr_function *attr_win_copy_fn;
113103

114104
/* For Fortran old MPI-1 callback functions */
115-
116-
ompi_fint_delete_attr_function attr_fint_delete_fn;
117-
ompi_fint_copy_attr_function attr_fint_copy_fn;
105+
ompi_fint_delete_attr_function attr_fint_delete_fn;
106+
ompi_fint_copy_attr_function attr_fint_copy_fn;
118107

119108
/* For Fortran new MPI-2 callback functions */
120-
121-
ompi_aint_delete_attr_function attr_aint_delete_fn;
122-
ompi_aint_copy_attr_function attr_aint_copy_fn;
109+
ompi_aint_delete_attr_function attr_aint_delete_fn;
110+
ompi_aint_copy_attr_function attr_aint_copy_fn;
123111
};
124112

125113
typedef union ompi_attribute_fn_ptr_union_t ompi_attribute_fn_ptr_union_t;

ompi/attribute/attribute_predefined.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2017 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
1616
* Copyright (c) 2020 Intel, Inc. All rights reserved.
17+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
18+
* All Rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -194,8 +196,8 @@ static int create_comm(int target_keyval, bool want_inherit)
194196
ompi_attribute_fn_ptr_union_t del;
195197

196198
keyval = -1;
197-
copy.attr_communicator_copy_fn = (MPI_Comm_internal_copy_attr_function)(
198-
want_inherit ? MPI_COMM_DUP_FN : MPI_COMM_NULL_COPY_FN);
199+
copy.attr_communicator_copy_fn =
200+
want_inherit ? MPI_COMM_DUP_FN : MPI_COMM_NULL_COPY_FN;
199201
del.attr_communicator_delete_fn = MPI_COMM_NULL_DELETE_FN;
200202
keyval = target_keyval;
201203
err = ompi_attr_create_keyval(COMM_ATTR, copy, del,
@@ -225,7 +227,7 @@ static int create_win(int target_keyval)
225227
ompi_attribute_fn_ptr_union_t del;
226228

227229
keyval = -1;
228-
copy.attr_win_copy_fn = (MPI_Win_internal_copy_attr_function) MPI_WIN_NULL_COPY_FN;
230+
copy.attr_win_copy_fn = MPI_WIN_NULL_COPY_FN;
229231
del.attr_win_delete_fn = MPI_WIN_NULL_DELETE_FN;
230232
keyval = target_keyval;
231233
err = ompi_attr_create_keyval(WIN_ATTR, copy, del,

ompi/mca/coll/hcoll/coll_hcoll_module.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* of Tennessee Research Foundation. All rights
66
* reserved.
77
* Copyright (c) 2018 Cisco Systems, Inc. All rights reserved
8+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
9+
* All Rights reserved.
810
* $COPYRIGHT$
911
*
1012
* Additional copyrights may follow
@@ -335,7 +337,7 @@ mca_coll_hcoll_comm_query(struct ompi_communicator_t *comm, int *priority)
335337
} else {
336338
cm->using_mem_hooks = 0;
337339
}
338-
copy_fn.attr_communicator_copy_fn = (MPI_Comm_internal_copy_attr_function*) MPI_COMM_NULL_COPY_FN;
340+
copy_fn.attr_communicator_copy_fn = MPI_COMM_NULL_COPY_FN;
339341
del_fn.attr_communicator_delete_fn = hcoll_comm_attr_del_fn;
340342
err = ompi_attr_create_keyval(COMM_ATTR, copy_fn, del_fn, &hcoll_comm_attr_keyval, NULL ,0, NULL);
341343
if (OMPI_SUCCESS != err) {
@@ -348,7 +350,7 @@ mca_coll_hcoll_comm_query(struct ompi_communicator_t *comm, int *priority)
348350

349351
if (mca_coll_hcoll_component.derived_types_support_enabled) {
350352
zero_dte_mapping.type = DTE_ZERO;
351-
copy_fn.attr_datatype_copy_fn = (MPI_Type_internal_copy_attr_function *) MPI_TYPE_NULL_COPY_FN;
353+
copy_fn.attr_datatype_copy_fn = MPI_TYPE_NULL_COPY_FN;
352354
del_fn.attr_datatype_delete_fn = hcoll_type_attr_del_fn;
353355
err = ompi_attr_create_keyval(TYPE_ATTR, copy_fn, del_fn, &hcoll_type_attr_keyval, NULL ,0, NULL);
354356
if (OMPI_SUCCESS != err) {

ompi/mca/coll/ucc/coll_ucc_module.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/**
22
* Copyright (c) 2021 Mellanox Technologies. All rights reserved.
3+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
4+
* All Rights reserved.
35
* $COPYRIGHT$
46
*
57
* Additional copyrights may follow
@@ -291,8 +293,7 @@ static int mca_coll_ucc_init_ctx() {
291293
}
292294
ucc_context_config_release(ctx_config);
293295

294-
copy_fn.attr_communicator_copy_fn = (MPI_Comm_internal_copy_attr_function)
295-
MPI_COMM_NULL_COPY_FN;
296+
copy_fn.attr_communicator_copy_fn = MPI_COMM_NULL_COPY_FN;
296297
del_fn.attr_communicator_delete_fn = ucc_comm_attr_del_fn;
297298
if (OMPI_SUCCESS != ompi_attr_create_keyval(COMM_ATTR, copy_fn, del_fn,
298299
&ucc_comm_attr_keyval, NULL ,0, NULL)) {

ompi/mca/pml/ucx/pml_ucx.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* and Technology (RIST). All rights reserved.
88
* Copyright (c) 2018 IBM Corporation. All rights reserved.
99
* Copyright (c) 2019 Intel, Inc. All rights reserved.
10+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
11+
* All Rights reserved.
1012
* $COPYRIGHT$
1113
*
1214
* Additional copyrights may follow
@@ -496,8 +498,7 @@ int mca_pml_ucx_enable(bool enable)
496498
int ret;
497499

498500
/* Create a key for adding custom attributes to datatypes */
499-
copy_fn.attr_datatype_copy_fn =
500-
(MPI_Type_internal_copy_attr_function)MPI_TYPE_NULL_COPY_FN;
501+
copy_fn.attr_datatype_copy_fn = MPI_TYPE_NULL_COPY_FN;
501502
del_fn.attr_datatype_delete_fn = mca_pml_ucx_datatype_attr_del_fn;
502503
ret = ompi_attr_create_keyval(TYPE_ATTR, copy_fn, del_fn,
503504
&ompi_pml_ucx.datatype_attr_keyval, NULL, 0,

ompi/mpi/c/comm_create_keyval.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
15+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
16+
* All Rights reserved.
1517
* $COPYRIGHT$
1618
*
1719
* Additional copyrights may follow
@@ -54,7 +56,7 @@ int MPI_Comm_create_keyval(MPI_Comm_copy_attr_function *comm_copy_attr_fn,
5456
}
5557
}
5658

57-
copy_fn.attr_communicator_copy_fn = (MPI_Comm_internal_copy_attr_function) comm_copy_attr_fn;
59+
copy_fn.attr_communicator_copy_fn = comm_copy_attr_fn;
5860
del_fn.attr_communicator_delete_fn = comm_delete_attr_fn;
5961

6062
ret = ompi_attr_create_keyval(COMM_ATTR, copy_fn,

ompi/mpi/c/keyval_create.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
15+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
16+
* All Rights reserved.
1517
* $COPYRIGHT$
1618
*
1719
* Additional copyrights may follow
@@ -56,7 +58,7 @@ int MPI_Keyval_create(MPI_Copy_function *copy_attr_fn,
5658
}
5759
}
5860

59-
copy_fn.attr_communicator_copy_fn = (MPI_Comm_internal_copy_attr_function) copy_attr_fn;
61+
copy_fn.attr_communicator_copy_fn = copy_attr_fn;
6062
del_fn.attr_communicator_delete_fn = delete_attr_fn;
6163

6264
ret = ompi_attr_create_keyval(COMM_ATTR, copy_fn,

ompi/mpi/c/type_create_keyval.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
15+
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
16+
* All Rights reserved.
1517
* $COPYRIGHT$
1618
*
1719
* Additional copyrights may follow
@@ -56,7 +58,7 @@ int MPI_Type_create_keyval(MPI_Type_copy_attr_function *type_copy_attr_fn,
5658
}
5759
}
5860

59-
copy_fn.attr_datatype_copy_fn = (MPI_Type_internal_copy_attr_function) type_copy_attr_fn;
61+
copy_fn.attr_datatype_copy_fn = type_copy_attr_fn;
6062
del_fn.attr_datatype_delete_fn = type_delete_attr_fn;
6163

6264
ret = ompi_attr_create_keyval(TYPE_ATTR, copy_fn, del_fn,

0 commit comments

Comments
 (0)