From 0f0828e7edc899cc0024d146d83e9c20b0879487 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 25 Nov 2023 11:44:17 -0500 Subject: [PATCH 01/10] Fix a variety of unused variable compiler warnings Where appropriate: * Use __opal_attribute_unused__ (which tells the computer that the variable *might* be unused; it does not promise that the variable is *not* used) * Protect usage with various #if macros * Remove actually-unused variables Signed-off-by: Jeff Squyres (cherry picked from commit dbbf187ebf650ed2d9604cbb4f1c9d2e43f2f56c) --- ompi/communicator/ft/comm_ft.c | 6 +++++- ompi/communicator/ft/comm_ft_detector.c | 3 ++- ompi/mca/coll/adapt/coll_adapt_ireduce.c | 4 +--- ompi/mca/coll/base/coll_base_reduce_scatter_block.c | 3 +-- ompi/mca/coll/tuned/coll_tuned_dynamic_file.c | 7 +++++++ ompi/mca/common/ompio/common_ompio_aggregators.c | 10 +--------- ompi/mca/common/ompio/common_ompio_file_read_all.c | 4 +--- ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c | 8 +++++++- .../dynamic_gen2/fcoll_dynamic_gen2_file_write_all.c | 7 +++++++ ompi/mca/fcoll/vulcan/fcoll_vulcan_file_write_all.c | 7 +++++++ ompi/mca/osc/rdma/osc_rdma_accumulate.c | 5 +---- ompi/mpi/c/info_f2c.c | 3 ++- ompi/mpi/fortran/mpif-h/comm_spawn_multiple_f.c | 3 ++- ompi/mpi/fortran/mpif-h/dist_graph_create_f.c | 4 +++- ompi/patterns/net/netpatterns_nary_tree.c | 9 +++------ opal/datatype/opal_datatype_get_count.c | 8 +++++++- opal/datatype/opal_datatype_unpack.c | 4 +++- opal/mca/base/mca_base_var_enum.c | 3 +++ opal/mca/timer/base/timer_base_open.c | 3 +-- opal/runtime/opal_params.c | 10 +++++++--- 20 files changed, 71 insertions(+), 40 deletions(-) diff --git a/ompi/communicator/ft/comm_ft.c b/ompi/communicator/ft/comm_ft.c index 3d834642e93..3ccd338c19e 100644 --- a/ompi/communicator/ft/comm_ft.c +++ b/ompi/communicator/ft/comm_ft.c @@ -6,6 +6,7 @@ * reserved. * * Copyright (c) 2021 Nanook Consulting. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -441,10 +442,13 @@ bool ompi_comm_is_proc_active(ompi_communicator_t *comm, int peer_id, bool remot int ompi_comm_set_rank_failed(ompi_communicator_t *comm, int peer_id, bool remote) { - /* populate the proc in the comm's group array so that it is not a sentinel and can be read as failed */ +#if OPAL_ENABLE_DEBUG + /* populate the proc in the comm's group array so that it is not a + sentinel and can be read as failed */ ompi_proc_t *ompi_proc = ompi_group_get_proc_ptr((remote ? comm->c_remote_group : comm->c_local_group), peer_id, true); assert(NULL != ompi_proc); +#endif /* Disable ANY_SOURCE */ comm->any_source_enabled = false; diff --git a/ompi/communicator/ft/comm_ft_detector.c b/ompi/communicator/ft/comm_ft_detector.c index 55a15ce16b6..7b835e84f81 100644 --- a/ompi/communicator/ft/comm_ft_detector.c +++ b/ompi/communicator/ft/comm_ft_detector.c @@ -6,6 +6,7 @@ * Copyright (c) 2021 Triad National Security, LLC. All rights * reserved. * + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -579,7 +580,7 @@ static void fd_event_cb(int fd, short flags, void* pdetector) } void* fd_progress(opal_object_t* obj) { - int ret; + int __opal_attribute_unused__ ret; MPI_Request req; if( OMPI_SUCCESS != ompi_comm_start_detector(&ompi_mpi_comm_world.comm)) { OPAL_THREAD_ADD_FETCH32(&fd_thread_active, -1); diff --git a/ompi/mca/coll/adapt/coll_adapt_ireduce.c b/ompi/mca/coll/adapt/coll_adapt_ireduce.c index da6486401f9..6428a90748f 100644 --- a/ompi/mca/coll/adapt/coll_adapt_ireduce.c +++ b/ompi/mca/coll/adapt/coll_adapt_ireduce.c @@ -4,6 +4,7 @@ * reserved. * Copyright (c) 2020 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2022 IBM Corporation. All rights reserved + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -663,7 +664,6 @@ int ompi_coll_adapt_ireduce_generic(const void *sbuf, void *rbuf, int count, con->next_recv_segs[i] = min - 1; } - int num_recvs = 0; for (int32_t seg_index = 0; seg_index < min; seg_index++) { /* For each child */ @@ -711,8 +711,6 @@ int ompi_coll_adapt_ireduce_generic(const void *sbuf, void *rbuf, int count, } /* Set the recv callback */ ompi_request_set_callback(recv_req, recv_cb, context); - - ++num_recvs; } } } diff --git a/ompi/mca/coll/base/coll_base_reduce_scatter_block.c b/ompi/mca/coll/base/coll_base_reduce_scatter_block.c index 3e692e9ab31..65d49e35b59 100644 --- a/ompi/mca/coll/base/coll_base_reduce_scatter_block.c +++ b/ompi/mca/coll/base/coll_base_reduce_scatter_block.c @@ -18,6 +18,7 @@ * Copyright (c) 2018 Siberian State University of Telecommunications * and Information Sciences. All rights reserved. * Copyright (c) 2022 IBM Corporation. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -245,7 +246,6 @@ ompi_coll_base_reduce_scatter_block_intra_recursivedoubling( int is_commutative = ompi_op_is_commute(op); /* Recursive distance doubling */ - int rdoubling_step = 0; for (int mask = 1; mask < comm_size; mask <<= 1) { int remote = rank ^ mask; int cur_tree_root = ompi_rounddown(rank, mask); @@ -350,7 +350,6 @@ ompi_coll_base_reduce_scatter_block_intra_recursivedoubling( if (MPI_SUCCESS != err) { goto cleanup_and_return; } } } - rdoubling_step++; err = ompi_datatype_destroy(&dtypesend); if (MPI_SUCCESS != err) { goto cleanup_and_return; } err = ompi_datatype_destroy(&dtyperecv); diff --git a/ompi/mca/coll/tuned/coll_tuned_dynamic_file.c b/ompi/mca/coll/tuned/coll_tuned_dynamic_file.c index a259c789ac2..e56ece1d0b4 100644 --- a/ompi/mca/coll/tuned/coll_tuned_dynamic_file.c +++ b/ompi/mca/coll/tuned/coll_tuned_dynamic_file.c @@ -11,6 +11,7 @@ * All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -69,8 +70,10 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t** /* stats info */ int total_alg_count = 0; +#if OPAL_ENABLE_DEBUG int total_com_count = 0; int total_msg_count = 0; +#endif if (!fname) { OPAL_OUTPUT((ompi_coll_tuned_stream,"Gave NULL as rule table configuration file for tuned collectives... ignoring!\n")); @@ -203,11 +206,15 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t** goto on_file_error; } +#if OPAL_ENABLE_DEBUG total_msg_count++; +#endif } /* msg size */ +#if OPAL_ENABLE_DEBUG total_com_count++; +#endif } /* comm size */ diff --git a/ompi/mca/common/ompio/common_ompio_aggregators.c b/ompi/mca/common/ompio/common_ompio_aggregators.c index 2f557172cbd..578c4363b7d 100644 --- a/ompi/mca/common/ompio/common_ompio_aggregators.c +++ b/ompi/mca/common/ompio/common_ompio_aggregators.c @@ -16,6 +16,7 @@ * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -195,16 +196,13 @@ int mca_common_ompio_forced_grouping ( ompio_file_t *fh, int rest = fh->f_size % num_groups; int flag = OMPI_COMM_IS_MAPBY_NODE (&ompi_mpi_comm_world.comm); int k=0, p=0, g=0; - int total_procs = 0; for ( k=0, p=0; p (size_t)OMPIO_MCA_GET(fh, bytes_per_agg)){ decision_list_tmp[i] = OMPIO_SPLIT; - split_count++; } else if((size_t)(aggr_bytes_per_group_tmp[i])< (size_t)OMPIO_MCA_GET(fh, bytes_per_agg)){ decision_list_tmp[i] = OMPIO_MERGE; - merge_count++; } else{ decision_list_tmp[i] = OMPIO_RETAIN; - retain_as_is_count++; } } diff --git a/ompi/mca/common/ompio/common_ompio_file_read_all.c b/ompi/mca/common/ompio/common_ompio_file_read_all.c index 27317b328ad..e3f2387d0ce 100644 --- a/ompi/mca/common/ompio/common_ompio_file_read_all.c +++ b/ompi/mca/common/ompio/common_ompio_file_read_all.c @@ -12,6 +12,7 @@ * Copyright (c) 2008-2022 University of Houston. All rights reserved. * Copyright (c) 2017-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -85,7 +86,6 @@ mca_common_ompio_base_file_read_all (struct ompio_file_t *fh, int **blocklen_per_process=NULL; MPI_Aint **displs_per_process=NULL; char *global_buf = NULL; - MPI_Aint global_count = 0; mca_io_ompio_local_io_array *file_offsets_for_agg=NULL; /* array that contains the sorted indices of the global_iov */ @@ -607,13 +607,11 @@ mca_common_ompio_base_file_read_all (struct ompio_file_t *fh, } /*Moving file offsets to an IO array!*/ temp_index = 0; - global_count = 0; for (i=0;if_procs_per_group; i++){ for(j=0;j 0){ file_offsets_for_agg[temp_index].length = blocklen_per_process[i][j]; - global_count += blocklen_per_process[i][j]; file_offsets_for_agg[temp_index].process_id = i; file_offsets_for_agg[temp_index].offset = displs_per_process[i][j]; diff --git a/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c b/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c index 25e99874cc5..fa7c69df67f 100644 --- a/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c +++ b/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c @@ -13,6 +13,7 @@ * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -86,8 +87,9 @@ mca_fcoll_dynamic_file_write_all (struct ompio_file_t *fh, int current_index = 0, temp_index=0; char *global_buf = NULL; +#if DEBUG_ON MPI_Aint global_count = 0; - +#endif /* array that contains the sorted indices of the global_iov */ int *sorted = NULL, *sorted_file_offsets=NULL; @@ -713,7 +715,9 @@ mca_fcoll_dynamic_file_write_all (struct ompio_file_t *fh, } /*Now update the displacements array with memory offsets*/ +#if DEBUG_ON global_count = 0; +#endif for (i=0;idisp_index[temp_pindex]); } +#if DEBUG_ON global_count += file_offsets_for_agg[sorted_file_offsets[i]].length; +#endif } if (NULL != temp_disp_index){ diff --git a/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_write_all.c b/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_write_all.c index e41f8a55208..c6fe8549fb0 100644 --- a/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_write_all.c +++ b/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_write_all.c @@ -12,6 +12,7 @@ * Copyright (c) 2008-2021 University of Houston. All rights reserved. * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -812,7 +813,9 @@ static int shuffle_init ( int index, int cycles, int aggregator, int rank, mca_i int temp_index=0; MPI_Aint *memory_displacements=NULL; int *temp_disp_index=NULL; +#if DEBUG_ON MPI_Aint global_count = 0; +#endif int* blocklength_proc=NULL; ptrdiff_t* displs_proc=NULL; @@ -1112,7 +1115,9 @@ static int shuffle_init ( int index, int cycles, int aggregator, int rank, mca_i } /*Now update the displacements array with memory offsets*/ +#if DEBUG_ON global_count = 0; +#endif for (i=0;idisp_index[temp_pindex]); } +#if DEBUG_ON global_count += file_offsets_for_agg[sorted_file_offsets[i]].length; +#endif } if (NULL != temp_disp_index){ diff --git a/ompi/mca/osc/rdma/osc_rdma_accumulate.c b/ompi/mca/osc/rdma/osc_rdma_accumulate.c index 04dc1b3e829..8bdb24187ff 100644 --- a/ompi/mca/osc/rdma/osc_rdma_accumulate.c +++ b/ompi/mca/osc/rdma/osc_rdma_accumulate.c @@ -12,6 +12,7 @@ * Copyright (c) 2022 Cisco Systems, Inc. All rights reserved * Copyright (c) 2022 Amazon.com, Inc. or its affiliates. * All Rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -544,7 +545,6 @@ static inline int ompi_osc_rdma_gacc_master (ompi_osc_rdma_sync_t *sync, const v /* needed for opal_convertor_raw but not used */ size_t source_size, target_size; ompi_osc_rdma_request_t *subreq; - size_t result_position; ptrdiff_t lb, extent; int ret, acc_len; bool done; @@ -667,7 +667,6 @@ static inline int ompi_osc_rdma_gacc_master (ompi_osc_rdma_sync_t *sync, const v target_iov_index = 0; target_iov_count = 0; source_iov_index = 0; - result_position = 0; subreq = NULL; do { @@ -730,8 +729,6 @@ static inline int ompi_osc_rdma_gacc_master (ompi_osc_rdma_sync_t *sync, const v target_iovec[target_iov_index].iov_base = (void *)((intptr_t) target_iovec[target_iov_index].iov_base + acc_len); target_iov_index += (0 == target_iovec[target_iov_index].iov_len); - result_position += acc_len; - if (source_datatype) { source_iov_index += (0 == source_iovec[source_iov_index].iov_len); source_iovec[source_iov_index].iov_len -= acc_len; diff --git a/ompi/mpi/c/info_f2c.c b/ompi/mpi/c/info_f2c.c index 2bcf2ffec2b..16f2161d5ed 100644 --- a/ompi/mpi/c/info_f2c.c +++ b/ompi/mpi/c/info_f2c.c @@ -15,6 +15,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2018-2022 Triad National Security, LLC. All rights * reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -37,7 +38,7 @@ #define MPI_Info_f2c PMPI_Info_f2c #endif -static const char FUNC_NAME[] = "MPI_Info_f2c"; +static const char FUNC_NAME[] __opal_attribute_unused__ = "MPI_Info_f2c"; /** diff --git a/ompi/mpi/fortran/mpif-h/comm_spawn_multiple_f.c b/ompi/mpi/fortran/mpif-h/comm_spawn_multiple_f.c index 93eda2f341a..fd676539ed3 100644 --- a/ompi/mpi/fortran/mpif-h/comm_spawn_multiple_f.c +++ b/ompi/mpi/fortran/mpif-h/comm_spawn_multiple_f.c @@ -14,6 +14,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2016 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -86,7 +87,7 @@ void ompi_comm_spawn_multiple_f(MPI_Fint *count, char *array_commands, int *c_errs; char **c_array_commands; char ***c_array_argv; - int maxprocs; + int __opal_attribute_unused__ maxprocs; OMPI_ARRAY_NAME_DECL(array_maxprocs); OMPI_ARRAY_NAME_DECL(array_errcds); diff --git a/ompi/mpi/fortran/mpif-h/dist_graph_create_f.c b/ompi/mpi/fortran/mpif-h/dist_graph_create_f.c index 3380be8a537..d702bdaecf2 100644 --- a/ompi/mpi/fortran/mpif-h/dist_graph_create_f.c +++ b/ompi/mpi/fortran/mpif-h/dist_graph_create_f.c @@ -9,6 +9,7 @@ * reserved. * Copyright (c) 2015-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -72,7 +73,8 @@ void ompi_dist_graph_create_f(MPI_Fint *comm_old, MPI_Fint *n, MPI_Fint *sources MPI_Fint *ierr) { MPI_Comm c_comm_old, c_comm_graph; - int count = 0, i; + int __opal_attribute_unused__ count = 0; + int i; MPI_Info c_info; int *c_weights; int c_ierr; diff --git a/ompi/patterns/net/netpatterns_nary_tree.c b/ompi/patterns/net/netpatterns_nary_tree.c index aaa57787d51..11e2ebffc17 100644 --- a/ompi/patterns/net/netpatterns_nary_tree.c +++ b/ompi/patterns/net/netpatterns_nary_tree.c @@ -5,6 +5,7 @@ * Copyright (c) 2014 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -37,7 +38,7 @@ int ompi_netpatterns_setup_narray_tree(int tree_order, int my_rank, int num_node netpatterns_tree_node_t *my_node) { /* local variables */ - int n_levels, result; + int result; int my_level_in_tree, cnt; int lvl,cum_cnt, my_rank_in_my_level,n_lvls_in_tree; int start_index,end_index; @@ -51,11 +52,9 @@ int ompi_netpatterns_setup_narray_tree(int tree_order, int my_rank, int num_node my_node->tree_size=num_nodes; /* figure out number of levels in tree */ - n_levels=0; result=num_nodes-1; while (0 < result ) { result/=tree_order; - n_levels++; }; /* figure out who my children and parents are */ @@ -177,7 +176,7 @@ int ompi_netpatterns_setup_narray_knomial_tree( netpatterns_narray_knomial_tree_node_t *my_node) { /* local variables */ - int n_levels, result; + int result; int my_level_in_tree, cnt ; int lvl,cum_cnt, my_rank_in_my_level,n_lvls_in_tree; int start_index,end_index; @@ -192,11 +191,9 @@ int ompi_netpatterns_setup_narray_knomial_tree( my_node->tree_size=num_nodes; /* figure out number of levels in tree */ - n_levels=0; result=num_nodes-1; while (0 < result ) { result/=tree_order; - n_levels++; }; /* figure out who my children and parents are */ diff --git a/opal/datatype/opal_datatype_get_count.c b/opal/datatype/opal_datatype_get_count.c index 8577a7ef865..e4b3ccc2431 100644 --- a/opal/datatype/opal_datatype_get_count.c +++ b/opal/datatype/opal_datatype_get_count.c @@ -4,6 +4,7 @@ * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -168,7 +169,10 @@ int opal_datatype_compute_ptypes(opal_datatype_t *datatype) { dt_stack_t *pStack; /* pointer to the position on the stack */ uint32_t pos_desc; /* actual position in the description of the derived datatype */ - ssize_t nbElems = 0, stack_pos = 0; + ssize_t stack_pos = 0; +#if defined(VERBOSE) + ssize_t nbElems = 0; +#endif dt_elem_desc_t *pElems; if (NULL != datatype->ptypes) { @@ -213,12 +217,14 @@ int opal_datatype_compute_ptypes(opal_datatype_t *datatype) datatype->ptypes[pElems[pos_desc].elem.common.type] += (size_t) pElems[pos_desc] .elem.count * pElems[pos_desc].elem.blocklen; +#if defined(VERBOSE) nbElems += (size_t) pElems[pos_desc].elem.count * pElems[pos_desc].elem.blocklen; DUMP(" compute_ptypes-add: type %d count %" PRIsize_t " (total type %u total %lld)\n", pElems[pos_desc].elem.common.type, datatype->ptypes[pElems[pos_desc].elem.common.type], pElems[pos_desc].elem.count, nbElems); +#endif pos_desc++; /* advance to the next data */ } } diff --git a/opal/datatype/opal_datatype_unpack.c b/opal/datatype/opal_datatype_unpack.c index 0a11a2586f3..e1f2d93acbf 100644 --- a/opal/datatype/opal_datatype_unpack.c +++ b/opal/datatype/opal_datatype_unpack.c @@ -16,6 +16,7 @@ * Copyright (c) 2017-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2022 IBM Corporation. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -72,7 +73,8 @@ int32_t opal_unpack_homogeneous_contig_function(opal_convertor_t *pConv, struct { const opal_datatype_t *pData = pConv->pDesc; unsigned char *user_memory, *packed_buffer; - uint32_t iov_idx, i; + uint32_t iov_idx; + uint32_t __opal_attribute_unused__ i; size_t remaining, initial_bytes_converted = pConv->bConverted; dt_stack_t *stack = pConv->pStack; ptrdiff_t extent = pData->ub - pData->lb; diff --git a/opal/mca/base/mca_base_var_enum.c b/opal/mca/base/mca_base_var_enum.c index 66907be7f87..bea61adc651 100644 --- a/opal/mca/base/mca_base_var_enum.c +++ b/opal/mca/base/mca_base_var_enum.c @@ -19,6 +19,7 @@ * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * Copyright (c) 2022 Computer Architecture and VLSI Systems (CARV) * Laboratory, ICS Forth. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -459,6 +460,7 @@ int mca_base_var_enum_create_flag(const char *name, const mca_base_var_enum_valu return OPAL_ERR_OUT_OF_RESOURCE; } +#if OPAL_ENABLE_DEBUG int all_flags = 0; for (i = 0; i < new_enum->super.enum_value_count; ++i) { new_enum->enum_flags[i].flag = flags[i].flag; @@ -472,6 +474,7 @@ int mca_base_var_enum_create_flag(const char *name, const mca_base_var_enum_valu assert(flags[i].flag); all_flags |= flags[i].flag; } +#endif *enumerator = new_enum; diff --git a/opal/mca/timer/base/timer_base_open.c b/opal/mca/timer/base/timer_base_open.c index fe830e9b904..491c23db206 100644 --- a/opal/mca/timer/base/timer_base_open.c +++ b/opal/mca/timer/base/timer_base_open.c @@ -12,6 +12,7 @@ * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2023 Triad National Security, LLC. All rights * reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -57,8 +58,6 @@ static int opal_timer_base_open(mca_base_open_flag_t flags) static int opal_timer_base_close(void) { - int ret; - OPAL_TIMING_DISABLE_NATIVE_TIMERS; return OPAL_SUCCESS; diff --git a/opal/runtime/opal_params.c b/opal/runtime/opal_params.c index 379b30e02f2..effc6d3ce0f 100644 --- a/opal/runtime/opal_params.c +++ b/opal/runtime/opal_params.c @@ -25,6 +25,7 @@ * Copyright (c) 2018-2022 Amazon.com, Inc. or its affiliates. All Rights reserved. * Copyright (c) 2021 Nanook Consulting. All rights reserved. * Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -60,8 +61,6 @@ static void opal_deregister_params(void) int opal_register_params(void) { - int ret; - if (opal_register_done) { return OPAL_SUCCESS; } @@ -70,15 +69,20 @@ int opal_register_params(void) #if defined(HAVE_SCHED_YIELD) opal_progress_yield_when_idle = false; - ret = mca_base_var_register("opal", "opal", "progress", "yield_when_idle", + int ret1; + ret1 = mca_base_var_register("opal", "opal", "progress", "yield_when_idle", "Yield the processor when waiting on progress", MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_LOCAL, &opal_progress_yield_when_idle); + if (ret1 < 0) { + return ret1; + } #endif #if OPAL_ENABLE_DEBUG opal_progress_debug = false; + int ret; ret = mca_base_var_register("opal", "opal", "progress", "debug", "Set to non-zero to debug progress engine features", MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, From 3c1846db03422630fc744a7c6bf77a7092401a75 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 25 Nov 2023 14:47:45 -0500 Subject: [PATCH 02/10] coll_base_util.c: ensure buffer is long enough Ensure that a buffer is long enough to hold the trailing \0. Signed-off-by: Jeff Squyres (cherry picked from commit 9aab29a6cd9242fe786f211f417601a835cbba5f) --- ompi/mca/coll/base/coll_base_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ompi/mca/coll/base/coll_base_util.c b/ompi/mca/coll/base/coll_base_util.c index 9465ef95c62..ae9010497d7 100644 --- a/ompi/mca/coll/base/coll_base_util.c +++ b/ompi/mca/coll/base/coll_base_util.c @@ -11,6 +11,7 @@ * All rights reserved. * Copyright (c) 2014-2020 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -398,7 +399,7 @@ int ompi_coll_base_file_getnext_long(FILE *fptr, int *fileline, long* val) int ompi_coll_base_file_getnext_string(FILE *fptr, int *fileline, char** val) { - char trash, token[32]; + char trash, token[33]; int rc; *val = NULL; /* security in case we fail */ From 7b2c178ff9a4eed30c7e799333882634a624f9f2 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 25 Nov 2023 14:49:08 -0500 Subject: [PATCH 03/10] Delete some dead code This code is not referred to anywhere; delete it. Signed-off-by: Jeff Squyres (cherry picked from commit f848448b8b8b7ee24c684c661139b4fe2aadd448) --- ompi/mca/coll/inter/coll_inter_allreduce.c | 1 + ompi/mca/coll/libnbc/libdict/dict.c | 28 ---------------------- ompi/mca/pml/cm/pml_cm_component.c | 13 +--------- 3 files changed, 2 insertions(+), 40 deletions(-) diff --git a/ompi/mca/coll/inter/coll_inter_allreduce.c b/ompi/mca/coll/inter/coll_inter_allreduce.c index 661143b8355..7bba3f45e3a 100644 --- a/ompi/mca/coll/inter/coll_inter_allreduce.c +++ b/ompi/mca/coll/inter/coll_inter_allreduce.c @@ -13,6 +13,7 @@ * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mca/coll/libnbc/libdict/dict.c b/ompi/mca/coll/libnbc/libdict/dict.c index d8eeacc4928..f4cfcdb4ee3 100644 --- a/ompi/mca/coll/libnbc/libdict/dict.c +++ b/ompi/mca/coll/libnbc/libdict/dict.c @@ -16,34 +16,6 @@ dict_malloc_func ompi_coll_libnbc_dict_malloc = malloc; dict_free_func ompi_coll_libnbc_dict_free = free; -static inline dict_malloc_func -dict_set_malloc(dict_malloc_func func) -{ - dict_malloc_func old = ompi_coll_libnbc_dict_malloc; - ompi_coll_libnbc_dict_malloc = func ? func : malloc; - return old; -} - -static inline dict_free_func -dict_set_free(dict_free_func func) -{ - dict_free_func old = ompi_coll_libnbc_dict_free; - ompi_coll_libnbc_dict_free = func ? func : free; - return old; -} - -/* - * In comparing, we cannot simply subtract because that might result in signed - * overflow. - */ -static inline int -dict_int_cmp(const void *k1, const void *k2) -{ - const int *a = (int*)k1, *b = (int*)k2; - - return (*a < *b) ? -1 : (*a > *b) ? +1 : 0; -} - int ompi_coll_libnbc_dict_uint_cmp(const void *k1, const void *k2) { diff --git a/ompi/mca/pml/cm/pml_cm_component.c b/ompi/mca/pml/cm/pml_cm_component.c index b2797fa4030..7ea3678cb6e 100644 --- a/ompi/mca/pml/cm/pml_cm_component.c +++ b/ompi/mca/pml/cm/pml_cm_component.c @@ -15,6 +15,7 @@ * Copyright (c) 2020 Amazon.com, Inc. or its affiliates. * All Rights reserved. * Copyright (c) 2022 IBM Corporation. All rights reserved + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -64,18 +65,6 @@ mca_pml_base_component_2_1_0_t mca_pml_cm_component = { .pmlm_finalize = mca_pml_cm_component_fini, }; -/* Array of send completion callback - one per send type - * These are called internally by the library when the send - * is completed from its perspective. - */ -static void (*send_completion_callbacks[MCA_PML_BASE_SEND_SIZE]) - (struct mca_mtl_request_t *mtl_request) = - { mca_pml_cm_send_request_completion, - mca_pml_cm_send_request_completion, - mca_pml_cm_send_request_completion, - mca_pml_cm_send_request_completion, - mca_pml_cm_send_request_completion } ; - static int mca_pml_cm_component_register(void) { From 771a1450f157c0ff75019f922f31a416d2325912 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 25 Nov 2023 14:50:04 -0500 Subject: [PATCH 04/10] mca_base_var.c: clear flags appropriately Fix an incorrect assignment of flags: flags_derived is meant to hold flags of type mca_base_var_syn_flag_t (i.e., synonym flags), whereas flags holds flags of type mca_base_var_flag_t (i.e., regular flags). These are two different types of flags, and are not intended to be mixed. Hence, initialize the per-variable synonym flags to 0 -- do *not* initialize them to the value of the regular flags. Signed-off-by: Jeff Squyres (cherry picked from commit 7741cd87b85ae52d0398d40f4a204b71294f0375) --- opal/mca/base/mca_base_var.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opal/mca/base/mca_base_var.c b/opal/mca/base/mca_base_var.c index b36ff099221..b9860c6ed1e 100644 --- a/opal/mca/base/mca_base_var.c +++ b/opal/mca/base/mca_base_var.c @@ -24,6 +24,7 @@ * Copyright (c) 2021 Nanook Consulting. All rights reserved. * Copyright (c) 2022 Computer Architecture and VLSI Systems (CARV) * Laboratory, ICS Forth. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -1547,7 +1548,7 @@ int mca_base_var_register(const char *project_name, const char *framework_name, } OPAL_LIST_FOREACH_DECL(alias_item, &alias->component_aliases, mca_base_alias_item_t) { - mca_base_var_syn_flag_t flags_derived = flags; + mca_base_var_syn_flag_t flags_derived = 0; if (alias_item->alias_flags & MCA_BASE_ALIAS_FLAG_DEPRECATED) { flags_derived = MCA_BASE_VAR_SYN_FLAG_DEPRECATED; } From e58a0ae12b25e1b3e96f5b43663504c85267a20f Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 25 Nov 2023 14:51:24 -0500 Subject: [PATCH 05/10] Add "void" to empty function param list Fix compiler warnings by changing "()" to "(void)" in some function definitions. Signed-off-by: Jeff Squyres (cherry picked from commit a4039d437e48ada6a3eec1971790ba0ea1b42039) --- opal/mca/btl/template/btl_template_component.c | 3 ++- opal/runtime/opal_info_support.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/opal/mca/btl/template/btl_template_component.c b/opal/mca/btl/template/btl_template_component.c index 3d94c1ae32f..af71db179a0 100644 --- a/opal/mca/btl/template/btl_template_component.c +++ b/opal/mca/btl/template/btl_template_component.c @@ -14,6 +14,7 @@ * reserved. * Copyright (c) 2020 Amazon.com, Inc. or its affiliates. * All Rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -143,7 +144,7 @@ mca_btl_base_module_t **mca_btl_template_component_init(int *num_btl_modules, * TEMPLATE component progress. */ -int mca_btl_template_component_progress() +int mca_btl_template_component_progress(void) { return 0; } diff --git a/opal/runtime/opal_info_support.c b/opal/runtime/opal_info_support.c index 1f38e82fda6..e167451d67f 100644 --- a/opal/runtime/opal_info_support.c +++ b/opal/runtime/opal_info_support.c @@ -20,6 +20,7 @@ * Copyright (c) 2021 Nanook Consulting. All rights reserved. * Copyright (c) 2022 Computer Architecture and VLSI Systems (CARV) * Laboratory, ICS Forth. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -842,12 +843,12 @@ void opal_info_show_mca_params(const char *type, const char *component, } } -void opal_info_do_arch() +void opal_info_do_arch(void) { opal_info_out("Configured architecture", "config:arch", OPAL_ARCH); } -void opal_info_do_hostname() +void opal_info_do_hostname(void) { opal_info_out("Configure host", "config:host", OPAL_CONFIGURE_HOST); } From 24458fe39aecaf7103895211f5013afd9ef4aac1 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 25 Nov 2023 14:52:51 -0500 Subject: [PATCH 06/10] Make some variables const to fix compiler warnings Signed-off-by: Jeff Squyres (cherry picked from commit 739d2d88a80b32ec022a0cf39b9d15b65307ce2b) --- ompi/mca/coll/inter/coll_inter_allreduce.c | 3 ++- ompi/mca/osc/rdma/osc_rdma.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ompi/mca/coll/inter/coll_inter_allreduce.c b/ompi/mca/coll/inter/coll_inter_allreduce.c index 7bba3f45e3a..86f6e7418c6 100644 --- a/ompi/mca/coll/inter/coll_inter_allreduce.c +++ b/ompi/mca/coll/inter/coll_inter_allreduce.c @@ -49,7 +49,8 @@ mca_coll_inter_allreduce_inter(const void *sbuf, void *rbuf, int count, mca_coll_base_module_t *module) { int err, rank, root = 0; - char *tmpbuf = NULL, *pml_buffer = NULL, *source; + char *tmpbuf = NULL, *pml_buffer = NULL; + const char *source; ptrdiff_t gap, span; rank = ompi_comm_rank(comm); diff --git a/ompi/mca/osc/rdma/osc_rdma.h b/ompi/mca/osc/rdma/osc_rdma.h index c17cbb4d210..2a91fb69264 100644 --- a/ompi/mca/osc/rdma/osc_rdma.h +++ b/ompi/mca/osc/rdma/osc_rdma.h @@ -18,6 +18,7 @@ * Copyright (c) 2020-2021 Google, LLC. All rights reserved. * Copyright (c) 2022 Amazon.com, Inc. or its affiliates. * All Rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -753,7 +754,7 @@ static inline int osc_rdma_accelerator_mem_move(void *dest, const void *src, siz * @retval >0 The buffer belongs to a managed buffer in * device memory. */ -static inline int osc_rdma_is_accel(void *buf) +static inline int osc_rdma_is_accel(const void *buf) { int dev_id; uint64_t flags; From 35fd860c3f890ee6ec50b81e436c9463ef73b095 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 25 Nov 2023 14:53:29 -0500 Subject: [PATCH 07/10] patcher: fix preprocessor macro usage HAVE__CLEAR_CACHE is either defined or not; it is not defined to 0 or 1. Signed-off-by: Jeff Squyres (cherry picked from commit cea0e2480312d4e16020357bb6661692514b9049) --- opal/mca/patcher/base/patcher_base_patch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opal/mca/patcher/base/patcher_base_patch.c b/opal/mca/patcher/base/patcher_base_patch.c index 57ee1d291a2..26f4c65c190 100644 --- a/opal/mca/patcher/base/patcher_base_patch.c +++ b/opal/mca/patcher/base/patcher_base_patch.c @@ -6,6 +6,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2022 Amazon.com, Inc. or its affiliates. * All Rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -84,7 +85,7 @@ static int PatchLoadImm(uintptr_t addr, unsigned int reg, size_t value) #endif -#if !HAVE___CLEAR_CACHE +#if !defined(HAVE___CLEAR_CACHE) static void flush_and_invalidate_cache(unsigned long a) { # if defined(PLATFORM_ARCH_X86) @@ -149,7 +150,7 @@ static inline void apply_patch(unsigned char *patch_data, uintptr_t address, siz { ModifyMemoryProtection(address, data_size, PROT_EXEC | PROT_READ | PROT_WRITE); memcpy((void *) address, patch_data, data_size); -#if HAVE___CLEAR_CACHE +#if defined(HAVE___CLEAR_CACHE) /* do not allow global declaration of compiler intrinsic */ void __clear_cache(void *beg, void *end); From b34742d0131e4ed21c536e147f4efa65ced6deb4 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 25 Nov 2023 14:54:17 -0500 Subject: [PATCH 08/10] osc_rdma: do pointer match on (const char*) Don't do pointer math on (void*). Signed-off-by: Jeff Squyres (cherry picked from commit b7f922175187b34523960f099c1781e9303513e5) --- ompi/mca/osc/rdma/osc_rdma_accumulate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ompi/mca/osc/rdma/osc_rdma_accumulate.c b/ompi/mca/osc/rdma/osc_rdma_accumulate.c index 8bdb24187ff..198d05c6be4 100644 --- a/ompi/mca/osc/rdma/osc_rdma_accumulate.c +++ b/ompi/mca/osc/rdma/osc_rdma_accumulate.c @@ -294,11 +294,11 @@ static int ompi_osc_rdma_fetch_and_op_cas (ompi_osc_rdma_sync_t *sync, const voi return ret; } } else if (&ompi_mpi_op_no_op.op != op) { - ret = osc_rdma_is_accel(origin_addr + dt->super.true_lb); + ret = osc_rdma_is_accel(((const char*) origin_addr) + dt->super.true_lb); if (0 < ret) { tmp_origin = malloc(dt->super.size); ret = opal_accelerator.mem_copy(MCA_ACCELERATOR_NO_DEVICE_ID, MCA_ACCELERATOR_NO_DEVICE_ID, - tmp_origin, origin_addr + dt->super.true_lb, dt->super.size, MCA_ACCELERATOR_TRANSFER_DTOH); + tmp_origin, ((const char*) origin_addr) + dt->super.true_lb, dt->super.size, MCA_ACCELERATOR_TRANSFER_DTOH); ompi_op_reduce (op, (void *) tmp_origin, (void*)((ptrdiff_t) &new_value + offset), 1, dt); free(tmp_origin); } else if (0 == ret) { From ead9a6bd44b3aea3c1ea9f268e7789c03b27c695 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 25 Nov 2023 14:54:54 -0500 Subject: [PATCH 09/10] fbtl_posix: fix sign comparisons Signed-off-by: Jeff Squyres (cherry picked from commit c64fb39c6bf4242b5dd173565c23d3273ed384e5) --- ompi/mca/fbtl/posix/fbtl_posix_preadv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ompi/mca/fbtl/posix/fbtl_posix_preadv.c b/ompi/mca/fbtl/posix/fbtl_posix_preadv.c index 7f32c8e227b..944fecdffdf 100644 --- a/ompi/mca/fbtl/posix/fbtl_posix_preadv.c +++ b/ompi/mca/fbtl/posix/fbtl_posix_preadv.c @@ -12,6 +12,7 @@ * Copyright (c) 2008-2021 University of Houston. All rights reserved. * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -221,11 +222,11 @@ ssize_t mca_fbtl_posix_preadv_datasieving (ompio_file_t *fh, struct flock *lock, size_t start_offset = (size_t) fh->f_io_array[startindex].offset; for ( i = startindex ; i < endindex ; i++) { pos = (size_t) fh->f_io_array[i].offset - start_offset; - if ( (ssize_t) pos > total_bytes ) { + if ( pos > total_bytes ) { break; } num_bytes = fh->f_io_array[i].length; - if ( ((ssize_t) pos + (ssize_t)num_bytes) > total_bytes ) { + if ( (pos + (size_t)num_bytes) > total_bytes ) { num_bytes = total_bytes - (ssize_t)pos; } From 5cadbd89fba1b159ce7230ba0c81cd6652d91b0f Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 27 Nov 2023 17:50:17 -0500 Subject: [PATCH 10/10] libdict/hb_tree.c: remove dead code Signed-off-by: Jeff Squyres --- ompi/mca/coll/libnbc/libdict/hb_tree.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/ompi/mca/coll/libnbc/libdict/hb_tree.c b/ompi/mca/coll/libnbc/libdict/hb_tree.c index c6762a40601..3ce9f601535 100644 --- a/ompi/mca/coll/libnbc/libdict/hb_tree.c +++ b/ompi/mca/coll/libnbc/libdict/hb_tree.c @@ -53,30 +53,6 @@ static hb_node *node_max __P((hb_node *node)); static hb_node *node_next __P((hb_node *node)); static hb_node *node_prev __P((hb_node *node)); -static dict *hb_dict_new __P((dict_cmp_func key_cmp, dict_del_func key_del, - dict_del_func dat_del)); -static dict_itor *hb_dict_itor_new __P((hb_tree *tree)); -static void hb_itor_invalidate __P((hb_itor *itor)); -static int hb_itor_first __P((hb_itor *itor)); -static void *hb_itor_data __P((hb_itor *itor)); -static const void *hb_itor_cdata __P((const hb_itor *itor)); -static int hb_itor_last __P((hb_itor *itor)); -static int hb_itor_nextn __P((hb_itor *itor, unsigned count)); -static int hb_itor_prev __P((hb_itor *itor)); -static int hb_itor_prevn __P((hb_itor *itor, unsigned count)); -static int hb_itor_search __P((hb_itor *itor, const void *key)); -static int hb_itor_set_data __P((hb_itor *itor, void *dat, int del)); -static unsigned hb_tree_count __P((const hb_tree *tree)); -static void hb_tree_destroy __P((hb_tree *tree, int del)); -static void hb_tree_empty __P((hb_tree *tree, int del)); -static unsigned hb_tree_height __P((const hb_tree *tree)); -static const void *hb_tree_max __P((const hb_tree *tree)); -static unsigned hb_tree_mheight __P((const hb_tree *tree)); -static const void *hb_tree_min __P((const hb_tree *tree)); -static unsigned hb_tree_pathlen __P((const hb_tree *tree)); -static int hb_tree_probe __P((hb_tree *tree, void *key, void **dat)); -static void hb_tree_walk __P((hb_tree *tree, dict_vis_func visit)); - hb_tree * ompi_coll_libnbc_hb_tree_new(dict_cmp_func key_cmp, dict_del_func key_del, dict_del_func dat_del)