diff --git a/contrib/platform/lanl/cray_xe6/debug-lustre.conf b/contrib/platform/lanl/cray_xe6/debug-lustre.conf index 00000cd815..80930dc7a2 100644 --- a/contrib/platform/lanl/cray_xe6/debug-lustre.conf +++ b/contrib/platform/lanl/cray_xe6/debug-lustre.conf @@ -61,7 +61,7 @@ # # Basic behavior to smooth startup -mca_component_show_load_errors = 0 +mca_base_component_show_load_errors = 0 orte_abort_timeout = 10 opal_set_max_sys_limits = 1 orte_report_launch_progress = 1 diff --git a/ompi/debuggers/ompi_debuggers.c b/ompi/debuggers/ompi_debuggers.c index 3b06821991..2f707ae0f7 100644 --- a/ompi/debuggers/ompi_debuggers.c +++ b/ompi/debuggers/ompi_debuggers.c @@ -128,6 +128,8 @@ OMPI_DECLSPEC volatile int MPIR_being_debugged = 0; OMPI_DECLSPEC volatile int MPIR_debug_state = 0; OMPI_DECLSPEC char *MPIR_debug_abort_string = ""; +static char *ompi_debugger_dll_path = NULL; + /* Check for a file in few direct ways for portability */ static void check(char *dir, char *file, char **locations) { @@ -164,18 +166,19 @@ extern void ompi_debugger_setup_dlls(void) { int i; - char *a, *b, **dirs, **tmp1 = NULL, **tmp2 = NULL; + char **dirs, **tmp1 = NULL, **tmp2 = NULL; - a = strdup(opal_install_dirs.pkglibdir); - mca_base_param_reg_string_name("ompi", - "debugger_dll_path", - "List of directories where MPI_INIT should search for debugger plugins", - false, false, a, &b); - free(a); + ompi_debugger_dll_path = opal_install_dirs.pkglibdir; + (void) mca_base_var_register("ompi", "ompi", "debugger", "dll_path", + "List of directories where MPI_INIT should search for debugger plugins", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_debugger_dll_path); /* Search the directory for MPI debugger DLLs */ - if (NULL != b) { - dirs = opal_argv_split(b, ':'); + if (NULL != ompi_debugger_dll_path) { + dirs = opal_argv_split(ompi_debugger_dll_path, ':'); for (i = 0; dirs[i] != NULL; ++i) { check(dirs[i], OMPI_MPIHANDLES_DLL_PREFIX, tmp1); check(dirs[i], OMPI_MSGQ_DLL_PREFIX, tmp2); diff --git a/ompi/mca/allocator/bucket/allocator_bucket.c b/ompi/mca/allocator/bucket/allocator_bucket.c index bb09713e18..0af766abe5 100644 --- a/ompi/mca/allocator/bucket/allocator_bucket.c +++ b/ompi/mca/allocator/bucket/allocator_bucket.c @@ -20,7 +20,6 @@ #include "ompi_config.h" #include "ompi/mca/allocator/allocator.h" #include "ompi/constants.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/allocator/bucket/allocator_bucket_alloc.h" #include "ompi/mca/mpool/mpool.h" @@ -80,9 +79,16 @@ struct mca_allocator_base_module_t* mca_allocator_bucket_module_init( return((mca_allocator_base_module_t *) allocator); } +static int mca_allocator_bucket_module_register(void) { + mca_allocator_num_buckets = 30; + (void) mca_base_component_var_register(&mca_allocator_bucket_component.allocator_version, + "num_buckets", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, &mca_allocator_num_buckets); + return(OMPI_SUCCESS); +} + int mca_allocator_bucket_module_open(void) { - (void) mca_base_param_reg_int_name ("allocator", "bucket_num_buckets", NULL, false, false, - 30, &mca_allocator_num_buckets); return(OMPI_SUCCESS); } @@ -116,7 +122,9 @@ mca_allocator_base_component_t mca_allocator_bucket_component = { OMPI_MINOR_VERSION, OMPI_RELEASE_VERSION, mca_allocator_bucket_module_open, /* module open */ - mca_allocator_bucket_module_close /* module close */ + mca_allocator_bucket_module_close, /* module close */ + NULL, + mca_allocator_bucket_module_register }, { /* The component is checkpoint ready */ diff --git a/ompi/mca/bcol/base/bcol_base_open.c b/ompi/mca/bcol/base/bcol_base_open.c index 9ad8502668..e0ebe612ca 100644 --- a/ompi/mca/bcol/base/bcol_base_open.c +++ b/ompi/mca/bcol/base/bcol_base_open.c @@ -40,6 +40,8 @@ int mca_bcol_base_output = 0; opal_list_t mca_bcol_base_components_opened; +static int mca_bcol_base_verbose = 0; + OMPI_DECLSPEC opal_list_t mca_bcol_base_components_in_use; OMPI_DECLSPEC char *ompi_bcol_bcols_string; OMPI_DECLSPEC int bcol_mpool_compatibility[BCOL_SIZE][BCOL_SIZE]; @@ -200,27 +202,46 @@ static int mca_bcol_base_set_components_to_use(opal_list_t *bcol_components_avai return OMPI_SUCCESS; } +static int mca_bcol_base_register(int flags) +{ + /* Debugging/Verbose output */ + (void) mca_base_var_register("ompi", "bcol", "base", "verbose", + "Verbosity level of BCOL framework", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_bcol_base_verbose); + + /* figure out which bcol and sbgp components will actually be used */ + /* get list of sub-grouping functions to use */ + ompi_bcol_bcols_string = "basesmuma,basesmuma,iboffload,ptpcoll,ugni"; + (void) mca_base_var_register("ompi", "bcol", "base", "string", + "Default set of basic collective components to use", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_bcol_bcols_string); + + return OMPI_SUCCESS; +} + /** * Function for finding and opening either all MCA components, or the one * that was specifically requested via a MCA parameter. */ int mca_bcol_base_open(void) { - int value, ret; + int ret; /*_bcol_base_components_available * Register some MCA parameters */ - /* Debugging/Verbose output */ - mca_base_param_reg_int_name("bcol", - "base_verbose", - "Verbosity level of BCOL framework", - false, false, - 0, &value); + (void) mca_bcol_base_register(0); - /* get fraemwork id */ + /* get framework id */ mca_bcol_base_output = opal_output_open(NULL); - opal_output_set_verbosity(mca_bcol_base_output, value); + opal_output_set_verbosity(mca_bcol_base_output, mca_bcol_base_verbose); /* Open up all available components */ if (OMPI_SUCCESS != @@ -230,12 +251,6 @@ int mca_bcol_base_open(void) return OMPI_ERROR; } - /* figure out which bcol and sbgp components will actually be used */ - /* get list of sub-grouping functions to use */ - mca_base_param_reg_string_name("bcol","base_string", - "Default set of basic collective components to use ", - false, false, "basesmuma,basesmuma,iboffload,ptpcoll,ugni", &ompi_bcol_bcols_string); - ret = mca_bcol_base_set_components_to_use(&mca_bcol_base_components_opened, &mca_bcol_base_components_in_use); diff --git a/ompi/mca/bcol/basesmuma/bcol_basesmuma.h b/ompi/mca/bcol/basesmuma/bcol_basesmuma.h index a394b5036e..377b356c2b 100644 --- a/ompi/mca/bcol/basesmuma/bcol_basesmuma.h +++ b/ompi/mca/bcol/basesmuma/bcol_basesmuma.h @@ -105,14 +105,8 @@ struct mca_bcol_basesmuma_component_t { /* management data for collectives with no user data */ - /** MCA parameter: control region size (bytes), per proc */ - size_t basesmuma_ctl_size_per_proc; - - /** MCA parameter: control region alignment */ - size_t basesmuma_ctl_alignment; - /** MCA parameter: number of memory banks */ - size_t basesmuma_num_mem_banks; + int basesmuma_num_mem_banks; /** MCA parameter: number of regions per memory bank */ int basesmuma_num_regions_per_bank; diff --git a/ompi/mca/bcol/basesmuma/bcol_basesmuma_component.c b/ompi/mca/bcol/basesmuma/bcol_basesmuma_component.c index a11b481b85..75cb7adec0 100644 --- a/ompi/mca/bcol/basesmuma/bcol_basesmuma_component.c +++ b/ompi/mca/bcol/basesmuma/bcol_basesmuma_component.c @@ -33,6 +33,7 @@ const char *mca_bcol_basesmuma_component_version_string = * Local functions */ +static int basesmuma_register(void); static int basesmuma_open(void); static int basesmuma_close(void); static int mca_bcol_basesmuma_deregister_ctl_sm( @@ -40,13 +41,23 @@ static int mca_bcol_basesmuma_deregister_ctl_sm( static inline int mca_bcol_basesmuma_param_register_int( - const char* param_name, int default_value) + const char* param_name, int default_value, int *storage) { - int param_value; + *storage = default_value; + return mca_base_component_var_register(&mca_bcol_basesmuma_component.super.bcol_version, param_name, + NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); +} - (void) mca_base_param_reg_int (&mca_bcol_basesmuma_component.super.bcol_version, param_name, - NULL, false, false, default_value, ¶m_value); - return param_value; +static inline int mca_bcol_basesmuma_param_register_bool( + const char* param_name, bool default_value, bool *storage) +{ + *storage = default_value; + return mca_base_component_var_register(&mca_bcol_basesmuma_component.super.bcol_version, param_name, + NULL, MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); } /* @@ -76,6 +87,8 @@ mca_bcol_basesmuma_component_t mca_bcol_basesmuma_component = { basesmuma_open, basesmuma_close, + NULL, + basesmuma_register }, /* Initialization / querying functions */ @@ -90,6 +103,76 @@ mca_bcol_basesmuma_component_t mca_bcol_basesmuma_component = { }, }; +/* + * Register the component + */ +static int basesmuma_register(void) +{ + mca_bcol_basesmuma_component_t *cs = &mca_bcol_basesmuma_component; + + /* set component priority */ + mca_bcol_basesmuma_param_register_int("priority", 90, &cs->super.priority); + + /* Number of memory banks */ + mca_bcol_basesmuma_param_register_int("basesmuma_num_ctl_banks", 2, + &cs->basesmuma_num_mem_banks); + + /* Number of regions per memory bank */ + mca_bcol_basesmuma_param_register_int("basesmuma_num_buffs_per_bank", 16, + &cs->basesmuma_num_regions_per_bank); + + /* number of polling loops to allow pending resources to + * complete their work + */ + mca_bcol_basesmuma_param_register_int("n_poll_loops", 4, &cs->n_poll_loops); + + + /* Number of groups supported */ + mca_bcol_basesmuma_param_register_int("n_groups_supported", 100, + &cs->n_groups_supported); + + /* order of fanin tree */ + mca_bcol_basesmuma_param_register_int("radix_fanin", 2, &cs->radix_fanin); + + /* order of fanout tree */ + mca_bcol_basesmuma_param_register_int("radix_fanout", 2, &cs->radix_fanout); + + /* order of read tree */ + mca_bcol_basesmuma_param_register_int("radix_read_tree", 3, + &cs->radix_read_tree); + + /* order of reduction fanout tree */ + mca_bcol_basesmuma_param_register_int("order_reduction_tree", 2, + &cs->order_reduction_tree); + + /* k-nomial radix */ + mca_bcol_basesmuma_param_register_int("k_nomial_radix", 3, &cs->k_nomial_radix); + + /* number of polling loops for non-blocking algorithms */ + mca_bcol_basesmuma_param_register_int("num_to_probe", 10, &cs->num_to_probe); + + /* radix of the k-ary scatter tree */ + mca_bcol_basesmuma_param_register_int("scatter_kary_radix", 4, + &cs->scatter_kary_radix); + + /* register parmeters controlling message fragementation */ + mca_bcol_basesmuma_param_register_int("min_frag_size", getpagesize(), + &cs->super.min_frag_size); + mca_bcol_basesmuma_param_register_int("max_frag_size", FRAG_SIZE_NO_LIMIT, + &cs->super.max_frag_size); + + /* by default use pre-registered shared memory segments */ + /* RLG NOTE: When we have a systematic way to handle single memory + * copy semantics, we need to update this logic + */ + mca_bcol_basesmuma_param_register_bool("can_use_user_buffers", false, + &cs->super.can_use_user_buffers); + + mca_bcol_basesmuma_param_register_int("verbose", 0, &cs->verbose); + + return OMPI_SUCCESS; +} + /* * Open the component */ @@ -102,37 +185,6 @@ static int basesmuma_open(void) opal_mutex_t *mutex_ptr; int dummy; - /* set component priority */ - cs->super.priority= - mca_bcol_basesmuma_param_register_int("priority",90); - - /* set control region size (bytes), per proc */ - cs->basesmuma_ctl_size_per_proc= - - mca_bcol_basesmuma_param_register_int("basesmuma_ctl_size_per_proc", - CACHE_LINE_SIZE); - - /* set control region alignment (bytes) */ - cs->basesmuma_ctl_alignment= - mca_bcol_basesmuma_param_register_int("basesmuma_ctl_alignment", - getpagesize()); - - /* Number of memory banks */ - cs->basesmuma_num_mem_banks= - mca_bcol_basesmuma_param_register_int("basesmuma_num_ctl_banks", - 2); - - /* Number of regions per memory bank */ - cs->basesmuma_num_regions_per_bank= - mca_bcol_basesmuma_param_register_int("basesmuma_num_buffs_per_bank", - 16); - - /* number of polling loops to allow pending resources to - * complete their work - */ - cs->n_poll_loops= - mca_bcol_basesmuma_param_register_int("n_poll_loops",4); - /* * Make sure that the number of banks is a power of 2 */ @@ -153,59 +205,10 @@ static int basesmuma_open(void) goto ERROR; } - /* Number of groups supported */ - cs->n_groups_supported= - mca_bcol_basesmuma_param_register_int("n_groups_supported",100); - - /* order of fanin tree */ - cs->radix_fanin= - mca_bcol_basesmuma_param_register_int("radix_fanin",2); - - /* order of fanout tree */ - cs->radix_fanout= - mca_bcol_basesmuma_param_register_int("radix_fanout",2); - - /* order of read tree */ - cs->radix_read_tree = - mca_bcol_basesmuma_param_register_int("radix_read_tree",3); - - /* order of reduction fanout tree */ - cs->order_reduction_tree= - mca_bcol_basesmuma_param_register_int("order_reduction_tree",2); - - /* k-nomial radix */ - cs->k_nomial_radix= - mca_bcol_basesmuma_param_register_int("k_nomial_radix",3); - - /* number of polling loops for non-blocking algorithms */ - cs->num_to_probe = - mca_bcol_basesmuma_param_register_int("num_to_probe",10); - - /* radix of the k-ary scatter tree */ - cs->scatter_kary_radix = - mca_bcol_basesmuma_param_register_int("scatter_kary_radix",4); - /* Portals initialization */ cs->portals_init = false; cs->portals_info = NULL; - cs->verbose = - mca_bcol_basesmuma_param_register_int("verbose",0); - - /* register parmeters controlling message fragementation */ - cs->super.min_frag_size= - mca_bcol_basesmuma_param_register_int("min_frag_size",getpagesize()); - cs->super.max_frag_size= - mca_bcol_basesmuma_param_register_int("max_frag_size",FRAG_SIZE_NO_LIMIT); - /* by default use pre-registered shared memory segments */ - /* RLG NOTE: When we have a systematic way to handle single memory - * copy semantics, we need to update this logic - */ - cs->super.can_use_user_buffers= - mca_bcol_basesmuma_param_register_int("can_use_user_buffers",0); - cs->super.use_pipeline= - mca_bcol_basesmuma_param_register_int("use_pipeline",1); - /* * initialization */ diff --git a/ompi/mca/bcol/bcol.h b/ompi/mca/bcol/bcol.h index 9228d0f964..e11105f45e 100644 --- a/ompi/mca/bcol/bcol.h +++ b/ompi/mca/bcol/bcol.h @@ -321,16 +321,13 @@ struct mca_bcol_base_component_2_0_0_t { */ /** Minimum fragement size */ - size_t min_frag_size; + int min_frag_size; /** Maximum fragment size */ - int32_t max_frag_size; + int max_frag_size; /** Supports direct use of user-buffers */ - int can_use_user_buffers; - - /** Support pipelining */ - int use_pipeline; + bool can_use_user_buffers; }; typedef struct mca_bcol_base_component_2_0_0_t mca_bcol_base_component_2_0_0_t; typedef struct mca_bcol_base_component_2_0_0_t mca_bcol_base_component_t; diff --git a/ompi/mca/bcol/iboffload/bcol_iboffload.h b/ompi/mca/bcol/iboffload/bcol_iboffload.h index 2a5bf04df6..1457373e89 100644 --- a/ompi/mca/bcol/iboffload/bcol_iboffload.h +++ b/ompi/mca/bcol/iboffload/bcol_iboffload.h @@ -178,43 +178,33 @@ struct mca_bcol_iboffload_component_t { /** name of ib memory pool */ char* mpool_name; /** max outstanding CQE on the CQ */ - uint32_t cq_size; + int cq_size; /** Max size of inline data */ - uint32_t max_inline_data; + int max_inline_data; /** IB partition definition */ uint32_t pkey_val; /** Outstanding atomic reads */ uint32_t qp_ous_rd_atom; /** IB MTU */ - uint32_t mtu; + int mtu; /** Recv not ready timer */ - uint32_t min_rnr_timer; + int min_rnr_timer; /** IB timeout */ - uint32_t timeout; + int timeout; /** IB retry count */ - uint32_t retry_count; + int retry_count; /** Recv not ready retry count */ - uint32_t rnr_retry; + int rnr_retry; /** IB maximum pending RDMA */ - uint32_t max_rdma_dst_ops; + int max_rdma_dst_ops; /** IB Service level (QOS) */ - uint32_t service_level; - /** number of iboffload modules that we want to open per single lid */ - uint32_t bcols_per_lid; - /** Max LMCs that we want to support */ - uint32_t max_lmc; - /** Max number of bcols */ - uint32_t max_bcols; - /** Use the async event handler */ - uint32_t use_async_event_thread; + int service_level; /** Preferred communication buffer alignment in Bytes (must be power of two) */ - uint32_t buffer_alignment; + int buffer_alignment; /** Max tasks number for MQ */ - uint32_t max_mqe_tasks; + int max_mqe_tasks; /** Max MQ size */ - uint32_t max_mq_size; - /** Memory fragment size */ - uint32_t frag_size; + int max_mq_size; /** HCA/Port include exclude list */ char *if_include; char **if_include_list; @@ -257,10 +247,6 @@ struct mca_bcol_iboffload_component_t { enum ibv_m_wr_calc_op map_ompi_to_ib_calcs[OMPI_OP_NUM_OF_TYPES]; /** array mapping Open MPI data types to MVerbs data types */ enum ibv_m_wr_data_type map_ompi_to_ib_dt[OMPI_DATATYPE_MPI_MAX_PREDEFINED]; - /** The last ib offload calculation will be done by the cpu */ - bool last_calc_in_cpu; - /** The last ib offload calculation will be done by the cpu */ - bool enable_rdma_calc; /** The order of the exchange tree */ int exchange_tree_order; /** Knomial tree order */ diff --git a/ompi/mca/bcol/iboffload/bcol_iboffload_component.c b/ompi/mca/bcol/iboffload/bcol_iboffload_component.c index 74b724ae09..d3fdb7ecb4 100644 --- a/ompi/mca/bcol/iboffload/bcol_iboffload_component.c +++ b/ompi/mca/bcol/iboffload/bcol_iboffload_component.c @@ -98,7 +98,8 @@ mca_bcol_iboffload_component_t mca_bcol_iboffload_component = { iboffload_open, iboffload_close, - NULL, /* mca_register_component_params() */ + NULL, /* query */ + mca_bcol_iboffload_register_params NULL, /* reserved */ }, @@ -110,41 +111,36 @@ mca_bcol_iboffload_component_t mca_bcol_iboffload_component = { true, /* collective calls with iboffload should to be ordered */ }, /* iboffload-component specifc information */ - 0, /* verbose */ - 0, /* number of qps to use */ - false, /* warn_default_gid_prefix */ - false, /* warn_nonexistent_if */ - 0, /* free_list_num */ - 0, /* free_list_max */ - 0, /* free_list_inc */ - NULL, /* mpool_name */ - 0, /* cq_size */ - 0, /* max_inline_data */ - 0, /* pkey_val */ - 0, /* qp_ous_rd_atom */ - 0, /* mtu */ - 0, /* min_rnr_timer */ - 0, /* timeout */ - 0, /* retry_count */ - 0, /* rnr_retry */ - 0, /* max_rdma_dst_ops */ - 0, /* service_level */ - 0, /* bcols_per_lid */ - 0, /* max_lmc */ - 0, /* max_bcols */ - 0, /* use_async_event_thread */ - 0, /* buffer_alignment */ - 0, /* max_mqe_tasks */ - 0, /* max_mq_size */ - 0, /* frag_size */ - NULL, /* if_include */ - NULL, /* if_include_list */ - NULL, /* if_exclude */ - NULL, /* if_exclude_list */ - NULL, /* if_list */ - NULL, /* ib_devs */ - 0, /* num_devs */ - NULL, /* receive_queues */ + .verbose = 0, /* verbose */ + .num_qps = 0, /* number of qps to use */ + .warn_default_gid_prefix = false, /* warn_default_gid_prefix */ + .warn_nonexistent_if = false, /* warn_nonexistent_if */ + .free_list_num = 0, /* free_list_num */ + .free_list_max = 0, /* free_list_max */ + .free_list_inc = 0, /* free_list_inc */ + .mpool_name = NULL, /* mpool_name */ + .cq_size = 0, /* cq_size */ + .max_inline_data = 0, /* max_inline_data */ + .pkey_val = 0, /* pkey_val */ + .qp_ous_rd_atom = 0, /* qp_ous_rd_atom */ + .mtu = 0, /* mtu */ + .min_rnr_timer = 0, /* min_rnr_timer */ + .timeout = 0, /* timeout */ + .retry_count = 0, /* retry_count */ + .rnr_retry = 0, /* rnr_retry */ + .max_rdma_dst_ops = 0, /* max_rdma_dst_ops */ + .service_level = 0, /* service_level */ + .buffer_alignment = 0, /* buffer_alignment */ + .max_mqe_tasks = 0, /* max_mqe_tasks */ + .max_mq_size = 0, /* max_mq_size */ + .if_include = NULL, /* if_include */ + .if_include_list = NULL, /* if_include_list */ + .if_exclude = NULL, /* if_exclude */ + .if_exclude_list = NULL, /* if_exclude_list */ + .if_list = NULL, /* if_list */ + .ib_devs = NULL, /* ib_devs */ + .num_devs = 0, /* num_devs */ + .receive_queues = NULL, /* receive_queues */ }; static int mca_bcol_iboffload_dummy_init_query( @@ -403,6 +399,8 @@ static int iboffload_open(void) IBOFFLOAD_VERBOSE(10, ("Open Iboffload component.\n")); + (void) mca_bcol_iboffload_verify_params(); + cm->super.priority = 100; cm->super.n_net_contexts = 0; cm->super.network_contexts = NULL; @@ -416,9 +414,20 @@ static int iboffload_open(void) goto close_device; } - /* load mca parametres */ - rc = mca_bcol_iboffload_register_params(); - if (OMPI_SUCCESS != rc) { + /* Check MCA parameters */ + if (0 == (ival & (ival - 1))) { + mca_bcol_iboffload_component.exchange_tree_order = ival; + } else { + IBOFFLOAD_ERROR(("Warning: ibcol_iboffload_exchange_tree_order is %d which is not a power of 2, setting it to 2", ival)); + mca_bcol_iboffload_component.exchange_tree_order = 2; + } + + /* Pasha: Since we do not have max inline check like in openib, + I will put some dummy check here. All mlnx devices support at least 512b */ + if (mca_bcol_iboffload_component.max_inline_data > 512) { + IBOFFLOAD_ERROR(("Warning the inline %d, is to big and unsupported", + mca_bcol_iboffload_component.max_inline_data)); + rc = OMPI_ERROR; goto close_device; } diff --git a/ompi/mca/bcol/iboffload/bcol_iboffload_mca.c b/ompi/mca/bcol/iboffload/bcol_iboffload_mca.c index fe369ee4b7..a9ccea0081 100644 --- a/ompi/mca/bcol/iboffload/bcol_iboffload_mca.c +++ b/ompi/mca/bcol/iboffload/bcol_iboffload_mca.c @@ -22,6 +22,8 @@ #include "ompi/mca/common/ofacm/base.h" #include "ompi/communicator/communicator.h" +#include "opal/util/show_help.h" + /* * Local flags */ @@ -38,37 +40,41 @@ enum { REGSTR_MAX = 0x88 }; +mca_base_var_enum_value_t mtu_values[] = { + {IBV_MTU_256, "256B"}, + {IBV_MTU_512, "512B"}, + {IBV_MTU_1024, "1k"}, + {IBV_MTU_4096, "4k"}, + {0, NULL} +}; + /* * utility routine for string parameter registration */ static int reg_string(const char* param_name, const char* deprecated_param_name, const char* param_desc, - const char* default_value, char **out_value, + const char* default_value, char **storage, int flags) { int index; - char *value; - index = mca_base_param_reg_string(&mca_bcol_iboffload_component.super.bcol_version, - param_name, param_desc, false, false, - default_value, &value); + *storage = default_value; + index = mca_base_component_var_register(&mca_bcol_iboffload_component.super.bcol_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); if (NULL != deprecated_param_name) { - mca_base_param_reg_syn(index, - &mca_bcol_iboffload_component.super.bcol_version, - deprecated_param_name, true); + (void) mca_base_var_register_synonym(index, "ompi", "bcol", "iboffload", deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); } - mca_base_param_lookup_string(index, &value); - - if (0 != (flags & REGSTR_EMPTY_OK) && 0 == strlen(value)) { + if (0 != (flags & REGSTR_EMPTY_OK) && 0 == strlen(*storage)) { opal_output(0, "Bad parameter value for parameter \"%s\"", param_name); return OMPI_ERR_BAD_PARAM; } - *out_value = value; - return OMPI_SUCCESS; } @@ -78,43 +84,111 @@ static int reg_string(const char* param_name, static int reg_int(const char* param_name, const char* deprecated_param_name, const char* param_desc, - int default_value, int *out_value, int flags) + int default_value, int *storage, int flags) { - int index, value; + int index; - index = mca_base_param_reg_int(&mca_bcol_iboffload_component.super.bcol_version, - param_name, param_desc, false, false, - default_value, NULL); + *storage = default_value; + index = mca_base_component_var_register(&mca_bcol_iboffload_component.super.bcol_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); if (NULL != deprecated_param_name) { - mca_base_param_reg_syn(index, - &mca_bcol_iboffload_component.super.bcol_version, - deprecated_param_name, true); + (void) mca_base_var_register_synonym(index, "ompi", "bcol", "iboffload", deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); } - mca_base_param_lookup_int(index, &value); - - if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == value) { - *out_value = value; + if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == *storage) { return OMPI_SUCCESS; } - if ((0 != (flags & REGINT_GE_ZERO) && value < 0) || - (0 != (flags & REGINT_GE_ONE) && value < 1) || - (0 != (flags & REGINT_NONZERO) && 0 == value)) { + if ((0 != (flags & REGINT_GE_ZERO) && *storage < 0) || + (0 != (flags & REGINT_GE_ONE) && *storage < 1) || + (0 != (flags & REGINT_NONZERO) && 0 == *storage)) { opal_output(0, "Bad parameter value for parameter \"%s\"", param_name); return OMPI_ERR_BAD_PARAM; } - *out_value = value; + return OMPI_SUCCESS; +} + +int mca_bcol_iboffload_verify_params(void) +{ + if (mca_bcol_iboffload_component.min_rnr_timer > 31) { + opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", + true, "bcol_iboffload_ib_min_rnr_timer > 31", + "bcol_iboffload_ib_min_rnr_timer reset to 31"); + mca_bcol_iboffload_component.min_rnr_timer = 31; + } else if (ival < 0){ + opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", + true, "bcol_iboffload_ib_min_rnr_timer < 0", + "bcol_iboffload_ib_min_rnr_timer reset to 0"); + mca_bcol_iboffload_component.min_rnr_timer = 0; + } + + if (mca_bcol_iboffload_component.timeout > 31) { + opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", + true, "bcol_iboffload_ib_timeout > 31", + "bcol_iboffload_ib_timeout reset to 31"); + mca_bcol_iboffload_component.timeout = 31; + } else if (ival < 0) { + opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", + true, "bcol_iboffload_ib_timeout < 0", + "bcol_iboffload_ib_timeout reset to 0"); + mca_bcol_iboffload_component.timeout = 0; + } + + if (mca_bcol_iboffload_component.retry_count > 7) { + opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", + true, "bcol_iboffload_ib_retry_count > 7", + "bcol_iboffload_ib_retry_count reset to 7"); + mca_bcol_iboffload_component.retry_count = 7; + } else if (mca_bcol_iboffload_component.retry_count < 0) { + opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", + true, "bcol_iboffload_ib_retry_count < 0", + "bcol_iboffload_ib_retry_count reset to 0"); + mca_bcol_iboffload_component.retry_count = 0; + } + + if (mca_bcol_iboffload_component.max_rdma_dst_ops > 7) { + opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", + true, "bcol_iboffload_ib_rnr_retry > 7", + "bcol_iboffload_ib_rnr_retry reset to 7"); + mca_bcol_iboffload_component.max_rdma_dst_ops = 7; + } else if (mca_bcol_iboffload_component.max_rdma_dst_ops < 0) { + opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", + true, "bcol_iboffload_ib_rnr_retry < 0", + "bcol_iboffload_ib_rnr_retry reset to 0"); + mca_bcol_iboffload_component.max_rdma_dst_ops = 0; + } + + if (mca_bcol_iboffload_component.service_level > 15) { + opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", + true, "bcol_iboffload_ib_service_level > 15", + "bcol_iboffload_ib_service_level reset to 15"); + mca_bcol_iboffload_component.service_level = 15; + } else if (mca_bcol_iboffload_component.service_level < 0) { + opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", + true, "bcol_iboffload_ib_service_level < 0", + "bcol_iboffload_ib_service_level reset to 0"); + mca_bcol_iboffload_component.service_level = 0; + } + + if(mca_bcol_iboffload_component.buffer_alignment <= 1 || + (mca_bcol_iboffload_component.buffer_alignment & (mca_bcol_iboffload_component.buffer_alignment - 1))) { + opal_show_help("help-mpi-bcol-iboffload.txt", "wrong buffer alignment", + true, ival, ompi_process_info.nodename, 64); + mca_bcol_iboffload_component.buffer_alignment = 64; + } return OMPI_SUCCESS; } int mca_bcol_iboffload_register_params(void) { - char *msg, *pkey; - int ival, ret = OMPI_SUCCESS, tmp; + char *msg; + int ret = OMPI_SUCCESS, tmp; #define CHECK(expr) do { \ tmp = (expr); \ @@ -123,43 +197,38 @@ int mca_bcol_iboffload_register_params(void) /* register openib component parameters */ CHECK(reg_int("k_nomial_radix", NULL, - "The radix of the K-nomial tree for scatther-gather type algorithms" - "(starts from 2)", 2, &ival, REGINT_GE_ONE)); - mca_bcol_iboffload_component.k_nomial_radix= ival; + "The radix of the K-nomial tree for scatther-gather type algorithms" + "(starts from 2)", 2, &mca_bcol_iboffload_component.k_nomial_radix, + REGINT_GE_ONE)); CHECK(reg_int("priority", NULL, "IB offload component priority" - "(from 0(low) to 90 (high))", 90, &ival, 0)); - mca_bcol_iboffload_component.super.priority = ival; + "(from 0(low) to 90 (high))", 90, + &mca_bcol_iboffload_component.super.priority, 0)); CHECK(reg_int("verbose", NULL, "Output some verbose IB offload BTL information " - "(0 = no output, nonzero = output)", 0, &ival, 0)); - mca_bcol_iboffload_component.verbose = ival; + "(0 = no output, nonzero = output)", 0, + &mca_bcol_iboffload_component.verbose, 0)); - CHECK(reg_int("warn_default_gid_prefix", NULL, - "Warn when there is more than one active ports and at least one of them connected to the network with only default GID prefix configured (0 = do not warn; any other value = warn)", - 1, &ival, 0)); - mca_bcol_iboffload_component.warn_default_gid_prefix = (0 != ival); - CHECK(reg_int("warn_nonexistent_if", NULL, - "Warn if non-existent devices and/or ports are specified in the bcol_iboffla_if_[in|ex]clude MCA parameters (0 = do not warn; any other value = warn)", - 1, &ival, 0)); - mca_bcol_iboffload_component.warn_nonexistent_if = (0 != ival); + CHECK(reg_bool("warn_default_gid_prefix", NULL, + "Warn when there is more than one active ports and at least one of them connected to the network with only default GID prefix configured (0 = do not warn; any other value = warn)", + true, &mca_bcol_iboffload_component.warn_default_gid_prefix, 0)); + + CHECK(reg_bool("warn_nonexistent_if", NULL, + "Warn if non-existent devices and/or ports are specified in the bcol_iboffla_if_[in|ex]clude MCA parameters (0 = do not warn; any other value = warn)", + true, &mca_bcol_iboffload_component.warn_nonexistent_if, 0)); CHECK(reg_int("max_pipeline_depth", NULL, - "The maximal number of fragments of the same collective request that can be transferred in parallel", 3, &ival, 0)); - mca_bcol_iboffload_component.max_pipeline_depth = ival; + "The maximal number of fragments of the same collective request that can be transferred in parallel", 3, + &mca_bcol_iboffload_component.max_pipeline_depth, 0)); - CHECK(reg_int("max_bcols", NULL, - "Maximum number of device ports to use (-1 = use all available, otherwise must be >= 1)", - -1, (int *)&mca_bcol_iboffload_component.max_bcols, - REGINT_NEG_ONE_OK | REGINT_GE_ONE)); CHECK(reg_int("max_mqe_tasks", NULL, "Maximum number of MQEs for each iboffload module", - 1024, (int *)&mca_bcol_iboffload_component.max_mqe_tasks, 0)); + 1024, &mca_bcol_iboffload_component.max_mqe_tasks, 0)); CHECK(reg_int("max_mq_size", NULL, "Maximum size of each MQ for each iboffload module", - 1024, (int *)&mca_bcol_iboffload_component.max_mq_size, 0)); + 1024, &mca_bcol_iboffload_component.max_mq_size, 0)); CHECK(reg_int("free_list_num", NULL, "Intial size of free lists (must be >= 1)", 256, &mca_bcol_iboffload_component.free_list_num, @@ -181,24 +250,16 @@ int mca_bcol_iboffload_register_params(void) "Size of the OpenFabrics completion " "queue (will automatically be set to a minimum of " "(2 * number_of_peers * bcol_iboffload_rd_num))", - 1024, &ival, REGINT_GE_ONE)); - mca_bcol_iboffload_component.cq_size = (uint32_t) ival; + 1024, &mca_bcol_iboffload_component.cq_size, REGINT_GE_ONE)); CHECK(reg_int("exchange_tree_order", NULL, "The order of the exchange tree. " "Must be power of two.", - 2, &ival, REGINT_GE_ONE)); - if (0 == (ival & (ival - 1))) { - mca_bcol_iboffload_component.exchange_tree_order = ival; - } else { - IBOFFLOAD_ERROR(("Warning: ibcol_iboffload_exchange_tree_order is %d which is not a power of 2, setting it to 2", ival)); - mca_bcol_iboffload_component.exchange_tree_order = 2; - } + 2, &mca_bcol_iboffload_component.exchange_tree_order, REGINT_GE_ONE)); CHECK(reg_int("knomial_tree_order", NULL, "The order of the knomial exchange tree. ", - 3, &ival, REGINT_GE_ONE)); - mca_bcol_iboffload_component.knomial_tree_order = ival; + 3, &mca_bcol_iboffload_component.knomial_tree_order, REGINT_GE_ONE)); CHECK(reg_int("max_inline_data", "max_inline_data", @@ -207,16 +268,10 @@ int mca_bcol_iboffload_register_params(void) "otherwise must be >= 0). " "If not explicitly set, use max_inline_data from " "the INI file containing device-specific parameters", - 128, &ival, REGINT_NEG_ONE_OK | REGINT_GE_ZERO)); - mca_bcol_iboffload_component.max_inline_data = (int32_t) ival; - /* Pasha: Since we do not have max inline check like in openib, - I will put some dummy check here. All mlnx devices support at least 512b */ - if (mca_bcol_iboffload_component.max_inline_data > 512) { - IBOFFLOAD_ERROR(("Warning the inline %d, is to big and unsupported", - mca_bcol_iboffload_component.max_inline_data)); - ret = OMPI_ERROR; - } + 128, &mca_bcol_iboffload_component.max_inline_data, + REGINT_NEG_ONE_OK | REGINT_GE_ZERO)); +#if 0 CHECK(reg_string("pkey", "ib_pkey_val", "OpenFabrics partition key (pkey) value. " "Unsigned integer decimal or hex values are allowed (e.g., \"3\" or \"0x3f\") and will be masked against the maximum allowable IB paritition key value (0x7fff)", @@ -226,6 +281,7 @@ int mca_bcol_iboffload_register_params(void) ompi_btl_openib_ini_intify(pkey) & MCA_BTL_IB_PKEY_MASK; free(pkey); */ +#endif CHECK(reg_string("receive_queues", NULL, "Colon-delimited, comma delimited list of receive queues: P,4096,8,6,4:P,32768,8,6,4", @@ -248,209 +304,96 @@ int mca_bcol_iboffload_register_params(void) /* Don't try to recover from this */ return OMPI_ERR_OUT_OF_RESOURCE; } - - CHECK(reg_int("mtu", "ib_mtu", msg, IBV_MTU_1024, &ival, 0)); + CHECK(mca_base_var_enum_create("infiniband mtu", mtu_values, &new_enum)); + mca_bcol_iboffload_component.mtu = IBV_MTU_1024; + tmp = mca_base_component_var_register(&mca_bcol_iboffload_component.super.bcol_version, + "mtu", MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_bcol_iboffload_component.mtu); + OBJ_RELEASE(new_enum); free(msg); - if (ival < IBV_MTU_1024 || ival > IBV_MTU_4096) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "invalid value for bcol_iboffload_ib_mtu", - "bcol_iboffload_ib_mtu reset to 1024"); - mca_bcol_iboffload_component.mtu = IBV_MTU_1024; - } else { - mca_bcol_iboffload_component.mtu = (uint32_t) ival; - } + if (0 > tmp) ret = tmp; + + tmp = mca_base_var_register_synonym(tmp, "ompi", "bcol", "iboffload", "ib_mtu", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + if (0 > tmp) ret = tmp; CHECK(reg_int("ib_min_rnr_timer", NULL, "InfiniBand minimum " "\"receiver not ready\" timer, in seconds " "(must be >= 0 and <= 31)", - 1 , &ival, 0)); + 1 , &mca_bcol_iboffload_component.min_rnr_timer, 0)); - if (ival > 31) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "bcol_iboffload_ib_min_rnr_timer > 31", - "bcol_iboffload_ib_min_rnr_timer reset to 31"); - ival = 31; - } else if (ival < 0){ - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "bcol_iboffload_ib_min_rnr_timer < 0", - "bcol_iboffload_ib_min_rnr_timer reset to 0"); - ival = 0; - } - - mca_bcol_iboffload_component.min_rnr_timer = (uint32_t) ival; - - CHECK(reg_int("ib_timeout", NULL, "InfiniBand transmit timeout, plugged into formula: 4.096 microseconds * (2^bcol_iboffload_ib_timeout)" - "(must be >= 0 and <= 31)", - 20, &ival, 0)); - if (ival > 31) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "bcol_iboffload_ib_timeout > 31", - "bcol_iboffload_ib_timeout reset to 31"); - ival = 31; - } else if (ival < 0) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "bcol_iboffload_ib_timeout < 0", - "bcol_iboffload_ib_timeout reset to 0"); - ival = 0; - } - - mca_bcol_iboffload_component.timeout = (uint32_t) ival; + CHECK(reg_int("ib_timeout", NULL, "InfiniBand transmit timeout, plugged into formula: 4.096 microseconds * " + "(2^bcol_iboffload_ib_timeout) (must be >= 0 and <= 31)", + 20, &mca_bcol_iboffload_component.timeout, 0)); CHECK(reg_int("ib_retry_count", NULL, "InfiniBand transmit retry count " "(must be >= 0 and <= 7)", - 7, &ival, 0)); - if (ival > 7) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "bcol_iboffload_ib_retry_count > 7", - "bcol_iboffload_ib_retry_count reset to 7"); - ival = 7; - } else if (ival < 0) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "bcol_iboffload_ib_retry_count < 0", - "bcol_iboffload_ib_retry_count reset to 0"); - ival = 0; - } - - mca_bcol_iboffload_component.retry_count = (uint32_t) ival; + 7, &mca_bcol_iboffload_component.retry_count, 0)); CHECK(reg_int("ib_rnr_retry", NULL, "InfiniBand \"receiver not ready\" " "retry count; applies *only* to SRQ/XRC queues. PP queues " "use RNR retry values of 0 because Open MPI performs " "software flow control to guarantee that RNRs never occur " "(must be >= 0 and <= 7; 7 = \"infinite\")", - 7, &ival, 0)); - if (ival > 7) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "bcol_iboffload_ib_rnr_retry > 7", - "bcol_iboffload_ib_rnr_retry reset to 7"); - ival = 7; - } else if (ival < 0) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "bcol_iboffload_ib_rnr_retry < 0", - "bcol_iboffload_ib_rnr_retry reset to 0"); - ival = 0; - } - - mca_bcol_iboffload_component.rnr_retry = (uint32_t) ival; + 7, &mca_bcol_iboffload_component.rnr_retry, 0)); CHECK(reg_int("ib_max_rdma_dst_ops", NULL, "InfiniBand maximum pending RDMA " "destination operations " "(must be >= 0)", - 4, &ival, REGINT_GE_ZERO)); - mca_bcol_iboffload_component.max_rdma_dst_ops = (uint32_t) ival; + 4, &mca_bcol_iboffload_component.max_rdma_dst_ops, REGINT_GE_ZERO)); CHECK(reg_int("ib_service_level", NULL, "InfiniBand service level " "(must be >= 0 and <= 15)", - 0, &ival, 0)); - if (ival > 15) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "bcol_iboffload_ib_service_level > 15", - "bcol_iboffload_ib_service_level reset to 15"); - ival = 15; - } else if (ival < 0) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "bcol_iboffload_ib_service_level < 0", - "bcol_iboffload_ib_service_level reset to 0"); - ival = 0; - } - - mca_bcol_iboffload_component.service_level = (uint32_t) ival; - - CHECK(reg_int("btls_per_lid", NULL, "Number of BTLs to create for each " - "InfiniBand LID " - "(must be >= 1)", - 1, &ival, REGINT_GE_ONE)); - mca_bcol_iboffload_component.bcols_per_lid = (uint32_t) ival; - - CHECK(reg_int("max_lmc", NULL, "Maximum number of LIDs to use for each device port " - "(must be >= 0, where 0 = use all available)", - 0, &ival, REGINT_GE_ZERO)); - mca_bcol_iboffload_component.max_lmc = (uint32_t) ival; - -#if OPAL_HAVE_THREADS - CHECK(reg_int("use_async_event_thread", NULL, - "If nonzero, use the thread that will handle InfiniBand asyncihronous events ", - 1, &ival, 0)); - mca_bcol_iboffload_component.use_async_event_thread = (0 != ival); -#endif + 0, &mca_bcol_iboffload_component.service_level, 0)); CHECK(reg_int("buffer_alignment", NULL, "Prefered communication buffer alignment, in bytes " "(must be > 0 and power of two)", - 64, &ival, REGINT_GE_ZERO)); - if(ival <= 1 || (ival & (ival - 1))) { - opal_show_help("help-mpi-bcol-iboffload.txt", "wrong buffer alignment", - true, ival, ompi_process_info.nodename, 64); - mca_bcol_iboffload_component.buffer_alignment = 64; - } else { - mca_bcol_iboffload_component.buffer_alignment = (uint32_t) ival; - } - - CHECK(reg_int("last_calc_in_cpu", NULL, - "If set, the last ib offload calculation will " - "be done in the cpu (default: yes)", - 1, &ival, REGINT_GE_ZERO)); - mca_bcol_iboffload_component.last_calc_in_cpu = (0 != ival); - - CHECK(reg_int("enable_rdma_calc", NULL, - "Enable RDMA Calc" - "(default: yes)", - 1, &ival, REGINT_GE_ZERO)); - mca_bcol_iboffload_component.enable_rdma_calc = (0 != ival); + 64, &mca_bcol_iboffload_component.buffer_alignment, REGINT_GE_ZERO)); /* register parmeters controlling message fragementation */ CHECK(reg_int("min_frag_size", NULL, - "Minimum fragment size", - getpagesize(), &ival, REGINT_GE_ONE)); - mca_bcol_iboffload_component.super.min_frag_size = ival; + "Minimum fragment size", + getpagesize(), &mca_bcol_iboffload_component.super.min_frag_size, + REGINT_GE_ONE)); CHECK(reg_int("max_frag_size", NULL, - "Maximum fragment size", - FRAG_SIZE_NO_LIMIT, &ival, REGINT_NONZERO)); - mca_bcol_iboffload_component.super.max_frag_size = ival; + "Maximum fragment size", + FRAG_SIZE_NO_LIMIT, &mca_bcol_iboffload_component.super.max_frag_size, + REGINT_NONZERO)); - CHECK(reg_int("can_use_user_buffers", NULL, - "User memory can be used by the collective algorithms", - 1, &ival, REGINT_GE_ZERO)); - mca_bcol_iboffload_component.super.can_use_user_buffers = ival; - - CHECK(reg_int("use_pipeline", NULL, - "Pipeline the algorithm", - 1, &ival, REGINT_GE_ZERO)); - mca_bcol_iboffload_component.super.use_pipeline = ival; + CHECK(reg_bool("can_use_user_buffers", NULL, + "User memory can be used by the collective algorithms", + true, &mca_bcol_iboffload_component.super.can_use_user_buffers)); CHECK(reg_int("barrier_mode", NULL, "Barrier mode: 0 - Recursive doubling; 1 - Recursive K-ing", - 0, &ival, REGINT_GE_ZERO)); - mca_bcol_iboffload_component.barrier_mode = ival; + 0, &mca_bcol_iboffload_component.barrier_mode, REGINT_GE_ZERO)); CHECK(reg_int("max_progress_pull", NULL, "Max number of progress pull checks", - 8, &ival, REGINT_GE_ZERO)); - mca_bcol_iboffload_component.max_progress_pull = ival; + 8, &mca_bcol_iboffload_component.max_progress_pull, REGINT_GE_ZERO)); CHECK(reg_int("use_brucks_smsg_alltoall_rdma", NULL, "Use brucks algorithm for smsg alltoall and RDMA semantics 1 = No Temp buffer recycling" "1 = Alg with no Temp Buffer Recycling (faster), 2 = Alg with temp Buffer Recycling (slower)", - 0, &ival, 0)); - mca_bcol_iboffload_component.use_brucks_smsg_alltoall_rdma = ival; + 0, &mca_bcol_iboffload_component.use_brucks_smsg_alltoall_rdma, 0)); CHECK(reg_int("use_brucks_smsg_alltoall_sr", NULL, "Use brucks algorithm for smsg alltoall and Send/Recv semantics " "1 = Alg with RTR (faster), 2 = Alg with RNR (slower)", - 0, &ival, 0)); - mca_bcol_iboffload_component.use_brucks_smsg_alltoall_sr = ival; + 0, &mca_bcol_iboffload_component.use_brucks_smsg_alltoall_sr, 0)); CHECK(reg_int("alltoall_bruck_radix", NULL, "Radix for Bruck algorithm for smsg alltoall", - 3, &ival, 0)); - mca_bcol_iboffload_component.k_alltoall_bruck_radix = ival; + 3, &mca_bcol_iboffload_component.k_alltoall_bruck_radix, 0)); CHECK(reg_int("k_alltoall_bruck_radix", NULL, "Temp Buffer alignment for Bruck algorithm for smsg alltoall", - 64, &ival, 0)); - mca_bcol_iboffload_component.tmp_buf_alignment = ival; + 64, &mca_bcol_iboffload_component.tmp_buf_alignment, 0)); /* CHECK(reg_string("if_include", NULL, @@ -464,6 +407,8 @@ int mca_bcol_iboffload_register_params(void) 0)); */ + CHECK(mca_bcol_iboffload_verify_params()); + /* Register any MCA params for the connect pseudo-components */ if (OMPI_SUCCESS == ret) { ret = ompi_common_ofacm_base_register(&mca_bcol_iboffload_component.super.bcol_version); diff --git a/ompi/mca/bcol/iboffload/bcol_iboffload_mca.h b/ompi/mca/bcol/iboffload/bcol_iboffload_mca.h index ac796ccd89..193860f2c4 100644 --- a/ompi/mca/bcol/iboffload/bcol_iboffload_mca.h +++ b/ompi/mca/bcol/iboffload/bcol_iboffload_mca.h @@ -15,5 +15,6 @@ #include "ompi_config.h" int mca_bcol_iboffload_register_params(void); +int mca_bcol_iboffload_verify_params(void); #endif diff --git a/ompi/mca/bcol/iboffload/bcol_iboffload_module.c b/ompi/mca/bcol/iboffload/bcol_iboffload_module.c index 59f9d4ddb2..c9af7f15aa 100644 --- a/ompi/mca/bcol/iboffload/bcol_iboffload_module.c +++ b/ompi/mca/bcol/iboffload/bcol_iboffload_module.c @@ -768,7 +768,7 @@ static inline struct ibv_cq *ibv_create_cq_compat(struct ibv_context *context, int mca_bcol_iboffload_adjust_cq(mca_bcol_iboffload_device_t *device, struct ibv_cq **ib_cq) { - uint32_t cq_size = mca_bcol_iboffload_component.cq_size; + uint32_t cq_size = (uint32_t) mca_bcol_iboffload_component.cq_size; if (NULL == *ib_cq) { *ib_cq = ibv_create_cq_compat(device->dev.ib_dev_context, cq_size, @@ -1070,8 +1070,8 @@ mca_bcol_iboffload_comm_query(mca_sbgp_base_module_t *sbgp, int *num_modules) } memset(&mqe_attr, 0, sizeof(mqe_attr)); - mqe_attr.max_mqe_tasks = mca_bcol_iboffload_component.max_mqe_tasks; - mqe_attr.max_mq_size = mca_bcol_iboffload_component.max_mq_size; + mqe_attr.max_mqe_tasks = (uint32_t)mca_bcol_iboffload_component.max_mqe_tasks; + mqe_attr.max_mq_size = (uint32_t)mca_bcol_iboffload_component.max_mq_size; mqe_attr.cq = iboffload_module->device->ib_mq_cq; /* ALL MQs have the same configuration */ diff --git a/ompi/mca/bcol/iboffload/bcol_iboffload_qp_info.c b/ompi/mca/bcol/iboffload/bcol_iboffload_qp_info.c index 1e6a42419d..5cbc55feca 100644 --- a/ompi/mca/bcol/iboffload/bcol_iboffload_qp_info.c +++ b/ompi/mca/bcol/iboffload/bcol_iboffload_qp_info.c @@ -232,7 +232,7 @@ static void mca_bcol_iboffload_fillin_qp_attr(int qp_index, Todo: copy max_inline_size() from ofacm to common area. */ - init_attr->cap.max_inline_data = cm->max_inline_data; + init_attr->cap.max_inline_data = (int32_t) cm->max_inline_data; /* We allocate SG list for some algorithms (Bruck's alltoall) */ max_sge = ep->iboffload_module->group_size / 2 + @@ -248,8 +248,8 @@ static void mca_bcol_iboffload_fillin_qp_attr(int qp_index, init_attr->cap.max_recv_sge = max_sge; /* Vasily: the value will be changed later */ /* TODO Pasha: this is real crap */ - init_attr->cap.max_recv_wr = cm->cq_size; - init_attr->cap.max_send_wr = cm->cq_size; + init_attr->cap.max_recv_wr = (uint32_t) cm->cq_size; + init_attr->cap.max_send_wr = (uint32_t) cm->cq_size; /* Set attributes */ @@ -257,13 +257,13 @@ static void mca_bcol_iboffload_fillin_qp_attr(int qp_index, attr->port_num = ep->iboffload_module->port; /* Vasily: the value will be changed later */ - attr->path_mtu = cm->mtu; + attr->path_mtu = (uint32_t)cm->mtu; attr->max_dest_rd_atomic = cm->max_rdma_dst_ops; - attr->min_rnr_timer = cm->min_rnr_timer; + attr->min_rnr_timer = (uint32_t)cm->min_rnr_timer; attr->ah_attr.is_global = 0; - attr->ah_attr.sl = cm->service_level; + attr->ah_attr.sl = (uint32_t)cm->service_level; /* Vasily: from struct mca_bcol_iboffload_port_t ????? */ /* attr->ah_attr.src_path_bits = iboffload_module->src_path_bits; @@ -272,10 +272,10 @@ static void mca_bcol_iboffload_fillin_qp_attr(int qp_index, /* JMS to be filled in later dynamically */ attr->ah_attr.static_rate = 0; /* RTS params */ - attr->timeout = cm->timeout; - attr->retry_cnt = cm->retry_count; - attr->rnr_retry = cm->rnr_retry; - attr->max_rd_atomic = cm->max_rdma_dst_ops; + attr->timeout = (uint32_t)cm->timeout; + attr->retry_cnt = (uint32_t)cm->retry_count; + attr->rnr_retry = (uint32_t)cm->rnr_retry; + attr->max_rd_atomic = (uint32_t)cm->max_rdma_dst_ops; /* Init for local mca_bcol_iboffload_endpoint_qp_t qps structure * that caches the qp information on endpoint */ diff --git a/ompi/mca/bcol/ptpcoll/bcol_ptpcoll_mca.c b/ompi/mca/bcol/ptpcoll/bcol_ptpcoll_mca.c index c2d7ade234..6a303c1ab3 100644 --- a/ompi/mca/bcol/ptpcoll/bcol_ptpcoll_mca.c +++ b/ompi/mca/bcol/ptpcoll/bcol_ptpcoll_mca.c @@ -41,27 +41,28 @@ enum { static int reg_string(const char* param_name, const char* deprecated_param_name, const char* param_desc, - const char* default_value, char **out_value, + const char* default_value, char **storage, int flags) { int index; - char *value; - index = mca_base_param_reg_string(&mca_bcol_ptpcoll_component.super.bcol_version, - param_name, param_desc, false, false, - default_value, &value); - if (NULL != deprecated_param_name) { - mca_base_param_reg_syn(index, - &mca_bcol_ptpcoll_component.super.bcol_version, - deprecated_param_name, true); - } - mca_base_param_lookup_string(index, &value); - if (0 != (flags & REGSTR_EMPTY_OK) && 0 == strlen(value)) { + *storage = default_value; + index = mca_base_component_var_register(&mca_bcol_ptpcoll_component.super.bcol_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + if (NULL != deprecated_param_name) { + (void) mca_base_var_register_synonym(index, "ompi", "bcol", "ptpcoll", + deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + } + + if (0 != (flags & REGSTR_EMPTY_OK) && (NULL == *storage || 0 == strlen(*storage))) { opal_output(0, "Bad parameter value for parameter \"%s\"", param_name); return OMPI_ERR_BAD_PARAM; } - *out_value = value; + return OMPI_SUCCESS; } #endif @@ -72,37 +73,63 @@ static int reg_string(const char* param_name, static int reg_int(const char* param_name, const char* deprecated_param_name, const char* param_desc, - int default_value, int *out_value, int flags) + int default_value, int *storage, int flags) { - int index, value; - index = mca_base_param_reg_int(&mca_bcol_ptpcoll_component.super.bcol_version, - param_name, param_desc, false, false, - default_value, NULL); - if (NULL != deprecated_param_name) { - mca_base_param_reg_syn(index, - &mca_bcol_ptpcoll_component.super.bcol_version, - deprecated_param_name, true); - } - mca_base_param_lookup_int(index, &value); + int index; - if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == value) { - *out_value = value; + *storage = default_value; + index = mca_base_component_var_register(&mca_bcol_ptpcoll_component.super.bcol_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + if (NULL != deprecated_param_name) { + (void) mca_base_var_register_synonym(index, "ompi", "bcol", "ptpcoll", + deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + } + + if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == *storage) { return OMPI_SUCCESS; } - if ((0 != (flags & REGINT_GE_ZERO) && value < 0) || - (0 != (flags & REGINT_GE_ONE) && value < 1) || - (0 != (flags & REGINT_NONZERO) && 0 == value)) { + if ((0 != (flags & REGINT_GE_ZERO) && *storage < 0) || + (0 != (flags & REGINT_GE_ONE) && *storage < 1) || + (0 != (flags & REGINT_NONZERO) && 0 == *storage)) { opal_output(0, "Bad parameter value for parameter \"%s\"", param_name); return OMPI_ERR_BAD_PARAM; } - *out_value = value; + + return OMPI_SUCCESS; +} + +static int reg_bool(const char* param_name, + const char* deprecated_param_name, + const char* param_desc, + bool default_value, bool *storage) +{ + int index; + + *storage = default_value; + index = mca_base_component_var_register(&mca_bcol_ptpcoll_component.super.bcol_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_BOOL, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + if (0 > index) { + return index; + } + + if (NULL != deprecated_param_name) { + (void) mca_base_var_register_synonym(index, "ompi", "bcol", "ptpcoll", + deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + } + return OMPI_SUCCESS; } int mca_bcol_ptpcoll_register_mca_params(void) { - int ival, ret, tmp; + int ret, tmp; mca_bcol_ptpcoll_component_t *cm = &mca_bcol_ptpcoll_component; ret = OMPI_SUCCESS; @@ -113,74 +140,57 @@ int mca_bcol_ptpcoll_register_mca_params(void) CHECK(reg_int("priority", NULL, "PTPCOLL component priority" - "(from 0(low) to 90 (high))", 90, &ival, 0)); - cm->super.priority = ival; + "(from 0(low) to 90 (high))", 90, &cm->super.priority, 0)); CHECK(reg_int("verbose", NULL, "Output some verbose PTPCOLL information " - "(0 = no output, nonzero = output)", 0, &ival, REGINT_GE_ZERO)); - cm->verbose = ival; + "(0 = no output, nonzero = output)", 0, &cm->verbose, REGINT_GE_ZERO)); CHECK(reg_int("k_nomial_radix", NULL, "The radix of K-Nomial Tree " - "(starts from 2)", 2, &ival, REGINT_GE_ONE)); - cm->k_nomial_radix = ival; + "(starts from 2)", 2, &cm->k_nomial_radix, REGINT_GE_ONE)); CHECK(reg_int("narray_radix", NULL, "The radix of Narray Tree " - "(starts from 2)", 2, &ival, REGINT_GE_ONE)); - cm->narray_radix = ival; + "(starts from 2)", 2, &cm->narray_radix, REGINT_GE_ONE)); CHECK(reg_int("narray_knomial_radix", NULL, "The radix of Narray/Knomial Tree for scatther-gather type algorithms" - "(starts from 2)", 2, &ival, REGINT_GE_ONE)); - cm->narray_knomial_radix = ival; + "(starts from 2)", 2, &cm->narray_knomial_radix, REGINT_GE_ONE)); CHECK(reg_int("num_to_probe", NULL, "Number of probe operation in single source data check" - "(starts from 8)", 8, &ival, REGINT_GE_ONE)); - cm->num_to_probe = ival; + "(starts from 8)", 8, &cm->num_to_probe, REGINT_GE_ONE)); CHECK(reg_int("bcast_small_msg_known_root_alg", NULL, "Algoritm selection for bcast small messages known root" - "(1 - K-nomial, 2 - N-array)", 1, &ival, REGINT_GE_ZERO)); - cm->bcast_small_messages_known_root_alg = ival; + "(1 - K-nomial, 2 - N-array)", 1, &cm->bcast_small_messages_known_root_alg, + REGINT_GE_ZERO)); CHECK(reg_int("bcast_large_msg_known_root_alg", NULL, "Algoritm selection for bcast large messages known root" "(1 - Binomial scatther-gather, 2 - N-array scather, K-nomial gather)", - 1, &ival, REGINT_GE_ZERO)); - cm->bcast_large_messages_known_root_alg = ival; + 1, &cm->bcast_large_messages_known_root_alg, REGINT_GE_ZERO)); CHECK(reg_int("barrier_alg", NULL, "Algoritm selection for Barrier" "(1 - Recursive doubling, 2 - Recursive K-ing)", - 1, &ival, REGINT_GE_ZERO)); - cm->barrier_alg = ival; + 1, &cm->barrier_alg, REGINT_GE_ZERO)); /* register parmeters controlling message fragementation */ CHECK(reg_int("min_frag_size", NULL, "Minimum fragment size", - getpagesize(), &ival, REGINT_GE_ONE)); - cm->super.min_frag_size=ival; + getpagesize(), &cm->super.min_frag_size, REGINT_GE_ONE)); CHECK(reg_int("max_frag_size", NULL, "Maximum fragment size", - FRAG_SIZE_NO_LIMIT, &ival, REGINT_NONZERO)); - cm->super.max_frag_size=ival; + FRAG_SIZE_NO_LIMIT, &cm->super.max_frag_size, REGINT_NONZERO)); - CHECK(reg_int("can_use_user_buffers", NULL, + CHECK(reg_bool("can_use_user_buffers", NULL, "User memory can be used by the collective algorithms", - 1, &ival, REGINT_GE_ZERO)); - cm->super.can_use_user_buffers=ival; - - CHECK(reg_int("use_pipeline", NULL, - "Pipeline the algorithm", - 1, &ival, REGINT_GE_ZERO)); - cm->super.use_pipeline=ival; + 1, &cm->super.can_use_user_buffers)); CHECK(reg_int("use_brucks_smsg_alltoall_rdma", NULL, "Use brucks algorithm for smsg alltoall and RDMA semantics 1 = No Temp buffer recycling" "1 = Alg with no Temp Buffer Recycling (faster), 2 = Alg with temp Buffer Recycling (slower)", - 0, &ival, 0)); - cm->use_brucks_smsg_alltoall_rdma = ival; + 0, &cm->use_brucks_smsg_alltoall_rdma, 0)); return ret; } diff --git a/ompi/mca/bml/base/bml_base_btl.c b/ompi/mca/bml/base/bml_base_btl.c index c40bf46902..5752cefff9 100644 --- a/ompi/mca/bml/base/bml_base_btl.c +++ b/ompi/mca/bml/base/bml_base_btl.c @@ -69,9 +69,9 @@ int mca_bml_base_btl_array_reserve(mca_bml_base_btl_array_t* array, size_t size) #if OPAL_ENABLE_DEBUG_RELIABILITY -extern double mca_bml_base_error_rate_floor; -extern double mca_bml_base_error_rate_ceiling; -extern int mca_bml_base_error_count; +extern int mca_bml_base_error_rate_floor; +extern int mca_bml_base_error_rate_ceiling; +extern int mca_bml_base_error_count; struct mca_bml_base_context_t { size_t index; @@ -102,9 +102,9 @@ int mca_bml_base_send( mca_bml_base_btl_t* bml_btl, { des->des_context = (void*)bml_btl; if(mca_bml_base_error_count <= 0 && mca_bml_base_error_rate_ceiling > 0) { - mca_bml_base_error_count = (int) ((mca_bml_base_error_rate_ceiling * rand())/(RAND_MAX+1.0)); - if(mca_bml_base_error_count < mca_bml_base_error_rate_floor) { - mca_bml_base_error_count = mca_bml_base_error_rate_floor; + mca_bml_base_error_count = (int) (((double) mca_bml_base_error_rate_ceiling * rand())/(RAND_MAX+1.0)); + if(mca_bml_base_error_count < (double) mca_bml_base_error_rate_floor) { + mca_bml_base_error_count = (double) mca_bml_base_error_rate_floor; } if(mca_bml_base_error_count % 2) { /* local completion - network "drops" packet */ diff --git a/ompi/mca/bml/base/bml_base_open.c b/ompi/mca/bml/base/bml_base_open.c index 9ede15060e..d8ad9aaf62 100644 --- a/ompi/mca/bml/base/bml_base_open.c +++ b/ompi/mca/bml/base/bml_base_open.c @@ -32,11 +32,51 @@ int mca_bml_base_already_opened = 0; opal_list_t mca_bml_base_components_available = {{0}}; #if OPAL_ENABLE_DEBUG_RELIABILITY -double mca_bml_base_error_rate_floor; -double mca_bml_base_error_rate_ceiling; -int mca_bml_base_error_count; +int mca_bml_base_error_rate_floor; +int mca_bml_base_error_rate_ceiling; +int mca_bml_base_error_count; +static bool mca_bml_base_srand; #endif +int mca_bml_base_register(int flags) +{ +#if OPAL_ENABLE_DEBUG_RELIABILITY + do { + int var_id; + + mca_bml_base_error_rate_floor = 0; + var_id = mca_base_var_register("ompi", "bml", "base", "error_rate_floor", NULL, + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_bml_base_error_rate_floor); + (void) mca_base_var_register_synonym(var_id, "ompi", "bml", NULL, "error_rate_floor", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + + mca_bml_base_error_rate_ceiling = 0; + var_id = mca_base_var_register("ompi", "bml", "base", "error_rate_ceiling", NULL, + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_bml_base_error_rate_ceiling); + (void) mca_base_var_register_synonym(var_id, "ompi", "bml", NULL, "error_rate_ceiling", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + + + mca_bml_base_srand = true; + var_id = mca_base_var_register("ompi", "bml", "base", "srand", NULL, + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_bml_base_srand); + (void) mca_base_var_register_synonym(var_id, "ompi", "bml", NULL, "srand", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + } while (0); +#endif + + return OMPI_SUCCESS; +} + int mca_bml_base_open(void) { /* See if we've already been here */ @@ -44,6 +84,8 @@ int mca_bml_base_open(void) return OMPI_SUCCESS; } + (void) mca_bml_base_register(0); + if(OMPI_SUCCESS != mca_base_components_open("bml", 0, mca_bml_base_static_components, &mca_bml_base_components_available, @@ -52,34 +94,20 @@ int mca_bml_base_open(void) } #if OPAL_ENABLE_DEBUG_RELIABILITY - do { - int param, value; + /* seed random number generator */ + if(mca_bml_base_srand) { + struct timeval tv; + gettimeofday(&tv, NULL); + srand(getpid() * tv.tv_usec); + } - (void) mca_base_param_reg_int_name ("bml", "error_rate_floor", NULL, false, false, - 0, &value); - mca_bml_base_error_rate_floor = (double) value; - - (void) mca_base_param_reg_int_name ("bml", "error_rate_ceiling", NULL, false, false, - 0, &value); - mca_bml_base_error_rate_ceiling = (double) value; - - (void) mca_base_param_reg_int_name ("bml", "srand", NULL, false, false, - 1, &value); - - /* seed random number generator */ - if(value) { - struct timeval tv; - gettimeofday(&tv, NULL); - srand(getpid() * tv.tv_usec); - } - - /* initialize count */ - if(mca_bml_base_error_rate_ceiling > 0 - && mca_bml_base_error_rate_floor <= mca_bml_base_error_rate_ceiling) { - mca_bml_base_error_count = (int) ((mca_bml_base_error_rate_ceiling * rand())/(RAND_MAX+1.0)); - } - } while (0); + /* initialize count */ + if(mca_bml_base_error_rate_ceiling > 0 + && mca_bml_base_error_rate_floor <= mca_bml_base_error_rate_ceiling) { + mca_bml_base_error_count = (int) (((double) mca_bml_base_error_rate_ceiling * rand())/(RAND_MAX+1.0)); + } #endif + return mca_btl_base_open(); } diff --git a/ompi/mca/bml/r2/bml_r2_component.c b/ompi/mca/bml/r2/bml_r2_component.c index 04ebb7eec8..9d5f6c44f7 100644 --- a/ompi/mca/bml/r2/bml_r2_component.c +++ b/ompi/mca/bml/r2/bml_r2_component.c @@ -22,9 +22,9 @@ #include "mpi.h" #include "ompi/mca/bml/bml.h" #include "ompi/mca/btl/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "bml_r2.h" +static int mca_bml_r2_component_register(void); mca_bml_base_component_2_0_0_t mca_bml_r2_component = { @@ -39,7 +39,9 @@ mca_bml_base_component_2_0_0_t mca_bml_r2_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_bml_r2_component_open, /* component open */ - mca_bml_r2_component_close /* component close */ + mca_bml_r2_component_close, /* component close */ + NULL, + mca_bml_r2_component_register }, { /* The component is checkpoint ready */ @@ -47,22 +49,23 @@ mca_bml_base_component_2_0_0_t mca_bml_r2_component = { }, mca_bml_r2_component_init }; - + +static int mca_bml_r2_component_register(void) +{ + mca_bml_r2.show_unreach_errors = true; + (void) mca_base_component_var_register(&mca_bml_r2_component.bml_version, + "show_unreach_errors", + "Show error message when procs are unreachable", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0,0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_bml_r2.show_unreach_errors); + + return OMPI_SUCCESS; +} int mca_bml_r2_component_open(void) { - int tmp; - - mca_base_param_reg_int(&mca_bml_r2_component.bml_version, - "show_unreach_errors", - "Show error message when procs are unreachable", - false, - false, - 1, - &tmp); - mca_bml_r2.show_unreach_errors = OPAL_INT_TO_BOOL(tmp); - - return OMPI_SUCCESS; } diff --git a/ompi/mca/bml/r2/bml_r2_ft.c b/ompi/mca/bml/r2/bml_r2_ft.c index 9eda760533..9cde7c36e6 100644 --- a/ompi/mca/bml/r2/bml_r2_ft.c +++ b/ompi/mca/bml/r2/bml_r2_ft.c @@ -47,7 +47,7 @@ int mca_bml_r2_ft_event(int state) int ret, p; int loc_state; int param_type = -1; - char *param_list = NULL; + const char **btl_list; ompi_rte_collective_t coll; if(OPAL_CRS_CHECKPOINT == state) { @@ -247,28 +247,22 @@ int mca_bml_r2_ft_event(int state) * Re-open the BTL framework to get the full list of components. * - but first clear the MCA value that was there */ - param_type = mca_base_param_find("btl", NULL, NULL); - mca_base_param_lookup_string(param_type, ¶m_list); + param_type = mca_base_var_find("ompi", "btl", NULL, NULL); + btl_list = NULL; + mca_base_var_get_value(param_type, &btl_list, NULL, NULL); opal_output_verbose(11, ompi_cr_output, - "Restart (Previous BTL MCA): <%s>\n", param_list); - if( NULL != param_list ) { - free(param_list); - param_list = NULL; - } - - /* Deregister the old value, and refresh the file cache to grab any updates */ - mca_base_param_deregister(param_type); - mca_base_param_recache_files(false); + "Restart (Previous BTL MCA): <%s>\n", btl_list ? btl_list[0] : ""); if( OMPI_SUCCESS != (ret = mca_btl_base_open()) ) { opal_output(0, "bml:r2: ft_event(Restart): Failed to open BTL framework\n"); return ret; } - param_type = mca_base_param_find("btl", NULL, NULL); - mca_base_param_lookup_string(param_type, ¶m_list); + /* The reregistered paramter is guaranteed to have the same index */ + btl_list = NULL; + mca_base_var_get_value(param_type, &btl_list, NULL, NULL); opal_output_verbose(11, ompi_cr_output, - "Restart (New BTL MCA): <%s>\n", param_list); + "Restart (New BTL MCA): <%s>\n", btl_list ? btl_list[0] : ""); if( NULL != param_list ) { free(param_list); param_list = NULL; diff --git a/ompi/mca/btl/base/base.h b/ompi/mca/btl/base/base.h index 2c22cee67b..c0c01271a1 100644 --- a/ompi/mca/btl/base/base.h +++ b/ompi/mca/btl/base/base.h @@ -63,6 +63,7 @@ OMPI_DECLSPEC void mca_btl_base_dump( int verbose); OMPI_DECLSPEC int mca_btl_base_param_register(mca_base_component_t *version, mca_btl_base_module_t *module); +OMPI_DECLSPEC int mca_btl_base_param_verify(mca_btl_base_module_t *module); /* * Globals diff --git a/ompi/mca/btl/base/btl_base_mca.c b/ompi/mca/btl/base/btl_base_mca.c index 48637df276..f528796f35 100644 --- a/ompi/mca/btl/base/btl_base_mca.c +++ b/ompi/mca/btl/base/btl_base_mca.c @@ -24,7 +24,6 @@ #include -#include "opal/mca/base/mca_base_param.h" #include "opal/util/output.h" @@ -35,18 +34,17 @@ int mca_btl_base_param_register(mca_base_component_t *version, mca_btl_base_module_t *module) { - int value, err = 0; char *msg; -#define REG_INT(N, H, D, L, T) \ - mca_base_param_reg_int(version, N, H, false, false, D, &value); \ - if(value < (L)) \ - err = -1; \ - else \ - D = (T)value; + /* If this is ever triggered change the uint32_ts in mca_btl_base_module_t to unsigned ints */ + assert(sizeof(unsigned int) == sizeof(uint32_t)); - REG_INT("exclusivity", "BTL exclusivity (must be >= 0)", - module->btl_exclusivity, 0, uint32_t); + (void) mca_base_component_var_register(version, "exclusivity", + "BTL exclusivity (must be >= 0)", + MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &module->btl_exclusivity); asprintf(&msg, "BTL bit flags (general flags: SEND=%d, PUT=%d, GET=%d, SEND_INPLACE=%d, RDMA_MATCHED=%d, HETEROGENEOUS_RDMA=%d; flags only used by the \"dr\" PML (ignored by others): ACK=%d, CHECKSUM=%d, RDMA_COMPLETION=%d; flags only used by the \"bfo\" PML (ignored by others): FAILOVER_SUPPORT=%d)", MCA_BTL_FLAGS_SEND, @@ -59,60 +57,76 @@ int mca_btl_base_param_register(mca_base_component_t *version, MCA_BTL_FLAGS_NEED_CSUM, MCA_BTL_FLAGS_RDMA_COMPLETION, MCA_BTL_FLAGS_FAILOVER_SUPPORT); - REG_INT("flags", msg, - module->btl_flags, - 0, uint32_t); + (void) mca_base_component_var_register(version, "flags", msg, + MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &module->btl_flags); free(msg); - REG_INT("rndv_eager_limit", "Size (in bytes, including header) of \"phase 1\" fragment sent for all large messages (must be >= 0 and <= eager_limit)", - module->btl_rndv_eager_limit, 0, size_t); + (void) mca_base_component_var_register(version, "rndv_eager_limit", "Size (in bytes, including header) of \"phase 1\" fragment sent for all large messages (must be >= 0 and <= eager_limit)", + MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &module->btl_rndv_eager_limit); - REG_INT("eager_limit", "Maximum size (in bytes, including header) of \"short\" messages (must be >= 1).", - module->btl_eager_limit, 1, size_t); + (void) mca_base_component_var_register(version, "eager_limit", "Maximum size (in bytes, including header) of \"short\" messages (must be >= 1).", + MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &module->btl_eager_limit); - REG_INT("max_send_size", "Maximum size (in bytes) of a single \"phase 2\" fragment of a long message when using the pipeline protocol (must be >= 1)", - module->btl_max_send_size, 1, size_t); + (void) mca_base_component_var_register(version, "max_send_size", "Maximum size (in bytes) of a single \"phase 2\" fragment of a long message when using the pipeline protocol (must be >= 1)", + MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &module->btl_max_send_size); - if(module->btl_flags & MCA_BTL_FLAGS_PUT) { - /* Obsolete synonym for rdma_pipeline_send_length -- no help - message needed because it's a "hidden" parameter. */ - mca_base_param_reg_int(version, "min_rdma_size", "", true, false, - 0, &value); - if(value != 0) { - opal_output(0, "min_rdma_size BTL parameter is deprecated. Please " - "use the rdma_pipeline_send_length BTL parameter instead\n"); - module->btl_rdma_pipeline_send_length = (size_t)value; - } + if (NULL != module->btl_put) { + (void) mca_base_component_var_register(version, "rdma_pipeline_send_length", "Length of the \"phase 2\" portion of a large message (in bytes) when using the pipeline protocol. This part of the message will be split into fragments of size max_send_size and sent using send/receive semantics (must be >= 0; only relevant when the PUT flag is set)", + MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &module->btl_rdma_pipeline_send_length); - REG_INT("rdma_pipeline_send_length", "Length of the \"phase 2\" portion of a large message (in bytes) when using the pipeline protocol. This part of the message will be split into fragments of size max_send_size and sent using send/receive semantics (must be >= 0; only relevant when the PUT flag is set)", - module->btl_rdma_pipeline_send_length, 0, size_t); + (void) mca_base_component_var_register(version, "rdma_pipeline_frag_size", "Maximum size (in bytes) of a single \"phase 3\" fragment from a long message when using the pipeline protocol. These fragments will be sent using RDMA semantics (must be >= 1; only relevant when the PUT flag is set)", + MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &module->btl_rdma_pipeline_frag_size); - /* Obsolete synonym for rdma_pipeline_frag_size -- no help - message needed because it's a "hidden" parameter. */ - mca_base_param_reg_int(version, "max_rdma_size", "", true, false, - 0, &value); - if (0 != value) { - opal_output(0, "The max_rdma_size BTL parameter is deprecated. Please use the rdma_pipeline_frag_size BTL parameter instead"); - module->btl_rdma_pipeline_frag_size = (size_t)value; - } + (void) mca_base_component_var_register(version, "min_rdma_pipeline_size", "Messages smaller than this size (in bytes) will not use the RDMA pipeline protocol. Instead, they will be split into fragments of max_send_size and sent using send/receive semantics (must be >=0, and is automatically adjusted up to at least (eager_limit+btl_rdma_pipeline_send_length); only relevant when the PUT flag is set)", + MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &module->btl_min_rdma_pipeline_size); - REG_INT("rdma_pipeline_frag_size", "Maximum size (in bytes) of a single \"phase 3\" fragment from a long message when using the pipeline protocol. These fragments will be sent using RDMA semantics (must be >= 1; only relevant when the PUT flag is set)", - module->btl_rdma_pipeline_frag_size, 1, size_t); - - REG_INT("min_rdma_pipeline_size", "Messages smaller than this size (in bytes) will not use the RDMA pipeline protocol. Instead, they will be split into fragments of max_send_size and sent using send/receive semantics (must be >=0, and is automatically adjusted up to at least (eager_limit+btl_rdma_pipeline_send_length); only relevant when the PUT flag is set)", - module->btl_min_rdma_pipeline_size, 0, size_t); - if (module->btl_min_rdma_pipeline_size < - (module->btl_eager_limit + module->btl_rdma_pipeline_send_length)) { - module->btl_min_rdma_pipeline_size = - module->btl_eager_limit + module->btl_rdma_pipeline_send_length; - } + (void) mca_base_component_var_register(version, "bandwidth", "Approximate maximum bandwidth of interconnect (0 = auto-detect value at run-time [not supported in all BTL modules], >= 1 = bandwidth in Mbps)", + MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &module->btl_latency); } - REG_INT("bandwidth", "Approximate maximum bandwidth of interconnect" - "(0 = auto-detect value at run-time [not supported in all BTL modules], >= 1 = bandwidth in Mbps)", module->btl_bandwidth, 0, uint32_t); - - REG_INT("latency", "Approximate latency of interconnect (must be >= 0)", - module->btl_latency, 0, uint32_t); - - return err; + return mca_btl_base_param_verify(module); +} + +/* Verify btl parameters make sense */ +int mca_btl_base_param_verify(mca_btl_base_module_t *module) +{ + if (module->btl_min_rdma_pipeline_size < + (module->btl_eager_limit + module->btl_rdma_pipeline_send_length)) { + module->btl_min_rdma_pipeline_size = + module->btl_eager_limit + module->btl_rdma_pipeline_send_length; + } + + if (NULL == module->btl_put) { + module->btl_flags &= ~MCA_BTL_FLAGS_PUT; + } + + if (NULL == module->btl_get) { + module->btl_flags &= ~MCA_BTL_FLAGS_GET; + } + + return OMPI_SUCCESS; } diff --git a/ompi/mca/btl/base/btl_base_open.c b/ompi/mca/btl/base/btl_base_open.c index 42841f2ee6..8e13858621 100644 --- a/ompi/mca/btl/base/btl_base_open.c +++ b/ompi/mca/btl/base/btl_base_open.c @@ -27,7 +27,6 @@ #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/btl/btl.h" #include "ompi/mca/btl/base/base.h" @@ -80,6 +79,48 @@ opal_list_t mca_btl_base_modules_initialized; int mca_btl_base_already_opened = 0; bool mca_btl_base_thread_multiple_override = false; +static int mca_btl_base_register(int flags) +{ + mca_btl_base_verbose = 0; + (void) mca_base_var_register("ompi", "btl", "base", "verbose", + "Verbosity level of the BTL framework", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_base_verbose); + + /* Override the per-BTL "don't run if THREAD_MULTIPLE selected" + embargo? */ + mca_btl_base_thread_multiple_override = false; + (void) mca_base_var_register("ompi", "btl", "base", "thread_multiple_override", + "Enable BTLs that are not normally enabled when MPI_THREAD_MULTIPLE is enabled (THIS IS FOR DEVELOPERS ONLY! SHOULD NOT BE USED BY END USERS!)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_INTERNAL, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_base_thread_multiple_override); + + (void) mca_base_var_register("ompi", "btl", "base", "include", NULL, + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_base_include); + (void) mca_base_var_register("ompi", "btl", "base", "exclude", NULL, + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_base_exclude); + (void) mca_base_var_register("ompi", "btl", "base", "warn_component_unused", + "This parameter is used to turn on warning messages when certain NICs are not used", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_base_warn_component_unused); + + return OMPI_SUCCESS; +} + /** * Function for finding and opening either all MCA components, or the one * that was specifically requested via a MCA parameter. @@ -89,33 +130,19 @@ int mca_btl_base_open(void) int i; if( ++mca_btl_base_already_opened > 1 ) return OMPI_SUCCESS; - /* Verbose output */ - mca_base_param_reg_int_name("btl", - "base_verbose", - "Verbosity level of the BTL framework", - false, false, - 0, - &mca_btl_base_verbose); + (void) mca_btl_base_register(0); + /* Verbose output */ mca_btl_base_output = opal_output_open(NULL); opal_output_set_verbosity(mca_btl_base_output, mca_btl_base_verbose); - /* Override the per-BTL "don't run if THREAD_MULTIPLE selected" - embargo? */ - mca_base_param_reg_int_name("btl", - "base_thread_multiple_override", - "Enable BTLs that are not normally enabled when MPI_THREAD_MULTIPLE is enabled (THIS IS FOR DEVELOPERS ONLY! SHOULD NOT BE USED BY END USERS!)", - true, false, - 0, &i); - mca_btl_base_thread_multiple_override = OPAL_INT_TO_BOOL(i); - - /* Open up all available components */ + /* Open up all available components */ - if (OMPI_SUCCESS != - mca_base_components_open("btl", mca_btl_base_output, mca_btl_base_static_components, - &mca_btl_base_components_opened, true)) { - return OMPI_ERROR; - } + if (OMPI_SUCCESS != + mca_base_components_open("btl", mca_btl_base_output, mca_btl_base_static_components, + &mca_btl_base_components_opened, true)) { + return OMPI_ERROR; + } /* Initialize the list so that in mca_btl_base_close(), we can iterate over it (even if it's empty, as in the case of @@ -123,15 +150,6 @@ int mca_btl_base_open(void) OBJ_CONSTRUCT(&mca_btl_base_modules_initialized, opal_list_t); - /* register parameters */ - (void) mca_base_param_reg_string_name ("btl", "base_include", NULL, false, false, NULL, - &mca_btl_base_include); - (void) mca_base_param_reg_string_name ("btl", "base_exclude", NULL, false, false, NULL, - &mca_btl_base_exclude); - (void) mca_base_param_reg_int_name ("btl", "base_warn_component_unused", - "This parameter is used to turn on warning messages when certain NICs are not used", - false, false, 1, &mca_btl_base_warn_component_unused); - /* All done */ return OMPI_SUCCESS; } diff --git a/ompi/mca/btl/btl.h b/ompi/mca/btl/btl.h index bde52a1d29..1d0c148729 100644 --- a/ompi/mca/btl/btl.h +++ b/ompi/mca/btl/btl.h @@ -10,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights + * Copyright (c) 2006-2013 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 NVIDIA Corporation. All rights reserved. @@ -31,8 +31,8 @@ * During library initialization, all available BTL components are * loaded and opened via their mca_base_open_component_fn_t * function. The BTL open function should register any mca parameters - * used to tune/adjust the behaviour of the BTL (mca_base_param_reg_int(), - * mca_base_param_reg_string()). Note that the open function may fail + * used to tune/adjust the behaviour of the BTL (mca_base_var_register() + * mca_base_component_var_register()). Note that the open function may fail * if the resources (e.g. shared libraries, etc) required by the network * transport are not available. * diff --git a/ompi/mca/btl/mx/btl_mx_component.c b/ompi/mca/btl/mx/btl_mx_component.c index b405d89a35..f6e3626372 100644 --- a/ompi/mca/btl/mx/btl_mx_component.c +++ b/ompi/mca/btl/mx/btl_mx_component.c @@ -25,7 +25,6 @@ #include "opal/util/opal_environ.h" #include "ompi/constants.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/runtime/ompi_module_exchange.h" #include "ompi/mca/btl/base/btl_base_error.h" #include "ompi/mca/common/mx/common_mx.h" @@ -72,30 +71,8 @@ mca_btl_mx_component_t mca_btl_mx_component = { } }; - -static int mca_btl_mx_component_register(void) +static int mca_btl_mx_component_verify(void) { - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "max_btls", - "Maximum number of accepted Myrinet cards", - false, false, 8, &mca_btl_mx_component.mx_max_btls ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "timeout", - "Timeout for connections", - false, false, MX_INFINITE, &mca_btl_mx_component.mx_timeout ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "retries", - "Number of retries for each new connection before considering the peer as unreacheable", - false, false, 20, &mca_btl_mx_component.mx_connection_retries ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "filter", - "Unique ID for the application (used to connect to the peers)", - false, false, 0xdeadbeef, &mca_btl_mx_component.mx_filter ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "self", - "Enable the MX support for self communications", - false, false, 0, &mca_btl_mx_component.mx_support_self ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "shared_mem", - "Enable the MX support for shared memory", - false, false, 0, &mca_btl_mx_component.mx_support_sharedmem ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "bonding", - "Integrate MX library bonding. Less than 0 is system default, everything else will set the MX_BONDING to the value.", - false, false, 1, &mca_btl_mx_component.mx_bonding ); if( 0 >= mca_btl_mx_component.mx_bonding ) { char* value = getenv("MX_BONDING"); if( NULL == value ) { @@ -110,34 +87,117 @@ static int mca_btl_mx_component_register(void) snprintf( value, 8, "%d\n", mca_btl_mx_component.mx_bonding ); opal_setenv( "MX_BONDING", value, true, &environ ); } -#ifdef HAVE_MX_REGISTER_UNEXP_HANDLER - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "register_unexp", - "Enable the MX support for the unexpected request handler (Open MPI matching)", - false, false, 0, &mca_btl_mx_component.mx_use_unexpected ); -#endif /* HAVE_MX_REGISTER_UNEXP_HANDLER */ - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "free_list_num", - "Number of allocated default request", - false, false, 8, &mca_btl_mx_component.mx_free_list_num ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "free_list_inc", - "Number of request we allocate each time we miss some", - false, false, 32, &mca_btl_mx_component.mx_free_list_inc ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "free_list_max", - "Maximum number of request this device is allowed to allocate", - false, false, 1024, &mca_btl_mx_component.mx_free_list_max ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_mx_component, "max_posted_recv", - "Number of received posted in advance. Increasing this number for" - " communication bound application can lead to visible improvement" - " in performances", - false, false, 16, &mca_btl_mx_component.mx_max_posted_recv ); + return mca_btl_base_param_verify(&mca_btl_mx_module.super); +} + +static int mca_btl_mx_component_register(void) +{ + mca_btl_mx_component.mx_max_btls = 8; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "max_btls", + "Maximum number of accepted Myrinet cards", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_max_btls); + mca_btl_mx_component.mx_timeout = MX_INFINITE; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "timeout", + "Timeout for connections", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_timeout); + mca_btl_mx_component.mx_connection_retries = 20; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "retries", + "Number of retries for each new connection before considering the peer as unreacheable", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_connection_retries); + mca_btl_mx_component.mx_filter = 0xdeadbeef; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "filter", + "Unique ID for the application (used to connect to the peers)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_filter); + mca_btl_mx_component.mx_support_self = 0; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "self", + "Enable the MX support for self communications", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_support_self); + mca_btl_mx_component.mx_support_sharedmem = 0; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "shared_mem", + "Enable the MX support for shared memory", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_support_sharedmem); + mca_btl_mx_component.mx_bonding = 1; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "bonding", + "Integrate MX library bonding. Less than 0 is system default, everything else will set the MX_BONDING to the value.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_bonding); + +#ifdef HAVE_MX_REGISTER_UNEXP_HANDLER + mca_btl_mx_component.mx_use_unexpected = 0; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "register_unexp", + "Enable the MX support for the unexpected request handler (Open MPI matching)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_use_unexpected); +#endif /* HAVE_MX_REGISTER_UNEXP_HANDLER */ + mca_btl_mx_component.mx_free_list_num = 8; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "free_list_num", + "Number of allocated default request", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_free_list_num); + mca_btl_mx_component.mx_free_list_inc = 32; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "free_list_inc", + "Number of request we allocate each time we miss some", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_free_list_inc); + mca_btl_mx_component.mx_free_list_max = 1024; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "free_list_max", + "Maximum number of request this device is allowed to allocate", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_free_list_max); + + mca_btl_mx_component.mx_max_posted_recv = 16; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "max_posted_recv", + "Number of received posted in advance. Increasing this number for communication " + "bound application can lead to visible improvement in performances", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_max_posted_recv); #if MX_HAVE_MAPPER_STATE - mca_base_param_reg_string( (mca_base_component_t*)&mca_btl_mx_component, "if_include", - "Myrinet card to use (last 6 digits from the mapper MAC)", - false, false, NULL, &mca_btl_mx_component.mx_if_include ); - mca_base_param_reg_string( (mca_base_component_t*)&mca_btl_mx_component, "if_exclude", - "Myrinet card to avoid (last 6 digits from the mapper MAC)", - false, false, NULL, &mca_btl_mx_component.mx_if_exclude ); + mca_btl_mx_component.mx_if_include = NULL; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "if_include", + "Myrinet card to use (last 6 digits from the mapper MAC)", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_if_include); + mca_btl_mx_component.mx_if_exclude = NULL; + (void) mca_base_component_var_register(&mca_btl_mx_component.btl_version, "if_exclude", + "Myrinet card to avoid (last 6 digits from the mapper MAC)", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_mx_component.mx_if_exclude); #endif /* MX_HAVE_MAPPER_STATE */ mca_btl_mx_module.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_DEFAULT; @@ -159,10 +219,11 @@ static int mca_btl_mx_component_register(void) mca_btl_mx_module.super.btl_seg_size = sizeof (mca_btl_mx_segment_t); mca_btl_mx_module.super.btl_bandwidth = 2000; mca_btl_mx_module.super.btl_latency = 5; + mca_btl_base_param_register(&mca_btl_mx_component.super.btl_version, &mca_btl_mx_module.super); - return OMPI_SUCCESS; + return mca_btl_mx_component_verify(); } @@ -173,11 +234,18 @@ static int mca_btl_mx_component_register(void) static int mca_btl_mx_component_open(void) { + int ret; + /* initialize state */ mca_btl_mx_component.mx_num_btls = 0; mca_btl_mx_component.mx_btls = NULL; mca_btl_mx_component.mx_use_unexpected = 0; + ret = mca_btl_mx_component_verify(); + if (OMPI_SUCCESS != ret) { + return ret; + } + /* initialize objects */ OBJ_CONSTRUCT(&mca_btl_mx_component.mx_procs, opal_list_t); if( 0 == mca_btl_mx_component.mx_support_sharedmem ) diff --git a/ompi/mca/btl/openib/btl_openib.h b/ompi/mca/btl/openib/btl_openib.h index a8132891c8..f7424ee4eb 100644 --- a/ompi/mca/btl/openib/btl_openib.h +++ b/ompi/mca/btl/openib/btl_openib.h @@ -206,41 +206,44 @@ struct mca_btl_openib_component_t { uint32_t ib_cq_size[2]; /**< Max outstanding CQE on the CQ */ - int32_t ib_max_inline_data; /**< Max size of inline data */ - uint32_t ib_pkey_val; - uint32_t ib_psn; - uint32_t ib_qp_ous_rd_atom; + int ib_max_inline_data; /**< Max size of inline data */ + unsigned int ib_pkey_val; + unsigned int ib_psn; + unsigned int ib_qp_ous_rd_atom; uint32_t ib_mtu; - uint32_t ib_min_rnr_timer; - uint32_t ib_timeout; - uint32_t ib_retry_count; - uint32_t ib_rnr_retry; - uint32_t ib_max_rdma_dst_ops; - uint32_t ib_service_level; + unsigned int ib_min_rnr_timer; + unsigned int ib_timeout; + unsigned int ib_retry_count; + unsigned int ib_rnr_retry; + unsigned int ib_max_rdma_dst_ops; + unsigned int ib_service_level; #if (ENABLE_DYNAMIC_SL) - uint32_t ib_path_record_service_level; + unsigned int ib_path_record_service_level; #endif - int32_t use_eager_rdma; - int32_t eager_rdma_threshold; /**< After this number of msg, use RDMA for short messages, always */ - int32_t eager_rdma_num; + int use_eager_rdma; + int eager_rdma_threshold; /**< After this number of msg, use RDMA for short messages, always */ + int eager_rdma_num; int32_t max_eager_rdma; - uint32_t btls_per_lid; - uint32_t max_lmc; - int32_t apm_lmc; - int32_t apm_ports; - uint32_t buffer_alignment; /**< Preferred communication buffer alignment in Bytes (must be power of two) */ + unsigned int btls_per_lid; + unsigned int max_lmc; + int apm_lmc; + int apm_ports; + unsigned int buffer_alignment; /**< Preferred communication buffer alignment in Bytes (must be power of two) */ #if OPAL_HAVE_THREADS int32_t error_counter; /**< Counts number on error events that we got on all devices */ int async_pipe[2]; /**< Pipe for comunication with async event thread */ int async_comp_pipe[2]; /**< Pipe for async thread comunication with main thread */ pthread_t async_thread; /**< Async thread that will handle fatal errors */ - uint32_t use_async_event_thread; /**< Use the async event handler */ + bool use_async_event_thread; /**< Use the async event handler */ mca_btl_openib_srq_manager_t srq_manager; /**< Hash table for all BTL SRQs */ #if BTL_OPENIB_FAILOVER_ENABLED - uint32_t port_error_failover; /**< Report port errors to speed up failover */ + bool port_error_failover; /**< Report port errors to speed up failover */ #endif #endif - btl_openib_device_type_t device_type; + /* declare as an int instead of btl_openib_device_type_t since there is no + guarantee about the size of an enum. this value will be registered as an + integer with the MCA variable system */ + int device_type; char *if_include; char **if_include_list; char *if_exclude; @@ -277,10 +280,10 @@ struct mca_btl_openib_component_t { that they all exist) */ char **if_list; bool use_message_coalescing; - uint32_t cq_poll_ratio; - uint32_t cq_poll_progress; - uint32_t cq_poll_batch; - uint32_t eager_rdma_poll_ratio; + unsigned int cq_poll_ratio; + unsigned int cq_poll_progress; + unsigned int cq_poll_batch; + unsigned int eager_rdma_poll_ratio; #ifdef HAVE_IBV_FORK_INIT /** Whether we want fork support or not */ int want_fork_support; @@ -309,7 +312,7 @@ struct mca_btl_openib_component_t { void* (*previous_malloc_hook)(size_t __size, const void*); #endif #if OMPI_CUDA_SUPPORT /* CUDA_ASYNC_SEND */ - int cuda_async_send; + bool cuda_async_send; int cuda_async_recv; #endif /* OMPI_CUDA_SUPPORT */ }; typedef struct mca_btl_openib_component_t mca_btl_openib_component_t; diff --git a/ompi/mca/btl/openib/btl_openib_component.c b/ompi/mca/btl/openib/btl_openib_component.c index a5002ad624..66c7edd296 100644 --- a/ompi/mca/btl/openib/btl_openib_component.c +++ b/ompi/mca/btl/openib/btl_openib_component.c @@ -49,7 +49,6 @@ #include "opal/sys/atomic.h" #include "opal/util/argv.h" #include "opal/memoryhooks/memory.h" -#include "opal/mca/base/mca_base_param.h" /* Define this before including hwloc.h so that we also get the hwloc verbs helper header file, too. We have to do this level of indirection because the hwloc subsystem is a component -- we don't @@ -173,7 +172,7 @@ static int btl_openib_component_register(void) /* if_include and if_exclude need to be mutually exclusive */ if (OPAL_SUCCESS != - mca_base_param_check_exclusive_string( + mca_base_var_check_exclusive("ompi", mca_btl_openib_component.super.btl_version.mca_type_name, mca_btl_openib_component.super.btl_version.mca_component_name, "if_include", @@ -620,15 +619,15 @@ static int openib_dereg_mr(void *reg_data, mca_mpool_base_registration_t *reg) openib_reg->mr = NULL; return OMPI_SUCCESS; } -static inline int param_register_int(const char* param_name, int default_value) + +static inline int param_register_uint(const char* param_name, unsigned int default_value, unsigned int *storage) { - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_btl_openib_component.super.btl_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; + *storage = default_value; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + param_name, NULL, MCA_BASE_VAR_TYPE_UNSIGNED_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; } #if OPAL_HAVE_THREADS @@ -809,37 +808,31 @@ static int init_one_port(opal_list_t *btl_list, mca_btl_openib_device_t *device, /* Check bandwidth configured for this device */ sprintf(param, "bandwidth_%s", ibv_get_device_name(device->ib_dev)); - openib_btl->super.btl_bandwidth = - param_register_int(param, openib_btl->super.btl_bandwidth); + param_register_uint(param, openib_btl->super.btl_bandwidth, &openib_btl->super.btl_bandwidth); /* Check bandwidth configured for this device/port */ sprintf(param, "bandwidth_%s:%d", ibv_get_device_name(device->ib_dev), port_num); - openib_btl->super.btl_bandwidth = - param_register_int(param, openib_btl->super.btl_bandwidth); + param_register_uint(param, openib_btl->super.btl_bandwidth, &openib_btl->super.btl_bandwidth); /* Check bandwidth configured for this device/port/LID */ sprintf(param, "bandwidth_%s:%d:%d", ibv_get_device_name(device->ib_dev), port_num, lid); - openib_btl->super.btl_bandwidth = - param_register_int(param, openib_btl->super.btl_bandwidth); + param_register_uint(param, openib_btl->super.btl_bandwidth, &openib_btl->super.btl_bandwidth); /* Check latency configured for this device */ sprintf(param, "latency_%s", ibv_get_device_name(device->ib_dev)); - openib_btl->super.btl_latency = - param_register_int(param, openib_btl->super.btl_latency); + param_register_uint(param, openib_btl->super.btl_latency, &openib_btl->super.btl_latency); /* Check latency configured for this device/port */ sprintf(param, "latency_%s:%d", ibv_get_device_name(device->ib_dev), port_num); - openib_btl->super.btl_latency = - param_register_int(param, openib_btl->super.btl_latency); + param_register_uint(param, openib_btl->super.btl_latency, &openib_btl->super.btl_latency); /* Check latency configured for this device/port/LID */ sprintf(param, "latency_%s:%d:%d", ibv_get_device_name(device->ib_dev), port_num, lid); - openib_btl->super.btl_latency = - param_register_int(param, openib_btl->super.btl_latency); + param_register_uint(param, openib_btl->super.btl_latency, &openib_btl->super.btl_latency); /* Auto-detect the port bandwidth */ if (0 == openib_btl->super.btl_bandwidth) { @@ -2443,7 +2436,7 @@ btl_openib_component_init(int *num_btl_modules, int distance; int index, value; bool found; - mca_base_param_source_t source; + mca_base_var_source_t source; int list_count = 0; /* initialization */ @@ -2520,36 +2513,20 @@ btl_openib_component_init(int *num_btl_modules, support */ if ((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) == ((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) & value)) { - ret = 0; - index = mca_base_param_find("mpi", NULL, "leave_pinned"); - if (index >= 0) { - if (OPAL_SUCCESS == mca_base_param_lookup_int(index, &value) && - -1 == value) { - ++ret; - } - } - index = mca_base_param_find("mpi", NULL, "leave_pinned_pipeline"); - if (index >= 0) { - if (OPAL_SUCCESS == mca_base_param_lookup_int(index, &value) && - OPAL_SUCCESS == mca_base_param_lookup_source(index, &source, - NULL)) { - if (0 == value && MCA_BASE_PARAM_SOURCE_DEFAULT == source) { - ++ret; - } - } - } - /* If we were good on both parameters, then set leave_pinned=1 */ - if (2 == ret) { + if (0 == ompi_mpi_leave_pinned_pipeline && + -1 == ompi_mpi_leave_pinned) { ompi_mpi_leave_pinned = 1; - ompi_mpi_leave_pinned_pipeline = 0; } + } else { + ompi_mpi_leave_pinned = 0; + ompi_mpi_leave_pinned_pipeline = 0; } - index = mca_base_param_find("btl", "openib", "max_inline_data"); + + index = mca_base_var_find("ompi", "btl", "openib", "max_inline_data"); if (index >= 0) { - if (OPAL_SUCCESS == mca_base_param_lookup_source(index, &source, - NULL)) { + if (OPAL_SUCCESS == mca_base_var_get_value(index, NULL, &source, NULL)) { if (-1 == mca_btl_openib_component.ib_max_inline_data && - MCA_BASE_PARAM_SOURCE_DEFAULT == source) { + MCA_BASE_VAR_SOURCE_DEFAULT == source) { /* If the user has not explicitly set this MCA parameter use max_inline_data value specified in the device-specific parameters INI file */ diff --git a/ompi/mca/btl/openib/btl_openib_ini.c b/ompi/mca/btl/openib/btl_openib_ini.c index 5bcaf9dac2..402038b9da 100644 --- a/ompi/mca/btl/openib/btl_openib_ini.c +++ b/ompi/mca/btl/openib/btl_openib_ini.c @@ -30,7 +30,6 @@ #include #endif -#include "opal/mca/base/mca_base_param.h" #include "opal/util/show_help.h" #include "btl_openib.h" diff --git a/ompi/mca/btl/openib/btl_openib_mca.c b/ompi/mca/btl/openib/btl_openib_mca.c index 2e06c2071c..6f4ff88b58 100644 --- a/ompi/mca/btl/openib/btl_openib_mca.c +++ b/ompi/mca/btl/openib/btl_openib_mca.c @@ -29,7 +29,6 @@ #include "opal/util/bit_ops.h" #include "opal/mca/installdirs/installdirs.h" #include "opal/util/output.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/util/show_help.h" #include "btl_openib.h" #include "btl_openib_mca.h" @@ -61,6 +60,31 @@ enum { REGSTR_MAX = 0x88 }; +static mca_base_var_enum_value_t ib_mtu_values[] = { + {IBV_MTU_256, "256B"}, + {IBV_MTU_512, "512B"}, + {IBV_MTU_1024, "1k"}, + {IBV_MTU_2048, "2k"}, + {IBV_MTU_4096, "4k"}, + {0, NULL} +}; + +static mca_base_var_enum_value_t device_type_values[] = { + {BTL_OPENIB_DT_IB, "infiniband"}, + {BTL_OPENIB_DT_IB, "ib"}, + {BTL_OPENIB_DT_IWARP, "iwarp"}, + {BTL_OPENIB_DT_IWARP, "iw"}, + {BTL_OPENIB_DT_ALL, "all"}, + {0, NULL} +}; + +static int btl_openib_cq_size; +static bool btl_openib_have_fork_support = OMPI_HAVE_IBV_FORK_INIT; + +#if BTL_OPENIB_FAILOVER_ENABLED +static int btl_openib_verbose_failover; +static bool btl_openib_failover_enabled = true; +#endif /* * utility routine for string parameter registration @@ -68,26 +92,29 @@ enum { static int reg_string(const char* param_name, const char* deprecated_param_name, const char* param_desc, - const char* default_value, char **out_value, + const char* default_value, char **storage, int flags) { int index; - char *value; - index = mca_base_param_reg_string(&mca_btl_openib_component.super.btl_version, - param_name, param_desc, false, false, - default_value, &value); + + /* The MCA variable system will not change this pointer */ + *storage = (char *) default_value; + index = mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); if (NULL != deprecated_param_name) { - mca_base_param_reg_syn(index, - &mca_btl_openib_component.super.btl_version, - deprecated_param_name, true); + (void) mca_base_var_register_synonym(index, "ompi", "btl", "openib", + deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); } - if (0 != (flags & REGSTR_EMPTY_OK) && 0 == strlen(value)) { + if (0 != (flags & REGSTR_EMPTY_OK) && (NULL == storage || 0 == strlen(*storage))) { opal_output(0, "Bad parameter value for parameter \"%s\"", param_name); return OMPI_ERR_BAD_PARAM; } - *out_value = value; + return OMPI_SUCCESS; } @@ -98,31 +125,89 @@ static int reg_string(const char* param_name, static int reg_int(const char* param_name, const char* deprecated_param_name, const char* param_desc, - int default_value, int *out_value, int flags) + int default_value, int *storage, int flags) { - int index, value; - index = mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - param_name, param_desc, false, false, - default_value, NULL); - if (NULL != deprecated_param_name) { - mca_base_param_reg_syn(index, - &mca_btl_openib_component.super.btl_version, - deprecated_param_name, true); - } - mca_base_param_lookup_int(index, &value); + int index; - if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == value) { - *out_value = value; + *storage = default_value; + index = mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + if (NULL != deprecated_param_name) { + (void) mca_base_var_register_synonym(index, "ompi", "btl", "openib", + deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + } + + if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == *storage) { return OMPI_SUCCESS; } - if ((0 != (flags & REGINT_GE_ZERO) && value < 0) || - (0 != (flags & REGINT_GE_ONE) && value < 1) || - (0 != (flags & REGINT_NONZERO) && 0 == value)) { + + if ((0 != (flags & REGINT_GE_ZERO) && *storage < 0) || + (0 != (flags & REGINT_GE_ONE) && *storage < 1) || + (0 != (flags & REGINT_NONZERO) && 0 == *storage)) { opal_output(0, "Bad parameter value for parameter \"%s\"", param_name); return OMPI_ERR_BAD_PARAM; } - *out_value = value; + + return OMPI_SUCCESS; +} + +/* + * utility routine for integer parameter registration + */ +static int reg_uint(const char* param_name, + const char* deprecated_param_name, + const char* param_desc, + unsigned int default_value, unsigned int *storage, + int flags) +{ + int index; + + *storage = default_value; + index = mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_UNSIGNED_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + if (NULL != deprecated_param_name) { + (void) mca_base_var_register_synonym(index, "ompi", "btl", "openib", + deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + } + + if ((0 != (flags & REGINT_GE_ONE) && *storage < 1) || + (0 != (flags & REGINT_NONZERO) && 0 == *storage)) { + opal_output(0, "Bad parameter value for parameter \"%s\"", + param_name); + return OMPI_ERR_BAD_PARAM; + } + + return OMPI_SUCCESS; +} + +/* + * utility routine for integer parameter registration + */ +static int reg_bool(const char* param_name, + const char* deprecated_param_name, + const char* param_desc, + bool default_value, bool *storage) +{ + int index; + + *storage = default_value; + index = mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_BOOL, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + if (NULL != deprecated_param_name) { + (void) mca_base_var_register_synonym(index, "ompi", "btl", "openib", + deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + } + return OMPI_SUCCESS; } @@ -131,10 +216,11 @@ static int reg_int(const char* param_name, */ int btl_openib_register_mca_params(void) { + mca_base_var_enum_t *new_enum; char default_qps[100]; uint32_t mid_qp_size; - char *msg, *str, *pkey; - int ival, ival2, ret, tmp; + char *msg, *str; + int ret, tmp; ret = OMPI_SUCCESS; #define CHECK(expr) do {\ @@ -143,61 +229,43 @@ int btl_openib_register_mca_params(void) } while (0) /* register openib component parameters */ - CHECK(reg_int("verbose", NULL, + CHECK(reg_bool("verbose", NULL, "Output some verbose OpenIB BTL information " - "(0 = no output, nonzero = output)", 0, &ival, 0)); - mca_btl_openib_component.verbose = (0 != ival); + "(0 = no output, nonzero = output)", false, + &mca_btl_openib_component.verbose)); - CHECK(reg_int("warn_no_device_params_found", + CHECK(reg_bool("warn_no_device_params_found", "warn_no_hca_params_found", "Warn when no device-specific parameters are found in the INI file specified by the btl_openib_device_param_files MCA parameter " "(0 = do not warn; any other value = warn)", - 1, &ival, 0)); - mca_btl_openib_component.warn_no_device_params_found = (0 != ival); - CHECK(reg_int("warn_default_gid_prefix", NULL, + true, &mca_btl_openib_component.warn_no_device_params_found)); + + CHECK(reg_bool("warn_default_gid_prefix", NULL, "Warn when there is more than one active ports and at least one of them connected to the network with only default GID prefix configured " "(0 = do not warn; any other value = warn)", - 1, &ival, 0)); - mca_btl_openib_component.warn_default_gid_prefix = (0 != ival); - CHECK(reg_int("warn_nonexistent_if", NULL, + true, &mca_btl_openib_component.warn_default_gid_prefix)); + + CHECK(reg_bool("warn_nonexistent_if", NULL, "Warn if non-existent devices and/or ports are specified in the btl_openib_if_[in|ex]clude MCA parameters " "(0 = do not warn; any other value = warn)", - 1, &ival, 0)); - mca_btl_openib_component.warn_nonexistent_if = (0 != ival); + true, &mca_btl_openib_component.warn_nonexistent_if)); /* If we print a warning about not having enough registered memory available, do we want to abort? */ - CHECK(reg_int("abort_not_enough_reg_mem", NULL, + CHECK(reg_bool("abort_not_enough_reg_mem", NULL, "If there is not enough registered memory available on the system for Open MPI to function properly, Open MPI will issue a warning. If this MCA parameter is set to true, then Open MPI will also abort all MPI jobs " "(0 = warn, but do not abort; any other value = warn and abort)", - 0, &ival, 0)); - mca_btl_openib_component.abort_not_enough_reg_mem = (0 != ival); + false, &mca_btl_openib_component.abort_not_enough_reg_mem)); - CHECK(reg_int("poll_cq_batch", NULL, - "Retrieve up to poll_cq_batch completions from CQ", - MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT, &ival, REGINT_GE_ONE)); + CHECK(reg_uint("poll_cq_batch", NULL, + "Retrieve up to poll_cq_batch completions from CQ", + MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT, &mca_btl_openib_component.cq_poll_batch, + REGINT_GE_ONE)); - mca_btl_openib_component.cq_poll_batch = (ival > MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT)? MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT : ival; - - if (OMPI_HAVE_IBV_FORK_INIT) { - ival2 = -1; - } else { - ival2 = 0; - } CHECK(reg_int("want_fork_support", NULL, "Whether fork support is desired or not " "(negative = try to enable fork support, but continue even if it is not available, 0 = do not enable fork support, positive = try to enable fork support and fail if it is not available)", - ival2, &ival, 0)); -#ifdef HAVE_IBV_FORK_INIT - mca_btl_openib_component.want_fork_support = ival; -#else - if (0 != ival) { - opal_show_help("help-mpi-btl-openib.txt", - "ibv_fork requested but not supported", true, - ompi_process_info.nodename); - return OMPI_ERR_BAD_PARAM; - } -#endif + OMPI_HAVE_IBV_FORK_INIT ? -1 : 0, &mca_btl_openib_component.want_fork_support, 0)); asprintf(&str, "%s/mca-btl-openib-device-params.ini", opal_install_dirs.pkgdatadir); @@ -210,25 +278,18 @@ int btl_openib_register_mca_params(void) 0)); free(str); - CHECK(reg_string("device_type", NULL, - "Specify to only use IB or iWARP network adapters " - "(infiniband = only use InfiniBand HCAs; iwarp = only use iWARP NICs; all = use any available adapters)", - "all", &str, 0)); - if (0 == strcasecmp(str, "ib") || - 0 == strcasecmp(str, "infiniband")) { - mca_btl_openib_component.device_type = BTL_OPENIB_DT_IB; - } else if (0 == strcasecmp(str, "iw") || - 0 == strcasecmp(str, "iwarp")) { - mca_btl_openib_component.device_type = BTL_OPENIB_DT_IWARP; - } else if (0 == strcasecmp(str, "all")) { - mca_btl_openib_component.device_type = BTL_OPENIB_DT_ALL; - } else { - opal_show_help("help-mpi-btl-openib.txt", - "ibv_fork requested but not supported", true, - ompi_process_info.nodename); - return OMPI_ERR_BAD_PARAM; - } - free(str); + (void)mca_base_var_enum_create("btl_openib_device_types", device_type_values, &new_enum); + mca_btl_openib_component.device_type = BTL_OPENIB_DT_ALL; + tmp = mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "device_type", "Specify to only use IB or iWARP " + "network adapters (infiniband = only use InfiniBand " + "HCAs; iwarp = only use iWARP NICs; all = use any " + "available adapters)", MCA_BASE_VAR_TYPE_INT, new_enum, + 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_openib_component.device_type); + if (0 > tmp) ret = tmp; + OBJ_RELEASE(new_enum); CHECK(reg_int("max_btls", NULL, "Maximum number of device ports to use " @@ -265,38 +326,33 @@ int btl_openib_register_mca_params(void) "(CQs are automatically sized based on the number " "of peer MPI processes; this value determines the " "*minimum* size of all CQs)", - 8192, &ival, REGINT_GE_ONE)); + 8192, &btl_openib_cq_size, REGINT_GE_ONE)); mca_btl_openib_component.ib_cq_size[BTL_OPENIB_LP_CQ] = - mca_btl_openib_component.ib_cq_size[BTL_OPENIB_HP_CQ] = (uint32_t) ival; + mca_btl_openib_component.ib_cq_size[BTL_OPENIB_HP_CQ] = (uint32_t) btl_openib_cq_size; CHECK(reg_int("max_inline_data", "ib_max_inline_data", "Maximum size of inline data segment " "(-1 = run-time probe to discover max value, otherwise must be >= 0). " "If not explicitly set, use max_inline_data from " "the INI file containing device-specific parameters", - -1, &ival, REGINT_NEG_ONE_OK | REGINT_GE_ZERO)); - mca_btl_openib_component.ib_max_inline_data = (int32_t) ival; + -1, &mca_btl_openib_component.ib_max_inline_data, + REGINT_NEG_ONE_OK | REGINT_GE_ZERO)); - CHECK(reg_string("pkey", "ib_pkey_val", - "OpenFabrics partition key (pkey) value. " - "Unsigned integer decimal or hex values are allowed (e.g., \"3\" or \"0x3f\") and will be masked against the maximum allowable IB partition key value (0x7fff)", - "0", &pkey, 0)); - mca_btl_openib_component.ib_pkey_val = - ompi_btl_openib_ini_intify(pkey) & MCA_BTL_IB_PKEY_MASK; - free(pkey); + CHECK(reg_uint("pkey", "ib_pkey_val", + "OpenFabrics partition key (pkey) value. " + "Unsigned integer decimal or hex values are allowed (e.g., \"3\" or \"0x3f\") and will be masked against the maximum allowable IB partition key value (0x7fff)", + 0, &mca_btl_openib_component.ib_pkey_val, 0)); - CHECK(reg_int("psn", "ib_psn", + CHECK(reg_uint("psn", "ib_psn", "OpenFabrics packet sequence starting number " "(must be >= 0)", - 0, &ival, REGINT_GE_ZERO)); - mca_btl_openib_component.ib_psn = (uint32_t) ival; - - CHECK(reg_int("ib_qp_ous_rd_atom", NULL, - "InfiniBand outstanding atomic reads " - "(must be >= 0)", - 4, &ival, REGINT_GE_ZERO)); - mca_btl_openib_component.ib_qp_ous_rd_atom = (uint32_t) ival; + 0, &mca_btl_openib_component.ib_psn, 0)); + CHECK(reg_uint("ib_qp_ous_rd_atom", NULL, + "InfiniBand outstanding atomic reads " + "(must be >= 0)", + 4, &mca_btl_openib_component.ib_qp_ous_rd_atom, 0)); + asprintf(&msg, "OpenFabrics MTU, in bytes (if not specified in INI files). Valid values are: %d=256 bytes, %d=512 bytes, %d=1024 bytes, %d=2048 bytes, %d=4096 bytes", IBV_MTU_256, IBV_MTU_512, @@ -307,244 +363,175 @@ int btl_openib_register_mca_params(void) /* Don't try to recover from this */ return OMPI_ERR_OUT_OF_RESOURCE; } - CHECK(reg_int("mtu", "ib_mtu", msg, IBV_MTU_1024, &ival, 0)); - free(msg); - if (ival < IBV_MTU_1024 || ival > IBV_MTU_4096) { - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "invalid value for btl_openib_ib_mtu", - "btl_openib_ib_mtu reset to 1024"); - mca_btl_openib_component.ib_mtu = IBV_MTU_1024; + mca_btl_openib_component.ib_mtu = IBV_MTU_1024; + (void) mca_base_var_enum_create("btl_openib_mtus", ib_mtu_values, &new_enum); + tmp = mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "mtu", msg, MCA_BASE_VAR_TYPE_INT, new_enum, + 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_openib_component.ib_mtu); + if (0 <= tmp) { + (void) mca_base_var_register_synonym(tmp, "ompi", "btl", "openib", "ib_mtu", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); } else { - mca_btl_openib_component.ib_mtu = (uint32_t) ival; + ret = tmp; } - CHECK(reg_int("ib_min_rnr_timer", NULL, "InfiniBand minimum " - "\"receiver not ready\" timer, in seconds " - "(must be >= 0 and <= 31)", - 25, &ival, 0)); - if (ival > 31) { - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_ib_min_rnr_timer > 31", - "btl_openib_ib_min_rnr_timer reset to 31"); - ival = 31; - } else if (ival < 0){ - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_ib_min_rnr_timer < 0", - "btl_openib_ib_min_rnr_timer reset to 0"); - ival = 0; - } - mca_btl_openib_component.ib_min_rnr_timer = (uint32_t) ival; + OBJ_RELEASE(new_enum); + free(msg); - CHECK(reg_int("ib_timeout", NULL, + CHECK(reg_uint("ib_min_rnr_timer", NULL, "InfiniBand minimum " + "\"receiver not ready\" timer, in seconds " + "(must be >= 0 and <= 31)", + 25, &mca_btl_openib_component.ib_min_rnr_timer, 0)); + + CHECK(reg_uint("ib_timeout", NULL, "InfiniBand transmit timeout, plugged into formula: 4.096 microseconds * (2^btl_openib_ib_timeout) " "(must be >= 0 and <= 31)", - 20, &ival, 0)); - if (ival > 31) { - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_ib_timeout > 31", - "btl_openib_ib_timeout reset to 31"); - ival = 31; - } else if (ival < 0) { - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_ib_timeout < 0", - "btl_openib_ib_timeout reset to 0"); - ival = 0; - } - mca_btl_openib_component.ib_timeout = (uint32_t) ival; - - CHECK(reg_int("ib_retry_count", NULL, + 20, &mca_btl_openib_component.ib_timeout, 0)); + + CHECK(reg_uint("ib_retry_count", NULL, "InfiniBand transmit retry count " "(must be >= 0 and <= 7)", - 7, &ival, 0)); - if (ival > 7) { - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_ib_retry_count > 7", - "btl_openib_ib_retry_count reset to 7"); - ival = 7; - } else if (ival < 0) { - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_ib_retry_count < 0", - "btl_openib_ib_retry_count reset to 0"); - ival = 0; - } - mca_btl_openib_component.ib_retry_count = (uint32_t) ival; + 7, &mca_btl_openib_component.ib_retry_count, 0)); - CHECK(reg_int("ib_rnr_retry", NULL, - "InfiniBand \"receiver not ready\" " - "retry count; applies *only* to SRQ/XRC queues. PP queues " - "use RNR retry values of 0 because Open MPI performs " - "software flow control to guarantee that RNRs never occur " - "(must be >= 0 and <= 7; 7 = \"infinite\")", - 7, &ival, 0)); - if (ival > 7) { - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_ib_rnr_retry > 7", - "btl_openib_ib_rnr_retry reset to 7"); - ival = 7; - } else if (ival < 0) { - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_ib_rnr_retry < 0", - "btl_openib_ib_rnr_retry reset to 0"); - ival = 0; - } - mca_btl_openib_component.ib_rnr_retry = (uint32_t) ival; + CHECK(reg_uint("ib_rnr_retry", NULL, + "InfiniBand \"receiver not ready\" " + "retry count; applies *only* to SRQ/XRC queues. PP queues " + "use RNR retry values of 0 because Open MPI performs " + "software flow control to guarantee that RNRs never occur " + "(must be >= 0 and <= 7; 7 = \"infinite\")", + 7, &mca_btl_openib_component.ib_rnr_retry, 0)); - CHECK(reg_int("ib_max_rdma_dst_ops", NULL, "InfiniBand maximum pending RDMA " + CHECK(reg_uint("ib_max_rdma_dst_ops", NULL, "InfiniBand maximum pending RDMA " "destination operations " "(must be >= 0)", - 4, &ival, REGINT_GE_ZERO)); - mca_btl_openib_component.ib_max_rdma_dst_ops = (uint32_t) ival; + 4, &mca_btl_openib_component.ib_max_rdma_dst_ops, 0)); - CHECK(reg_int("ib_service_level", NULL, "InfiniBand service level " - "(must be >= 0 and <= 15)", - 0, &ival, 0)); - if (ival > 15) { - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_ib_service_level > 15", - "btl_openib_ib_service_level reset to 15"); - ival = 15; - } else if (ival < 0) { - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_ib_service_level < 0", - "btl_openib_ib_service_level reset to 0"); - ival = 0; - } - mca_btl_openib_component.ib_service_level = (uint32_t) ival; + CHECK(reg_uint("ib_service_level", NULL, "InfiniBand service level " + "(must be >= 0 and <= 15)", + 0, &mca_btl_openib_component.ib_service_level, 0)); #if (ENABLE_DYNAMIC_SL) - CHECK(reg_int("ib_path_record_service_level", NULL, - "Enable getting InfiniBand service level from PathRecord " - "(must be >= 0, 0 = disabled, positive = try to get the " - "service level from PathRecord)", - 0, &ival, REGINT_GE_ZERO)); - mca_btl_openib_component.ib_path_record_service_level = (uint32_t) ival; + CHECK(reg_uint("ib_path_record_service_level", NULL, + "Enable getting InfiniBand service level from PathRecord " + "(must be >= 0, 0 = disabled, positive = try to get the " + "service level from PathRecord)", + 0, &mca_btl_openib_component.ib_path_record_service_level, 0)); #endif CHECK(reg_int("use_eager_rdma", NULL, "Use RDMA for eager messages " "(-1 = use device default, 0 = do not use eager RDMA, " "1 = use eager RDMA)", - -1, &ival, 0)); - mca_btl_openib_component.use_eager_rdma = (int32_t) ival; + -1, &mca_btl_openib_component.use_eager_rdma, 0)); CHECK(reg_int("eager_rdma_threshold", NULL, "Use RDMA for short messages after this number of " "messages are received from a given peer " "(must be >= 1)", - 16, &ival, REGINT_GE_ONE)); - mca_btl_openib_component.eager_rdma_threshold = (int32_t) ival; + 16, &mca_btl_openib_component.eager_rdma_threshold, REGINT_GE_ONE)); CHECK(reg_int("max_eager_rdma", NULL, "Maximum number of peers allowed to use " "RDMA for short messages (RDMA is used for all long " "messages, except if explicitly disabled, such as " "with the \"dr\" pml) " "(must be >= 0)", - 16, &ival, REGINT_GE_ZERO)); - mca_btl_openib_component.max_eager_rdma = (int32_t) ival; + 16, &mca_btl_openib_component.max_eager_rdma, REGINT_GE_ZERO)); CHECK(reg_int("eager_rdma_num", NULL, "Number of RDMA buffers to allocate " "for small messages " "(must be >= 1)", - 16, &ival, REGINT_GE_ONE)); - mca_btl_openib_component.eager_rdma_num = (int32_t) (ival + 1); + 16, &mca_btl_openib_component.eager_rdma_num, REGINT_GE_ONE)); + mca_btl_openib_component.eager_rdma_num++; - CHECK(reg_int("btls_per_lid", NULL, "Number of BTLs to create for each " + CHECK(reg_uint("btls_per_lid", NULL, "Number of BTLs to create for each " "InfiniBand LID " "(must be >= 1)", - 1, &ival, REGINT_GE_ONE)); - mca_btl_openib_component.btls_per_lid = (uint32_t) ival; + 1, &mca_btl_openib_component.btls_per_lid, REGINT_GE_ONE)); - CHECK(reg_int("max_lmc", NULL, "Maximum number of LIDs to use for each device port " - "(must be >= 0, where 0 = use all available)", - 0, &ival, REGINT_GE_ZERO)); - mca_btl_openib_component.max_lmc = (uint32_t) ival; + CHECK(reg_uint("max_lmc", NULL, "Maximum number of LIDs to use for each device port " + "(must be >= 0, where 0 = use all available)", + 0, &mca_btl_openib_component.max_lmc, 0)); #if OPAL_HAVE_THREADS CHECK(reg_int("enable_apm_over_lmc", NULL, "Maximum number of alternative paths for each device port " "(must be >= -1, where 0 = disable apm, -1 = all available alternative paths )", - 0, &ival, REGINT_NEG_ONE_OK|REGINT_GE_ZERO)); - mca_btl_openib_component.apm_lmc = (uint32_t) ival; + 0, &mca_btl_openib_component.apm_lmc, REGINT_NEG_ONE_OK|REGINT_GE_ZERO)); + CHECK(reg_int("enable_apm_over_ports", NULL, "Enable alternative path migration (APM) over different ports of the same device " "(must be >= 0, where 0 = disable APM over ports, 1 = enable APM over ports of the same device)", - 0, &ival, REGINT_GE_ZERO)); - mca_btl_openib_component.apm_ports = (uint32_t) ival; + 0, &mca_btl_openib_component.apm_ports, REGINT_GE_ZERO)); - CHECK(reg_int("use_async_event_thread", NULL, - "If nonzero, use the thread that will handle InfiniBand asynchronous events", - 1, &ival, 0)); - mca_btl_openib_component.use_async_event_thread = (0 != ival); + CHECK(reg_bool("use_async_event_thread", NULL, + "If nonzero, use the thread that will handle InfiniBand asynchronous events", + true, &mca_btl_openib_component.use_async_event_thread)); #if BTL_OPENIB_FAILOVER_ENABLED /* failover specific output */ CHECK(reg_int("verbose_failover", NULL, "Output some verbose OpenIB BTL failover information " - "(0 = no output, nonzero = output)", 0, &ival, 0)); + "(0 = no output, nonzero = output)", 0, &btl_openib_verbose_failover, 0)); mca_btl_openib_component.verbose_failover = opal_output_open(NULL); - opal_output_set_verbosity(mca_btl_openib_component.verbose_failover, ival); + opal_output_set_verbosity(mca_btl_openib_component.verbose_failover, ); - CHECK(reg_int("port_error_failover", NULL, - "If nonzero, asynchronous port errors will trigger failover", - 0, &ival, 0)); - mca_btl_openib_component.port_error_failover = (0 != ival); + CHECK(reg_bool("port_error_failover", NULL, + "If nonzero, asynchronous port errors will trigger failover", + 0, &mca_btl_openib_component.port_error_failover)); /* Make non writeable parameter that indicates failover is configured in. */ - tmp = mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "failover_enabled", - "openib failover is configured: run with bfo PML to support failover between openib BTLs", - false, true, - 1, NULL); + tmp = mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "failover_enabled", + "openib failover is configured: run with bfo PML to support failover between openib BTLs", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_CONSTANT, + &btl_openib_failover_enabled); + if (0 > tmp) ret = tmp; #endif - - CHECK(reg_int("enable_srq_resize", NULL, - "Enable/Disable on demand SRQ resize. " - "(0 = without resizing, nonzero = with resizing)", 1, &ival, 0)); - mca_btl_openib_component.enable_srq_resize = (0 != ival); + + CHECK(reg_bool("enable_srq_resize", NULL, + "Enable/Disable on demand SRQ resize. " + "(0 = without resizing, nonzero = with resizing)", 1, + &mca_btl_openib_component.enable_srq_resize)); #else - mca_btl_openib_component.enable_srq_resize = 0; + mca_btl_openib_component.enable_srq_resize = false; #endif - CHECK(reg_int("buffer_alignment", NULL, - "Preferred communication buffer alignment, in bytes " - "(must be > 0 and power of two)", - 64, &ival, REGINT_GE_ZERO)); - if(ival <= 1 || (ival & (ival - 1))) { - opal_show_help("help-mpi-btl-openib.txt", "wrong buffer alignment", - true, ival, ompi_process_info.nodename, 64); - mca_btl_openib_component.buffer_alignment = 64; - } else { - mca_btl_openib_component.buffer_alignment = (uint32_t) ival; - } + CHECK(reg_uint("buffer_alignment", NULL, + "Preferred communication buffer alignment, in bytes " + "(must be > 0 and power of two)", + 64, &mca_btl_openib_component.buffer_alignment, 0)); - CHECK(reg_int("use_message_coalescing", NULL, - "If nonzero, use message coalescing", 1, &ival, 0)); - mca_btl_openib_component.use_message_coalescing = (0 != ival); + CHECK(reg_bool("use_message_coalescing", NULL, + "If nonzero, use message coalescing", true, + &mca_btl_openib_component.use_message_coalescing)); - CHECK(reg_int("cq_poll_ratio", NULL, - "How often to poll high priority CQ versus low priority CQ", - 100, &ival, REGINT_GE_ONE)); - mca_btl_openib_component.cq_poll_ratio = (uint32_t)ival; - CHECK(reg_int("eager_rdma_poll_ratio", NULL, - "How often to poll eager RDMA channel versus CQ", - 100, &ival, REGINT_GE_ONE)); - mca_btl_openib_component.eager_rdma_poll_ratio = (uint32_t)ival; - CHECK(reg_int("hp_cq_poll_per_progress", NULL, + CHECK(reg_uint("cq_poll_ratio", NULL, + "How often to poll high priority CQ versus low priority CQ", + 100, &mca_btl_openib_component.cq_poll_ratio, REGINT_GE_ONE)); + CHECK(reg_uint("eager_rdma_poll_ratio", NULL, + "How often to poll eager RDMA channel versus CQ", + 100, &mca_btl_openib_component.eager_rdma_poll_ratio, REGINT_GE_ONE)); + CHECK(reg_uint("hp_cq_poll_per_progress", NULL, "Max number of completion events to process for each call " "of BTL progress engine", - 10, &ival, REGINT_GE_ONE)); - mca_btl_openib_component.cq_poll_progress = (uint32_t)ival; + 10, &mca_btl_openib_component.cq_poll_progress, REGINT_GE_ONE)); - CHECK(reg_int("max_hw_msg_size", NULL, - "Maximum size (in bytes) of a single fragment of a long message when using the RDMA protocols (must be > 0 and <= hw capabilities).", - 0, &ival, REGINT_GE_ZERO)); - mca_btl_openib_component.max_hw_msg_size = (uint32_t)ival; + CHECK(reg_uint("max_hw_msg_size", NULL, + "Maximum size (in bytes) of a single fragment of a long message when using the RDMA protocols (must be > 0 and <= hw capabilities).", + 0, &mca_btl_openib_component.max_hw_msg_size, 0)); /* Info only */ - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "have_fork_support", - "Whether the OpenFabrics stack supports applications that invoke the \"fork()\" system call or not (0 = no, 1 = yes). " - "Note that this value does NOT indicate whether the system being run on supports \"fork()\" with OpenFabrics applications or not.", - false, true, - OMPI_HAVE_IBV_FORK_INIT ? 1 : 0, - NULL); + tmp = mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "have_fork_support", + "Whether the OpenFabrics stack supports applications that invoke the \"fork()\" system call or not (0 = no, 1 = yes). " + "Note that this value does NOT indicate whether the system being run on supports \"fork()\" with OpenFabrics applications or not.", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_CONSTANT, + &btl_openib_have_fork_support); mca_btl_openib_module.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_DEFAULT; @@ -568,23 +555,16 @@ int btl_openib_register_mca_params(void) #if OMPI_CUDA_SUPPORT /* CUDA_ASYNC_RECV */ /* Default is enabling CUDA asynchronous send copies */ - CHECK(reg_int("cuda_async_send", NULL, - "Enable or disable CUDA async send copies " - "(1 = async; 0 = sync)", - 1, &ival, 0)); - mca_btl_openib_component.cuda_async_send = (0 != ival); - if (mca_btl_openib_component.cuda_async_send) { - mca_btl_openib_module.super.btl_flags |= MCA_BTL_FLAGS_CUDA_COPY_ASYNC_SEND; - } + CHECK(reg_bool("cuda_async_send", NULL, + "Enable or disable CUDA async send copies " + "(true = async; false = sync)", + true, &mca_btl_openib_component.cuda_async_send)); + /* Default is enabling CUDA asynchronous receive copies */ - CHECK(reg_int("cuda_async_recv", NULL, - "Enable or disable CUDA async recv copies " - "(1 = async; 0 = sync)", - 1, &ival, 0)); - mca_btl_openib_component.cuda_async_recv = (0 != ival); - if (mca_btl_openib_component.cuda_async_recv) { - mca_btl_openib_module.super.btl_flags |= MCA_BTL_FLAGS_CUDA_COPY_ASYNC_RECV; - } + CHECK(reg_bool("cuda_async_recv", NULL, + "Enable or disable CUDA async recv copies " + "(true = async; false = sync)", + true, &mca_btl_openib_component.cuda_async_recv)); /* Also make the max send size larger for better GPU buffer performance */ mca_btl_openib_module.super.btl_max_send_size = 128 * 1024; /* Turn of message coalescing - not sure if it works with GPU buffers */ @@ -652,7 +632,101 @@ int btl_openib_register_mca_params(void) "alignment for all malloc calls if btl openib is used.", 32, &mca_btl_openib_component.use_memalign, REGINT_GE_ZERO)); - + + mca_btl_openib_component.memalign_threshold = mca_btl_openib_component.eager_limit; + tmp = mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "memalign_threshold", + "Allocating memory more than btl_openib_memalign_threshhold" + "bytes will automatically be algined to the value of btl_openib_memalign bytes." + "memalign_threshhold defaults to the same value as mca_btl_openib_eager_limit.", + MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_openib_component.memalign_threshold); + if (0 > tmp) ret = tmp; +#endif + + /* Register any MCA params for the connect pseudo-components */ + if (OMPI_SUCCESS == ret) { + ret = ompi_btl_openib_connect_base_register(); + } + + return btl_openib_verify_mca_params(); +} + +int btl_openib_verify_mca_params (void) +{ + if (mca_btl_openib_component.cq_poll_batch > MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT) { + mca_btl_openib_component.cq_poll_batch = MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT; + } + +#if !HAVE_IBV_FORK_INIT + if (0 != mca_btl_openib_component.want_fork_support) { + opal_show_help("help-mpi-btl-openib.txt", + "ibv_fork requested but not supported", true, + ompi_process_info.nodename); + return OMPI_ERR_BAD_PARAM; + } +#endif + + mca_btl_openib_component.ib_pkey_val &= MCA_BTL_IB_PKEY_MASK; + + if (mca_btl_openib_component.ib_min_rnr_timer > 31) { + opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", + true, "btl_openib_ib_min_rnr_timer > 31", + "btl_openib_ib_min_rnr_timer reset to 31"); + mca_btl_openib_component.ib_min_rnr_timer = 31; + } + + if (mca_btl_openib_component.ib_timeout > 31) { + opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", + true, "btl_openib_ib_timeout > 31", + "btl_openib_ib_timeout reset to 31"); + mca_btl_openib_component.ib_timeout = 31; + } + + if (mca_btl_openib_component.ib_retry_count > 7) { + opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", + true, "btl_openib_ib_retry_count > 7", + "btl_openib_ib_retry_count reset to 7"); + mca_btl_openib_component.ib_retry_count = 7; + } + + if (mca_btl_openib_component.ib_rnr_retry > 7) { + opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", + true, "btl_openib_ib_rnr_retry > 7", + "btl_openib_ib_rnr_retry reset to 7"); + mca_btl_openib_component.ib_rnr_retry = 7; + } + + if (mca_btl_openib_component.ib_service_level > 15) { + opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", + true, "btl_openib_ib_service_level > 15", + "btl_openib_ib_service_level reset to 15"); + mca_btl_openib_component.ib_service_level = 15; + } + + if(mca_btl_openib_component.buffer_alignment <= 1 || + (mca_btl_openib_component.buffer_alignment & (mca_btl_openib_component.buffer_alignment - 1))) { + opal_show_help("help-mpi-btl-openib.txt", "wrong buffer alignment", + true, mca_btl_openib_component.buffer_alignment, ompi_process_info.nodename, 64); + mca_btl_openib_component.buffer_alignment = 64; + } + +#if OMPI_CUDA_SUPPORT /* CUDA_ASYNC_RECV */ + if (mca_btl_openib_component.cuda_async_send) { + mca_btl_openib_module.super.btl_flags |= MCA_BTL_FLAGS_CUDA_COPY_ASYNC_SEND; + } else { + mca_btl_openib_module.super.btl_flags &= ~MCA_BTL_FLAGS_CUDA_COPY_ASYNC_SEND; + } + + if (mca_btl_openib_component.cuda_async_recv) { + mca_btl_openib_module.super.btl_flags |= MCA_BTL_FLAGS_CUDA_COPY_ASYNC_RECV; + } else { + mca_btl_openib_module.super.btl_flags &= ~MCA_BTL_FLAGS_CUDA_COPY_ASYNC_RECV; + } +#endif + if (mca_btl_openib_component.use_memalign != 32 && mca_btl_openib_component.use_memalign != 64 && mca_btl_openib_component.use_memalign != 0){ @@ -661,27 +735,6 @@ int btl_openib_register_mca_params(void) "btl_openib_memalign is reset to 32"); mca_btl_openib_component.use_memalign = 32; } - reg_int("memalign_threshold", NULL, - "Allocating memory more than btl_openib_memalign_threshhold" - "bytes will automatically be algined to the value of btl_openib_memalign bytes." - "memalign_threshhold defaults to the same value as mca_btl_openib_eager_limit.", - mca_btl_openib_component.eager_limit, - &ival, - REGINT_GE_ZERO); - if (ival < 0){ - opal_show_help("help-mpi-btl-openib.txt", "invalid mca param value", - true, "btl_openib_memalign_threshold must be positive", - "btl_openib_memalign_threshold is reset to btl_openib_eager_limit"); - ival = mca_btl_openib_component.eager_limit; - } - mca_btl_openib_component.memalign_threshold = (size_t)ival; -#endif - /* Register any MCA params for the connect pseudo-components */ - if (OMPI_SUCCESS == ret) { - ret = ompi_btl_openib_connect_base_register(); - } - - return ret; + return OMPI_SUCCESS; } - diff --git a/ompi/mca/btl/openib/btl_openib_mca.h b/ompi/mca/btl/openib/btl_openib_mca.h index 789284cbd9..49635644e8 100644 --- a/ompi/mca/btl/openib/btl_openib_mca.h +++ b/ompi/mca/btl/openib/btl_openib_mca.h @@ -16,6 +16,7 @@ BEGIN_C_DECLS * Function to register MCA params and check for sane values */ int btl_openib_register_mca_params(void); + int btl_openib_verify_mca_params (void); END_C_DECLS #endif diff --git a/ompi/mca/btl/openib/connect/btl_openib_connect_base.c b/ompi/mca/btl/openib/connect/btl_openib_connect_base.c index 99b92220c1..b4850f8570 100644 --- a/ompi/mca/btl/openib/connect/btl_openib_connect_base.c +++ b/ompi/mca/btl/openib/connect/btl_openib_connect_base.c @@ -66,6 +66,9 @@ static ompi_btl_openib_connect_base_component_t *all[] = { static ompi_btl_openib_connect_base_component_t **available = NULL; static int num_available = 0; +static char *btl_openib_cpc_include; +static char *btl_openib_cpc_exclude; + /* * Register MCA parameters */ @@ -73,7 +76,6 @@ int ompi_btl_openib_connect_base_register(void) { int i, j, save; char **temp = NULL, *string = NULL, *all_cpc_names = NULL; - char *cpc_include = NULL, *cpc_exclude = NULL; /* Make an MCA parameter to select which connect module to use */ for (i = 0; NULL != all[i]; ++i) { @@ -88,18 +90,24 @@ int ompi_btl_openib_connect_base_register(void) "Method used to select OpenFabrics connections (valid values: %s)", all_cpc_names); - mca_base_param_reg_string(&mca_btl_openib_component.super.btl_version, - "cpc_include", string, false, false, - NULL, &cpc_include); + btl_openib_cpc_include = NULL; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "cpc_include", string, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &btl_openib_cpc_include); free(string); asprintf(&string, "Method used to exclude OpenFabrics connections (valid values: %s)", all_cpc_names); - mca_base_param_reg_string(&mca_btl_openib_component.super.btl_version, - "cpc_exclude", string, false, false, - NULL, &cpc_exclude); + btl_openib_cpc_include = NULL; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "cpc_exclude", string, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &btl_openib_cpc_exclude); free(string); /* Parse the if_[in|ex]clude paramters to come up with a list of @@ -108,9 +116,9 @@ int ompi_btl_openib_connect_base_register(void) /* If we have an "include" list, then find all those CPCs and put them in available[] */ - if (NULL != cpc_include) { + if (NULL != btl_openib_cpc_include) { mca_btl_openib_component.cpc_explicitly_defined = true; - temp = opal_argv_split(cpc_include, ','); + temp = opal_argv_split(btl_openib_cpc_include, ','); for (save = j = 0; NULL != temp[j]; ++j) { for (i = 0; NULL != all[i]; ++i) { if (0 == strcmp(temp[j], all[i]->cbc_name)) { @@ -124,7 +132,7 @@ int ompi_btl_openib_connect_base_register(void) opal_show_help("help-mpi-btl-openib-cpc-base.txt", "cpc name not found", true, "include", ompi_process_info.nodename, - "include", cpc_include, temp[j], + "include", btl_openib_cpc_include, temp[j], all_cpc_names); opal_argv_free(temp); free(all_cpc_names); @@ -136,9 +144,9 @@ int ompi_btl_openib_connect_base_register(void) /* Otherwise, if we have an "exclude" list, take all the CPCs that are not in that list and put them in available[] */ - else if (NULL != cpc_exclude) { + else if (NULL != btl_openib_cpc_exclude) { mca_btl_openib_component.cpc_explicitly_defined = true; - temp = opal_argv_split(cpc_exclude, ','); + temp = opal_argv_split(btl_openib_cpc_exclude, ','); /* First: error check -- ensure that all the names are valid */ for (j = 0; NULL != temp[j]; ++j) { for (i = 0; NULL != all[i]; ++i) { @@ -150,7 +158,7 @@ int ompi_btl_openib_connect_base_register(void) opal_show_help("help-mpi-btl-openib-cpc-base.txt", "cpc name not found", true, "exclude", ompi_process_info.nodename, - "exclude", cpc_exclude, temp[j], + "exclude", btl_openib_cpc_exclude, temp[j], all_cpc_names); opal_argv_free(temp); free(all_cpc_names); diff --git a/ompi/mca/btl/openib/connect/btl_openib_connect_oob.c b/ompi/mca/btl/openib/connect/btl_openib_connect_oob.c index 08f3a63a22..123fef25e7 100644 --- a/ompi/mca/btl/openib/connect/btl_openib_connect_oob.c +++ b/ompi/mca/btl/openib/connect/btl_openib_connect_oob.c @@ -98,10 +98,14 @@ ompi_btl_openib_connect_base_component_t ompi_btl_openib_connect_oob = { /* Open - this functions sets up any oob specific commandline params */ static void oob_component_register(void) { - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_oob_priority", - "The selection method priority for oob", - false, false, oob_priority, &oob_priority); + oob_priority = 50; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_oob_priority", + "The selection method priority for oob", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &oob_priority); if (oob_priority > 100) { oob_priority = 100; @@ -166,6 +170,13 @@ static int oob_component_query(mca_btl_openib_module_t *btl, "openib BTL: oob CPC system error (malloc failed)"); return OMPI_ERR_OUT_OF_RESOURCE; } + + if (oob_priority > 100) { + oob_priority = 100; + } else if (oob_priority < -1) { + oob_priority = -1; + } + (*cpc)->data.cbm_component = &ompi_btl_openib_connect_oob; (*cpc)->data.cbm_priority = oob_priority; (*cpc)->data.cbm_modex_message = NULL; diff --git a/ompi/mca/btl/openib/connect/btl_openib_connect_rdmacm.c b/ompi/mca/btl/openib/connect/btl_openib_connect_rdmacm.c index 3054b58db7..8b60344000 100644 --- a/ompi/mca/btl/openib/connect/btl_openib_connect_rdmacm.c +++ b/ompi/mca/btl/openib/connect/btl_openib_connect_rdmacm.c @@ -164,7 +164,7 @@ static opal_list_t client_list; static opal_mutex_t client_list_lock; static struct rdma_event_channel *event_channel = NULL; static int rdmacm_priority = 30; -static uint16_t rdmacm_port = 0; +static unsigned int rdmacm_port = 0; static uint32_t rdmacm_addr = 0; static int rdmacm_resolve_timeout = 30000; static int rdmacm_resolve_max_retry_count = 20; @@ -229,55 +229,70 @@ static void rdmacm_component_register(void) { int value; - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_rdmacm_priority", - "The selection method priority for rdma_cm", - false, false, rdmacm_priority, &rdmacm_priority); - + rdmacm_priority = 30; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_rdmacm_priority", + "The selection method priority for rdma_cm", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &rdmacm_priority); if (rdmacm_priority > 100) { rdmacm_priority = 100; } else if (rdmacm_priority < 0) { rdmacm_priority = 0; } - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_rdmacm_port", - "The selection method port for rdma_cm", - false, false, rdmacm_port, &value); - if (value >= 0 && value < 65536) { - rdmacm_port = (uint16_t) value; - } else { + rdmacm_port = 0; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_rdmacm_port", + "The selection method port for rdma_cm", + MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &rdmacm_port); + if (rdmacm_port & ~0xfffful) { opal_show_help("help-mpi-btl-openib-cpc-rdmacm.txt", - "illegal tcp port", true, value); + "illegal tcp port", true, (int) rdmacm_port); + rdmacm_port = 0; } - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_rdmacm_resolve_timeout", - "The timeout (in miliseconds) for address and route resolution", - false, false, rdmacm_resolve_timeout, &value); - if (value > 0) { - rdmacm_resolve_timeout = value; - } else { + rdmacm_resolve_timeout = 30000; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_rdmacm_resolve_timeout", + "The timeout (in miliseconds) for address and route resolution", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &rdmacm_resolve_timeout); + if (0 > rdmacm_resolve_timeout) { opal_show_help("help-mpi-btl-openib-cpc-rdmacm.txt", - "illegal timeout", true, value); + "illegal timeout", true, rdmacm_resolve_timeout); + rdmacm_resolve_timeout = 30000; } - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_rdmacm_retry_count", - "Maximum number of times rdmacm will retry route resolution", - false, false, rdmacm_resolve_max_retry_count, &value); - if (value > 0) { - rdmacm_resolve_max_retry_count = value; - } else { + rdmacm_resolve_max_retry_count = 20; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_rdmacm_retry_count", + "Maximum number of times rdmacm will retry route resolution", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &rdmacm_resolve_max_retry_count); + if (0 > rdmacm_resolve_max_retry_count) { opal_show_help("help-mpi-btl-openib-cpc-rdmacm.txt", - "illegal retry count", true, value); + "illegal retry count", true, rdmacm_resolve_max_retry_count); + rdmacm_resolve_max_retry_count = 20; } - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_rdmacm_reject_causes_connect_error", - "The drivers for some devices are buggy such that an RDMA REJECT action may result in a CONNECT_ERROR event instead of a REJECTED event. Setting this MCA parameter to true tells Open MPI to treat CONNECT_ERROR events on connections where a REJECT is expected as a REJECT (default: false)", - false, false, 0, &value); - rdmacm_reject_causes_connect_error = (bool) (value != 0); + rdmacm_reject_causes_connect_error = false; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_rdmacm_reject_causes_connect_error", + "The drivers for some devices are buggy such that an RDMA REJECT action may result in a CONNECT_ERROR event instead of a REJECTED event. Setting this MCA parameter to true tells Open MPI to treat CONNECT_ERROR events on connections where a REJECT is expected as a REJECT (default: false)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &rdmacm_reject_causes_connect_error); } /* @@ -1864,7 +1879,7 @@ static int rdmacm_component_query(mca_btl_openib_module_t *openib_btl, ompi_btl_ memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = rdmacm_addr; - sin.sin_port = rdmacm_port; + sin.sin_port = (uint16_t) rdmacm_port; /* Bind the rdmacm server to the local IP address and an ephemerial * port or one specified by a comand arg. diff --git a/ompi/mca/btl/openib/connect/btl_openib_connect_udcm.c b/ompi/mca/btl/openib/connect/btl_openib_connect_udcm.c index 9a3a6fd6e9..d05b4049f0 100644 --- a/ompi/mca/btl/openib/connect/btl_openib_connect_udcm.c +++ b/ompi/mca/btl/openib/connect/btl_openib_connect_udcm.c @@ -354,38 +354,41 @@ ompi_btl_openib_connect_base_component_t ompi_btl_openib_connect_udcm = { static void udcm_component_register(void) { - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_udcm_priority", - "The selection method priority for ud", - false, false, udcm_priority, &udcm_priority); - if (udcm_priority > 100) { - udcm_priority = 100; - } else if (udcm_priority < 0) { - udcm_priority = 0; - } + udcm_priority = 0; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_udcm_priority", + "The selection method priority for ud", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &udcm_priority); - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_udcm_recv_count", - "Number of connection buffers to post", - false, false, udcm_recv_count, - &udcm_recv_count); - if (UDCM_MIN_RECV_COUNT > udcm_recv_count) { - udcm_recv_count = UDCM_MIN_RECV_COUNT; - } + udcm_recv_count = UDCM_MIN_RECV_COUNT; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_udcm_recv_count", + "Number of connection buffers to post", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &udcm_recv_count); - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_udcm_timeout", - "Microseconds to wait for ud connection response", - false, false, udcm_timeout, - &udcm_timeout); - if (UDCM_MIN_TIMEOUT > udcm_timeout) { - udcm_timeout = UDCM_MIN_TIMEOUT; - } + udcm_timeout = UDCM_MIN_TIMEOUT; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_udcm_timeout", + "Microseconds to wait for ud connection response", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &udcm_timeout); - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_udcm_max_retry", - "Maximum number of times to retry sending a connection message", - false, false, udcm_max_retry, &udcm_max_retry); + udcm_max_retry = 10; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_udcm_max_retry", + "Maximum number of times to retry sending a connection message", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &udcm_max_retry); } static int udcm_component_query(mca_btl_openib_module_t *btl, @@ -423,7 +426,19 @@ static int udcm_component_query(mca_btl_openib_module_t *btl, break; } - signal (SIGSEGV, SIG_DFL); + if (udcm_priority > 100) { + udcm_priority = 100; + } else if (udcm_priority < 0) { + udcm_priority = 0; + } + + if (UDCM_MIN_RECV_COUNT > udcm_recv_count) { + udcm_recv_count = UDCM_MIN_RECV_COUNT; + } + + if (UDCM_MIN_TIMEOUT > udcm_timeout) { + udcm_timeout = UDCM_MIN_TIMEOUT; + } rc = udcm_module_init (m, btl); if (OMPI_SUCCESS != rc) { diff --git a/ompi/mca/btl/openib/connect/btl_openib_connect_xoob.c b/ompi/mca/btl/openib/connect/btl_openib_connect_xoob.c index 5cfaf9c00a..49116af5b0 100644 --- a/ompi/mca/btl/openib/connect/btl_openib_connect_xoob.c +++ b/ompi/mca/btl/openib/connect/btl_openib_connect_xoob.c @@ -1038,6 +1038,12 @@ static int xoob_component_query(mca_btl_openib_module_t *openib_btl, rml_recv_posted = true; } + if (xoob_priority > 100) { + xoob_priority = 100; + } else if (xoob_priority < -1) { + xoob_priority = -1; + } + (*cpc)->data.cbm_component = &ompi_btl_openib_connect_xoob; (*cpc)->data.cbm_priority = xoob_priority; (*cpc)->data.cbm_modex_message = NULL; @@ -1059,10 +1065,14 @@ static int xoob_component_query(mca_btl_openib_module_t *openib_btl, /* Open - this functions sets up any xoob specific commandline params */ static void xoob_component_register(void) { - mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version, - "connect_xoob_priority", - "The selection method priority for xoob", - false, false, xoob_priority, &xoob_priority); + xoob_priority = 60; + (void) mca_base_component_var_register(&mca_btl_openib_component.super.btl_version, + "connect_xoob_priority", + "The selection method priority for xoob", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &xoob_priority); if (xoob_priority > 100) { xoob_priority = 100; diff --git a/ompi/mca/btl/sctp/btl_sctp_component.c b/ompi/mca/btl/sctp/btl_sctp_component.c index 96c6f94644..dc58e6f216 100644 --- a/ompi/mca/btl/sctp/btl_sctp_component.c +++ b/ompi/mca/btl/sctp/btl_sctp_component.c @@ -46,7 +46,6 @@ #include "opal/util/argv.h" #include "ompi/mca/btl/btl.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/runtime/ompi_module_exchange.h" #include "ompi/runtime/mpiruntime.h" #include "ompi/mca/mpool/base/base.h" @@ -104,27 +103,29 @@ struct mca_btl_sctp_proc_table_node *sender_proc_table; */ static inline char* mca_btl_sctp_param_register_string( - const char* param_name, - const char* default_value) + const char* param_name, + const char* default_value, + char **storage) { - char *param_value; - char *help_string = NULL; - mca_base_param_reg_string(&mca_btl_sctp_component.super.btl_version, - param_name, help_string, false, false, - default_value, ¶m_value); - return param_value; + *storage = default_value; + (void) mca_base_component_var_register(&mca_btl_sctp_component.super.btl_version, + param_name, NULL, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; } static inline int mca_btl_sctp_param_register_int( const char* param_name, - int default_value) + int default_value, + int *storage) { - int param_value; - char *help_string = NULL; - mca_base_param_reg_int(&mca_btl_sctp_component.super.btl_version, - param_name, help_string, false, false, - default_value, ¶m_value); - return param_value; + *storage = default_value; + (void) mca_base_component_var_register(&mca_btl_sctp_component.super.btl_version, + param_name, NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; } @@ -166,39 +167,38 @@ OBJ_CLASS_INSTANCE( static void mca_btl_sctp_component_recv_handler(int, short, void*); /* for 1-1 */ /* mca_btl_sctp_recv_handler(int, short, void*) for 1-many is in btl_sctp_recv_handler.h */ +static bool use_nagle = false; static int mca_btl_sctp_component_register(void) { /* register SCTP component parameters */ /* num links */ - mca_btl_sctp_component.sctp_if_include = - mca_btl_sctp_param_register_string("if_include", ""); - mca_btl_sctp_component.sctp_if_exclude = - mca_btl_sctp_param_register_string("if_exclude", "lo"); - mca_btl_sctp_component.sctp_free_list_num = - mca_btl_sctp_param_register_int ("free_list_num", 8); - mca_btl_sctp_component.sctp_free_list_max = - mca_btl_sctp_param_register_int ("free_list_max", -1); - mca_btl_sctp_component.sctp_free_list_inc = - mca_btl_sctp_param_register_int ("free_list_inc", 32); - mca_btl_sctp_component.sctp_sndbuf = - mca_btl_sctp_param_register_int ("sndbuf", 128*1024); - mca_btl_sctp_component.sctp_rcvbuf = - mca_btl_sctp_param_register_int ("rcvbuf", 128*1024); - mca_btl_sctp_component.sctp_endpoint_cache = - mca_btl_sctp_param_register_int ("endpoint_cache", 30*1024); - mca_btl_sctp_component.sctp_use_nodelay = - !mca_btl_sctp_param_register_int ("use_nagle", 0); + mca_btl_sctp_param_register_string("if_include", "", &mca_btl_sctp_component.sctp_if_include); + mca_btl_sctp_param_register_string("if_exclude", "lo", &mca_btl_sctp_component.sctp_if_exclude); + mca_btl_sctp_param_register_int("free_list_num", 8, &mca_btl_sctp_component.sctp_free_list_num); + mca_btl_sctp_param_register_int("free_list_max", -1, &mca_btl_sctp_component.sctp_free_list_max); + mca_btl_sctp_param_register_int("free_list_inc", 32, &mca_btl_sctp_component.sctp_free_list_inc); + mca_btl_sctp_param_register_int("sndbuf", 128*1024, &mca_btl_sctp_component.sctp_sndbuf); + mca_btl_sctp_param_register_int("rcvbuf", 128*1024, &mca_btl_sctp_component.sctp_rcvbuf); + mca_btl_sctp_param_register_int("endpoint_cache", 30*1024, &mca_btl_sctp_component.sctp_endpoint_cache); + + (void) mca_base_component_var_register(&mca_btl_sctp_component.super.btl_version, + "use_nagle", NULL, MCA_BASE_VAR_TYPE_BOOL, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &use_nagle); + /* port_min */ /* port_range */ /* use a single one-to-many socket by default except in Solaris (see * the configure.m4 file) */ - mca_base_param_reg_int(&mca_btl_sctp_component.super.btl_version, - "if_11", "If 0, have one SCTP BTL module and let SCTP do multilink scheduling. If non-zero, have an SCTP BTL module per link and let the PML do the scheduling.", - false, false, - OMPI_MCA_BTL_SCTP_USE_ONE_TO_ONE_SOCKET, - &mca_btl_sctp_component.sctp_if_11); + mca_btl_sctp_component.sctp_if_11 = OMPI_MCA_BTL_SCTP_USE_ONE_TO_ONE_SOCKET; + (void) mca_base_component_var_register(&mca_btl_sctp_component.super.btl_version, + "if_11", "If 0, have one SCTP BTL module and let SCTP do multilink scheduling. If non-zero, have an SCTP BTL module per link and let the PML do the scheduling.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_sctp_component.sctp_if_11); /* have lower exclusivity than tcp */ mca_btl_sctp_module.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_LOW; @@ -234,6 +234,8 @@ static int mca_btl_sctp_component_open(void) mca_btl_sctp_component.sctp_num_btls=0; /* addr_count */ mca_btl_sctp_component.sctp_btls=NULL; + + mca_btl_sctp_component.sctp_use_nodelay = !use_nagle; /* initialize objects */ OBJ_CONSTRUCT(&mca_btl_sctp_component.sctp_lock, opal_mutex_t); @@ -257,7 +259,7 @@ static int mca_btl_sctp_component_open(void) /* if_include and if_exclude need to be mutually exclusive */ if (OPAL_SUCCESS != - mca_base_param_check_exclusive_string( + mca_base_var_check_exclusive("ompi", mca_btl_sctp_component.super.btl_version.mca_type_name, mca_btl_sctp_component.super.btl_version.mca_component_name, "if_include", @@ -374,11 +376,11 @@ static int mca_btl_sctp_create(int if_index, const char* if_name) /* allow user to specify interface bandwidth */ sprintf(param, "bandwidth_%s", if_name); - btl->super.btl_bandwidth = mca_btl_sctp_param_register_int(param, 0); + mca_btl_sctp_param_register_int(param, 0, &btl->super.btl_bandwidth); /* allow user to override/specify latency ranking */ sprintf(param, "latency_%s", if_name); - btl->super.btl_latency = mca_btl_sctp_param_register_int(param, 0); + mca_btl_sctp_param_register_int(param, 0, &btl->super.btl_latency); #if 0 && OPAL_ENABLE_DEBUG BTL_OUTPUT(("interface: %s bandwidth %d latency %d", @@ -420,11 +422,11 @@ static int mca_btl_sctp_create(int if_index, const char* if_name) /* allow user to specify interface bandwidth */ sprintf(param, "bandwidth_%s", if_name); - btl->super.btl_bandwidth = mca_btl_sctp_param_register_int(param, 0); + mca_btl_sctp_param_register_int(param, 0, &btl->super.btl_bandwidth); /* allow user to override/specify latency ranking */ sprintf(param, "latency_%s", if_name); - btl->super.btl_latency = mca_btl_sctp_param_register_int(param, 0); + mca_btl_sctp_param_register_int(param, 0, &btl->super.btl_latency); #if 0 && OPAL_ENABLE_DEBUG BTL_OUTPUT(("interface: %s bandwidth %d latency %d", diff --git a/ompi/mca/btl/sctp/btl_sctp_recv_handler.c b/ompi/mca/btl/sctp/btl_sctp_recv_handler.c index 4bd3367b49..e12ba82046 100644 --- a/ompi/mca/btl/sctp/btl_sctp_recv_handler.c +++ b/ompi/mca/btl/sctp/btl_sctp_recv_handler.c @@ -39,7 +39,6 @@ #include "ompi/constants.h" #include "opal/mca/event/event.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/mpool/base/base.h" #include "ompi/mca/btl/base/btl_base_error.h" #include "btl_sctp.h" diff --git a/ompi/mca/btl/self/btl_self_component.c b/ompi/mca/btl/self/btl_self_component.c index 533da8718f..3550184710 100644 --- a/ompi/mca/btl/self/btl_self_component.c +++ b/ompi/mca/btl/self/btl_self_component.c @@ -30,11 +30,10 @@ #include "ompi/constants.h" #include "opal/runtime/opal.h" #include "opal/mca/event/event.h" -#include "opal/mca/base/mca_base_param.h" #include "btl_self.h" #include "btl_self_frag.h" - +static int mca_btl_self_component_register(void); /* * Shared Memory (SELF) component instance. @@ -52,7 +51,9 @@ mca_btl_self_component_t mca_btl_self_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_btl_self_component_open, /* component open */ - mca_btl_self_component_close /* component close */ + mca_btl_self_component_close, /* component close */ + NULL, + mca_btl_self_component_register }, { /* The component is checkpoint ready */ @@ -69,18 +70,33 @@ mca_btl_self_component_t mca_btl_self_component = { * component parameters. */ -int mca_btl_self_component_open(void) +static int mca_btl_self_component_register(void) { + mca_base_var_group_component_register(&mca_btl_self_component.super.btl_version, + "BTL for self communication"); + /* register SELF component parameters */ - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_self_component, "free_list_num", - "Number of fragments by default", false, false, - 0, &mca_btl_self_component.free_list_num ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_self_component, "free_list_max", - "Maximum number of fragments", false, false, - -1, &mca_btl_self_component.free_list_max ); - mca_base_param_reg_int( (mca_base_component_t*)&mca_btl_self_component, "free_list_inc", - "Increment by this number of fragments", false, false, - 32, &mca_btl_self_component.free_list_inc ); + mca_btl_self_component.free_list_num = 0; + (void) mca_base_component_var_register(&mca_btl_self_component.super.btl_version, "free_list_num", + "Number of fragments by default", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_self_component.free_list_num); + mca_btl_self_component.free_list_max = -1; + (void) mca_base_component_var_register(&mca_btl_self_component.super.btl_version, "free_list_max", + "Maximum number of fragments", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_self_component.free_list_max); + mca_btl_self_component.free_list_inc = 32; + (void) mca_base_component_var_register(&mca_btl_self_component.super.btl_version, "free_list_inc", + "Increment by this number of fragments", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_self_component.free_list_inc); mca_btl_self.btl_exclusivity = MCA_BTL_EXCLUSIVITY_HIGH; mca_btl_self.btl_eager_limit = 128 * 1024; @@ -96,11 +112,17 @@ int mca_btl_self_component_open(void) mca_btl_base_param_register(&mca_btl_self_component.super.btl_version, &mca_btl_self); + return OMPI_SUCCESS; +} + +int mca_btl_self_component_open(void) +{ /* initialize objects */ OBJ_CONSTRUCT(&mca_btl_self_component.self_lock, opal_mutex_t); OBJ_CONSTRUCT(&mca_btl_self_component.self_frags_eager, ompi_free_list_t); OBJ_CONSTRUCT(&mca_btl_self_component.self_frags_send, ompi_free_list_t); OBJ_CONSTRUCT(&mca_btl_self_component.self_frags_rdma, ompi_free_list_t); + return OMPI_SUCCESS; } diff --git a/ompi/mca/btl/sm/btl_sm.h b/ompi/mca/btl/sm/btl_sm.h index e3646a24f9..ab0ed676ac 100644 --- a/ompi/mca/btl/sm/btl_sm.h +++ b/ompi/mca/btl/sm/btl_sm.h @@ -130,7 +130,7 @@ struct mca_btl_sm_component_t { int sm_free_list_num; /**< initial size of free lists */ int sm_free_list_max; /**< maximum size of free lists */ int sm_free_list_inc; /**< number of elements to alloc when growing free lists */ - int32_t sm_max_procs; /**< upper limit on the number of processes using the shared memory pool */ + int sm_max_procs; /**< upper limit on the number of processes using the shared memory pool */ int sm_extra_procs; /**< number of extra procs to allow */ char* sm_mpool_name; /**< name of shared memory pool module */ mca_mpool_base_module_t **sm_mpools; /**< shared memory pools (one for each memory node) */ @@ -149,8 +149,8 @@ struct mca_btl_sm_component_t { but this one, in process private memory, is a real virtual address */ uint16_t *mem_nodes; /**< cached copy of mem nodes of each local rank */ - size_t fifo_size; /**< number of FIFO queue entries */ - size_t fifo_lazy_free; /**< number of reads before lazy fifo free is triggered */ + unsigned int fifo_size; /**< number of FIFO queue entries */ + unsigned int fifo_lazy_free; /**< number of reads before lazy fifo free is triggered */ int nfifos; /**< number of FIFOs per receiver */ int32_t num_smp_procs; /**< current number of smp procs on this host */ int32_t my_smp_rank; /**< My SMP process rank. Used for accessing @@ -190,7 +190,7 @@ struct mca_btl_sm_component_t { /** MCA: minimal message size (bytes) to offload on DMA engine when using knem */ - uint32_t knem_dma_min; + unsigned int knem_dma_min; /** MCA: how many simultaneous ongoing knem operations to support */ diff --git a/ompi/mca/btl/sm/btl_sm_component.c b/ompi/mca/btl/sm/btl_sm_component.c index 8e0aa68a63..a0fc3653d4 100644 --- a/ompi/mca/btl/sm/btl_sm_component.c +++ b/ompi/mca/btl/sm/btl_sm_component.c @@ -42,7 +42,6 @@ #include /* for mkfifo */ #endif /* HAVE_SYS_STAT_H */ -#include "opal/mca/base/mca_base_param.h" #include "opal/mca/shmem/base/base.h" #include "opal/mca/shmem/shmem.h" #include "opal/util/bit_ops.h" @@ -78,6 +77,8 @@ typedef enum { MCA_BTL_SM_RNDV_MOD_MPOOL } mca_btl_sm_rndv_module_type_t; +static bool btl_sm_have_knem = OMPI_BTL_SM_HAVE_KNEM; + /* * Shared Memory (SM) component instance. */ @@ -112,116 +113,33 @@ mca_btl_sm_component_t mca_btl_sm_component = { * utility routines for parameter registration */ -static inline char* mca_btl_sm_param_register_string( - const char* param_name, - const char* default_value) -{ - char *param_value; - - (void) mca_base_param_reg_string (&mca_btl_sm_component.super.btl_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; -} - static inline int mca_btl_sm_param_register_int( const char* param_name, - int default_value) + int default_value, + int *storage) { - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_btl_sm_component.super.btl_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; + *storage = default_value; + (void) mca_base_component_var_register (&mca_btl_sm_component.super.btl_version, + param_name, NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; } - -static int sm_register(void) +static inline unsigned int mca_btl_sm_param_register_uint( + const char* param_name, + unsigned int default_value, + unsigned int *storage) { - int i; + *storage = default_value; + (void) mca_base_component_var_register (&mca_btl_sm_component.super.btl_version, + param_name, NULL, MCA_BASE_VAR_TYPE_UNSIGNED_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; +} - /* Register an MCA param to indicate whether we have knem support - or not */ - mca_base_param_reg_int(&mca_btl_sm_component.super.btl_version, - "have_knem_support", "Whether this component supports the knem Linux kernel module or not", - false, true, OMPI_BTL_SM_HAVE_KNEM, NULL); - - if (OMPI_BTL_SM_HAVE_KNEM) { - i = -1; - } else { - i = 0; - } - mca_base_param_reg_int(&mca_btl_sm_component.super.btl_version, - "use_knem", - "Whether knem support is desired or not " - "(negative = try to enable knem support, but continue even if it is not available, 0 = do not enable knem support, positive = try to enable knem support and fail if it is not available)", - false, false, i, &i); - if (OMPI_BTL_SM_HAVE_KNEM) { - mca_btl_sm_component.use_knem = i; - } else { - if (i > 0) { - opal_show_help("help-mpi-btl-sm.txt", - "knem requested but not supported", true, - ompi_process_info.nodename); - return OMPI_ERROR; - } - mca_btl_sm_component.use_knem = 0; - } - /* Currently disabling DMA mode by default; it's not clear that - this is useful in all applications and architectures. */ - mca_base_param_reg_int(&mca_btl_sm_component.super.btl_version, - "knem_dma_min", - "Minimum message size (in bytes) to use the knem DMA mode; ignored if knem does not support DMA mode (0 = do not use the knem DMA mode)", - false, false, 0, &i); - mca_btl_sm_component.knem_dma_min = (uint32_t) i; - - mca_base_param_reg_int(&mca_btl_sm_component.super.btl_version, - "knem_max_simultaneous", - "Max number of simultaneous ongoing knem operations to support (0 = do everything synchronously, which probably gives the best large message latency; >0 means to do all operations asynchronously, which supports better overlap for simultaneous large message sends)", - false, false, 0, - &mca_btl_sm_component.knem_max_simultaneous); - - /* CMA parameters */ - mca_base_param_reg_int(&mca_btl_sm_component.super.btl_version, - "use_cma", - "Whether or not to enable CMA", - false, false, 0, &mca_btl_sm_component.use_cma); - - - /* register SM component parameters */ - mca_btl_sm_component.sm_free_list_num = - mca_btl_sm_param_register_int("free_list_num", 8); - mca_btl_sm_component.sm_free_list_max = - mca_btl_sm_param_register_int("free_list_max", -1); - mca_btl_sm_component.sm_free_list_inc = - mca_btl_sm_param_register_int("free_list_inc", 64); - mca_btl_sm_component.sm_max_procs = - mca_btl_sm_param_register_int("max_procs", -1); - mca_btl_sm_component.sm_mpool_name = - mca_btl_sm_param_register_string("mpool", "sm"); - mca_btl_sm_component.fifo_size = - mca_btl_sm_param_register_int("fifo_size", 4096); - mca_btl_sm_component.nfifos = - mca_btl_sm_param_register_int("num_fifos", 1); - - mca_btl_sm_component.fifo_lazy_free = - mca_btl_sm_param_register_int("fifo_lazy_free", 120); - - /* default number of extra procs to allow for future growth */ - mca_btl_sm_component.sm_extra_procs = - mca_btl_sm_param_register_int("sm_extra_procs", 0); - - mca_btl_sm.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_HIGH-1; - mca_btl_sm.super.btl_eager_limit = 4*1024; - mca_btl_sm.super.btl_rndv_eager_limit = 4*1024; - mca_btl_sm.super.btl_max_send_size = 32*1024; - mca_btl_sm.super.btl_rdma_pipeline_send_length = 64*1024; - mca_btl_sm.super.btl_rdma_pipeline_frag_size = 64*1024; - mca_btl_sm.super.btl_min_rdma_pipeline_size = 64*1024; - mca_btl_sm.super.btl_flags = MCA_BTL_FLAGS_SEND; +static int mca_btl_sm_component_verify(void) { #if OMPI_BTL_SM_HAVE_KNEM || OMPI_BTL_SM_HAVE_CMA if (mca_btl_sm_component.use_knem || mca_btl_sm_component.use_cma) { mca_btl_sm.super.btl_flags |= MCA_BTL_FLAGS_GET; @@ -234,6 +152,93 @@ static int sm_register(void) } #endif /* OMPI_BTL_SM_HAVE_KNEM || OMPI_BTL_SM_HAVE_CMA */ + + return mca_btl_base_param_verify(&mca_btl_sm.super); +} + +static int sm_register(void) +{ + mca_base_var_flag_t var_flags; + + /* Register an MCA param to indicate whether we have knem support + or not */ + (void) mca_base_component_var_register(&mca_btl_sm_component.super.btl_version, + "have_knem_support", "Whether this component supports the knem Linux kernel module or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &btl_sm_have_knem); + if (OMPI_BTL_SM_HAVE_KNEM) { + var_flags = 0; + mca_btl_sm_component.use_knem = -1; + } else { + var_flags = MCA_BASE_VAR_FLAG_DEFAULT_ONLY; + mca_btl_sm_component.use_knem = 0; + } + (void) mca_base_component_var_register(&mca_btl_sm_component.super.btl_version, + "use_knem", "Whether knem support is desired or not " + "(negative = try to enable knem support, but continue " + "even if it is not available, 0 = do not enable knem " + "support, positive = try to enable knem support and " + "fail if it is not available)", MCA_BASE_VAR_TYPE_INT, + NULL, 0, var_flags, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_btl_sm_component.use_knem); + + /* Currently disabling DMA mode by default; it's not clear that + this is useful in all applications and architectures. */ + mca_btl_sm_component.knem_dma_min = 0; + (void) mca_base_component_var_register(&mca_btl_sm_component.super.btl_version, + "knem_dma_min", + "Minimum message size (in bytes) to use the knem DMA mode; " + "ignored if knem does not support DMA mode (0 = do not use the " + "knem DMA mode)", MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, + 0, OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_sm_component.knem_dma_min); + + mca_btl_sm_component.knem_max_simultaneous = 0; + (void) mca_base_component_var_register(&mca_btl_sm_component.super.btl_version, + "knem_max_simultaneous", + "Max number of simultaneous ongoing knem operations to support " + "(0 = do everything synchronously, which probably gives the " + "best large message latency; >0 means to do all operations " + "asynchronously, which supports better overlap for simultaneous " + "large message sends)", MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, + 0, OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_sm_component.knem_max_simultaneous); + + /* CMA parameters */ + mca_btl_sm_component.use_cma = 0; + (void) mca_base_component_var_register(&mca_btl_sm_component.super.btl_version, + "use_cma", "Whether or not to enable CMA", + MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_sm_component.use_cma); + + /* register SM component parameters */ + mca_btl_sm_param_register_int("free_list_num", 8, &mca_btl_sm_component.sm_free_list_num); + mca_btl_sm_param_register_int("free_list_max", -1, &mca_btl_sm_component.sm_free_list_max); + mca_btl_sm_param_register_int("free_list_inc", 64, &mca_btl_sm_component.sm_free_list_inc); + mca_btl_sm_param_register_int("max_procs", -1, &mca_btl_sm_component.sm_max_procs); + /* there is no practical use for the mpool name parameter since mpool resources differ + between components */ + mca_btl_sm_component.sm_mpool_name = "sm"; + mca_btl_sm_param_register_uint("fifo_size", 4096, &mca_btl_sm_component.fifo_size); + mca_btl_sm_param_register_int("num_fifos", 1, &mca_btl_sm_component.nfifos); + + mca_btl_sm_param_register_uint("fifo_lazy_free", 120, &mca_btl_sm_component.fifo_lazy_free); + + /* default number of extra procs to allow for future growth */ + mca_btl_sm_param_register_int("sm_extra_procs", 0, &mca_btl_sm_component.sm_extra_procs); + + mca_btl_sm.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_HIGH-1; + mca_btl_sm.super.btl_eager_limit = 4*1024; + mca_btl_sm.super.btl_rndv_eager_limit = 4*1024; + mca_btl_sm.super.btl_max_send_size = 32*1024; + mca_btl_sm.super.btl_rdma_pipeline_send_length = 64*1024; + mca_btl_sm.super.btl_rdma_pipeline_frag_size = 64*1024; + mca_btl_sm.super.btl_min_rdma_pipeline_size = 64*1024; + mca_btl_sm.super.btl_flags = MCA_BTL_FLAGS_SEND; mca_btl_sm.super.btl_seg_size = sizeof (mca_btl_sm_segment_t); mca_btl_sm.super.btl_bandwidth = 9000; /* Mbs */ mca_btl_sm.super.btl_latency = 1; /* Microsecs */ @@ -242,7 +247,7 @@ static int sm_register(void) mca_btl_base_param_register(&mca_btl_sm_component.super.btl_version, &mca_btl_sm.super); - return OMPI_SUCCESS; + return mca_btl_sm_component_verify(); } /* @@ -252,6 +257,10 @@ static int sm_register(void) static int mca_btl_sm_component_open(void) { + if (OMPI_SUCCESS != mca_btl_sm_component_verify()) { + return OMPI_ERROR; + } + mca_btl_sm_component.sm_max_btls = 1; /* make sure the number of fifos is a power of 2 */ @@ -352,10 +361,6 @@ static int mca_btl_sm_component_close(void) } #endif - if (NULL != mca_btl_sm_component.sm_mpool_name) { - free(mca_btl_sm_component.sm_mpool_name); - } - CLEANUP: /* return */ @@ -423,40 +428,26 @@ static int get_min_mpool_size(mca_btl_sm_component_t *comp_ptr, size_t *out_size) { - char *type_name = "mpool"; - char *param_name = "min_size"; - char *min_size = NULL; + const char *type_name = "mpool"; + const char *param_name = "min_size"; + const mca_base_var_storage_t *min_size; int id = 0; - size_t default_min = 67108864; - size_t size = 0; - long tmp_size = 0; - if (0 > (id = mca_base_param_find(type_name, comp_ptr->sm_mpool_name, + if (0 > (id = mca_base_var_find("ompi", type_name, comp_ptr->sm_mpool_name, param_name))) { - opal_output(0, "mca_base_param_find: failure looking for %s_%s_%s\n", + opal_output(0, "mca_base_var_find: failure looking for %s_%s_%s\n", type_name, comp_ptr->sm_mpool_name, param_name); return OMPI_ERR_NOT_FOUND; } - if (OPAL_ERROR == mca_base_param_lookup_string(id, &min_size)) { - opal_output(0, "mca_base_param_lookup_string failure\n"); + + if (OPAL_SUCCESS != mca_base_var_get_value(id, &min_size, NULL, NULL)) { + opal_output(0, "mca_base_var_get_value failure\n"); return OMPI_ERROR; } - errno = 0; - tmp_size = strtol(min_size, (char **)NULL, 10); - if (ERANGE == errno || EINVAL == errno || tmp_size <= 0) { - opal_output(0, "mca_btl_sm::get_min_mpool_size: " - "Unusable %s_%s_min_size provided. " - "Continuing with %lu.", type_name, - comp_ptr->sm_mpool_name, - (unsigned long)default_min); - size = default_min; - } - else { - size = (size_t)tmp_size; - } - free(min_size); - *out_size = size; + /* the min_size variable is an unsigned long long */ + *out_size = (size_t) min_size->ullval; + return OMPI_SUCCESS; } diff --git a/ompi/mca/btl/smcuda/btl_smcuda.h b/ompi/mca/btl/smcuda/btl_smcuda.h index 73a050c27c..0857a071e7 100644 --- a/ompi/mca/btl/smcuda/btl_smcuda.h +++ b/ompi/mca/btl/smcuda/btl_smcuda.h @@ -127,7 +127,7 @@ struct mca_btl_smcuda_component_t { int sm_free_list_num; /**< initial size of free lists */ int sm_free_list_max; /**< maximum size of free lists */ int sm_free_list_inc; /**< number of elements to alloc when growing free lists */ - int32_t sm_max_procs; /**< upper limit on the number of processes using the shared memory pool */ + int sm_max_procs; /**< upper limit on the number of processes using the shared memory pool */ int sm_extra_procs; /**< number of extra procs to allow */ char* sm_mpool_name; /**< name of shared memory pool module */ mca_mpool_base_module_t **sm_mpools; /**< shared memory pools (one for each memory node) */ diff --git a/ompi/mca/btl/smcuda/btl_smcuda_component.c b/ompi/mca/btl/smcuda/btl_smcuda_component.c index 1a5aaa7636..a1d671b6ce 100644 --- a/ompi/mca/btl/smcuda/btl_smcuda_component.c +++ b/ompi/mca/btl/smcuda/btl_smcuda_component.c @@ -41,7 +41,6 @@ #include /* for mkfifo */ #endif /* HAVE_SYS_STAT_H */ -#include "opal/mca/base/mca_base_param.h" #include "opal/mca/shmem/base/base.h" #include "opal/mca/shmem/shmem.h" #include "opal/util/bit_ops.h" @@ -116,55 +115,47 @@ mca_btl_smcuda_component_t mca_btl_smcuda_component = { static inline char* mca_btl_smcuda_param_register_string( const char* param_name, - const char* default_value) + const char* default_value, + char **storage) { - char *param_value; - - (void) mca_base_param_reg_string (&mca_btl_smcuda_component.super.btl_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; + *storage = default_value; + (void) mca_base_component_var_register(&mca_btl_smcuda_component.super.btl_version, + param_name, NULL, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; } static inline int mca_btl_smcuda_param_register_int( const char* param_name, - int default_value) + int default_value, + int *storage) { - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_btl_smcuda_component.super.btl_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; + *storage = default_value; + (void) mca_base_component_var_register(&mca_btl_smcuda_component.super.btl_version, + param_name, NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; } static int smcuda_register(void) { /* register SM component parameters */ - mca_btl_smcuda_component.sm_free_list_num = - mca_btl_smcuda_param_register_int("free_list_num", 8); - mca_btl_smcuda_component.sm_free_list_max = - mca_btl_smcuda_param_register_int("free_list_max", -1); - mca_btl_smcuda_component.sm_free_list_inc = - mca_btl_smcuda_param_register_int("free_list_inc", 64); - mca_btl_smcuda_component.sm_max_procs = - mca_btl_smcuda_param_register_int("max_procs", -1); - mca_btl_smcuda_component.sm_mpool_name = - mca_btl_smcuda_param_register_string("mpool", "sm"); - mca_btl_smcuda_component.fifo_size = - mca_btl_smcuda_param_register_int("fifo_size", 4096); - mca_btl_smcuda_component.nfifos = - mca_btl_smcuda_param_register_int("num_fifos", 1); + mca_btl_smcuda_param_register_int("free_list_num", 8, &mca_btl_smcuda_component.sm_free_list_num); + mca_btl_smcuda_param_register_int("free_list_max", -1, &mca_btl_smcuda_component.sm_free_list_max); + mca_btl_smcuda_param_register_int("free_list_inc", 64, &mca_btl_smcuda_component.sm_free_list_inc); + mca_btl_smcuda_param_register_int("max_procs", -1, &mca_btl_smcuda_component.sm_max_procs); + /* NTH: selection variables for mpool names don't really work so hard-code the mpool name */ + mca_btl_smcuda_component.sm_mpool_name = "sm"; + mca_btl_smcuda_param_register_int("fifo_size", 4096, &mca_btl_smcuda_component.fifo_size); + mca_btl_smcuda_param_register_int("num_fifos", 1, &mca_btl_smcuda_component.nfifos); - mca_btl_smcuda_component.fifo_lazy_free = - mca_btl_smcuda_param_register_int("fifo_lazy_free", 120); + mca_btl_smcuda_param_register_int("fifo_lazy_free", 120, &mca_btl_smcuda_component.fifo_lazy_free); /* default number of extra procs to allow for future growth */ - mca_btl_smcuda_component.sm_extra_procs = - mca_btl_smcuda_param_register_int("sm_extra_procs", 0); + mca_btl_smcuda_param_register_int("sm_extra_procs", 0, &mca_btl_smcuda_component.sm_extra_procs); #if OMPI_CUDA_SUPPORT /* Lower priority when CUDA support is not requested */ @@ -204,6 +195,10 @@ static int smcuda_register(void) static int mca_btl_smcuda_component_open(void) { + if (OMPI_SUCCESS != mca_btl_base_param_verify(&mca_btl_smcuda.super)) { + return OMPI_ERROR; + } + mca_btl_smcuda_component.sm_max_btls = 1; /* make sure the number of fifos is a power of 2 */ @@ -289,10 +284,6 @@ static int mca_btl_smcuda_component_close(void) } #endif - if (NULL != mca_btl_smcuda_component.sm_mpool_name) { - free(mca_btl_smcuda_component.sm_mpool_name); - } - CLEANUP: /* return */ @@ -362,38 +353,24 @@ get_min_mpool_size(mca_btl_smcuda_component_t *comp_ptr, { char *type_name = "mpool"; char *param_name = "min_size"; - char *min_size = NULL; + const mca_base_var_storage_t *min_size; int id = 0; - size_t default_min = 67108864; - size_t size = 0; - long tmp_size = 0; - if (0 > (id = mca_base_param_find(type_name, comp_ptr->sm_mpool_name, - param_name))) { - opal_output(0, "mca_base_param_find: failure looking for %s_%s_%s\n", + if (0 > (id = mca_base_var_find("ompi", type_name, comp_ptr->sm_mpool_name, + param_name))) { + opal_output(0, "mca_base_var_find: failure looking for %s_%s_%s\n", type_name, comp_ptr->sm_mpool_name, param_name); return OMPI_ERR_NOT_FOUND; } - if (OPAL_ERROR == mca_base_param_lookup_string(id, &min_size)) { - opal_output(0, "mca_base_param_lookup_string failure\n"); - return OMPI_ERROR; - } - errno = 0; - tmp_size = strtol(min_size, (char **)NULL, 10); - if (ERANGE == errno || EINVAL == errno || tmp_size <= 0) { - opal_output(0, "mca_btl_sm::get_min_mpool_size: " - "Unusable %s_%s_min_size provided. " - "Continuing with %lu.", type_name, - comp_ptr->sm_mpool_name, - (unsigned long)default_min); - size = default_min; + if (OPAL_SUCCESS != mca_base_var_get_value(id, &min_size, NULL, NULL)) { + opal_output(0, "mca_base_var_get_value failure!"); + return OMPI_ERROR; } - else { - size = (size_t)tmp_size; - } - free(min_size); - *out_size = size; + + /* min_size is a unsigned long long */ + *out_size = (size_t) min_size->ullval; + return OMPI_SUCCESS; } diff --git a/ompi/mca/btl/tcp/btl_tcp.h b/ompi/mca/btl/tcp/btl_tcp.h index 15c46ccb7a..77e8da89a1 100644 --- a/ompi/mca/btl/tcp/btl_tcp.h +++ b/ompi/mca/btl/tcp/btl_tcp.h @@ -54,7 +54,7 @@ struct mca_btl_tcp_component_t { mca_btl_base_component_2_0_0_t super; /**< base BTL component */ uint32_t tcp_addr_count; /**< total number of addresses */ uint32_t tcp_num_btls; /**< number of interfaces available to the TCP component */ - uint32_t tcp_num_links; /**< number of logical links per physical device */ + unsigned int tcp_num_links; /**< number of logical links per physical device */ struct mca_btl_tcp_module_t **tcp_btls; /**< array of available BTL modules */ struct mca_btl_tcp_proc_t* tcp_local; /**< local proc struct */ int tcp_free_list_num; /**< initial size of free lists */ @@ -68,14 +68,14 @@ struct mca_btl_tcp_component_t { opal_event_t tcp_recv_event; /**< recv event for IPv4 listen socket */ int tcp_listen_sd; /**< IPv4 listen socket for incoming connection requests */ unsigned short tcp_listen_port; /**< IPv4 listen port */ - int32_t tcp_port_min; /**< IPv4 minimum port */ - int32_t tcp_port_range; /**< IPv4 port range */ + int tcp_port_min; /**< IPv4 minimum port */ + int tcp_port_range; /**< IPv4 port range */ #if OPAL_WANT_IPV6 opal_event_t tcp6_recv_event; /**< recv event for IPv6 listen socket */ int tcp6_listen_sd; /**< IPv6 listen socket for incoming connection requests */ unsigned short tcp6_listen_port; /**< IPv6 listen port */ - int32_t tcp6_port_min; /**< IPv4 minimum port */ - int32_t tcp6_port_range; /**< IPv4 port range */ + int tcp6_port_min; /**< IPv4 minimum port */ + int tcp6_port_range; /**< IPv4 port range */ #endif /* Port range restriction */ @@ -91,7 +91,7 @@ struct mca_btl_tcp_component_t { ompi_free_list_t tcp_frag_user; /* Do we want to use TCP_NODELAY? */ - int tcp_use_nodelay; + int tcp_not_use_nodelay; /* If btl_tcp_if_seq was specified, this is the one interface (name) that we're supposed to use. */ diff --git a/ompi/mca/btl/tcp/btl_tcp_component.c b/ompi/mca/btl/tcp/btl_tcp_component.c index 646eb14bb0..ebacd2d3bc 100644 --- a/ompi/mca/btl/tcp/btl_tcp_component.c +++ b/ompi/mca/btl/tcp/btl_tcp_component.c @@ -56,7 +56,6 @@ #include "opal/util/argv.h" #include "opal/util/net.h" #include "opal/util/show_help.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/constants.h" #include "ompi/mca/btl/btl.h" @@ -78,6 +77,7 @@ static int mca_btl_tcp_component_register(void); static int mca_btl_tcp_component_open(void); static int mca_btl_tcp_component_close(void); +static char *mca_btl_tcp_if_seq_string; mca_btl_tcp_component_t mca_btl_tcp_component = { { @@ -113,25 +113,43 @@ mca_btl_tcp_component_t mca_btl_tcp_component = { static inline char* mca_btl_tcp_param_register_string( const char* param_name, const char* help_string, - const char* default_value) + const char* default_value, + char **storage) { - char *value; - mca_base_param_reg_string(&mca_btl_tcp_component.super.btl_version, - param_name, help_string, false, false, - default_value, &value); - return value; + *storage = (char *) default_value; + (void) mca_base_component_var_register(&mca_btl_tcp_component.super.btl_version, + param_name, help_string, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; } static inline int mca_btl_tcp_param_register_int( const char* param_name, const char* help_string, - int default_value) + int default_value, + int *storage) { - int value; - mca_base_param_reg_int(&mca_btl_tcp_component.super.btl_version, - param_name, help_string, false, false, - default_value, &value); - return value; + *storage = default_value; + (void) mca_base_component_var_register(&mca_btl_tcp_component.super.btl_version, + param_name, help_string, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; +} + +static inline unsigned int mca_btl_tcp_param_register_uint( + const char* param_name, + const char* help_string, + unsigned int default_value, + unsigned int *storage) +{ + *storage = default_value; + (void) mca_base_component_var_register(&mca_btl_tcp_component.super.btl_version, + param_name, help_string, MCA_BASE_VAR_TYPE_UNSIGNED_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; } @@ -172,6 +190,25 @@ OBJ_CLASS_INSTANCE( static void mca_btl_tcp_component_recv_handler(int, short, void*); static void mca_btl_tcp_component_accept_handler(int, short, void*); +static int mca_btl_tcp_component_verify(void) +{ + if( mca_btl_tcp_component.tcp_port_min > USHRT_MAX ) { + opal_show_help("help-mpi-btl-tcp.txt", "invalid minimum port", + true, "v4", ompi_process_info.nodename, + mca_btl_tcp_component.tcp_port_min ); + mca_btl_tcp_component.tcp_port_min = 1024; + } +#if OPAL_WANT_IPV6 + if( mca_btl_tcp_component.tcp6_port_min > USHRT_MAX ) { + opal_show_help("help-mpi-btl-tcp.txt", "invalid minimum port", + true, "v6", ompi_process_info.nodename, + mca_btl_tcp_component.tcp6_port_min ); + mca_btl_tcp_component.tcp6_port_min = 1024; + } +#endif + + return OMPI_SUCCESS; +} /* * Called by MCA framework to open the component, registers @@ -183,69 +220,48 @@ static int mca_btl_tcp_component_register(void) char* message; /* register TCP component parameters */ - mca_btl_tcp_component.tcp_num_links = - mca_btl_tcp_param_register_int("links", NULL, 1); - mca_btl_tcp_component.tcp_if_include = - mca_btl_tcp_param_register_string("if_include", "Comma-delimited list of devices and/or CIDR notation of networks to use for MPI communication (e.g., \"eth0,192.168.0.0/16\"). Mutually exclusive with btl_tcp_if_exclude.", ""); - mca_btl_tcp_component.tcp_if_exclude = - mca_btl_tcp_param_register_string("if_exclude", "Comma-delimited list of devices and/or CIDR notation of networks to NOT use for MPI communication -- all devices not matching these specifications will be used (e.g., \"eth0,192.168.0.0/16\"). If set to a non-default value, it is mutually exclusive with btl_tcp_if_include.", - "127.0.0.1/8,sppp" - ); + mca_btl_tcp_param_register_uint("links", NULL, 1, &mca_btl_tcp_component.tcp_num_links); + mca_btl_tcp_param_register_string("if_include", "Comma-delimited list of devices and/or CIDR notation of networks to use for MPI communication (e.g., \"eth0,192.168.0.0/16\"). Mutually exclusive with btl_tcp_if_exclude.", "", &mca_btl_tcp_component.tcp_if_include); + mca_btl_tcp_param_register_string("if_exclude", "Comma-delimited list of devices and/or CIDR notation of networks to NOT use for MPI communication -- all devices not matching these specifications will be used (e.g., \"eth0,192.168.0.0/16\"). If set to a non-default value, it is mutually exclusive with btl_tcp_if_include.", + "127.0.0.1/8,sppp", + &mca_btl_tcp_component.tcp_if_exclude); + + mca_btl_tcp_param_register_int ("free_list_num", NULL, 8, &mca_btl_tcp_component.tcp_free_list_num); + mca_btl_tcp_param_register_int ("free_list_max", NULL, -1, &mca_btl_tcp_component.tcp_free_list_max); + mca_btl_tcp_param_register_int ("free_list_inc", NULL, 32, &mca_btl_tcp_component.tcp_free_list_inc); + mca_btl_tcp_param_register_int ("sndbuf", NULL, 128*1024, &mca_btl_tcp_component.tcp_sndbuf); + mca_btl_tcp_param_register_int ("rcvbuf", NULL, 128*1024, &mca_btl_tcp_component.tcp_rcvbuf); + mca_btl_tcp_param_register_int ("endpoint_cache", + "The size of the internal cache for each TCP connection. This cache is" + " used to reduce the number of syscalls, by replacing them with memcpy." + " Every read will read the expected data plus the amount of the" + " endpoint_cache", 30*1024, &mca_btl_tcp_component.tcp_endpoint_cache); + mca_btl_tcp_param_register_int ("use_nagle", "Whether to use Nagle's algorithm or not (using Nagle's algorithm may increase short message latency)", 0, &mca_btl_tcp_component.tcp_not_use_nodelay); + mca_btl_tcp_param_register_int( "port_min_v4", + "The minimum port where the TCP BTL will try to bind (default 1024)", + 1024, &mca_btl_tcp_component.tcp_port_min); - mca_btl_tcp_component.tcp_free_list_num = - mca_btl_tcp_param_register_int ("free_list_num", NULL, 8); - mca_btl_tcp_component.tcp_free_list_max = - mca_btl_tcp_param_register_int ("free_list_max", NULL, -1); - mca_btl_tcp_component.tcp_free_list_inc = - mca_btl_tcp_param_register_int ("free_list_inc", NULL, 32); - mca_btl_tcp_component.tcp_sndbuf = - mca_btl_tcp_param_register_int ("sndbuf", NULL, 128*1024); - mca_btl_tcp_component.tcp_rcvbuf = - mca_btl_tcp_param_register_int ("rcvbuf", NULL, 128*1024); - mca_btl_tcp_component.tcp_endpoint_cache = - mca_btl_tcp_param_register_int ("endpoint_cache", - "The size of the internal cache for each TCP connection. This cache is" - " used to reduce the number of syscalls, by replacing them with memcpy." - " Every read will read the expected data plus the amount of the" - " endpoint_cache", 30*1024); - mca_btl_tcp_component.tcp_use_nodelay = - !mca_btl_tcp_param_register_int ("use_nagle", "Whether to use Nagle's algorithm or not (using Nagle's algorithm may increase short message latency)", 0); - mca_btl_tcp_component.tcp_port_min = - mca_btl_tcp_param_register_int( "port_min_v4", - "The minimum port where the TCP BTL will try to bind (default 1024)", 1024 ); - if( mca_btl_tcp_component.tcp_port_min > USHRT_MAX ) { - opal_show_help("help-mpi-btl-tcp.txt", "invalid minimum port", - true, "v4", ompi_process_info.nodename, - mca_btl_tcp_component.tcp_port_min ); - mca_btl_tcp_component.tcp_port_min = 1024; - } asprintf( &message, "The number of ports where the TCP BTL will try to bind (default %d)." " This parameter together with the port min, define a range of ports" " where Open MPI will open sockets.", (0x1 << 16) - mca_btl_tcp_component.tcp_port_min - 1 ); - mca_btl_tcp_component.tcp_port_range = - mca_btl_tcp_param_register_int( "port_range_v4", message, - (0x1 << 16) - mca_btl_tcp_component.tcp_port_min - 1); + mca_btl_tcp_param_register_int( "port_range_v4", message, + (0x1 << 16) - mca_btl_tcp_component.tcp_port_min - 1, + &mca_btl_tcp_component.tcp_port_range); free(message); #if OPAL_WANT_IPV6 - mca_btl_tcp_component.tcp6_port_min = - mca_btl_tcp_param_register_int( "port_min_v6", - "The minimum port where the TCP BTL will try to bind (default 1024)", 1024 ); - if( mca_btl_tcp_component.tcp6_port_min > USHRT_MAX ) { - opal_show_help("help-mpi-btl-tcp.txt", "invalid minimum port", - true, "v6", ompi_process_info.nodename, - mca_btl_tcp_component.tcp6_port_min ); - mca_btl_tcp_component.tcp6_port_min = 1024; - } + mca_btl_tcp_param_register_int( "port_min_v6", + "The minimum port where the TCP BTL will try to bind (default 1024)", 1024, + & mca_btl_tcp_component.tcp6_port_min ); asprintf( &message, "The number of ports where the TCP BTL will try to bind (default %d)." " This parameter together with the port min, define a range of ports" " where Open MPI will open sockets.", (0x1 << 16) - mca_btl_tcp_component.tcp6_port_min - 1 ); - mca_btl_tcp_component.tcp6_port_range = - mca_btl_tcp_param_register_int( "port_range_v6", message, - (0x1 << 16) - mca_btl_tcp_component.tcp6_port_min - 1); + mca_btl_tcp_param_register_int( "port_range_v6", message, + (0x1 << 16) - mca_btl_tcp_component.tcp6_port_min - 1, + &mca_btl_tcp_component.tcp6_port_range ); free(message); #endif @@ -268,15 +284,15 @@ static int mca_btl_tcp_component_register(void) mca_btl_base_param_register(&mca_btl_tcp_component.super.btl_version, &mca_btl_tcp_module.super); - mca_btl_tcp_component.tcp_disable_family = - mca_btl_tcp_param_register_int ("disable_family", NULL, 0); + mca_btl_tcp_param_register_int ("disable_family", NULL, 0, &mca_btl_tcp_component.tcp_disable_family); /* Register a list of interfaces to use in sequence */ - message = mca_btl_tcp_param_register_string("if_seq", - "If specified, a comma-delimited list of TCP interfaces. Interfaces will be assigned, one to each MPI process, in a round-robin fashion on each server. For example, if the list is \"eth0,eth1\" and four MPI processes are run on a single server, then local ranks 0 and 2 will use eth0 and local ranks 1 and 3 will use eth1.", NULL); + mca_btl_tcp_param_register_string("if_seq", + "If specified, a comma-delimited list of TCP interfaces. Interfaces will be assigned, one to each MPI process, in a round-robin fashion on each server. For example, if the list is \"eth0,eth1\" and four MPI processes are run on a single server, then local ranks 0 and 2 will use eth0 and local ranks 1 and 3 will use eth1.", NULL, &mca_btl_tcp_if_seq_string); + mca_btl_tcp_component.tcp_if_seq = NULL; - if (NULL != message && '\0' != *message) { - char **argv = opal_argv_split(message, ','); + if (NULL != mca_btl_tcp_if_seq_string && '\0' != *mca_btl_tcp_if_seq_string) { + char **argv = opal_argv_split(mca_btl_tcp_if_seq_string, ','); if (NULL != argv && '\0' != *(argv[0])) { int if_index, rc, count; @@ -320,11 +336,15 @@ static int mca_btl_tcp_component_register(void) } } - return OMPI_SUCCESS; + return mca_btl_tcp_component_verify(); } static int mca_btl_tcp_component_open(void) { + if (OMPI_SUCCESS != mca_btl_tcp_component_verify()) { + return OMPI_ERROR; + } + /* initialize state */ mca_btl_tcp_component.tcp_listen_sd = -1; #if OPAL_WANT_IPV6 @@ -345,7 +365,7 @@ static int mca_btl_tcp_component_open(void) /* if_include and if_exclude need to be mutually exclusive */ if (OPAL_SUCCESS != - mca_base_param_check_exclusive_string( + mca_base_var_check_exclusive("ompi", mca_btl_tcp_component.super.btl_version.mca_type_name, mca_btl_tcp_component.super.btl_version.mca_component_name, "if_include", @@ -370,21 +390,13 @@ static int mca_btl_tcp_component_close(void) opal_list_item_t* item; opal_list_item_t* next; - if(NULL != mca_btl_tcp_component.tcp_if_include) { - free(mca_btl_tcp_component.tcp_if_include); - mca_btl_tcp_component.tcp_if_include = NULL; - } - if(NULL != mca_btl_tcp_component.tcp_if_exclude) { - free(mca_btl_tcp_component.tcp_if_exclude); - mca_btl_tcp_component.tcp_if_exclude = NULL; - } if (NULL != mca_btl_tcp_component.tcp_if_seq) { free(mca_btl_tcp_component.tcp_if_seq); } if (NULL != mca_btl_tcp_component.tcp_btls) free(mca_btl_tcp_component.tcp_btls); - + if (mca_btl_tcp_component.tcp_listen_sd >= 0) { opal_event_del(&mca_btl_tcp_component.tcp_recv_event); CLOSE_THE_SOCKET(mca_btl_tcp_component.tcp_listen_sd); @@ -450,11 +462,11 @@ static int mca_btl_tcp_create(int if_kindex, const char* if_name) /* allow user to specify interface bandwidth */ sprintf(param, "bandwidth_%s", if_name); - btl->super.btl_bandwidth = mca_btl_tcp_param_register_int(param, NULL, btl->super.btl_bandwidth); + mca_btl_tcp_param_register_uint(param, NULL, btl->super.btl_bandwidth, &btl->super.btl_bandwidth); /* allow user to override/specify latency ranking */ sprintf(param, "latency_%s", if_name); - btl->super.btl_latency = mca_btl_tcp_param_register_int(param, NULL, btl->super.btl_latency); + mca_btl_tcp_param_register_uint(param, NULL, btl->super.btl_latency, &btl->super.btl_latency); if( i > 0 ) { btl->super.btl_bandwidth >>= 1; btl->super.btl_latency <<= 1; @@ -462,11 +474,11 @@ static int mca_btl_tcp_create(int if_kindex, const char* if_name) /* allow user to specify interface bandwidth */ sprintf(param, "bandwidth_%s:%d", if_name, i); - btl->super.btl_bandwidth = mca_btl_tcp_param_register_int(param, NULL, btl->super.btl_bandwidth); + mca_btl_tcp_param_register_uint(param, NULL, btl->super.btl_bandwidth, &btl->super.btl_bandwidth); /* allow user to override/specify latency ranking */ sprintf(param, "latency_%s:%d", if_name, i); - btl->super.btl_latency = mca_btl_tcp_param_register_int(param, NULL, btl->super.btl_latency); + mca_btl_tcp_param_register_uint(param, NULL, btl->super.btl_latency, &btl->super.btl_latency); #if 0 && OPAL_ENABLE_DEBUG BTL_OUTPUT(("interface %s instance %i: bandwidth %d latency %d\n", if_name, i, btl->super.btl_bandwidth, btl->super.btl_latency)); diff --git a/ompi/mca/btl/tcp/btl_tcp_endpoint.c b/ompi/mca/btl/tcp/btl_tcp_endpoint.c index 7f705fb895..bcd10441f7 100644 --- a/ompi/mca/btl/tcp/btl_tcp_endpoint.c +++ b/ompi/mca/btl/tcp/btl_tcp_endpoint.c @@ -533,7 +533,7 @@ void mca_btl_tcp_set_socket_options(int sd) { int optval; #if defined(TCP_NODELAY) - optval = mca_btl_tcp_component.tcp_use_nodelay; + optval = mca_btl_tcp_component.tcp_not_use_nodelay; if(setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char *)&optval, sizeof(optval)) < 0) { BTL_ERROR(("setsockopt(TCP_NODELAY) failed: %s (%d)", strerror(opal_socket_errno), opal_socket_errno)); diff --git a/ompi/mca/btl/template/btl_template_component.c b/ompi/mca/btl/template/btl_template_component.c index aac9482cc3..b98104b975 100644 --- a/ompi/mca/btl/template/btl_template_component.c +++ b/ompi/mca/btl/template/btl_template_component.c @@ -22,7 +22,6 @@ #include "opal/mca/event/event.h" #include "ompi/mca/btl/btl.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/mpool/base/base.h" #include "btl_template.h" #include "btl_template_frag.h" @@ -72,37 +71,6 @@ mca_btl_template_component_t mca_btl_template_component = { } }; - -/* - * utility routines for parameter registration - */ - -static inline char* mca_btl_template_param_register_string( - const char* param_name, - const char* default_value) -{ - char *param_value; - - (void) mca_base_param_reg_string (&mca_btl_template_component.super.btl_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; -} - -static inline int mca_btl_template_param_register_int( - const char* param_name, - int default_value) -{ - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_btl_template_component.super.btl_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; -} - static int mca_btl_template_component_open(void) { return OMPI_SUCCESS; @@ -118,31 +86,41 @@ static int mca_btl_template_component_register(void) OBJ_CONSTRUCT(&mca_btl_template_component.template_procs, opal_list_t); /* register TEMPLATE component parameters */ - mca_btl_template_component.template_free_list_num = - mca_btl_template_param_register_int ("free_list_num", 8); - mca_btl_template_component.template_free_list_max = - mca_btl_template_param_register_int ("free_list_max", 1024); - mca_btl_template_component.template_free_list_inc = - mca_btl_template_param_register_int ("free_list_inc", 32); - mca_btl_template_component.template_mpool_name = - mca_btl_template_param_register_string("mpool", "ib"); - mca_btl_template_module.super.btl_exclusivity = - mca_btl_template_param_register_int ("exclusivity", 0); - mca_btl_template_module.super.btl_eager_limit = - mca_btl_template_param_register_int ("first_frag_size", 64*1024) - sizeof(mca_btl_base_header_t); - mca_btl_template_module.super.btl_rndv_eager_limit = - mca_btl_template_param_register_int ("min_send_size", 64*1024) - sizeof(mca_btl_base_header_t); - mca_btl_template_module.super.btl_max_send_size = - mca_btl_template_param_register_int ("max_send_size", 128*1024) - sizeof(mca_btl_base_header_t); - mca_btl_template_module.super.btl_min_rdma_pipeline_size = - mca_btl_template_param_register_int("min_rdma_pipeline_size", 1024*1024); - mca_btl_template_module.super.btl_rdma_pipeline_frag_size = - mca_btl_template_param_register_int("rdma_pipeline_frag_size", 1024*1024); - mca_btl_template_module.super.btl_rdma_pipeline_send_length = - mca_btl_template_param_register_int("rdma_pipeline_send_length", 1024*1024); - mca_btl_template_module.super.btl_flags = - mca_btl_template_param_register_int("flags", MCA_BTL_FLAGS_PUT); - return OMPI_SUCCESS; + mca_btl_template_component.template_free_list_num = 8; + (void) mca_base_component_var_register(&mca_btl_template_component.super.btl_version, + "free_list_num", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_template_component.template_free_list_num); + (void) mca_base_component_var_register(&mca_btl_template_component.super.btl_version, + "free_list_max", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_template_component.template_free_list_max); + (void) mca_base_component_var_register(&mca_btl_template_component.super.btl_version, + "free_list_inc", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_template_component.template_free_list_inc); + + mca_btl_template_component.template_mpool_name = "grdma"; + (void) mca_base_component_var_register(&mca_btl_template_component.super.btl_version, + "mpool", NULL, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_btl_template_component.template_mpool_name); + + mca_btl_template_module.super.btl_exclusivity = 0; + mca_btl_template_module.super.btl_eager_limit = 64*1024; + mca_btl_template_module.super.btl_rndv_eager_limit = 64*1024; + mca_btl_template_module.super.btl_max_send_size = 128*1024; + mca_btl_template_module.super.btl_min_rdma_pipeline_size = 1024*1024; + mca_btl_template_module.super.btl_rdma_pipeline_frag_size = 1024*1024; + mca_btl_template_module.super.btl_rdma_pipeline_send_length = 1024*1024; + mca_btl_template_module.super.btl_flags = MCA_BTL_FLAGS_PUT; + + return mca_btl_base_param_register(&mca_btl_template_component.super.btl_version, + &mca_btl_template_module.super); } /* diff --git a/ompi/mca/btl/udapl/btl_udapl.h b/ompi/mca/btl/udapl/btl_udapl.h index b9b540ab8e..94a0495de5 100644 --- a/ompi/mca/btl/udapl/btl_udapl.h +++ b/ompi/mca/btl/udapl/btl_udapl.h @@ -54,13 +54,13 @@ struct mca_btl_udapl_component_t { int32_t udapl_verbosity; /**< report out level, see "Report Out from uDAPL BTL" below for details. */ size_t udapl_num_btls; /**< number of hcas available to the uDAPL component */ - size_t udapl_max_btls; /**< maximum number of supported hcas */ + unsigned int udapl_max_btls; /**< maximum number of supported hcas */ struct mca_btl_udapl_module_t **udapl_btls; /**< array of available BTL modules */ int32_t udapl_num_recvs; /**< number of recv buffers to keep posted */ int32_t udapl_num_sends; /**< number of sends to post on endpoint */ int32_t udapl_sr_win; /**< number of fragments recieved before returning credits to sender */ - uint32_t udapl_timeout; /**< connection timeout, in microseconds */ + unsigned int udapl_timeout; /**< connection timeout, in microseconds */ size_t udapl_eager_frag_size; size_t udapl_max_frag_size; size_t udapl_eager_rdma_frag_size; /* size of the rdma fragement including data diff --git a/ompi/mca/btl/udapl/btl_udapl_component.c b/ompi/mca/btl/udapl/btl_udapl_component.c index bc1ea5c78b..7498801b94 100644 --- a/ompi/mca/btl/udapl/btl_udapl_component.c +++ b/ompi/mca/btl/udapl/btl_udapl_component.c @@ -29,7 +29,6 @@ #include "opal/util/argv.h" #include "ompi/mca/btl/btl.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/mpool/base/base.h" #include "btl_udapl.h" #include "btl_udapl_frag.h" @@ -55,7 +54,6 @@ static int mca_btl_udapl_modify_ia_list(DAT_COUNT *num_info_entries, static const char* mca_btl_udapl_dat_event_to_string(DAT_EVENT_NUMBER event_number); - mca_btl_udapl_component_t mca_btl_udapl_component = { { /* First, the mca_base_component_t struct containing meta information @@ -68,7 +66,9 @@ mca_btl_udapl_component_t mca_btl_udapl_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_btl_udapl_component_open, /* component open */ - mca_btl_udapl_component_close /* component close */ + mca_btl_udapl_component_close, /* component close */ + NULL, + mca_btl_udapl_register_mca_params }, { /* The component is not checkpoint ready */ @@ -179,7 +179,6 @@ mca_btl_udapl_error(DAT_RETURN ret, char* str) * Called by MCA framework to open the component, registers * component parameters. */ - int mca_btl_udapl_component_open(void) { int rc = OMPI_SUCCESS; @@ -193,9 +192,6 @@ int mca_btl_udapl_component_open(void) OBJ_CONSTRUCT(&mca_btl_udapl_component.udapl_procs, opal_list_t); OBJ_CONSTRUCT(&mca_btl_udapl_component.udapl_lock, opal_mutex_t); - /* register uDAPL MCA parameters */ - rc = mca_btl_udapl_register_mca_params(); - /* compute udapl_eager_frag_size and udapl_max_frag_size */ mca_btl_udapl_component.udapl_eager_frag_size = mca_btl_udapl_module.super.btl_eager_limit; diff --git a/ompi/mca/btl/udapl/btl_udapl_mca.c b/ompi/mca/btl/udapl/btl_udapl_mca.c index 62be487112..9bc694cdc0 100644 --- a/ompi/mca/btl/udapl/btl_udapl_mca.c +++ b/ompi/mca/btl/udapl/btl_udapl_mca.c @@ -19,7 +19,7 @@ */ #include "ompi_config.h" -#include "opal/mca/base/mca_base_param.h" +#include "opal/mca/base/base.h" #include "btl_udapl.h" #include "btl_udapl_mca.h" #include @@ -39,28 +39,28 @@ static inline int mca_btl_udapl_reg_string(const char* param_name, const char* param_desc, const char* default_value, - char **out_value, int flags) + char **storage, int flags) { - char *value; - - mca_base_param_reg_string(&mca_btl_udapl_component.super.btl_version, - param_name, param_desc, false, false, default_value, &value); + *storage = default_value; + (void) mca_base_component_var_register(&mca_btl_udapl_component.super.btl_version, param_name, + param_desc, MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); - if (NULL == value && !((flags & REGSTR_EMPTY_OK) == REGSTR_EMPTY_OK)) { + if (NULL == *storage && !((flags & REGSTR_EMPTY_OK) == REGSTR_EMPTY_OK)) { BTL_ERROR(("ERROR: MCA Parameter %s : Value (NULL) out of range : " "Default value (%s)\n \t Parameter Description : %s", param_name, default_value, param_desc)); return OMPI_ERR_BAD_PARAM; } - if ((flags & REGSTR_EMPTY_NOT_OK) && 0 == strlen(value)) { + if ((flags & REGSTR_EMPTY_NOT_OK) && 0 == strlen(*storage)) { BTL_ERROR(("ERROR: MCA Parameter %s : Value (%s) out of range : " "Default value (%s)\n \t Parameter Description : %s", - param_name, value, default_value, param_desc)); + param_name, *storage, default_value, param_desc)); return OMPI_ERR_BAD_PARAM; } - *out_value = value; return OMPI_SUCCESS; } @@ -79,27 +79,28 @@ static inline int mca_btl_udapl_reg_string(const char* param_name, */ static inline int mca_btl_udapl_reg_int(const char* param_name, const char* param_desc, - int default_value, int *out_value, + int default_value, int *storage, int flags) { - int value; + *storage = default_value; + (void) mca_base_component_var_register(&mca_btl_udapl_component.super.btl_version, param_name, + param_desc, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); - mca_base_param_reg_int(&mca_btl_udapl_component.super.btl_version, - param_name, param_desc, false, false, default_value, &value); - - if ((flags & REGINT_NEG_ONE_OK) && -1 == value) { - *out_value = value; + if ((flags & REGINT_NEG_ONE_OK) && -1 == *storage) { return OMPI_SUCCESS; } - if (((flags & REGINT_GE_ZERO) && value < 0) || - ((flags & REGINT_GE_ONE) && value < 1) || - ((flags & REGINT_NONZERO) && 0 == value)) { + + if (((flags & REGINT_GE_ZERO) && *storage < 0) || + ((flags & REGINT_GE_ONE) && *storage < 1) || + ((flags & REGINT_NONZERO) && 0 == *storage)) { BTL_ERROR(("ERROR: MCA Parameter %s : Value (%d) out of range : " "Default value (%d)\n \t Parameter Description : %s\n", - param_name, value, default_value, param_desc)); + param_name, *storage, default_value, param_desc)); return OMPI_ERR_BAD_PARAM; } - *out_value = value; + return OMPI_SUCCESS; } @@ -111,7 +112,7 @@ static inline int mca_btl_udapl_reg_int(const char* param_name, */ int mca_btl_udapl_register_mca_params(void) { - int ival, rc, tmp_rc; + int rc, tmp_rc; rc = OMPI_SUCCESS; @@ -144,9 +145,8 @@ int mca_btl_udapl_register_mca_params(void) CHECK_PARAM_REGISTER_RETURN_VALUE(mca_btl_udapl_reg_int("max_modules", "Maximum number of supported HCAs.", 8, - &ival, + &mca_btl_udapl_component.udapl_max_btls, REGINT_GE_ONE), tmp_rc, rc); - mca_btl_udapl_component.udapl_max_btls = (uint32_t) ival; CHECK_PARAM_REGISTER_RETURN_VALUE(mca_btl_udapl_reg_int("num_recvs", "Total number of receive buffers to keep posted " @@ -203,9 +203,8 @@ int mca_btl_udapl_register_mca_params(void) CHECK_PARAM_REGISTER_RETURN_VALUE(mca_btl_udapl_reg_int("timeout", "Connection timeout, in microseconds.", MCA_BTL_UDAPL_CONN_TIMEOUT_DEFAULT, - &ival, + &mca_btl_udapl_component.udapl_timeout, REGINT_GE_ONE), tmp_rc, rc); - mca_btl_udapl_component.udapl_timeout = (uint32_t) ival; CHECK_PARAM_REGISTER_RETURN_VALUE(mca_btl_udapl_reg_int("conn_priv_data", "Use connect private data to establish connections " diff --git a/ompi/mca/btl/ugni/btl_ugni_component.c b/ompi/mca/btl/ugni/btl_ugni_component.c index f3e6314eae..9e01aacb6d 100644 --- a/ompi/mca/btl/ugni/btl_ugni_component.c +++ b/ompi/mca/btl/ugni/btl_ugni_component.c @@ -16,7 +16,6 @@ #include "btl_ugni_smsg.h" #include "opal/include/opal/align.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/memoryhooks/memory.h" #include "ompi/runtime/params.h" @@ -51,81 +50,141 @@ mca_btl_ugni_component_t mca_btl_ugni_component = { } }; -static inline int -mca_btl_ugni_param_register_int (const char *param_name, const char *help, - int value) -{ - mca_base_param_reg_int(&mca_btl_ugni_component.super.btl_version, - param_name, help, false, false, value, &value); - return value; -} - static int btl_ugni_component_register(void) { - mca_btl_ugni_component.ugni_free_list_num = - mca_btl_ugni_param_register_int("free_list_num", NULL, 8); - mca_btl_ugni_component.ugni_free_list_max = - mca_btl_ugni_param_register_int("free_list_max", NULL, 16384); - mca_btl_ugni_component.ugni_free_list_inc = - mca_btl_ugni_param_register_int("free_list_inc", NULL, 64); + (void) mca_base_var_group_component_register(&mca_btl_ugni_component.super.btl_version, + "Gemini byte transport layer"); - mca_btl_ugni_component.ugni_eager_num = - mca_btl_ugni_param_register_int("eager_num", NULL, 16); - mca_btl_ugni_component.ugni_eager_max = - mca_btl_ugni_param_register_int("eager_max", NULL, 128); - mca_btl_ugni_component.ugni_eager_inc = - mca_btl_ugni_param_register_int("eager_inc", NULL, 16); + mca_btl_ugni_component.ugni_free_list_num = 8; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "free_list_num", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.ugni_free_list_num); + mca_btl_ugni_component.ugni_free_list_max = 16384; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "free_list_max", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.ugni_free_list_max); + mca_btl_ugni_component.ugni_free_list_inc = 64; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "free_list_inc", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.ugni_free_list_inc); - mca_btl_ugni_component.remote_cq_size = - mca_btl_ugni_param_register_int("remote_cq_size", "Remote SMSG completion queue " - "size (default 40000)", 40000); + mca_btl_ugni_component.ugni_eager_num = 16; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "eager_num", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.ugni_eager_num); + mca_btl_ugni_component.ugni_eager_max = 128; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "eager_max", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.ugni_eager_max); + mca_btl_ugni_component.ugni_eager_inc = 16; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "eager_inc", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.ugni_eager_inc); - mca_btl_ugni_component.local_cq_size = - mca_btl_ugni_param_register_int("local_cq_size", "Local completion queue size " - "(default 8192)", 8192); + mca_btl_ugni_component.remote_cq_size = 40000; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "remote_cq_size", "Remote SMSG completion queue " + "size (default 40000)", MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.remote_cq_size); + mca_btl_ugni_component.local_cq_size = 8192; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "local_cq_size", "Local completion queue size " + "(default 8192)", MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.local_cq_size); - mca_btl_ugni_component.ugni_smsg_limit = - mca_btl_ugni_param_register_int("smsg_limit", "Maximum size message that " - "will be sent using the SMSG/MSGQ protocol " - "(0 - autoselect(default), 16k max)", 0); + mca_btl_ugni_component.ugni_smsg_limit = 0; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "smsg_limit", "Maximum size message that " + "will be sent using the SMSG/MSGQ protocol " + "(0 - autoselect(default), 16k max)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.ugni_smsg_limit); - if (16384 < mca_btl_ugni_component.ugni_smsg_limit) { - mca_btl_ugni_component.ugni_smsg_limit = 16384; - } + mca_btl_ugni_component.smsg_max_credits = 32; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "smsg_max_credits", "Maximum number of " + "outstanding SMSG/MSGQ message (default 32)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.smsg_max_credits); - mca_btl_ugni_component.smsg_max_credits = - mca_btl_ugni_param_register_int("smsg_max_credits", "Maximum number of " - "outstanding SMSG/MSGQ message (default 32)", - 32); + mca_btl_ugni_component.ugni_fma_limit = 1024; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "fma_limit", "Maximum size message that " + "will be sent using the FMA (Fast Memory " + "Access) protocol (default 1024, 64k max)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.ugni_fma_limit); - mca_btl_ugni_component.ugni_fma_limit = - mca_btl_ugni_param_register_int("fma_limit", "Maximum size message that " - "will be sent using the FMA (Fast Memory " - "Access) protocol (default 1024, 64k max)", - 1024); + mca_btl_ugni_component.ugni_get_limit = 1 * 1024 * 1024; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "get_limit", "Maximum size message that " + "will be sent using a get protocol " + "(default 1M)", MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.ugni_get_limit); - if (65536 < mca_btl_ugni_component.ugni_fma_limit) { - mca_btl_ugni_component.ugni_fma_limit = 65536; - } + mca_btl_ugni_component.rdma_max_retries = 16; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "rdma_max_retries", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.rdma_max_retries); - mca_btl_ugni_component.ugni_get_limit = - mca_btl_ugni_param_register_int("get_limit", "Maximum size message that " - "will be sent using a get protocol " - "(default 1M)", 1 * 1024 * 1024); + mca_btl_ugni_component.smsg_max_retries = 16; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "smsg_max_retries", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.smsg_max_retries); - mca_btl_ugni_component.rdma_max_retries = - mca_btl_ugni_param_register_int("rdma_max_retries", NULL, 16); - - - mca_btl_ugni_component.smsg_max_retries = - mca_btl_ugni_param_register_int("smsg_max_retries", NULL, 16); - - mca_btl_ugni_component.max_mem_reg = - mca_btl_ugni_param_register_int("max_mem_reg", "Maximum number of " - "memory registrations a process can " - "hold (0 - autoselect, -1 - unlimited)" - " (default 0)", 0); + mca_btl_ugni_component.max_mem_reg = 0; + (void) mca_base_component_var_register(&mca_btl_ugni_component.super.btl_version, + "max_mem_reg", "Maximum number of " + "memory registrations a process can " + "hold (0 - autoselect, -1 - unlimited)" + " (default 0)", MCA_BASE_VAR_TYPE_INT, + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_ugni_component.max_mem_reg); mca_btl_ugni_module.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_HIGH; @@ -175,40 +234,16 @@ btl_ugni_component_close(void) } static void mca_btl_ugni_autoset_leave_pinned (void) { - mca_base_param_source_t source; - int index, rc, value; - - /* If we have a memory manager available, and - mpi_leave_pinned==-1, then unless the user explicitly set - mpi_leave_pinned_pipeline==0, then set mpi_leave_pinned to 1. - We have a memory manager if we have both FREE and MUNMAP - support */ - value = opal_mem_hooks_support_level(); + int value = opal_mem_hooks_support_level(); if ((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) == ((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) & value)) { - rc = 0; - index = mca_base_param_find("mpi", NULL, "leave_pinned"); - if (index >= 0) { - if (OPAL_SUCCESS == mca_base_param_lookup_int(index, &value) && - -1 == value) { - ++rc; - } - } - index = mca_base_param_find("mpi", NULL, "leave_pinned_pipeline"); - if (index >= 0) { - if (OPAL_SUCCESS == mca_base_param_lookup_int(index, &value) && - OPAL_SUCCESS == mca_base_param_lookup_source(index, &source, - NULL)) { - if (0 == value && MCA_BASE_PARAM_SOURCE_DEFAULT == source) { - ++rc; - } - } - } - /* If we were good on both parameters, then set leave_pinned=1 */ - if (2 == rc) { - ompi_mpi_leave_pinned = 1; - ompi_mpi_leave_pinned_pipeline = 0; + /* Set leave pinned to 1 if leave pinned pipeline is not set */ + if (-1 == ompi_mpi_leave_pinned) { + ompi_mpi_leave_pinned = !ompi_mpi_leave_pinned_pipeline; } + } else { + ompi_mpi_leave_pinned = 0; + ompi_mpi_leave_pinned_pipeline = 0; } } @@ -264,6 +299,14 @@ mca_btl_ugni_component_init (int *num_btl_modules, unsigned int i; int rc; + if (16384 < mca_btl_ugni_component.ugni_smsg_limit) { + mca_btl_ugni_component.ugni_smsg_limit = 16384; + } + + if (65536 < mca_btl_ugni_component.ugni_fma_limit) { + mca_btl_ugni_component.ugni_fma_limit = 65536; + } + /* Initialize ugni library and create communication domain */ rc = ompi_common_ugni_init(); if (OMPI_SUCCESS != rc) { diff --git a/ompi/mca/btl/vader/btl_vader.h b/ompi/mca/btl/vader/btl_vader.h index 15bac7e139..134d625b76 100644 --- a/ompi/mca/btl/vader/btl_vader.h +++ b/ompi/mca/btl/vader/btl_vader.h @@ -92,7 +92,6 @@ struct mca_btl_vader_component_t { int vader_free_list_max; /**< maximum size of free lists */ int vader_free_list_inc; /**< number of elements to alloc * when growing free lists */ - char *vader_mpool_name; /**< name of shared memory pool module */ mca_mpool_base_module_t *vader_mpool; /**< mpool on local node */ void *vader_mpool_base; /**< base address of shared memory pool */ size_t eager_limit; /**< send fragment size */ diff --git a/ompi/mca/btl/vader/btl_vader_component.c b/ompi/mca/btl/vader/btl_vader_component.c index bc3bd794a6..80161ec2be 100644 --- a/ompi/mca/btl/vader/btl_vader_component.c +++ b/ompi/mca/btl/vader/btl_vader_component.c @@ -26,7 +26,6 @@ #include "ompi/constants.h" #include "opal/util/output.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/btl/base/btl_base_error.h" #include "btl_vader.h" @@ -77,56 +76,56 @@ mca_btl_vader_component_t mca_btl_vader_component = { } /* end super */ }; - -/* - * utility routines for parameter registration - */ - -static inline char *mca_btl_vader_param_register_string(const char *param_name, - const char *default_value) -{ - char *param_value; - - (void) mca_base_param_reg_string (&mca_btl_vader_component.super.btl_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; -} - -static inline int mca_btl_vader_param_register_int(const char *param_name, - int value) -{ - (void) mca_base_param_reg_int (&mca_btl_vader_component.super.btl_version, - param_name, NULL, false, false, value, &value); - return value; -} - static int mca_btl_vader_component_register (void) { - /* register VADER component parameters */ - mca_btl_vader_component.vader_free_list_num = - mca_btl_vader_param_register_int("free_list_num", 8); - mca_btl_vader_component.vader_free_list_max = - mca_btl_vader_param_register_int("free_list_max", -1); - mca_btl_vader_component.vader_free_list_inc = - mca_btl_vader_param_register_int("free_list_inc", 64); - mca_btl_vader_component.vader_mpool_name = - mca_btl_vader_param_register_string("mpool", "sm"); - mca_btl_vader_memcpy_limit = - mca_btl_vader_param_register_int("memcpy_limit", mca_btl_vader_memcpy_limit); - mca_btl_vader_log_align = - mca_btl_vader_param_register_int("log_align", mca_btl_vader_log_align); + (void) mca_base_var_group_component_register(&mca_btl_vader_component.super.btl_version, + "XPMEM shared memory byte transport later"); - /* limit segment alignment to be between 4k and 16M */ - if (mca_btl_vader_log_align < 12) { - mca_btl_vader_log_align = 12; - } else if (mca_btl_vader_log_align > 25) { - mca_btl_vader_log_align = 25; - } + /* register VADER component variables */ + mca_btl_vader_component.vader_free_list_num = 8; + (void) mca_base_component_var_register(&mca_btl_vader_component.super.btl_version, + "free_list_num", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_vader_component.vader_free_list_num); + mca_btl_vader_component.vader_free_list_max = 8192; + (void) mca_base_component_var_register(&mca_btl_vader_component.super.btl_version, + "free_list_max", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_vader_component.vader_free_list_max); + mca_btl_vader_component.vader_free_list_inc = 64; + (void) mca_base_component_var_register(&mca_btl_vader_component.super.btl_version, + "free_list_inc", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_vader_component.vader_free_list_inc); - mca_btl_vader_max_inline_send = - mca_btl_vader_param_register_int("max_inline_send", mca_btl_vader_max_inline_send); + mca_btl_vader_memcpy_limit = 524288; + (void) mca_base_component_var_register(&mca_btl_vader_component.super.btl_version, + "memcpy_limit", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_vader_memcpy_limit); + mca_btl_vader_log_align = 21; + (void) mca_base_component_var_register(&mca_btl_vader_component.super.btl_version, + "log_align", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_LOCAL, + &mca_btl_vader_log_align); + + mca_btl_vader_max_inline_send = 256; + (void) mca_base_component_var_register(&mca_btl_vader_component.super.btl_version, + "max_inline_send", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_ALL_EQ, + &mca_btl_vader_max_inline_send); mca_btl_vader.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_HIGH; mca_btl_vader.super.btl_eager_limit = 64 * 1024; @@ -156,6 +155,14 @@ static int mca_btl_vader_component_register (void) static int mca_btl_vader_component_open(void) { + + /* limit segment alignment to be between 4k and 16M */ + if (mca_btl_vader_log_align < 12) { + mca_btl_vader_log_align = 12; + } else if (mca_btl_vader_log_align > 25) { + mca_btl_vader_log_align = 25; + } + mca_btl_vader_component.eager_limit = mca_btl_vader.super.btl_eager_limit; /* initialize objects */ @@ -200,10 +207,6 @@ static int mca_btl_vader_component_close(void) OBJ_RELEASE(mca_btl_vader_component.vader_seg); } - if (NULL != mca_btl_vader_component.vader_mpool_name) { - free(mca_btl_vader_component.vader_mpool_name); - } - OBJ_DESTRUCT(&mca_btl_vader_component.active_sends); CLEANUP: diff --git a/ompi/mca/btl/vader/btl_vader_module.c b/ompi/mca/btl/vader/btl_vader_module.c index 1b85eda749..443eb17ed6 100644 --- a/ompi/mca/btl/vader/btl_vader_module.c +++ b/ompi/mca/btl/vader/btl_vader_module.c @@ -133,8 +133,7 @@ static inline int vader_init_mpool (mca_btl_vader_t *vader_btl, int n) /* now, create it */ component->vader_mpool = - mca_mpool_base_module_create(component->vader_mpool_name, - vader_btl, &res); + mca_mpool_base_module_create("sm", vader_btl, &res); /* Sanity check to ensure that we found it */ if(NULL == component->vader_mpool) { return OMPI_ERR_OUT_OF_RESOURCE; diff --git a/ompi/mca/coll/base/coll_base_open.c b/ompi/mca/coll/base/coll_base_open.c index bebab0adb9..bd9fd41287 100644 --- a/ompi/mca/coll/base/coll_base_open.c +++ b/ompi/mca/coll/base/coll_base_open.c @@ -24,7 +24,6 @@ #include "opal/mca/mca.h" #include "opal/util/output.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/coll/coll.h" diff --git a/ompi/mca/coll/basic/coll_basic_component.c b/ompi/mca/coll/basic/coll_basic_component.c index b5dc262366..7af7edf96d 100644 --- a/ompi/mca/coll/basic/coll_basic_component.c +++ b/ompi/mca/coll/basic/coll_basic_component.c @@ -89,16 +89,20 @@ basic_register(void) { /* Use a low priority, but allow other components to be lower */ - mca_base_param_reg_int(&mca_coll_basic_component.collm_version, - "priority", - "Priority of the basic coll component", - false, false, mca_coll_basic_priority, - &mca_coll_basic_priority); - mca_base_param_reg_int(&mca_coll_basic_component.collm_version, - "crossover", - "Minimum number of processes in a communicator before using the logarithmic algorithms", - false, false, mca_coll_basic_crossover, - &mca_coll_basic_crossover); + mca_coll_basic_priority = 10; + (void) mca_base_component_var_register(&mca_coll_basic_component.collm_version, "priority", + "Priority of the basic coll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_basic_priority); + mca_coll_basic_crossover = 4; + (void) mca_base_component_var_register(&mca_coll_basic_component.collm_version, "crossover", + "Minimum number of processes in a communicator before using the logarithmic algorithms", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_basic_crossover); return OMPI_SUCCESS; } diff --git a/ompi/mca/coll/basic/coll_basic_module.c b/ompi/mca/coll/basic/coll_basic_module.c index 36b0ba748b..779e19a5ad 100644 --- a/ompi/mca/coll/basic/coll_basic_module.c +++ b/ompi/mca/coll/basic/coll_basic_module.c @@ -23,7 +23,6 @@ #include #include "mpi.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/coll/coll.h" #include "ompi/mca/coll/base/base.h" #include "coll_basic.h" diff --git a/ompi/mca/coll/demo/coll_demo.h b/ompi/mca/coll/demo/coll_demo.h index 0d333464bf..e4d6005e03 100644 --- a/ompi/mca/coll/demo/coll_demo.h +++ b/ompi/mca/coll/demo/coll_demo.h @@ -31,8 +31,7 @@ BEGIN_C_DECLS /* Globally exported variables */ OMPI_MODULE_DECLSPEC extern const mca_coll_base_component_2_0_0_t mca_coll_demo_component; - extern int mca_coll_demo_priority_param; - extern int mca_coll_demo_verbose_param; + extern int mca_coll_demo_priority; extern int mca_coll_demo_verbose; diff --git a/ompi/mca/coll/demo/coll_demo_component.c b/ompi/mca/coll/demo/coll_demo_component.c index e8a98b346d..7dbde395cb 100644 --- a/ompi/mca/coll/demo/coll_demo_component.c +++ b/ompi/mca/coll/demo/coll_demo_component.c @@ -38,14 +38,13 @@ const char *mca_coll_demo_component_version_string = /* * Global variable */ -int mca_coll_demo_priority_param = -1; -int mca_coll_demo_verbose_param = -1; +int mca_coll_demo_priority = -1; int mca_coll_demo_verbose = 0; /* * Local function */ -static int demo_open(void); +static int demo_register(void); /* @@ -68,8 +67,10 @@ const mca_coll_base_component_2_0_0_t mca_coll_demo_component = { OMPI_RELEASE_VERSION, /* Component open and close functions */ - demo_open, - NULL + NULL, + NULL, + NULL, + demo_register }, { /* The component is checkpoint ready */ @@ -83,15 +84,20 @@ const mca_coll_base_component_2_0_0_t mca_coll_demo_component = { }; -static int demo_open(void) +static int demo_register(void) { - mca_coll_demo_priority_param = - mca_base_param_reg_int(&mca_coll_demo_component.collm_version, - "priority", NULL, false, false, 20, NULL); - mca_coll_demo_verbose_param = - mca_base_param_reg_int(&mca_coll_demo_component.collm_version, - "verbose", NULL, false, false, - mca_coll_demo_verbose, NULL); + mca_coll_demo_priority = 20; + (void) mca_base_component_var_register(&mca_coll_demo_component.collm_version, "priority", + NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_demo_priority); + mca_coll_demo_verbose = 0; + (void) mca_base_component_var_register(&mca_coll_demo_component.collm_version, "verbose", + NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_demo_verbose); return OMPI_SUCCESS; } diff --git a/ompi/mca/coll/demo/coll_demo_module.c b/ompi/mca/coll/demo/coll_demo_module.c index dc71410879..eab6cbd9ed 100644 --- a/ompi/mca/coll/demo/coll_demo_module.c +++ b/ompi/mca/coll/demo/coll_demo_module.c @@ -120,10 +120,7 @@ mca_coll_demo_comm_query(struct ompi_communicator_t *comm, int *priority) demo_module = OBJ_NEW(mca_coll_demo_module_t); if (NULL == demo_module) return NULL; - if (OMPI_SUCCESS != - mca_base_param_lookup_int(mca_coll_demo_priority_param, priority)) { - return NULL; - } + *priority = mca_coll_demo_priority; demo_module->super.coll_module_enable = mca_coll_demo_module_enable; demo_module->super.ft_event = mca_coll_demo_ft_event; @@ -182,8 +179,6 @@ mca_coll_demo_module_enable(mca_coll_base_module_t *module, { mca_coll_demo_module_t *demo_module = (mca_coll_demo_module_t*) module; - mca_base_param_lookup_int(mca_coll_demo_verbose_param, - &mca_coll_demo_verbose); if (mca_coll_demo_verbose > 0) { printf("Hello! This is the \"demo\" coll component. I'll be your coll component\ntoday. Please tip your waitresses well.\n"); } diff --git a/ompi/mca/coll/fca/coll_fca_component.c b/ompi/mca/coll/fca/coll_fca_component.c index 2718a9689b..42634206f6 100644 --- a/ompi/mca/coll/fca/coll_fca_component.c +++ b/ompi/mca/coll/fca/coll_fca_component.c @@ -176,109 +176,142 @@ static int fca_register(void) c = &mca_coll_fca_component.super.collm_version; - mca_base_param_reg_int(c, "priority", - "Priority of the fca coll component", - false, false, - 80, - &mca_coll_fca_component.fca_priority); + mca_coll_fca_component.fca_priority = 80; + (void) mca_base_component_var_register(c, "priority", + "Priority of the fca coll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_priority); - mca_base_param_reg_int(c, "verbose", - "Verbose level of the fca coll component", - false, false, - 0, - &mca_coll_fca_component.fca_verbose); + mca_coll_fca_component.fca_verbose = 0; + (void) mca_base_component_var_register(c, "verbose", + "Verbose level of the fca coll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_verbose); - mca_base_param_reg_int(c, "enable", - "[1|0|] Enable/Disable Fabric Collective Accelerator", - false, false, - 1, - &mca_coll_fca_component.fca_enable); + mca_coll_fca_component.fca_enable = 1; + (void) mca_base_component_var_register(c, "enable", + "[1|0|] Enable/Disable Fabric Collective Accelerator", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable); - mca_base_param_reg_string(c, "spec_file", - "Path to the FCA configuration file fca_mpi_spec.ini", - false, false, - ""COLL_FCA_HOME"/etc/fca_mpi_spec.ini", - &mca_coll_fca_component.fca_spec_file); + mca_coll_fca_component.fca_spec_file = ""COLL_FCA_HOME"/etc/fca_mpi_spec.ini"; + (void) mca_base_component_var_register(c, "spec_file", + "Path to the FCA configuration file fca_mpi_spec.ini", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_spec_file); - mca_base_param_reg_int(c, "np", - "[integer] Minimal allowed job's NP to activate FCA", - false, false, - 64, - &mca_coll_fca_component.fca_np); + mca_coll_fca_component.fca_np = 64; + (void) mca_base_component_var_register(c, "np", + "[integer] Minimal allowed job's NP to activate FCA", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_np); - mca_base_param_reg_int(c, "enable_barrier", - "[1|0|] Enable/Disable FCA Barrier support", - false, false, - OMPI_FCA_BCAST, - &mca_coll_fca_component.fca_enable_barrier); + mca_coll_fca_component.fca_enable_barrier = OMPI_FCA_BCAST; + (void) mca_base_component_var_register(c, "enable_barrier", + "[1|0|] Enable/Disable FCA Barrier support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_barrier); - mca_base_param_reg_int(c, "enable_bcast", - "[1|0|] Enable/Disable FCA Bcast support", - false, false, - OMPI_FCA_BCAST, - &mca_coll_fca_component.fca_enable_bcast); + mca_coll_fca_component.fca_enable_bcast = OMPI_FCA_BCAST; + (void) mca_base_component_var_register(c, "enable_bcast", + "[1|0|] Enable/Disable FCA Bcast support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_bcast); - mca_base_param_reg_int(c, "enable_reduce", - "[1|0|] Enable/Disable FCA Reduce support", - false, false, - OMPI_FCA_REDUCE, - &mca_coll_fca_component.fca_enable_reduce); + mca_coll_fca_component.fca_enable_reduce = OMPI_FCA_REDUCE; + (void) mca_base_component_var_register(c, "enable_reduce", + "[1|0|] Enable/Disable FCA Reduce support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_reduce); - mca_base_param_reg_int(c, "enable_reduce_scatter", - "[1|0|] Enable/Disable FCA Reduce support", - false, false, - OMPI_FCA_REDUCE_SCATTER, - &mca_coll_fca_component.fca_enable_reduce_scatter); + mca_coll_fca_component.fca_enable_reduce_scatter = OMPI_FCA_REDUCE_SCATTER; + (void) mca_base_component_var_register(c, "enable_reduce_scatter", + "[1|0|] Enable/Disable FCA Reduce support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_reduce_scatter); - mca_base_param_reg_int(c, "enable_allreduce", - "[1|0|] Enable/Disable FCA Allreduce support", - false, false, - OMPI_FCA_ALLREDUCE, - &mca_coll_fca_component.fca_enable_allreduce); + mca_coll_fca_component.fca_enable_allreduce = OMPI_FCA_ALLREDUCE; + (void) mca_base_component_var_register(c, "enable_allreduce", + "[1|0|] Enable/Disable FCA Allreduce support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_allreduce); - mca_base_param_reg_int(c, "enable_allgather", - "[1|0|] Enable/Disable FCA Allgather support", - false, false, - OMPI_FCA_ALLGATHER, - &mca_coll_fca_component.fca_enable_allgather); + mca_coll_fca_component.fca_enable_allgather = OMPI_FCA_ALLGATHER; + (void) mca_base_component_var_register(c, "enable_allgather", + "[1|0|] Enable/Disable FCA Allgather support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_allgather); - mca_base_param_reg_int(c, "enable_allgatherv", - "[1|0|] Enable/Disable FCA Allgatherv support", - false, false, - OMPI_FCA_ALLGATHERV, - &mca_coll_fca_component.fca_enable_allgatherv); + mca_coll_fca_component.fca_enable_allgatherv = OMPI_FCA_ALLGATHERV; + (void) mca_base_component_var_register(c, "enable_allgatherv", + "[1|0|] Enable/Disable FCA Allgatherv support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_allgatherv); - mca_base_param_reg_int(c, "enable_gather", - "[1|0|] Enable/Disable FCA Gather support", - false, false, - OMPI_FCA_GATHER, - &mca_coll_fca_component.fca_enable_gather); + mca_coll_fca_component.fca_enable_gather = OMPI_FCA_GATHER; + (void) mca_base_component_var_register(c, "enable_gather", + "[1|0|] Enable/Disable FCA Gather support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_gather); - mca_base_param_reg_int(c, "enable_gatherv", - "[1|0|] Enable/Disable FCA Gatherv support", - false, false, - OMPI_FCA_GATHER, - &mca_coll_fca_component.fca_enable_gatherv); + mca_coll_fca_component.fca_enable_gatherv = OMPI_FCA_GATHER; + (void) mca_base_component_var_register(c, "enable_gatherv", + "[1|0|] Enable/Disable FCA Gatherv support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_gatherv); - mca_base_param_reg_int(c, "enable_alltoall", - "[1|0|] Enable/Disable FCA AlltoAll support", - false, false, - OMPI_FCA_ALLTOALL, - &mca_coll_fca_component.fca_enable_alltoall); + mca_coll_fca_component.fca_enable_alltoall = OMPI_FCA_ALLTOALL; + (void) mca_base_component_var_register(c, "enable_alltoall", + "[1|0|] Enable/Disable FCA AlltoAll support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_alltoall); - mca_base_param_reg_int(c, "enable_alltoallv", - "[1|0|] Enable/Disable FCA AlltoAllv support", - false, false, - OMPI_FCA_ALLTOALLV, - &mca_coll_fca_component.fca_enable_alltoallv); - - mca_base_param_reg_int(c, "enable_alltoallw", - "[1|0|] Enable/Disable FCA AlltoAllw support", - false, false, - OMPI_FCA_ALLTOALLW, - &mca_coll_fca_component.fca_enable_alltoallw); + mca_coll_fca_component.fca_enable_alltoallv = OMPI_FCA_ALLTOALLV; + (void) mca_base_component_var_register(c, "enable_alltoallv", + "[1|0|] Enable/Disable FCA AlltoAllv support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_alltoallv); + mca_coll_fca_component.fca_enable_alltoallw = OMPI_FCA_ALLTOALLW; + (void) mca_base_component_var_register(c, "enable_alltoallw", + "[1|0|] Enable/Disable FCA AlltoAllw support", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_fca_component.fca_enable_alltoallw); return OMPI_SUCCESS; } diff --git a/ompi/mca/coll/hierarch/coll_hierarch_component.c b/ompi/mca/coll/hierarch/coll_hierarch_component.c index 4b7241a1cb..d188d99def 100644 --- a/ompi/mca/coll/hierarch/coll_hierarch_component.c +++ b/ompi/mca/coll/hierarch/coll_hierarch_component.c @@ -52,7 +52,7 @@ int mca_coll_hierarch_segsize_param=32768; /* * Local function */ -static int hierarch_open(void); +static int hierarch_register(void); /* * Instantiate the public struct with all of our public information @@ -74,8 +74,10 @@ const mca_coll_base_component_2_0_0_t mca_coll_hierarch_component = { OMPI_RELEASE_VERSION, /* Component open and close functions */ - hierarch_open, - NULL + NULL, + NULL, + NULL, + hierarch_register }, { /* The component is checkpoint ready */ @@ -88,58 +90,75 @@ const mca_coll_base_component_2_0_0_t mca_coll_hierarch_component = { }; -static int hierarch_open(void) +static int hierarch_register(void) { - - /* Use a high priority, but allow other components to be higher */ - mca_base_param_reg_int(&mca_coll_hierarch_component.collm_version, - "priority", - "Priority of the hierarchical coll component", - false, false, mca_coll_hierarch_priority_param, - &mca_coll_hierarch_priority_param); + mca_coll_hierarch_priority_param = 0; + (void) mca_base_component_var_register(&mca_coll_hierarch_component.collm_version, + "priority", "Priority of the hierarchical coll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_hierarch_priority_param); + + mca_coll_hierarch_verbose_param = 0; + (void) mca_base_component_var_register(&mca_coll_hierarch_component.collm_version, + "verbose", + "Turn verbose message of the hierarchical coll component on/off", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_hierarch_verbose_param); + + mca_coll_hierarch_use_rdma_param = 0; + (void) mca_base_component_var_register(&mca_coll_hierarch_component.collm_version, + "use_rdma", + "Switch from the send btl list used to detect hierarchies to " + "the rdma btl list", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_hierarch_use_rdma_param); + + mca_coll_hierarch_ignore_sm_param = 0; + (void) mca_base_component_var_register(&mca_coll_hierarch_component.collm_version, + "ignore_sm", + "Ignore sm protocol when detecting hierarchies. " + "Required to enable the usage of protocol" + " specific collective operations", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_hierarch_ignore_sm_param); + + mca_coll_hierarch_detection_alg_param = 2; + (void) mca_base_component_var_register(&mca_coll_hierarch_component.collm_version, + "detection_alg", + "Used to specify the algorithm for detecting Hierarchy." + "Choose between all or two levels of hierarchy", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_hierarch_detection_alg_param); - mca_base_param_reg_int(&mca_coll_hierarch_component.collm_version, - "verbose", - "Turn verbose message of the hierarchical coll component on/off", - false, false, mca_coll_hierarch_verbose_param, - &mca_coll_hierarch_verbose_param); + mca_coll_hierarch_bcast_alg_param = COLL_HIERARCH_BASIC_BCAST_ALG; + (void) mca_base_component_var_register(&mca_coll_hierarch_component.collm_version, + "bcast_alg", + "Used to specify the algorithm used for bcast operations.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_hierarch_bcast_alg_param); - mca_base_param_reg_int(&mca_coll_hierarch_component.collm_version, - "use_rdma", - "Switch from the send btl list used to detect hierarchies to " - "the rdma btl list", - false, false, mca_coll_hierarch_use_rdma_param, - &mca_coll_hierarch_use_rdma_param); - - mca_base_param_reg_int(&mca_coll_hierarch_component.collm_version, - "ignore_sm", - "Ignore sm protocol when detecting hierarchies. " - "Required to enable the usage of protocol" - " specific collective operations", - false, false, mca_coll_hierarch_ignore_sm_param, - &mca_coll_hierarch_ignore_sm_param); - - mca_base_param_reg_int(&mca_coll_hierarch_component.collm_version, - "detection_alg", - "Used to specify the algorithm for detecting Hierarchy." - "Choose between all or two levels of hierarchy", - false, false, mca_coll_hierarch_detection_alg_param, - &mca_coll_hierarch_detection_alg_param); - - - mca_base_param_reg_int(&mca_coll_hierarch_component.collm_version, - "bcast_alg", - "Used to specify the algorithm used for bcast operations.", - false, false, mca_coll_hierarch_bcast_alg_param, - &mca_coll_hierarch_bcast_alg_param); - - mca_base_param_reg_int(&mca_coll_hierarch_component.collm_version, - "segment_size", - "Used to specify the segment size for segmented algorithms.", - false, false, mca_coll_hierarch_segsize_param, - &mca_coll_hierarch_segsize_param); + mca_coll_hierarch_segsize_param = 32768; + (void) mca_base_component_var_register(&mca_coll_hierarch_component.collm_version, + "segment_size", + "Used to specify the segment size for segmented algorithms.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_hierarch_segsize_param); return OMPI_SUCCESS; } diff --git a/ompi/mca/coll/inter/coll_inter_component.c b/ompi/mca/coll/inter/coll_inter_component.c index f7d644fae0..0ed3c8a872 100644 --- a/ompi/mca/coll/inter/coll_inter_component.c +++ b/ompi/mca/coll/inter/coll_inter_component.c @@ -46,7 +46,7 @@ int mca_coll_inter_verbose_param = 0; /* * Local function */ -static int inter_open(void); +static int inter_register(void); /* * Instantiate the public struct with all of our public information @@ -68,8 +68,10 @@ const mca_coll_base_component_2_0_0_t mca_coll_inter_component = { OMPI_RELEASE_VERSION, /* Component open and close functions */ - inter_open, - NULL + NULL, + NULL, + NULL, + inter_register }, { /* This component is checkpointable */ @@ -82,23 +84,25 @@ const mca_coll_base_component_2_0_0_t mca_coll_inter_component = { }; -static int inter_open(void) +static int inter_register(void) { - - /* Use a high priority, but allow other components to be higher */ - mca_base_param_reg_int(&mca_coll_inter_component.collm_version, - "priority", - "Priority of the inter coll component", - false, false, mca_coll_inter_priority_param, - &mca_coll_inter_priority_param); + mca_coll_inter_priority_param = 40; + (void) mca_base_component_var_register(&mca_coll_inter_component.collm_version, + "priority", "Priority of the inter coll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_inter_priority_param); - - mca_base_param_reg_int(&mca_coll_inter_component.collm_version, - "verbose", - "Turn verbose message of the inter coll component on/off", - false, false, mca_coll_inter_verbose_param, - &mca_coll_inter_verbose_param); + mca_coll_inter_verbose_param = 0; + (void) mca_base_component_var_register(&mca_coll_inter_component.collm_version, + "verbose", + "Turn verbose message of the inter coll component on/off", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_inter_verbose_param); return OMPI_SUCCESS; } diff --git a/ompi/mca/coll/libnbc/coll_libnbc_component.c b/ompi/mca/coll/libnbc/coll_libnbc_component.c index 11735fdc0a..ac9b156450 100644 --- a/ompi/mca/coll/libnbc/coll_libnbc_component.c +++ b/ompi/mca/coll/libnbc/coll_libnbc_component.c @@ -122,12 +122,13 @@ static int libnbc_register(void) { /* Use a low priority, but allow other components to be lower */ - - mca_base_param_reg_int(&mca_coll_libnbc_component.super.collm_version, - "priority", - "Priority of the libnbc coll component", - false, false, libnbc_priority, - &libnbc_priority); + libnbc_priority = 10; + (void) mca_base_component_var_register(&mca_coll_libnbc_component.super.collm_version, + "priority", "Priority of the libnbc coll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &libnbc_priority); return OMPI_SUCCESS; } diff --git a/ompi/mca/coll/ml/coll_ml.h b/ompi/mca/coll/ml/coll_ml.h index d25c23bf70..5c32117fe6 100644 --- a/ompi/mca/coll/ml/coll_ml.h +++ b/ompi/mca/coll/ml/coll_ml.h @@ -499,7 +499,7 @@ struct mca_coll_ml_component_t { int verbose; /** max of communicators available to run ML */ - uint32_t max_comm; + unsigned int max_comm; /** min size of comm to be available to run ML */ int min_comm_size; @@ -547,7 +547,7 @@ struct mca_coll_ml_component_t { int n_payload_buffs_per_bank; /* size of payload buffer */ - size_t payload_buffer_size; + unsigned long long payload_buffer_size; /* pipeline depth for msg fragmentation */ int pipeline_depth; @@ -579,10 +579,10 @@ struct mca_coll_ml_component_t { bool progress_is_busy; /* Temporary hack for IMB test - not all bcols have allgather */ - int disable_allgather; + bool disable_allgather; /* Temporary hack for IMB test - not all bcols have alltoall */ - int disable_alltoall; + bool disable_alltoall; /* Brucks alltoall mca and other params */ int use_brucks_smsg_alltoall; diff --git a/ompi/mca/coll/ml/coll_ml_config.c b/ompi/mca/coll/ml/coll_ml_config.c index 6aa1e69be7..3b1e73a4a9 100644 --- a/ompi/mca/coll/ml/coll_ml_config.c +++ b/ompi/mca/coll/ml/coll_ml_config.c @@ -8,8 +8,6 @@ #include #endif -#include "opal/mca/base/mca_base_param.h" - #include "coll_ml.h" #include "coll_ml_inlines.h" #include "coll_ml_config.h" diff --git a/ompi/mca/coll/ml/coll_ml_lmngr.c b/ompi/mca/coll/ml/coll_ml_lmngr.c index a7a45374f8..781057aee9 100644 --- a/ompi/mca/coll/ml/coll_ml_lmngr.c +++ b/ompi/mca/coll/ml/coll_ml_lmngr.c @@ -124,21 +124,24 @@ int mca_coll_ml_lmngr_tune(mca_coll_ml_lmngr_t *lmngr, int mca_coll_ml_lmngr_reg(void) { - int ival, tmp; - int ret = OMPI_SUCCESS; + int tmp, ret = OMPI_SUCCESS; mca_coll_ml_component_t *cm = &mca_coll_ml_component; #define CHECK(expr) do {\ tmp = (expr); \ - if (OMPI_SUCCESS != tmp) ret = tmp; \ + if (0 > tmp) ret = tmp; \ } while (0) ML_VERBOSE(7, ("Setting parameters for list manager")); - CHECK(reg_int("memory_manager_list_size", NULL, - "Memory manager list size", 8, &ival, 0)); - cm->lmngr_size = ival; + cm->lmngr_size = 8; + CHECK(mca_base_component_var_register(&mca_coll_ml_component.super.collm_version, + "memory_manager_list_size", "Memory manager list size", + MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cm->lmngr_size)); /* The size list couldn't be less than possible max of ML modules, it = max supported communicators by ML */ @@ -146,17 +149,25 @@ int mca_coll_ml_lmngr_reg(void) cm->lmngr_size = cm->max_comm; } - CHECK(reg_int("memory_manager_block_size", NULL, - "Memory manager block size", - cm->payload_buffer_size * - cm->n_payload_buffs_per_bank * - cm->n_payload_mem_banks * - cm->lmngr_size, &ival, 0)); - mca_coll_ml_component.lmngr_block_size = ival; + mca_coll_ml_component.lmngr_block_size = cm->payload_buffer_size * + cm->n_payload_buffs_per_bank * + cm->n_payload_mem_banks * + cm->lmngr_size; - CHECK(reg_int("memory_manager_alignment", NULL, - "Memory manager alignment", 4 * 1024, &ival, 0)); - cm->lmngr_alignment = ival; + CHECK(mca_base_component_var_register(&mca_coll_ml_component.super.collm_version, + "memory_manager_block_size", "Memory manager block size", + MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_ml_component.lmngr_block_size)); + + cm->lmngr_alignment = 4 * 1024; + CHECK(mca_base_component_var_register(&mca_coll_ml_component.super.collm_version, + "memory_manager_alignment", "Memory manager alignment", + MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_coll_ml_component.lmngr_block_size)); return ret; } diff --git a/ompi/mca/coll/ml/coll_ml_mca.c b/ompi/mca/coll/ml/coll_ml_mca.c index 0245d9f3d1..c523ad876f 100644 --- a/ompi/mca/coll/ml/coll_ml_mca.c +++ b/ompi/mca/coll/ml/coll_ml_mca.c @@ -47,70 +47,132 @@ enum { static int reg_string(const char* param_name, const char* deprecated_param_name, const char* param_desc, - const char* default_value, char **out_value, + const char* default_value, char **storage, int flags) { int index; - char *value; - index = mca_base_param_reg_string(&mca_coll_ml_component.super.collm_version, - param_name, param_desc, false, false, - default_value, &value); + *storage = (char *) default_value; + index = mca_base_component_var_register(&mca_coll_ml_component.super.collm_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); if (NULL != deprecated_param_name) { - mca_base_param_reg_syn(index, - &mca_coll_ml_component.super.collm_version, - deprecated_param_name, true); + (void) mca_base_var_register_synonym(index, "ompi", "coll", "ml", deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); } - if (0 != (flags & REGSTR_EMPTY_OK) && 0 == strlen(value)) { + if (0 != (flags & REGSTR_EMPTY_OK) && (NULL == *storage || 0 == strlen(*storage))) { opal_output(0, "Bad parameter value for parameter \"%s\"", param_name); return OMPI_ERR_BAD_PARAM; } - *out_value = value; return OMPI_SUCCESS; } + /* * utility routine for integer parameter registration */ -int reg_int(const char* param_name, +static int reg_int(const char* param_name, const char* deprecated_param_name, const char* param_desc, - int default_value, int *out_value, int flags) + int default_value, int *storage, int flags) { - int index, value; - index = mca_base_param_reg_int(&mca_coll_ml_component.super.collm_version, - param_name, param_desc, false, false, - default_value, NULL); + int index; + + *storage = default_value; + index = mca_base_component_var_register(&mca_coll_ml_component.super.collm_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0,OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); if (NULL != deprecated_param_name) { - mca_base_param_reg_syn(index, - &mca_coll_ml_component.super.collm_version, - deprecated_param_name, true); + (void) mca_base_var_register_synonym(index, "ompi", "coll", "ml", deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); } - mca_base_param_lookup_int(index, &value); - - if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == value) { - *out_value = value; + if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == *storage) { return OMPI_SUCCESS; } - if ((0 != (flags & REGINT_GE_ZERO) && value < 0) || - (0 != (flags & REGINT_GE_ONE) && value < 1) || - (0 != (flags & REGINT_NONZERO) && 0 == value)) { + if ((0 != (flags & REGINT_GE_ZERO) && *storage < 0) || + (0 != (flags & REGINT_GE_ONE) && *storage < 1) || + (0 != (flags & REGINT_NONZERO) && 0 == *storage)) { opal_output(0, "Bad parameter value for parameter \"%s\"", param_name); return OMPI_ERR_BAD_PARAM; } - *out_value = value; + return OMPI_SUCCESS; +} + +static int reg_bool(const char* param_name, + const char* deprecated_param_name, + const char* param_desc, + bool default_value, bool *storage) +{ + int index; + + *storage = default_value; + index = mca_base_component_var_register(&mca_coll_ml_component.super.collm_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_BOOL, + NULL, 0, 0,OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + if (NULL != deprecated_param_name) { + (void) mca_base_var_register_synonym(index, "ompi", "coll", "ml", deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + } + + return OMPI_SUCCESS; +} + +static int reg_ullint(const char* param_name, + const char* deprecated_param_name, + const char* param_desc, + unsigned long long default_value, unsigned long long *storage, int flags) +{ + int index; + + *storage = default_value; + index = mca_base_component_var_register(&mca_coll_ml_component.super.collm_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, + NULL, 0, 0,OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + if (NULL != deprecated_param_name) { + (void) mca_base_var_register_synonym(index, "ompi", "coll", "ml", deprecated_param_name, + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + } + + if ((0 != (flags & REGINT_GE_ONE) && *storage < 1) || + (0 != (flags & REGINT_NONZERO) && 0 == *storage)) { + opal_output(0, "Bad parameter value for parameter \"%s\"", + param_name); + return OMPI_ERR_BAD_PARAM; + } + + return OMPI_SUCCESS; +} + +static int mca_coll_ml_verify_params(void) +{ + int dummy; + + /* Make sure that the the number of memory banks is a power of 2 */ + mca_coll_ml_component.n_payload_mem_banks = + roundup_to_power_radix(2, mca_coll_ml_component.n_payload_mem_banks, + &dummy); + + /* Make sure that the the number of buffers is a power of 2 */ + mca_coll_ml_component.n_payload_buffs_per_bank = + roundup_to_power_radix(2, mca_coll_ml_component.n_payload_buffs_per_bank, + &dummy); + return OMPI_SUCCESS; } int mca_coll_ml_register_params(void) { - int ival, ret, tmp, dummy; + int ret, tmp; char *str = NULL; ret = OMPI_SUCCESS; @@ -123,99 +185,70 @@ int mca_coll_ml_register_params(void) CHECK(reg_int("priority", NULL, "ML component priority" - "(from 0(low) to 90 (high))", 0, &ival, 0)); - mca_coll_ml_component.ml_priority = ival; + "(from 0(low) to 90 (high))", 0, &mca_coll_ml_component.ml_priority, 0)); CHECK(reg_int("verbose", NULL, "Output some verbose ML information " - "(0 = no output, nonzero = output)", 0, &ival, 0)); - mca_coll_ml_component.verbose = ival; + "(0 = no output, nonzero = output)", 0, &mca_coll_ml_component.verbose, 0)); CHECK(reg_int("n_levels", NULL, - "number of levels in the hierarchy ", 1, &ival, 0)); - mca_coll_ml_component.ml_n_levels = ival; + "number of levels in the hierarchy ", 1, &mca_coll_ml_component.ml_n_levels, 0)); CHECK(reg_int("max_comm", NULL, - "max of communicators available to run ML", 12, &ival, 0)); - mca_coll_ml_component.max_comm = ival; + "max of communicators available to run ML", 12, (int *) &mca_coll_ml_component.max_comm, 0)); CHECK(reg_int("min_comm_size", NULL, - " min size of comm to be available to run ML", 0, &ival, 0)); - mca_coll_ml_component.min_comm_size = ival; + " min size of comm to be available to run ML", 0, &mca_coll_ml_component.min_comm_size, 0)); CHECK(reg_int("n_payload_mem_banks", NULL, - " number of payload memory banks", 2, &ival, 0)); - mca_coll_ml_component.n_payload_mem_banks = ival; - - /* Make sure that the the number of memory banks is a power of 2 */ - mca_coll_ml_component.n_payload_mem_banks = - roundup_to_power_radix(2, mca_coll_ml_component.n_payload_mem_banks, - &dummy); + "number of payload memory banks", 2, &mca_coll_ml_component.n_payload_mem_banks, 0)); CHECK(reg_int("n_payload_buffs_per_bank", NULL, - " number of payload buffers per bank", 16, &ival, 0)); - mca_coll_ml_component.n_payload_buffs_per_bank = ival; - - /* Make sure that the the number of buffers is a power of 2 */ - mca_coll_ml_component.n_payload_buffs_per_bank = - roundup_to_power_radix(2, mca_coll_ml_component.n_payload_buffs_per_bank, - &dummy); + "number of payload buffers per bank", 16, &mca_coll_ml_component.n_payload_buffs_per_bank, 0)); /* RLG: need to handle alignment and size */ - CHECK(reg_int("payload_buffer_size", NULL, - " size of payload buffer", 4*1024, &ival, 0)); - mca_coll_ml_component.payload_buffer_size = (size_t) ival; + CHECK(reg_ullint("payload_buffer_size", NULL, + "size of payload buffer", 4*1024, &mca_coll_ml_component.payload_buffer_size, 0)); /* get the pipeline depth, default is 2 */ CHECK(reg_int("pipeline_depth", NULL, - "size of fragmentation pipeline", 2, &ival, 0)); - mca_coll_ml_component.pipeline_depth = (int) ival; + "size of fragmentation pipeline", 2, &mca_coll_ml_component.pipeline_depth, 0)); CHECK(reg_int("free_list_init_size", NULL, - " Initial size for free lists in ML", 128, &ival, 0)); - mca_coll_ml_component.free_list_init_size = (size_t) ival; + " Initial size for free lists in ML", 128, &mca_coll_ml_component.free_list_init_size, 0)); CHECK(reg_int("free_list_grow_size", NULL, - " Initial size for free lists in ML", 64, &ival, 0)); - mca_coll_ml_component.free_list_grow_size = (size_t) ival; + " Initial size for free lists in ML", 64, &mca_coll_ml_component.free_list_grow_size, 0)); CHECK(reg_int("free_list_max_size", NULL, - " Initial size for free lists in ML", -1, &ival, 0)); - mca_coll_ml_component.free_list_max_size = (size_t) ival; + " Initial size for free lists in ML", -1, &mca_coll_ml_component.free_list_max_size, 0)); CHECK(reg_int("use_knomial_allreduce", NULL, "Use k-nomial Allreduce supports only p2p currently" - , 1, &ival, 0)); - mca_coll_ml_component.use_knomial_allreduce = ival; + , 1, &mca_coll_ml_component.use_knomial_allreduce, 0)); - CHECK(reg_int("use_static_bcast", NULL, - "Use new bcast static algorithm", 1, &ival, 0)); - mca_coll_ml_component.use_static_bcast = (0 != ival); + CHECK(reg_bool("use_static_bcast", NULL, + "Use new bcast static algorithm", true, &mca_coll_ml_component.use_static_bcast)); - CHECK(reg_int("use_sequential_bcast", NULL, - "Use new bcast static algorithm", 0, &ival, 0)); - mca_coll_ml_component.use_sequential_bcast = (0 != ival); + CHECK(reg_bool("use_sequential_bcast", NULL, + "Use new bcast static algorithm", false, &mca_coll_ml_component.use_sequential_bcast)); - CHECK(reg_int("disable_allgather", NULL, + CHECK(reg_bool("disable_allgather", NULL, "Allgather disabling", - 0, &ival, 0)); - mca_coll_ml_component.disable_allgather = (0 != ival); + false, &mca_coll_ml_component.disable_allgather)); - CHECK(reg_int("disable_alltoall", NULL, + CHECK(reg_bool("disable_alltoall", NULL, "Alltoall disabling", - 0, &ival, 0)); - mca_coll_ml_component.disable_alltoall = (0 != ival); + false, &mca_coll_ml_component.disable_alltoall)); - CHECK(reg_int("enable_fragmentation", NULL, - "Disable/Enable fragmentation for large messages" - , 0, &ival, 0)); - mca_coll_ml_component.enable_fragmentation = (0 != ival); + CHECK(reg_bool("enable_fragmentation", NULL, + "Disable/Enable fragmentation for large messages", + false, &mca_coll_ml_component.enable_fragmentation)); CHECK(reg_int("use_brucks_smsg_alltoall", NULL, "Use Bruck's Algo for Small Msg Alltoall" "1 - Bruck's Algo with RDMA; 2 - Bruck's with Send Recv" - , 0, &ival, 0)); - mca_coll_ml_component.use_brucks_smsg_alltoall = ival; + , 0, &mca_coll_ml_component.use_brucks_smsg_alltoall, 0)); asprintf(&str, "%s/mca-coll-ml.config", opal_install_dirs.pkgdatadir); @@ -232,5 +265,8 @@ int mca_coll_ml_register_params(void) /* Reading parameters for list manager */ CHECK(mca_coll_ml_lmngr_reg()); + /* Verify the parameters */ + CHECK(mca_coll_ml_verify_params()); + return ret; } diff --git a/ompi/mca/coll/ml/coll_ml_mca.h b/ompi/mca/coll/ml/coll_ml_mca.h index 11d4371cad..7730bd284d 100644 --- a/ompi/mca/coll/ml/coll_ml_mca.h +++ b/ompi/mca/coll/ml/coll_ml_mca.h @@ -15,11 +15,6 @@ #include #include "ompi_config.h" -int reg_int(const char* param_name, - const char* deprecated_param_name, - const char* param_desc, - int default_value, int *out_value, int flags); - int mca_coll_ml_register_params(void); #endif diff --git a/ompi/mca/coll/self/coll_self.h b/ompi/mca/coll/self/coll_self.h index f938af55fa..bf48e624d2 100644 --- a/ompi/mca/coll/self/coll_self.h +++ b/ompi/mca/coll/self/coll_self.h @@ -34,8 +34,7 @@ BEGIN_C_DECLS */ OMPI_MODULE_DECLSPEC extern const mca_coll_base_component_2_0_0_t mca_coll_self_component; -extern int mca_coll_self_priority_param; - +extern int ompi_coll_self_priority; /* * coll API functions diff --git a/ompi/mca/coll/self/coll_self_component.c b/ompi/mca/coll/self/coll_self_component.c index 6a92fa7869..8fc050ef8b 100644 --- a/ompi/mca/coll/self/coll_self_component.c +++ b/ompi/mca/coll/self/coll_self_component.c @@ -39,12 +39,12 @@ const char *mca_coll_self_component_version_string = /* * Global variable */ -int mca_coll_self_priority_param = -1; +int ompi_coll_self_priority = 0; /* * Local function */ -static int self_open(void); +static int self_register(void); /* @@ -67,8 +67,10 @@ const mca_coll_base_component_2_0_0_t mca_coll_self_component = { OMPI_RELEASE_VERSION, /* Component open and close functions */ - self_open, - NULL + NULL, + NULL, + NULL, + self_register }, { /* The component is checkpoint ready */ @@ -81,15 +83,16 @@ const mca_coll_base_component_2_0_0_t mca_coll_self_component = { mca_coll_self_comm_query }; - -static int self_open(void) +static int self_register(void) { /* We'll always be picked if there's only one process in the communicator */ - - mca_coll_self_priority_param = - mca_base_param_reg_int (&mca_coll_self_component.collm_version, - "priority", NULL, false, false, 75, NULL); + ompi_coll_self_priority = 75; + (void) mca_base_component_var_register(&mca_coll_self_component.collm_version, + "priority", NULL, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_coll_self_priority); return OMPI_SUCCESS; } diff --git a/ompi/mca/coll/self/coll_self_module.c b/ompi/mca/coll/self/coll_self_module.c index 9f1bd44877..cfbead8772 100644 --- a/ompi/mca/coll/self/coll_self_module.c +++ b/ompi/mca/coll/self/coll_self_module.c @@ -23,7 +23,6 @@ #include "mpi.h" #include "ompi/communicator/communicator.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/coll/coll.h" #include "ompi/mca/coll/base/base.h" #include "coll_self.h" @@ -56,11 +55,7 @@ mca_coll_self_comm_query(struct ompi_communicator_t *comm, /* We only work on intracommunicators of size 1 */ if (!OMPI_COMM_IS_INTER(comm) && 1 == ompi_comm_size(comm)) { - if (OMPI_SUCCESS != - mca_base_param_lookup_int(mca_coll_self_priority_param, - priority)) { - return NULL; - } + *priority = ompi_coll_self_priority; module = OBJ_NEW(mca_coll_self_module_t); if (NULL == module) return NULL; diff --git a/ompi/mca/coll/sm/coll_sm_component.c b/ompi/mca/coll/sm/coll_sm_component.c index 247bc175aa..816ba9fdaa 100644 --- a/ompi/mca/coll/sm/coll_sm_component.c +++ b/ompi/mca/coll/sm/coll_sm_component.c @@ -46,6 +46,7 @@ const char *mca_coll_sm_component_version_string = static int sm_close(void); static int sm_register(void); +static int coll_sm_shared_mem_used_data; /* * Instantiate the public struct with all of our public information @@ -127,54 +128,19 @@ static int sm_close(void) return OMPI_SUCCESS; } -/* - * Register MCA params - */ -static int sm_register(void) +static int sm_verify_mca_variables(void) { - size_t size; - mca_base_component_t *c = &mca_coll_sm_component.super.collm_version; mca_coll_sm_component_t *cs = &mca_coll_sm_component; - /* If we want to be selected (i.e., all procs on one node), then - we should have a high priority */ - - mca_base_param_reg_int(c, "priority", - "Priority of the sm coll component", - false, false, - cs->sm_priority, - &cs->sm_priority); - - mca_base_param_reg_int(c, "control_size", - "Length of the control data -- should usually be either the length of a cache line on most SMPs, or the size of a page on machines that support direct memory affinity page placement (in bytes)", - false, false, - cs->sm_control_size, - &cs->sm_control_size); - - mca_base_param_reg_int(c, "fragment_size", - "Fragment size (in bytes) used for passing data through shared memory (will be rounded up to the nearest control_size size)", - false, false, - cs->sm_fragment_size, - &cs->sm_fragment_size); if (0 != (cs->sm_fragment_size % cs->sm_control_size)) { cs->sm_fragment_size += cs->sm_control_size - (cs->sm_fragment_size % cs->sm_control_size); } - mca_base_param_reg_int(c, "comm_in_use_flags", - "Number of \"in use\" flags, used to mark a message passing area segment as currently being used or not (must be >= 2 and <= comm_num_segments)", - false, false, - cs->sm_comm_num_in_use_flags, - &cs->sm_comm_num_in_use_flags); if (cs->sm_comm_num_in_use_flags < 2) { cs->sm_comm_num_in_use_flags = 2; } - mca_base_param_reg_int(c, "comm_num_segments", - "Number of segments in each communicator's shared memory message passing area (must be >= 2, and must be a multiple of comm_in_use_flags)", - false, false, - cs->sm_comm_num_segments, - &cs->sm_comm_num_segments); if (cs->sm_comm_num_segments < cs->sm_comm_num_in_use_flags) { cs->sm_comm_num_segments = cs->sm_comm_num_in_use_flags; } @@ -185,11 +151,6 @@ static int sm_register(void) cs->sm_segs_per_inuse_flag = cs->sm_comm_num_segments / cs->sm_comm_num_in_use_flags; - mca_base_param_reg_int(c, "tree_degree", - "Degree of the tree for tree-based operations (must be => 1 and <= min(control_size, 255))", - false, false, - cs->sm_tree_degree, - &cs->sm_tree_degree); if (cs->sm_tree_degree > cs->sm_control_size) { opal_show_help("help-mpi-coll-sm.txt", "tree-degree-larger-than-control", true, @@ -203,23 +164,95 @@ static int sm_register(void) cs->sm_tree_degree = 255; } - /* INFO: Calculate how much space we need in the per-communicator - shmem data segment. This formula taken directly from - coll_sm_module.c. */ - mca_base_param_reg_int(c, "info_num_procs", - "Number of processes to use for the calculation of the shared_mem_size MCA information parameter (must be => 2)", - false, false, - cs->sm_info_comm_size, - &cs->sm_info_comm_size); - - size = 4 * cs->sm_control_size + + coll_sm_shared_mem_used_data = (int)(4 * cs->sm_control_size + (cs->sm_comm_num_in_use_flags * cs->sm_control_size) + (cs->sm_comm_num_segments * (cs->sm_info_comm_size * cs->sm_control_size * 2)) + - (cs->sm_comm_num_segments * (cs->sm_info_comm_size * cs->sm_fragment_size)); - mca_base_param_reg_int(c, "shared_mem_used_data", - "Amount of shared memory used, per communicator, in the shared memory data area for info_num_procs processes (in bytes)", - false, true, - (int)size, NULL); + (cs->sm_comm_num_segments * (cs->sm_info_comm_size * cs->sm_fragment_size))); return OMPI_SUCCESS; } + +/* + * Register MCA params + */ +static int sm_register(void) +{ + mca_base_component_t *c = &mca_coll_sm_component.super.collm_version; + mca_coll_sm_component_t *cs = &mca_coll_sm_component; + + /* If we want to be selected (i.e., all procs on one node), then + we should have a high priority */ + + cs->sm_priority = 0; + (void) mca_base_component_var_register(c, "priority", "Priority of the sm coll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cs->sm_priority); + + cs->sm_control_size = 4096; + (void) mca_base_component_var_register(c, "control_size", + "Length of the control data -- should usually be either the length of a cache line on most SMPs, or the size of a page on machines that support direct memory affinity page placement (in bytes)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cs->sm_control_size); + + cs->sm_fragment_size = 8192; + (void) mca_base_component_var_register(c, "fragment_size", + "Fragment size (in bytes) used for passing data through shared memory (will be rounded up to the nearest control_size size)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cs->sm_fragment_size); + + cs->sm_comm_num_in_use_flags = 2; + (void) mca_base_component_var_register(c, "comm_in_use_flags", + "Number of \"in use\" flags, used to mark a message passing area segment as currently being used or not (must be >= 2 and <= comm_num_segments)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cs->sm_comm_num_in_use_flags); + + cs->sm_comm_num_segments = 8; + (void) mca_base_component_var_register(c, "comm_num_segments", + "Number of segments in each communicator's shared memory message passing area (must be >= 2, and must be a multiple of comm_in_use_flags)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cs->sm_comm_num_segments); + + cs->sm_tree_degree = 4; + (void) mca_base_component_var_register(c, "tree_degree", + "Degree of the tree for tree-based operations (must be => 1 and <= min(control_size, 255))", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cs->sm_tree_degree); + + /* INFO: Calculate how much space we need in the per-communicator + shmem data segment. This formula taken directly from + coll_sm_module.c. */ + cs->sm_info_comm_size = 4; + (void) mca_base_component_var_register(c, "info_num_procs", + "Number of processes to use for the calculation of the shared_mem_size MCA information parameter (must be => 2)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cs->sm_info_comm_size); + + coll_sm_shared_mem_used_data = (int)(4 * cs->sm_control_size + + (cs->sm_comm_num_in_use_flags * cs->sm_control_size) + + (cs->sm_comm_num_segments * (cs->sm_info_comm_size * cs->sm_control_size * 2)) + + (cs->sm_comm_num_segments * (cs->sm_info_comm_size * cs->sm_fragment_size))); + + (void) mca_base_component_var_register(c, "shared_mem_used_data", + "Amount of shared memory used, per communicator, in the shared memory data area for info_num_procs processes (in bytes)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_sm_shared_mem_used_data); + + return sm_verify_mca_variables(); +} diff --git a/ompi/mca/coll/tuned/coll_tuned.h b/ompi/mca/coll/tuned/coll_tuned.h index 144236df6a..fd770eed65 100644 --- a/ompi/mca/coll/tuned/coll_tuned.h +++ b/ompi/mca/coll/tuned/coll_tuned.h @@ -80,7 +80,7 @@ BEGIN_C_DECLS extern int ompi_coll_tuned_stream; extern int ompi_coll_tuned_priority; extern int ompi_coll_tuned_preallocate_memory_comm_size_limit; -extern int ompi_coll_tuned_use_dynamic_rules; +extern bool ompi_coll_tuned_use_dynamic_rules; extern char* ompi_coll_tuned_dynamic_rules_filename; extern int ompi_coll_tuned_init_tree_fanout; extern int ompi_coll_tuned_init_chain_fanout; diff --git a/ompi/mca/coll/tuned/coll_tuned_allgather.c b/ompi/mca/coll/tuned/coll_tuned_allgather.c index 673c5d0ba5..47dc750a60 100644 --- a/ompi/mca/coll/tuned/coll_tuned_allgather.c +++ b/ompi/mca/coll/tuned/coll_tuned_allgather.c @@ -10,6 +10,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2009 University of Houston. All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All Rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -30,6 +32,24 @@ #include "coll_tuned_topo.h" #include "coll_tuned_util.h" +/* allgather algorithm variables */ +static int coll_tuned_allgather_algorithm_count = 6; +static int coll_tuned_allgather_forced_algorithm = 0; +static int coll_tuned_allgather_segment_size = 0; +static int coll_tuned_allgather_tree_fanout; +static int coll_tuned_allgather_chain_fanout; + +/* valid values for coll_tuned_allgather_forced_algorithm */ +static mca_base_var_enum_value_t allgather_algorithms[] = { + {0, "ignore"}, + {1, "linear"}, + {2, "bruck"}, + {3, "recursive_doubling"}, + {4, "ring"}, + {5, "neighbor"}, + {6, "two_proc"}, + {0, NULL} +}; /* * ompi_coll_tuned_allgather_intra_bruck @@ -748,54 +768,64 @@ ompi_coll_tuned_allgather_intra_basic_linear(void *sbuf, int scount, int ompi_coll_tuned_allgather_intra_check_forced_init(coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int max_alg = 6, requested_alg; + mca_base_var_enum_t *new_enum; - ompi_coll_tuned_forced_max_algorithms[ALLGATHER] = max_alg; + ompi_coll_tuned_forced_max_algorithms[ALLGATHER] = coll_tuned_allgather_algorithm_count; - mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "allgather_algorithm_count", - "Number of allgather algorithms available", - false, true, max_alg, NULL); - - mca_param_indices->algorithm_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "allgather_algorithm", - "Which allgather algorithm is used. Can be locked down to choice of: 0 ignore, 1 basic linear, 2 bruck, 3 recursive doubling, 4 ring, 5 neighbor exchange, 6: two proc only.", - false, false, 0, NULL); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allgather_algorithm_count", + "Number of allgather algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_allgather_algorithm_count); + + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_allgather_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_allgather_algorithms", allgather_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allgather_algorithm", + "Which allallgather algorithm is used. Can be locked down to choice of: 0 ignore, 1 basic linear, 2 bruck, 3 recursive doubling, 4 ring, 5 neighbor exchange, 6: two proc only.", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allgather_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int(mca_param_indices->algorithm_param_index, - &(requested_alg)); - if( 0 > requested_alg || requested_alg > max_alg ) { - if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { - opal_output( 0, "Allgather algorithm #%d is not available (range [0..%d]). Switching back to ignore(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0); - } - - mca_param_indices->segsize_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "allgather_algorithm_segmentsize", - "Segment size in bytes used by default for allgather algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation. Currently, available algorithms do not support segmentation.", - false, false, 0, NULL); - - mca_param_indices->tree_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "allgather_algorithm_tree_fanout", - "Fanout for n-tree used for allgather algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation. Currently, available algorithms do not support n-tree topologies.", - false, false, - ompi_coll_tuned_init_tree_fanout, /* get system wide default */ - NULL); - mca_param_indices->chain_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "allgather_algorithm_chain_fanout", - "Fanout for chains used for allgather algorithms. Only has meaning if algorithm is forced and supports chain topo based operation. Currently, available algorithms do not support chain topologies.", - false, false, - ompi_coll_tuned_init_chain_fanout, /* get system wide default */ - NULL); + coll_tuned_allgather_segment_size = 0; + mca_param_indices->segsize_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allgather_algorithm_segmentsize", + "Segment size in bytes used by default for allgather algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation. Currently, available algorithms do not support segmentation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allgather_segment_size); + + coll_tuned_allgather_tree_fanout = ompi_coll_tuned_init_tree_fanout; /* get system wide default */ + mca_param_indices->tree_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allgather_algorithm_tree_fanout", + "Fanout for n-tree used for allgather algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation. Currently, available algorithms do not support n-tree topologies.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allgather_tree_fanout); + + coll_tuned_allgather_chain_fanout = ompi_coll_tuned_init_chain_fanout; /* get system wide default */ + mca_param_indices->chain_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allgather_algorithm_chain_fanout", + "Fanout for chains used for allgather algorithms. Only has meaning if algorithm is forced and supports chain topo based operation. Currently, available algorithms do not support chain topologies.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allgather_chain_fanout); return (MPI_SUCCESS); } diff --git a/ompi/mca/coll/tuned/coll_tuned_allgatherv.c b/ompi/mca/coll/tuned/coll_tuned_allgatherv.c index e28729abac..2c4801ef36 100644 --- a/ompi/mca/coll/tuned/coll_tuned_allgatherv.c +++ b/ompi/mca/coll/tuned/coll_tuned_allgatherv.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,6 +11,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2009 University of Houston. All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All Rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,6 +32,24 @@ #include "coll_tuned_topo.h" #include "coll_tuned_util.h" +/* allgatherv algorithm variables */ +static int coll_tuned_allgatherv_algorithm_count = 5; +static int coll_tuned_allgatherv_forced_algorithm = 0; +static int coll_tuned_allgatherv_segment_size = 0; +static int coll_tuned_allgatherv_tree_fanout; +static int coll_tuned_allgatherv_chain_fanout; + +/* valid values for coll_tuned_allgatherv_forced_algorithm */ +static mca_base_var_enum_value_t allgatherv_algorithms[] = { + {0, "ignore"}, + {1, "default"}, + {2, "bruck"}, + {3, "ring"}, + {4, "neighbor"}, + {5, "two_proc"}, + {0, NULL} +}; + /* * ompi_coll_tuned_allgatherv_intra_bruck * @@ -665,54 +686,64 @@ ompi_coll_tuned_allgatherv_intra_basic_default(void *sbuf, int scount, int ompi_coll_tuned_allgatherv_intra_check_forced_init(coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int max_alg = 5, requested_alg; - - ompi_coll_tuned_forced_max_algorithms[ALLGATHERV] = max_alg; - - mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "allgatherv_algorithm_count", - "Number of allgather algorithms available", - false, true, max_alg, NULL); - - mca_param_indices->algorithm_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "allgatherv_algorithm", - "Which allgather algorithm is used. Can be locked down to choice of: 0 ignore, 1 default (gatherv + bcast), 2 bruck, 3 ring, 4 neighbor exchange, 5: two proc only.", - false, false, 0, NULL); + mca_base_var_enum_t *new_enum; + + ompi_coll_tuned_forced_max_algorithms[ALLGATHERV] = coll_tuned_allgatherv_algorithm_count; + + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allgatherv_algorithm_count", + "Number of allgatherv algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_allgatherv_algorithm_count); + + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_allgatherv_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_allgatherv_algorithms", allgatherv_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allgatherv_algorithm", + "Which allallgatherv algorithm is used. Can be locked down to choice of: 0 ignore, 1 default (allgathervv + bcast), 2 bruck, 3 ring, 4 neighbor exchange, 5: two proc only.", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allgatherv_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int(mca_param_indices->algorithm_param_index, - &(requested_alg)); - if( 0 > requested_alg || requested_alg > max_alg ) { - if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { - opal_output( 0, "Allgather algorithm #%d is not available (range [0..%d]). Switching back to ignore(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0); - } - - mca_param_indices->segsize_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "allgatherv_algorithm_segmentsize", - "Segment size in bytes used by default for allgather algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation. Currently, available algorithms do not support segmentation.", - false, false, 0, NULL); - - mca_param_indices->tree_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "allgatherv_algorithm_tree_fanout", - "Fanout for n-tree used for allgather algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation. Currently, available algorithms do not support n-tree topologies.", - false, false, - ompi_coll_tuned_init_tree_fanout, /* get system wide default */ - NULL); - mca_param_indices->chain_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "allgatherv_algorithm_chain_fanout", - "Fanout for chains used for allgather algorithms. Only has meaning if algorithm is forced and supports chain topo based operation. Currently, available algorithms do not support chain topologies.", - false, false, - ompi_coll_tuned_init_chain_fanout, /* get system wide default */ - NULL); + coll_tuned_allgatherv_segment_size = 0; + mca_param_indices->segsize_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allgatherv_algorithm_segmentsize", + "Segment size in bytes used by default for allgatherv algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation. Currently, available algorithms do not support segmentation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allgatherv_segment_size); + + coll_tuned_allgatherv_tree_fanout = ompi_coll_tuned_init_tree_fanout; /* get system wide default */ + mca_param_indices->tree_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allgatherv_algorithm_tree_fanout", + "Fanout for n-tree used for allgatherv algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation. Currently, available algorithms do not support n-tree topologies.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allgatherv_tree_fanout); + + coll_tuned_allgatherv_chain_fanout = ompi_coll_tuned_init_chain_fanout; /* get system wide default */ + mca_param_indices->chain_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allgatherv_algorithm_chain_fanout", + "Fanout for chains used for allgatherv algorithms. Only has meaning if algorithm is forced and supports chain topo based operation. Currently, available algorithms do not support chain topologies.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allgatherv_chain_fanout); return (MPI_SUCCESS); } diff --git a/ompi/mca/coll/tuned/coll_tuned_allreduce.c b/ompi/mca/coll/tuned/coll_tuned_allreduce.c index 5f99e11a2e..2e8134ae63 100644 --- a/ompi/mca/coll/tuned/coll_tuned_allreduce.c +++ b/ompi/mca/coll/tuned/coll_tuned_allreduce.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,6 +11,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2009 University of Houston. All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All Rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -32,6 +35,24 @@ #include "coll_tuned_topo.h" #include "coll_tuned_util.h" +/* allreduce algorithm variables */ +static int coll_tuned_allreduce_algorithm_count = 5; +static int coll_tuned_allreduce_forced_algorithm = 0; +static int coll_tuned_allreduce_segment_size = 0; +static int coll_tuned_allreduce_tree_fanout; +static int coll_tuned_allreduce_chain_fanout; + +/* valid values for coll_tuned_allreduce_forced_algorithm */ +static mca_base_var_enum_value_t allreduce_algorithms[] = { + {0, "ignore"}, + {1, "basic_linear"}, + {2, "nonoverlapping"}, + {3, "recursive_doubling"}, + {4, "ring"}, + {5, "segmented_ring"}, + {0, NULL} +}; + /* * ompi_coll_tuned_allreduce_intra_nonoverlapping * @@ -921,52 +942,64 @@ ompi_coll_tuned_allreduce_intra_basic_linear(void *sbuf, void *rbuf, int count, int ompi_coll_tuned_allreduce_intra_check_forced_init (coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int max_alg = 5, requested_alg; + mca_base_var_enum_t *new_enum; - ompi_coll_tuned_forced_max_algorithms[ALLREDUCE] = max_alg; + ompi_coll_tuned_forced_max_algorithms[ALLREDUCE] = coll_tuned_allreduce_algorithm_count; - mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "allreduce_algorithm_count", - "Number of allreduce algorithms available", - false, true, max_alg, NULL); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allreduce_algorithm_count", + "Number of allreduce algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_allreduce_algorithm_count); - mca_param_indices->algorithm_param_index - = mca_base_param_reg_int( &mca_coll_tuned_component.super.collm_version, - "allreduce_algorithm", - "Which allreduce algorithm is used. Can be locked down to any of: 0 ignore, 1 basic linear, 2 nonoverlapping (tuned reduce + tuned bcast), 3 recursive doubling, 4 ring, 5 segmented ring", - false, false, 0, NULL); + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_allreduce_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_allreduce_algorithms", allreduce_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allreduce_algorithm", + "Which allreduce algorithm is used. Can be locked down to any of: 0 ignore, 1 basic linear, 2 nonoverlapping (tuned reduce + tuned bcast), 3 recursive doubling, 4 ring, 5 segmented ring", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allreduce_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int( mca_param_indices->algorithm_param_index, &(requested_alg)); - if( 0 > requested_alg || requested_alg > max_alg ) { - if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { - opal_output( 0, "Allreduce algorithm #%d is not available (range [0..%d]). Switching back to ignore(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0); - } - mca_param_indices->segsize_param_index - = mca_base_param_reg_int( &mca_coll_tuned_component.super.collm_version, - "allreduce_algorithm_segmentsize", - "Segment size in bytes used by default for allreduce algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.", - false, false, 0, NULL); - - mca_param_indices->tree_fanout_param_index - = mca_base_param_reg_int( &mca_coll_tuned_component.super.collm_version, - "allreduce_algorithm_tree_fanout", - "Fanout for n-tree used for allreduce algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.", - false, false, ompi_coll_tuned_init_tree_fanout, /* get system wide default */ - NULL); + coll_tuned_allreduce_segment_size = 0; + mca_param_indices->segsize_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allreduce_algorithm_segmentsize", + "Segment size in bytes used by default for allreduce algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allreduce_segment_size); - mca_param_indices->chain_fanout_param_index - = mca_base_param_reg_int( &mca_coll_tuned_component.super.collm_version, - "allreduce_algorithm_chain_fanout", - "Fanout for chains used for allreduce algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.", - false, false, - ompi_coll_tuned_init_chain_fanout, /* get system wide default */ - NULL); + coll_tuned_allreduce_tree_fanout = ompi_coll_tuned_init_tree_fanout; /* get system wide default */ + mca_param_indices->tree_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allreduce_algorithm_tree_fanout", + "Fanout for n-tree used for allreduce algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allreduce_tree_fanout); + + coll_tuned_allreduce_chain_fanout = ompi_coll_tuned_init_chain_fanout; /* get system wide default */ + mca_param_indices->chain_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "allreduce_algorithm_chain_fanout", + "Fanout for chains used for allreduce algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_allreduce_chain_fanout); return (MPI_SUCCESS); } diff --git a/ompi/mca/coll/tuned/coll_tuned_alltoall.c b/ompi/mca/coll/tuned/coll_tuned_alltoall.c index 974ca2371e..1a87c3c8ea 100644 --- a/ompi/mca/coll/tuned/coll_tuned_alltoall.c +++ b/ompi/mca/coll/tuned/coll_tuned_alltoall.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -9,6 +10,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All Rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,6 +32,25 @@ #include "coll_tuned_topo.h" #include "coll_tuned_util.h" +/* alltoall algorithm variables */ +static int coll_tuned_alltoall_algorithm_count = 5; +static int coll_tuned_alltoall_forced_algorithm = 0; +static int coll_tuned_alltoall_segment_size = 0; +static int coll_tuned_alltoall_max_requests; +static int coll_tuned_alltoall_tree_fanout; +static int coll_tuned_alltoall_chain_fanout; + +/* valid values for coll_tuned_alltoall_forced_algorithm */ +static mca_base_var_enum_value_t alltoall_algorithms[] = { + {0, "ignore"}, + {1, "linear"}, + {2, "pairwise"}, + {3, "modified_bruck"}, + {4, "linear_sync"}, + {5, "two_proc"}, + {0, NULL} +}; + int ompi_coll_tuned_alltoall_intra_pairwise(void *sbuf, int scount, struct ompi_datatype_t *sdtype, void* rbuf, int rcount, @@ -580,72 +602,84 @@ int ompi_coll_tuned_alltoall_intra_basic_linear(void *sbuf, int scount, int ompi_coll_tuned_alltoall_intra_check_forced_init (coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int max_alg = 5, requested_alg, max_requests; + mca_base_var_enum_t*new_enum; - ompi_coll_tuned_forced_max_algorithms[ALLTOALL] = max_alg; + ompi_coll_tuned_forced_max_algorithms[ALLTOALL] = coll_tuned_alltoall_algorithm_count; - mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "alltoall_algorithm_count", - "Number of alltoall algorithms available", - false, true, max_alg, NULL); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "alltoall_algorithm_count", + "Number of alltoall algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_alltoall_algorithm_count); - mca_param_indices->algorithm_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "alltoall_algorithm", - "Which alltoall algorithm is used. Can be locked down to choice of: 0 ignore, 1 basic linear, 2 pairwise, 3: modified bruck, 4: linear with sync, 5:two proc only.", - false, false, 0, NULL); + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_alltoall_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_alltoall_algorithms", alltoall_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "alltoall_algorithm", + "Which alltoall algorithm is used. Can be locked down to choice of: 0 ignore, 1 basic linear, 2 pairwise, 3: modified bruck, 4: linear with sync, 5:two proc only.", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_alltoall_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int(mca_param_indices->algorithm_param_index, &(requested_alg)); - if( 0 > requested_alg || requested_alg > max_alg ) { - if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { - opal_output( 0, "Alltoall algorithm #%d is not available (range [0..%d]). Switching back to ignore(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0); - } - - mca_param_indices->segsize_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "alltoall_algorithm_segmentsize", - "Segment size in bytes used by default for alltoall algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.", - false, false, 0, NULL); - - mca_param_indices->tree_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "alltoall_algorithm_tree_fanout", - "Fanout for n-tree used for alltoall algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.", - false, false, - ompi_coll_tuned_init_tree_fanout, /* get system wide default */ - NULL); - mca_param_indices->chain_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "alltoall_algorithm_chain_fanout", - "Fanout for chains used for alltoall algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.", - false, false, - ompi_coll_tuned_init_chain_fanout, /* get system wide default */ - NULL); + coll_tuned_alltoall_segment_size = 0; + mca_param_indices->segsize_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "alltoall_algorithm_segmentsize", + "Segment size in bytes used by default for alltoall algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_alltoall_segment_size); - mca_param_indices->max_requests_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "alltoall_algorithm_max_requests", - "Maximum number of outstanding send or recv requests. Only has meaning for synchronized algorithms.", - false, false, - ompi_coll_tuned_init_max_requests, /* get system wide default */ - NULL); + coll_tuned_alltoall_tree_fanout = ompi_coll_tuned_init_tree_fanout; /* get system wide default */ + mca_param_indices->tree_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "alltoall_algorithm_tree_fanout", + "Fanout for n-tree used for alltoall algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_alltoall_tree_fanout); + + coll_tuned_alltoall_chain_fanout = ompi_coll_tuned_init_chain_fanout; /* get system wide default */ + mca_param_indices->chain_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "alltoall_algorithm_chain_fanout", + "Fanout for chains used for alltoall algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_alltoall_chain_fanout); + + coll_tuned_alltoall_max_requests = 0; /* no limit for alltoall by default */ + mca_param_indices->max_requests_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "alltoall_algorithm_max_requests", + "Maximum number of outstanding send or recv requests. Only has meaning for synchronized algorithms.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_alltoall_max_requests); if (mca_param_indices->max_requests_param_index < 0) { - return mca_param_indices->algorithm_param_index; + return mca_param_indices->max_requests_param_index; } - mca_base_param_lookup_int(mca_param_indices->max_requests_param_index, &(max_requests)); - if( max_requests <= 1 ) { + + if (coll_tuned_alltoall_max_requests < 0) { if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { opal_output( 0, "Maximum outstanding requests must be positive number greater than 1. Switching to system level default %d \n", ompi_coll_tuned_init_max_requests ); } - mca_base_param_set_int( mca_param_indices->max_requests_param_index, - ompi_coll_tuned_init_max_requests); + coll_tuned_alltoall_max_requests = 0; } return (MPI_SUCCESS); diff --git a/ompi/mca/coll/tuned/coll_tuned_alltoallv.c b/ompi/mca/coll/tuned/coll_tuned_alltoallv.c index 5f4f56487d..2999f35ff2 100644 --- a/ompi/mca/coll/tuned/coll_tuned_alltoallv.c +++ b/ompi/mca/coll/tuned/coll_tuned_alltoallv.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,6 +11,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All Rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -30,6 +33,18 @@ #include "coll_tuned_topo.h" #include "coll_tuned_util.h" +/* alltoallv algorithm variables */ +static int coll_tuned_alltoallv_algorithm_count = 2; +static int coll_tuned_alltoallv_forced_algorithm = 0; + +/* valid values for coll_tuned_alltoallv_forced_algorithm */ +static mca_base_var_enum_value_t alltoallv_algorithms[] = { + {0, "ignore"}, + {1, "basic_linear"}, + {2, "pairwise"}, + {0, NULL} +}; + int ompi_coll_tuned_alltoallv_intra_pairwise(void *sbuf, int *scounts, int *sdisps, struct ompi_datatype_t *sdtype, @@ -198,34 +213,36 @@ ompi_coll_tuned_alltoallv_intra_basic_linear(void *sbuf, int *scounts, int *sdis int ompi_coll_tuned_alltoallv_intra_check_forced_init(coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int max_alg = 2, requested_alg; + mca_base_var_enum_t *new_enum; - ompi_coll_tuned_forced_max_algorithms[ALLTOALLV] = max_alg; + ompi_coll_tuned_forced_max_algorithms[ALLTOALLV] = coll_tuned_alltoallv_algorithm_count; - mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "alltoallv_algorithm_count", - "Number of alltoallv algorithms available", - false, true, max_alg, NULL); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "alltoallv_algorithm_count", + "Number of alltoallv algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_alltoallv_algorithm_count); - mca_param_indices->algorithm_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "alltoallv_algorithm", - "Which alltoallv algorithm is used. " - "Can be locked down to choice of: 0 ignore, " - "1 basic linear, 2 pairwise.", - false, false, 0, NULL); + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_alltoallv_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_alltoallv_algorithms", alltoallv_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "alltoallv_algorithm", + "Which alltoallv algorithm is used. " + "Can be locked down to choice of: 0 ignore, " + "1 basic linear, 2 pairwise.", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_alltoallv_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int(mca_param_indices->algorithm_param_index, &(requested_alg)); - if (0 > requested_alg || requested_alg > max_alg) { - if (0 == ompi_comm_rank( MPI_COMM_WORLD)) { - opal_output(0, "Alltoallv algorithm #%d is not available (range [0..%d]). " - "Switching back to ignore(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int(mca_param_indices->algorithm_param_index, 0); - } return (MPI_SUCCESS); } diff --git a/ompi/mca/coll/tuned/coll_tuned_barrier.c b/ompi/mca/coll/tuned/coll_tuned_barrier.c index d660c839f1..0041df6e0c 100644 --- a/ompi/mca/coll/tuned/coll_tuned_barrier.c +++ b/ompi/mca/coll/tuned/coll_tuned_barrier.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,6 +11,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All Rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -30,6 +33,22 @@ #include "coll_tuned_topo.h" #include "coll_tuned_util.h" +/* barrier algorithm variables */ +static int coll_tuned_barrier_algorithm_count = 6; +static int coll_tuned_barrier_forced_algorithm = 0; + +/* valid values for coll_tuned_barrier_forced_algorithm */ +static mca_base_var_enum_value_t barrier_algorithms[] = { + {0, "ignore"}, + {1, "linear"}, + {2, "double_ring"}, + {3, "recursive_doubling"}, + {4, "bruck"}, + {5, "two_proc"}, + {6, "tree"}, + {0, NULL} +}; + /* * Barrier is ment to be a synchronous operation, as some BTLs can mark * a request done before its passed to the NIC and progress might not be made @@ -405,32 +424,34 @@ int ompi_coll_tuned_barrier_intra_tree(struct ompi_communicator_t *comm, int ompi_coll_tuned_barrier_intra_check_forced_init (coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int max_alg = 6, requested_alg; + mca_base_var_enum_t *new_enum; - ompi_coll_tuned_forced_max_algorithms[BARRIER] = max_alg; + ompi_coll_tuned_forced_max_algorithms[BARRIER] = coll_tuned_barrier_algorithm_count; - mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "barrier_algorithm_count", - "Number of barrier algorithms available", - false, true, max_alg, NULL); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "barrier_algorithm_count", + "Number of barrier algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_barrier_algorithm_count); - mca_param_indices->algorithm_param_index = - mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "barrier_algorithm", - "Which barrier algorithm is used. Can be locked down to choice of: 0 ignore, 1 linear, 2 double ring, 3: recursive doubling 4: bruck, 5: two proc only, 6: tree", - false, false, 0, NULL); + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_barrier_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_barrier_algorithms", barrier_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "barrier_algorithm", + "Which barrier algorithm is used. Can be locked down to choice of: 0 ignore, 1 linear, 2 double ring, 3: recursive doubling 4: bruck, 5: two proc only, 6: tree", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_barrier_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int(mca_param_indices->algorithm_param_index, - &(requested_alg)); - if( 0 > requested_alg || requested_alg > max_alg ) { - if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { - opal_output( 0, "Barrier algorithm #%d is not available (range [0..%d]). Switching back to ignore(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0); - } return (MPI_SUCCESS); } diff --git a/ompi/mca/coll/tuned/coll_tuned_bcast.c b/ompi/mca/coll/tuned/coll_tuned_bcast.c index 843a8aa99f..079dbbcacc 100644 --- a/ompi/mca/coll/tuned/coll_tuned_bcast.c +++ b/ompi/mca/coll/tuned/coll_tuned_bcast.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -30,6 +31,25 @@ #include "coll_tuned_topo.h" #include "coll_tuned_util.h" +/* bcast algorithm variables */ +static int coll_tuned_bcast_algorithm_count = 6; +static int coll_tuned_bcast_forced_algorithm = 0; +static int coll_tuned_bcast_segment_size = 0; +static int coll_tuned_bcast_tree_fanout; +static int coll_tuned_bcast_chain_fanout; + +/* valid values for coll_tuned_bcast_forced_algorithm */ +static mca_base_var_enum_value_t bcast_algorithms[] = { + {0, "ignore"}, + {1, "basic_linear"}, + {2, "chain"}, + {3, "pipeline"}, + {4, "split_binary_tree"}, + {5, "binary_tree"}, + {6, "binomial"}, + {0, NULL} +}; + int ompi_coll_tuned_bcast_intra_generic( void* buffer, int original_count, @@ -712,54 +732,64 @@ ompi_coll_tuned_bcast_intra_basic_linear (void *buff, int count, int ompi_coll_tuned_bcast_intra_check_forced_init (coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int rc, max_alg = 6, requested_alg; + mca_base_var_enum_t *new_enum; - ompi_coll_tuned_forced_max_algorithms[BCAST] = max_alg; + ompi_coll_tuned_forced_max_algorithms[BCAST] = coll_tuned_bcast_algorithm_count; - rc = mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "bcast_algorithm_count", - "Number of bcast algorithms available", - false, true, max_alg, NULL); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "bcast_algorithm_count", + "Number of bcast algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_bcast_algorithm_count); - - mca_param_indices->algorithm_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "bcast_algorithm", - "Which bcast algorithm is used. Can be locked down to choice of: 0 ignore, 1 basic linear, 2 chain, 3: pipeline, 4: split binary tree, 5: binary tree, 6: binomial tree.", - false, false, 0, NULL); + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_bcast_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_bcast_algorithms", bcast_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "bcast_algorithm", + "Which bcast algorithm is used. Can be locked down to choice of: 0 ignore, 1 basic linear, 2 chain, 3: pipeline, 4: split binary tree, 5: binary tree, 6: binomial tree.", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_bcast_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int(mca_param_indices->algorithm_param_index, &(requested_alg)); - if( 0 > requested_alg || requested_alg > max_alg ) { - if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { - opal_output( 0, "Broadcast algorithm #%d is not available (range [0..%d]). Switching back to ignore(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0); - } - mca_param_indices->segsize_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "bcast_algorithm_segmentsize", - "Segment size in bytes used by default for bcast algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.", - false, false, 0, NULL); + coll_tuned_bcast_segment_size = 0; + mca_param_indices->segsize_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "bcast_algorithm_segmentsize", + "Segment size in bytes used by default for bcast algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_bcast_segment_size); - mca_param_indices->tree_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "bcast_algorithm_tree_fanout", - "Fanout for n-tree used for bcast algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.", - false, false, - ompi_coll_tuned_init_tree_fanout, /* get system wide default */ - NULL); + coll_tuned_bcast_tree_fanout = ompi_coll_tuned_init_tree_fanout; /* get system wide default */ + mca_param_indices->tree_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "bcast_algorithm_tree_fanout", + "Fanout for n-tree used for bcast algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_bcast_tree_fanout); - mca_param_indices->chain_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "bcast_algorithm_chain_fanout", - "Fanout for chains used for bcast algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.", - false, false, - ompi_coll_tuned_init_chain_fanout, /* get system wide default */ - NULL); + coll_tuned_bcast_chain_fanout = ompi_coll_tuned_init_chain_fanout; /* get system wide default */ + mca_param_indices->chain_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "bcast_algorithm_chain_fanout", + "Fanout for chains used for bcast algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_bcast_chain_fanout); return (MPI_SUCCESS); } diff --git a/ompi/mca/coll/tuned/coll_tuned_component.c b/ompi/mca/coll/tuned/coll_tuned_component.c index e38c194bd0..248d31e575 100644 --- a/ompi/mca/coll/tuned/coll_tuned_component.c +++ b/ompi/mca/coll/tuned/coll_tuned_component.c @@ -45,7 +45,7 @@ const char *ompi_coll_tuned_component_version_string = int ompi_coll_tuned_stream = -1; int ompi_coll_tuned_priority = 30; int ompi_coll_tuned_preallocate_memory_comm_size_limit = (32 * 1024); -int ompi_coll_tuned_use_dynamic_rules = 0; +bool ompi_coll_tuned_use_dynamic_rules = false; char* ompi_coll_tuned_dynamic_rules_filename = (char*) NULL; int ompi_coll_tuned_init_tree_fanout = 4; int ompi_coll_tuned_init_chain_fanout = 4; @@ -60,6 +60,7 @@ int ompi_coll_tuned_forced_max_algorithms[COLLCOUNT]; /* * Local function */ +static int tuned_register(void); static int tuned_open(void); static int tuned_close(void); @@ -84,7 +85,9 @@ mca_coll_tuned_component_t mca_coll_tuned_component = { /* Component open and close functions */ tuned_open, - tuned_close + tuned_close, + NULL, + tuned_register }, { /* The component is checkpoint ready */ @@ -104,6 +107,80 @@ mca_coll_tuned_component_t mca_coll_tuned_component = { NULL /* ompi_coll_alg_rule_t ptr */ }; +static int tuned_register(void) +{ + + /* Use a low priority, but allow other components to be lower */ + ompi_coll_tuned_priority = 30; + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "priority", "Priority of the tuned coll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_6, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_coll_tuned_priority); + + /* parameter for pre-allocated memory requests etc */ + ompi_coll_tuned_preallocate_memory_comm_size_limit = (32 * 1024); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "pre_allocate_memory_comm_size_limit", + "Size of communicator were we stop pre-allocating memory for the fixed internal buffer used for message requests etc that is hung off the communicator data segment. I.e. if you have a 100'000 nodes you might not want to pre-allocate 200'000 request handle slots per communicator instance!", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_6, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_coll_tuned_preallocate_memory_comm_size_limit); + + /* some initial guesses at topology parameters */ + ompi_coll_tuned_init_tree_fanout = 4; + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "init_tree_fanout", + "Inital fanout used in the tree topologies for each communicator. This is only an initial guess, if a tuned collective needs a different fanout for an operation, it build it dynamically. This parameter is only for the first guess and might save a little time", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_6, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_coll_tuned_init_tree_fanout); + + ompi_coll_tuned_init_chain_fanout = 4; + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "init_chain_fanout", + "Inital fanout used in the chain (fanout followed by pipeline) topologies for each communicator. This is only an initial guess, if a tuned collective needs a different fanout for an operation, it build it dynamically. This parameter is only for the first guess and might save a little time", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_6, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_coll_tuned_init_chain_fanout); + + ompi_coll_tuned_use_dynamic_rules = false; + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "use_dynamic_rules", + "Switch used to decide if we use static (compiled/if statements) or dynamic (built at runtime) decision function rules", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_6, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_coll_tuned_use_dynamic_rules); + + ompi_coll_tuned_dynamic_rules_filename = NULL; + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "dynamic_rules_filename", + "Filename of configuration file that contains the dynamic (@runtime) decision function rules", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_6, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_coll_tuned_dynamic_rules_filename); + + /* register forced params */ + ompi_coll_tuned_allreduce_intra_check_forced_init(&ompi_coll_tuned_forced_params[ALLREDUCE]); + ompi_coll_tuned_alltoall_intra_check_forced_init(&ompi_coll_tuned_forced_params[ALLTOALL]); + ompi_coll_tuned_allgather_intra_check_forced_init(&ompi_coll_tuned_forced_params[ALLGATHER]); + ompi_coll_tuned_allgatherv_intra_check_forced_init(&ompi_coll_tuned_forced_params[ALLGATHERV]); + ompi_coll_tuned_alltoallv_intra_check_forced_init(&ompi_coll_tuned_forced_params[ALLTOALLV]); + ompi_coll_tuned_barrier_intra_check_forced_init(&ompi_coll_tuned_forced_params[BARRIER]); + ompi_coll_tuned_bcast_intra_check_forced_init(&ompi_coll_tuned_forced_params[BCAST]); + ompi_coll_tuned_reduce_intra_check_forced_init(&ompi_coll_tuned_forced_params[REDUCE]); + ompi_coll_tuned_reduce_scatter_intra_check_forced_init(&ompi_coll_tuned_forced_params[REDUCESCATTER]); + ompi_coll_tuned_gather_intra_check_forced_init(&ompi_coll_tuned_forced_params[GATHER]); + ompi_coll_tuned_scatter_intra_check_forced_init(&ompi_coll_tuned_forced_params[SCATTER]); + + return OMPI_SUCCESS; +} static int tuned_open(void) { @@ -113,44 +190,17 @@ static int tuned_open(void) { int param; - param = mca_base_param_find("coll", NULL, "base_verbose"); + param = mca_base_var_find("ompi", "coll", "base", "verbose"); if (param >= 0) { - int verbose; - mca_base_param_lookup_int(param, &verbose); - if (verbose > 0) { + const int *verbose = NULL; + mca_base_var_get_value(param, &verbose, NULL, NULL); + if (verbose && verbose[0] > 0) { ompi_coll_tuned_stream = opal_output_open(NULL); } } } #endif /* OPAL_ENABLE_DEBUG */ - /* Use a low priority, but allow other components to be lower */ - mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "priority", - "Priority of the tuned coll component", - false, false, ompi_coll_tuned_priority, - &ompi_coll_tuned_priority); - - /* parameter for pre-allocated memory requests etc */ - mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "pre_allocate_memory_comm_size_limit", - "Size of communicator were we stop pre-allocating memory for the fixed internal buffer used for message requests etc that is hung off the communicator data segment. I.e. if you have a 100'000 nodes you might not want to pre-allocate 200'000 request handle slots per communicator instance!", - false, false, ompi_coll_tuned_preallocate_memory_comm_size_limit, - &ompi_coll_tuned_preallocate_memory_comm_size_limit); - - /* some initial guesses at topology parameters */ - mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "init_tree_fanout", - "Inital fanout used in the tree topologies for each communicator. This is only an initial guess, if a tuned collective needs a different fanout for an operation, it build it dynamically. This parameter is only for the first guess and might save a little time", - false, false, ompi_coll_tuned_init_tree_fanout, - &ompi_coll_tuned_init_tree_fanout); - - mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "init_chain_fanout", - "Inital fanout used in the chain (fanout followed by pipeline) topologies for each communicator. This is only an initial guess, if a tuned collective needs a different fanout for an operation, it build it dynamically. This parameter is only for the first guess and might save a little time", - false, false, ompi_coll_tuned_init_chain_fanout, - &ompi_coll_tuned_init_chain_fanout); - /* now check that the user hasn't overrode any of the decision functions if dynamic rules are enabled */ /* the user can redo this before every comm dup/create if they like */ /* this is useful for benchmarking and user knows best tuning */ @@ -160,18 +210,7 @@ static int tuned_open(void) /* intra functions first */ /* if dynamic rules allowed then look up dynamic rules config filename, else we leave it an empty filename (NULL) */ /* by default DISABLE dynamic rules and instead use fixed [if based] rules */ - mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "use_dynamic_rules", - "Switch used to decide if we use static (compiled/if statements) or dynamic (built at runtime) decision function rules", - false, false, ompi_coll_tuned_use_dynamic_rules, - &ompi_coll_tuned_use_dynamic_rules); - if (ompi_coll_tuned_use_dynamic_rules) { - mca_base_param_reg_string(&mca_coll_tuned_component.super.collm_version, - "dynamic_rules_filename", - "Filename of configuration file that contains the dynamic (@runtime) decision function rules", - false, false, ompi_coll_tuned_dynamic_rules_filename, - &ompi_coll_tuned_dynamic_rules_filename); if( ompi_coll_tuned_dynamic_rules_filename ) { OPAL_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:component_open Reading collective rules file [%s]", ompi_coll_tuned_dynamic_rules_filename)); @@ -184,17 +223,6 @@ static int tuned_open(void) mca_coll_tuned_component.all_base_rules = NULL; } } - ompi_coll_tuned_allreduce_intra_check_forced_init(&ompi_coll_tuned_forced_params[ALLREDUCE]); - ompi_coll_tuned_alltoall_intra_check_forced_init(&ompi_coll_tuned_forced_params[ALLTOALL]); - ompi_coll_tuned_allgather_intra_check_forced_init(&ompi_coll_tuned_forced_params[ALLGATHER]); - ompi_coll_tuned_allgatherv_intra_check_forced_init(&ompi_coll_tuned_forced_params[ALLGATHERV]); - ompi_coll_tuned_alltoallv_intra_check_forced_init(&ompi_coll_tuned_forced_params[ALLTOALLV]); - ompi_coll_tuned_barrier_intra_check_forced_init(&ompi_coll_tuned_forced_params[BARRIER]); - ompi_coll_tuned_bcast_intra_check_forced_init(&ompi_coll_tuned_forced_params[BCAST]); - ompi_coll_tuned_reduce_intra_check_forced_init(&ompi_coll_tuned_forced_params[REDUCE]); - ompi_coll_tuned_reduce_scatter_intra_check_forced_init(&ompi_coll_tuned_forced_params[REDUCESCATTER]); - ompi_coll_tuned_gather_intra_check_forced_init(&ompi_coll_tuned_forced_params[GATHER]); - ompi_coll_tuned_scatter_intra_check_forced_init(&ompi_coll_tuned_forced_params[SCATTER]); } OPAL_OUTPUT((ompi_coll_tuned_stream, "coll:tuned:component_open: done!")); diff --git a/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c b/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c index 4032d5993e..226112760b 100644 --- a/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c +++ b/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c @@ -23,7 +23,6 @@ #include "ompi/constants.h" #include "ompi/datatype/ompi_datatype.h" #include "ompi/communicator/communicator.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/coll/base/base.h" #include "ompi/mca/coll/coll.h" #include "ompi/mca/coll/base/coll_tags.h" diff --git a/ompi/mca/coll/tuned/coll_tuned_gather.c b/ompi/mca/coll/tuned/coll_tuned_gather.c index 24ca8169ea..36f26caa27 100644 --- a/ompi/mca/coll/tuned/coll_tuned_gather.c +++ b/ompi/mca/coll/tuned/coll_tuned_gather.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -9,6 +10,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All Rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,6 +32,21 @@ #include "coll_tuned_topo.h" #include "coll_tuned_util.h" +/* gather algorithm variables */ +static int coll_tuned_gather_algorithm_count = 3; +static int coll_tuned_gather_forced_algorithm = 0; +static int coll_tuned_gather_segment_size = 0; +static int coll_tuned_gather_tree_fanout; +static int coll_tuned_gather_chain_fanout; + +/* valid values for coll_tuned_gather_forced_algorithm */ +static mca_base_var_enum_value_t gather_algorithms[] = { + {0, "ignore"}, + {1, "basic_linear"}, + {2, "binomial"}, + {3, "linear_sync"}, + {0, NULL} +}; /* Todo: gather_intra_generic, gather_intra_binary, gather_intra_chain, * gather_intra_pipeline, segmentation? */ @@ -418,54 +436,64 @@ ompi_coll_tuned_gather_intra_basic_linear(void *sbuf, int scount, int ompi_coll_tuned_gather_intra_check_forced_init(coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int rc, max_alg = 3, requested_alg; + mca_base_var_enum_t *new_enum; - ompi_coll_tuned_forced_max_algorithms[GATHER] = max_alg; + ompi_coll_tuned_forced_max_algorithms[GATHER] = coll_tuned_gather_algorithm_count; - rc = mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "gather_algorithm_count", - "Number of gather algorithms available", - false, true, max_alg, NULL); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "gather_algorithm_count", + "Number of gather algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_gather_algorithm_count); - mca_param_indices->algorithm_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "gather_algorithm", - "Which gather algorithm is used. Can be locked down to choice of: 0 ignore, 1 basic linear, 2 binomial, 3 linear with synchronization.", - false, false, 0, NULL); + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_gather_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_gather_algorithms", gather_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "gather_algorithm", + "Which gather algorithm is used. Can be locked down to choice of: 0 ignore, 1 basic linear, 2 binomial, 3 linear with synchronization.", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_gather_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int(mca_param_indices->algorithm_param_index, - &(requested_alg)); - if( 0 > requested_alg || requested_alg > max_alg ) { - if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { - opal_output( 0, "Gather algorithm #%d is not available (range [0..%d]). Switching back to default(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0); - } - mca_param_indices->segsize_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "gather_algorithm_segmentsize", - "Segment size in bytes used by default for gather algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation. Currently, available algorithms do not support segmentation.", - false, false, 0, NULL); + coll_tuned_gather_segment_size = 0; + mca_param_indices->segsize_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "gather_algorithm_segmentsize", + "Segment size in bytes used by default for gather algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation. Currently, available algorithms do not support segmentation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_gather_segment_size); - mca_param_indices->tree_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "gather_algorithm_tree_fanout", - "Fanout for n-tree used for gather algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation. Currently, available algorithms do not support n-tree topologies.", - false, false, - ompi_coll_tuned_init_tree_fanout, /* get system wide default */ - NULL); + coll_tuned_gather_tree_fanout = ompi_coll_tuned_init_tree_fanout; /* get system wide default */ + mca_param_indices->tree_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "gather_algorithm_tree_fanout", + "Fanout for n-tree used for gather algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation. Currently, available algorithms do not support n-tree topologies.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_gather_tree_fanout); - mca_param_indices->chain_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "gather_algorithm_chain_fanout", - "Fanout for chains used for gather algorithms. Only has meaning if algorithm is forced and supports chain topo based operation. Currently, available algorithms do not support chain topologies.", - false, false, - ompi_coll_tuned_init_chain_fanout, /* get system wide default */ - NULL); + coll_tuned_gather_chain_fanout = ompi_coll_tuned_init_chain_fanout; /* get system wide default */ + mca_param_indices->chain_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "gather_algorithm_chain_fanout", + "Fanout for chains used for gather algorithms. Only has meaning if algorithm is forced and supports chain topo based operation. Currently, available algorithms do not support chain topologies.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_gather_chain_fanout); return (MPI_SUCCESS); } diff --git a/ompi/mca/coll/tuned/coll_tuned_module.c b/ompi/mca/coll/tuned/coll_tuned_module.c index c96ff923ca..29b6262849 100644 --- a/ompi/mca/coll/tuned/coll_tuned_module.c +++ b/ompi/mca/coll/tuned/coll_tuned_module.c @@ -24,7 +24,6 @@ #include "mpi.h" #include "ompi/communicator/communicator.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/coll/coll.h" #include "ompi/mca/coll/base/base.h" #include "coll_tuned.h" @@ -121,6 +120,7 @@ ompi_coll_tuned_forced_getvalues( enum COLLTYPE type, coll_tuned_force_algorithm_params_t *forced_values ) { coll_tuned_force_algorithm_mca_param_indices_t* mca_params; + const int *tmp; mca_params = &(ompi_coll_tuned_forced_params[type]); @@ -129,13 +129,18 @@ ompi_coll_tuned_forced_getvalues( enum COLLTYPE type, * to see if it was setted explicitly (if we suppose that setting it to 0 enable the * default behavior) or not. */ - forced_values->algorithm = 0; - mca_base_param_lookup_int (mca_params->algorithm_param_index, &(forced_values->algorithm)); + mca_base_var_get_value(mca_params->algorithm_param_index, &tmp, NULL, NULL); + forced_values->algorithm = tmp ? tmp[0] : 0; + if( BARRIER != type ) { - mca_base_param_lookup_int (mca_params->segsize_param_index, &(forced_values->segsize)); - mca_base_param_lookup_int (mca_params->tree_fanout_param_index, &(forced_values->tree_fanout)); - mca_base_param_lookup_int (mca_params->chain_fanout_param_index, &(forced_values->chain_fanout)); - mca_base_param_lookup_int (mca_params->max_requests_param_index, &(forced_values->max_requests)); + mca_base_var_get_value(mca_params->segsize_param_index, &tmp, NULL, NULL); + if (tmp) forced_values->segsize = tmp[0]; + mca_base_var_get_value(mca_params->tree_fanout_param_index, &tmp, NULL, NULL); + if (tmp) forced_values->tree_fanout = tmp[0]; + mca_base_var_get_value(mca_params->chain_fanout_param_index, &tmp, NULL, NULL); + if (tmp) forced_values->chain_fanout = tmp[0]; + mca_base_var_get_value(mca_params->max_requests_param_index, &tmp, NULL, NULL); + if (tmp) forced_values->max_requests = tmp[0]; } return (MPI_SUCCESS); } @@ -159,7 +164,7 @@ ompi_coll_tuned_forced_getvalues( enum COLLTYPE type, } \ if( 1 == need_dynamic_decision ) { \ OPAL_OUTPUT((ompi_coll_tuned_stream,"coll:tuned: enable dynamic selection for "#TYPE)); \ - ompi_coll_tuned_use_dynamic_rules = 1; \ + ompi_coll_tuned_use_dynamic_rules = true; \ EXECUTE; \ } \ } @@ -219,7 +224,7 @@ tuned_module_enable( mca_coll_base_module_t *module, /** * Reset it to 0, it will be enabled again if we discover any need for dynamic decisions. */ - ompi_coll_tuned_use_dynamic_rules = 0; + ompi_coll_tuned_use_dynamic_rules = false; /** * next dynamic state, recheck all forced rules as well @@ -258,7 +263,7 @@ tuned_module_enable( mca_coll_base_module_t *module, COLL_TUNED_EXECUTE_IF_DYNAMIC(data, SCATTERV, tuned_module->super.coll_scatterv = NULL); - if( 0 == ompi_coll_tuned_use_dynamic_rules ) { + if( false == ompi_coll_tuned_use_dynamic_rules ) { /* no real need for dynamic decisions */ OPAL_OUTPUT((ompi_coll_tuned_stream, "coll:tuned:module_enable switch back to fixed" " decision by lack of dynamic rules")); diff --git a/ompi/mca/coll/tuned/coll_tuned_reduce.c b/ompi/mca/coll/tuned/coll_tuned_reduce.c index 66824489cc..a89dac9e77 100644 --- a/ompi/mca/coll/tuned/coll_tuned_reduce.c +++ b/ompi/mca/coll/tuned/coll_tuned_reduce.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -9,6 +10,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All Rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,6 +32,26 @@ #include "coll_tuned.h" #include "coll_tuned_topo.h" +/* reduce algorithm variables */ +static int coll_tuned_reduce_algorithm_count = 6; +static int coll_tuned_reduce_forced_algorithm = 0; +static int coll_tuned_reduce_segment_size = 0; +static int coll_tuned_reduce_max_requests; +static int coll_tuned_reduce_tree_fanout; +static int coll_tuned_reduce_chain_fanout; + +/* valid values for coll_tuned_reduce_forced_algorithm */ +static mca_base_var_enum_value_t reduce_algorithms[] = { + {0, "ignore"}, + {1, "linear"}, + {2, "chain"}, + {3, "pipeline"}, + {4, "binary"}, + {5, "binomial"}, + {6, "in-order_binary"}, + {0, NULL} +}; + /** * This is a generic implementation of the reduce protocol. It used the tree * provided as an argument and execute all operations using a segment of @@ -711,72 +734,86 @@ ompi_coll_tuned_reduce_intra_basic_linear(void *sbuf, void *rbuf, int count, * perms module does not call this they call the forced_getvalues routine * instead. */ + int ompi_coll_tuned_reduce_intra_check_forced_init (coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int rc, requested_alg, max_alg = 6, max_requests; + mca_base_var_enum_t*new_enum; - ompi_coll_tuned_forced_max_algorithms[REDUCE] = max_alg; + ompi_coll_tuned_forced_max_algorithms[REDUCE] = coll_tuned_reduce_algorithm_count; - rc = mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "reduce_algorithm_count", - "Number of reduce algorithms available", - false, true, max_alg, NULL); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_algorithm_count", + "Number of reduce algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_reduce_algorithm_count); - mca_param_indices->algorithm_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "reduce_algorithm", - "Which reduce algorithm is used. Can be locked down to choice of: 0 ignore, 1 linear, 2 chain, 3 pipeline, 4 binary, 5 binomial, 6 in-order binary", - false, false, 0, NULL); + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_reduce_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_reduce_algorithms", reduce_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_algorithm", + "Which reduce algorithm is used. Can be locked down to choice of: 0 ignore, 1 linear, 2 chain, 3 pipeline, 4 binary, 5 binomial, 6 in-order binary", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_reduce_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int(mca_param_indices->algorithm_param_index, &(requested_alg)); - if( 0 > requested_alg || requested_alg > max_alg ) { - if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { - opal_output( 0, "Reduce algorithm #%d is not available (range [0..%d]). Switching back to ignore(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0); - } - mca_param_indices->segsize_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "reduce_algorithm_segmentsize", - "Segment size in bytes used by default for reduce algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.", - false, false, 0, NULL); + coll_tuned_reduce_segment_size = 0; + mca_param_indices->segsize_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_algorithm_segmentsize", + "Segment size in bytes used by default for reduce algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_reduce_segment_size); - mca_param_indices->tree_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "reduce_algorithm_tree_fanout", - "Fanout for n-tree used for reduce algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.", - false, false, - ompi_coll_tuned_init_tree_fanout, /* get system wide default */ - NULL); + coll_tuned_reduce_tree_fanout = ompi_coll_tuned_init_tree_fanout; /* get system wide default */ + mca_param_indices->tree_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_algorithm_tree_fanout", + "Fanout for n-tree used for reduce algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_reduce_tree_fanout); - mca_param_indices->chain_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "reduce_algorithm_chain_fanout", - "Fanout for chains used for reduce algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.", - false, false, - ompi_coll_tuned_init_chain_fanout, /* get system wide default */ - NULL); - - mca_param_indices->max_requests_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "reduce_algorithm_max_requests", - "Maximum number of outstanding send requests on leaf nodes. 0 means no limit.", - false, false, 0, /* no limit for reduce by default */ - NULL); + coll_tuned_reduce_chain_fanout = ompi_coll_tuned_init_chain_fanout; /* get system wide default */ + mca_param_indices->chain_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_algorithm_chain_fanout", + "Fanout for chains used for reduce algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_reduce_chain_fanout); + coll_tuned_reduce_max_requests = 0; /* no limit for reduce by default */ + mca_param_indices->max_requests_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_algorithm_max_requests", + "Maximum number of outstanding send requests on leaf nodes. 0 means no limit.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_reduce_max_requests); if (mca_param_indices->max_requests_param_index < 0) { return mca_param_indices->max_requests_param_index; } - mca_base_param_lookup_int(mca_param_indices->max_requests_param_index, &(max_requests)); - if( max_requests < 0 ) { + + if (coll_tuned_reduce_max_requests < 0) { if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { opal_output( 0, "Maximum outstanding requests must be positive number or 0. Initializing to 0 (no limit).\n" ); } - mca_base_param_set_int( mca_param_indices->max_requests_param_index, 0); + coll_tuned_reduce_max_requests = 0; } return (MPI_SUCCESS); diff --git a/ompi/mca/coll/tuned/coll_tuned_reduce_scatter.c b/ompi/mca/coll/tuned/coll_tuned_reduce_scatter.c index 1a5470f7f8..810f133704 100644 --- a/ompi/mca/coll/tuned/coll_tuned_reduce_scatter.c +++ b/ompi/mca/coll/tuned/coll_tuned_reduce_scatter.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -32,6 +33,22 @@ #include "coll_tuned.h" #include "coll_tuned_topo.h" +/* reduce_scatter algorithm variables */ +static int coll_tuned_reduce_scatter_algorithm_count = 2; +static int coll_tuned_reduce_scatter_forced_algorithm = 0; +static int coll_tuned_reduce_scatter_segment_size = 0; +static int coll_tuned_reduce_scatter_tree_fanout; +static int coll_tuned_reduce_scatter_chain_fanout; + +/* valid values for coll_tuned_reduce_scatter_forced_algorithm */ +static mca_base_var_enum_value_t reduce_scatter_algorithms[] = { + {0, "ignore"}, + {1, "non-overlapping"}, + {2, "recursive_halfing"}, + {3, "ring"}, + {0, NULL} +}; + /******************************************************************************* * ompi_coll_tuned_reduce_scatter_intra_nonoverlapping * @@ -629,55 +646,68 @@ ompi_coll_tuned_reduce_scatter_intra_ring(void *sbuf, void *rbuf, int *rcounts, * perms module does not call this they call the forced_getvalues routine * instead */ + int ompi_coll_tuned_reduce_scatter_intra_check_forced_init (coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int rc, requested_alg, max_alg = 3; + mca_base_var_enum_t *new_enum; - ompi_coll_tuned_forced_max_algorithms[REDUCESCATTER] = max_alg; + ompi_coll_tuned_forced_max_algorithms[REDUCESCATTER] = coll_tuned_reduce_scatter_algorithm_count; - rc = mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "reduce_scatter_algorithm_count", - "Number of reduce_scatter algorithms available", - false, true, max_alg, NULL); - - mca_param_indices->algorithm_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "reduce_scatter_algorithm", - "Which reduce reduce_scatter algorithm is used. Can be locked down to choice of: 0 ignore, 1 non-overlapping (Reduce + Scatterv), 2 recursive halving, 3 ring", - false, false, 0, NULL); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_scatter_algorithm_count", + "Number of reduce_scatter algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_reduce_scatter_algorithm_count); + + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_reduce_scatter_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_reduce_scatter_algorithms", reduce_scatter_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_scatter_algorithm", + "Which reduce reduce_scatter algorithm is used. Can be locked down to choice of: 0 ignore, 1 non-overlapping (Reduce + Scatterv), 2 recursive halving, 3 ring", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_reduce_scatter_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int(mca_param_indices->algorithm_param_index, &(requested_alg)); - if( 0 > requested_alg || requested_alg > max_alg ) { - if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { - opal_output( 0, "Reduce_scatter algorithm #%d is not available (range [0..%d]). Switching back to ignore(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0); - } - mca_param_indices->segsize_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "reduce_scatter_algorithm_segmentsize", - "Segment size in bytes used by default for reduce_scatter algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.", - false, false, 0, NULL); + coll_tuned_reduce_scatter_segment_size = 0; + mca_param_indices->segsize_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_scatter_algorithm_segmentsize", + "Segment size in bytes used by default for reduce_scatter algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_reduce_scatter_segment_size); - mca_param_indices->tree_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "reduce_scatter_algorithm_tree_fanout", - "Fanout for n-tree used for reduce_scatter algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.", - false, false, - ompi_coll_tuned_init_tree_fanout, /* get system wide default */ - NULL); + coll_tuned_reduce_scatter_tree_fanout = ompi_coll_tuned_init_tree_fanout; /* get system wide default */ + mca_param_indices->tree_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_scatter_algorithm_tree_fanout", + "Fanout for n-tree used for reduce_scatter algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_reduce_scatter_tree_fanout); + + coll_tuned_reduce_scatter_chain_fanout = ompi_coll_tuned_init_chain_fanout; /* get system wide default */ + mca_param_indices->chain_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "reduce_scatter_algorithm_chain_fanout", + "Fanout for chains used for reduce_scatter algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_reduce_scatter_chain_fanout); - mca_param_indices->chain_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "reduce_scatter_algorithm_chain_fanout", - "Fanout for chains used for reduce_scatter algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.", - false, false, - ompi_coll_tuned_init_chain_fanout, /* get system wide default */ - NULL); return (MPI_SUCCESS); } diff --git a/ompi/mca/coll/tuned/coll_tuned_scatter.c b/ompi/mca/coll/tuned/coll_tuned_scatter.c index 996f0cf7e5..b8a76846d7 100644 --- a/ompi/mca/coll/tuned/coll_tuned_scatter.c +++ b/ompi/mca/coll/tuned/coll_tuned_scatter.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -9,6 +10,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -29,6 +32,20 @@ #include "coll_tuned_topo.h" #include "coll_tuned_util.h" +/* scatter algorithm variables */ +static int coll_tuned_scatter_algorithm_count = 2; +static int coll_tuned_scatter_forced_algorithm = 0; +static int coll_tuned_scatter_segment_size = 0; +static int coll_tuned_scatter_tree_fanout; +static int coll_tuned_scatter_chain_fanout; + +/* valid values for coll_tuned_scatter_forced_algorithm */ +static mca_base_var_enum_value_t scatter_algorithms[] = { + {0, "ignore"}, + {1, "basic_linear"}, + {2, "binomial"}, + {0, NULL} +}; int ompi_coll_tuned_scatter_intra_binomial(void *sbuf, int scount, @@ -267,54 +284,64 @@ ompi_coll_tuned_scatter_intra_basic_linear(void *sbuf, int scount, int ompi_coll_tuned_scatter_intra_check_forced_init(coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices) { - int rc, max_alg = 2, requested_alg; + mca_base_var_enum_t *new_enum; - ompi_coll_tuned_forced_max_algorithms[SCATTER] = max_alg; + ompi_coll_tuned_forced_max_algorithms[SCATTER] = coll_tuned_scatter_algorithm_count; - rc = mca_base_param_reg_int (&mca_coll_tuned_component.super.collm_version, - "scatter_algorithm_count", - "Number of scatter algorithms available", - false, true, max_alg, NULL); + (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "scatter_algorithm_count", + "Number of scatter algorithms available", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &coll_tuned_scatter_algorithm_count); - mca_param_indices->algorithm_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "scatter_algorithm", - "Which scatter algorithm is used. Can be locked down to choice of: 0 ignore, 1 basic linear, 2 binomial.", - false, false, 0, NULL); + /* MPI_T: This variable should eventually be bound to a communicator */ + coll_tuned_scatter_forced_algorithm = 0; + (void) mca_base_var_enum_create("coll_tuned_scatter_algorithms", scatter_algorithms, &new_enum); + mca_param_indices->algorithm_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "scatter_algorithm", + "Which scatter algorithm is used. Can be locked down to choice of: 0 ignore, 1 basic linear, 2 binomial.", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_scatter_forced_algorithm); + OBJ_RELEASE(new_enum); if (mca_param_indices->algorithm_param_index < 0) { return mca_param_indices->algorithm_param_index; } - mca_base_param_lookup_int(mca_param_indices->algorithm_param_index, - &(requested_alg)); - if( 0 > requested_alg || requested_alg > max_alg ) { - if( 0 == ompi_comm_rank( MPI_COMM_WORLD ) ) { - opal_output( 0, "Scatter algorithm #%d is not available (range [0..%d]). Switching back to ignore(0)\n", - requested_alg, max_alg ); - } - mca_base_param_set_int( mca_param_indices->algorithm_param_index, 0); - } - mca_param_indices->segsize_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "scatter_algorithm_segmentsize", - "Segment size in bytes used by default for scatter algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation. Currently, available algorithms do not support segmentation.", - false, false, 0, NULL); + coll_tuned_scatter_segment_size = 0; + mca_param_indices->segsize_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "scatter_algorithm_segmentsize", + "Segment size in bytes used by default for scatter algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation. Currently, available algorithms do not support segmentation.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_scatter_segment_size); - mca_param_indices->tree_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "scatter_algorithm_tree_fanout", - "Fanout for n-tree used for scatter algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation. Currently, available algorithms do not support n-tree topologies.", - false, false, - ompi_coll_tuned_init_tree_fanout, /* get system wide default */ - NULL); + coll_tuned_scatter_tree_fanout = ompi_coll_tuned_init_tree_fanout; /* get system wide default */ + mca_param_indices->tree_fanout_param_index = + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "scatter_algorithm_tree_fanout", + "Fanout for n-tree used for scatter algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation. Currently, available algorithms do not support n-tree topologies.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_scatter_tree_fanout); - mca_param_indices->chain_fanout_param_index - = mca_base_param_reg_int(&mca_coll_tuned_component.super.collm_version, - "scatter_algorithm_chain_fanout", - "Fanout for chains used for scatter algorithms. Only has meaning if algorithm is forced and supports chain topo based operation. Currently, available algorithms do not support chain topologies.", - false, false, - ompi_coll_tuned_init_chain_fanout, /* get system wide default */ - NULL); + coll_tuned_scatter_chain_fanout = ompi_coll_tuned_init_chain_fanout; /* get system wide default */ + mca_param_indices->chain_fanout_param_index= + mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version, + "scatter_algorithm_chain_fanout", + "Fanout for chains used for scatter algorithms. Only has meaning if algorithm is forced and supports chain topo based operation. Currently, available algorithms do not support chain topologies.", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &coll_tuned_scatter_chain_fanout); return (MPI_SUCCESS); } diff --git a/ompi/mca/common/cuda/common_cuda.c b/ompi/mca/common/cuda/common_cuda.c index e851c7b706..5b5859cda7 100644 --- a/ompi/mca/common/cuda/common_cuda.c +++ b/ompi/mca/common/cuda/common_cuda.c @@ -30,7 +30,6 @@ #include #include "opal/align.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/datatype/opal_convertor.h" #include "opal/datatype/opal_datatype_cuda.h" #include "opal/util/output.h" @@ -182,6 +181,69 @@ static void cuda_dump_memhandle(int, void *, char *) __opal_attribute_unused__ ; #endif /* OMPI_CUDA_SUPPORT_41 */ +int mca_common_cuda_register_mca_variables(void) +{ + static bool registered = false; + + if (registered) { + return OMPI_SUCCESS; + } + + registered = true; + + /* Set different levels of verbosity in the cuda related code. */ + mca_common_cuda_verbose = 0; + (void) mca_base_var_register("ompi", "mpi", "common_cuda", "verbose", + "Set level of common cuda verbosity", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_common_cuda_verbose); + + /* Control whether system buffers get CUDA pinned or not. Allows for + * performance analysis. */ + mca_common_cuda_register_memory = true; + (void) mca_base_var_register("ompi", "mpi", "common_cuda", "register_memory", + "Whether to cuMemHostRegister preallocated BTL buffers", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_common_cuda_register_memory); + + /* Control whether we see warnings when CUDA memory registration fails. This is + * useful when CUDA support is configured in, but we are running a regular MPI + * application without CUDA. */ + mca_common_cuda_warning = true; + (void) mca_base_var_register("ompi", "mpi", "common_cuda", "warning", + "Whether to print warnings when CUDA registration fails", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_common_cuda_warning); + +#if OMPI_CUDA_SUPPORT_41 + /* Use this flag to test async vs sync copies */ + mca_common_cuda_async = 1; + (void) mca_base_var_register("ompi", "mpi", "common_cuda", "memcpy_async", + "Set to 0 to force CUDA sync copy instead of async", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_common_cuda_async); + + /* Use this parameter to increase the number of outstanding events allows */ + cuda_event_max = 200; + (void) mca_base_var_register("ompi", "mpi", "common_cuda", "event_max", + "Set number of oustanding CUDA events", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cuda_event_max); +#endif /* OMPI_CUDA_SUPPORT_41 */ + + return OMPI_SUCCESS; +} + /** * This function is registered with the OPAL CUDA support. In that way, * we will complete initialization when OPAL detects the first GPU memory @@ -203,35 +265,17 @@ static int mca_common_cuda_init(opal_common_cuda_function_table_t *ftable) return OMPI_SUCCESS; } + /* Make sure this component's variables are registered */ + mca_common_cuda_register_mca_variables(); + ftable->gpu_is_gpu_buffer = &mca_common_cuda_is_gpu_buffer; ftable->gpu_cu_memcpy_async = &mca_common_cuda_cu_memcpy_async; ftable->gpu_cu_memcpy = &mca_common_cuda_cu_memcpy; ftable->gpu_memmove = &mca_common_cuda_memmove; - /* Set different levels of verbosity in the cuda related code. */ - id = mca_base_param_reg_int_name("mpi", "common_cuda_verbose", - "Set level of common cuda verbosity", - false, false, 0, &mca_common_cuda_verbose); mca_common_cuda_output = opal_output_open(NULL); opal_output_set_verbosity(mca_common_cuda_output, mca_common_cuda_verbose); - /* Control whether system buffers get CUDA pinned or not. Allows for - * performance analysis. */ - id = mca_base_param_reg_int_name("mpi", "common_cuda_register_memory", - "Whether to cuMemHostRegister preallocated BTL buffers", - false, false, - (int) mca_common_cuda_register_memory, &value); - mca_common_cuda_register_memory = OPAL_INT_TO_BOOL(value); - - /* Control whether we see warnings when CUDA memory registration fails. This is - * useful when CUDA support is configured in, but we are running a regular MPI - * application without CUDA. */ - id = mca_base_param_reg_int_name("mpi", "common_cuda_warning", - "Whether to print warnings when CUDA registration fails", - false, false, - (int) mca_common_cuda_warning, &value); - mca_common_cuda_warning = OPAL_INT_TO_BOOL(value); - /* If we cannot load the libary, then disable support */ if (0 != mca_common_cuda_load_libcuda()) { common_cuda_initialized = true; @@ -239,20 +283,6 @@ static int mca_common_cuda_init(opal_common_cuda_function_table_t *ftable) return OMPI_ERROR; } -#if OMPI_CUDA_SUPPORT_41 - /* Use this flag to test async vs sync copies */ - id = mca_base_param_reg_int_name("mpi", "common_cuda_memcpy_async", - "Set to 0 to force CUDA sync copy instead of async", - false, false, mca_common_cuda_async, &i); - mca_common_cuda_async = i; - - /* Use this parameter to increase the number of outstanding events allows */ - id = mca_base_param_reg_int_name("mpi", "common_cuda_event_max", - "Set number of oustanding CUDA events", - false, false, cuda_event_max, &i); - cuda_event_max = i; -#endif /* OMPI_CUDA_SUPPORT_41 */ - /* Check to see if this process is running in a CUDA context. If * so, all is good. If not, then disable registration of memory. */ res = cuFunc.cuCtxGetCurrent(&cuContext); diff --git a/ompi/mca/common/cuda/common_cuda.h b/ompi/mca/common/cuda/common_cuda.h index f64dbf5735..0ab7c2a80c 100644 --- a/ompi/mca/common/cuda/common_cuda.h +++ b/ompi/mca/common/cuda/common_cuda.h @@ -31,6 +31,8 @@ struct mca_mpool_common_cuda_reg_t { }; typedef struct mca_mpool_common_cuda_reg_t mca_mpool_common_cuda_reg_t; +OMPI_DECLSPEC int mca_common_cuda_register_mca_variables(void); + OMPI_DECLSPEC void mca_common_cuda_register(void *ptr, size_t amount, char *msg); OMPI_DECLSPEC void mca_common_cuda_unregister(void *ptr, char *msg); diff --git a/ompi/mca/common/mx/common_mx.c b/ompi/mca/common/mx/common_mx.c index c13df5b4e0..949a383354 100644 --- a/ompi/mca/common/mx/common_mx.c +++ b/ompi/mca/common/mx/common_mx.c @@ -27,7 +27,6 @@ #include #include "opal/memoryhooks/memory.h" #include "opal/util/output.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/runtime/params.h" diff --git a/ompi/mca/common/ofacm/common_ofacm_base.c b/ompi/mca/common/ofacm/common_ofacm_base.c index 126a3b558a..c75ad637d6 100644 --- a/ompi/mca/common/ofacm/common_ofacm_base.c +++ b/ompi/mca/common/ofacm/common_ofacm_base.c @@ -26,9 +26,12 @@ #include "opal/util/show_help.h" #include "infiniband/verbs.h" -/* Global variables */ static ompi_common_ofacm_base_component_t **available = NULL; static int num_available = 0; +static char *ompi_common_ofacm_cpc_include; +static char *ompi_common_ofacm_cpc_exclude; + +/* Global variables */ int ompi_common_ofacm_base_verbose = 0; /* disabled by default */ char* ompi_common_ofacm_three_dim_torus = NULL; bool cpc_explicitly_defined = false; @@ -196,6 +199,7 @@ ompi_common_ofacm_base_proc_t* ompi_common_ofacm_base_find_proc } return ret; } + /* * Register MCA parameters */ @@ -203,7 +207,6 @@ int ompi_common_ofacm_base_register(mca_base_component_t *base) { int i, j, save; char **temp = NULL, *string = NULL, *all_cpc_names = NULL; - char *cpc_include = NULL, *cpc_exclude = NULL; if (ompi_common_ofacm_base_register_was_called) { return OMPI_SUCCESS; @@ -224,30 +227,41 @@ int ompi_common_ofacm_base_register(mca_base_component_t *base) "Method used to select OpenFabrics connections (valid values: %s)", all_cpc_names); - mca_base_param_reg_string(base, "ofacm_cpc_include", string, false, false, - NULL, &cpc_include); + ompi_common_ofacm_cpc_include = NULL; + (void) mca_base_component_var_register(base, "ofacm_cpc_include", string, + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_common_ofacm_cpc_include); free(string); asprintf(&string, "Method used to exclude OpenFabrics connections (valid values: %s)", all_cpc_names); - - mca_base_param_reg_string(base, "ofacm_cpc_exclude", string, false, false, - NULL, &cpc_exclude); + ompi_common_ofacm_cpc_exclude = NULL; + (void) mca_base_component_var_register(base, "ofacm_cpc_exclude", string, + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_common_ofacm_cpc_exclude); free(string); /* Register the name of the file containing the fabric's Service Levels (SL) */ - mca_base_param_reg_string_name("common", "ofacm_three_dim_torus", - "The name of the file contating Service Level (SL) data for 3D-Torus cluster", - false, false, NULL, &ompi_common_ofacm_three_dim_torus); + ompi_common_ofacm_three_dim_torus = NULL; + (void) mca_base_var_register("ompi", "common", "ofacm", "three_dim_torus", + "The name of the file contating Service Level (SL) data for 3D-Torus cluster", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_common_ofacm_three_dim_torus); - - mca_base_param_reg_int_name("common", - "ofacm_base_verbose", - "Verbosity level of the OFACM framework", - false, false, - 0, - &ompi_common_ofacm_base_verbose); + ompi_common_ofacm_base_verbose = 0; + (void) mca_base_var_register("ompi", "common", "ofacm", "base_verbose", + "Verbosity level of the OFACM framework", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_common_ofacm_base_verbose); /* Parse the if_[in|ex]clude paramters to come up with a list of @@ -256,9 +270,9 @@ int ompi_common_ofacm_base_register(mca_base_component_t *base) /* If we have an "include" list, then find all those CPCs and put them in available[] */ - if (NULL != cpc_include) { + if (NULL != ompi_common_ofacm_cpc_include) { cpc_explicitly_defined = true; - temp = opal_argv_split(cpc_include, ','); + temp = opal_argv_split(ompi_common_ofacm_cpc_include, ','); for (save = j = 0; NULL != temp[j]; ++j) { for (i = 0; NULL != all[i]; ++i) { if (0 == strcmp(temp[j], all[i]->cbc_name)) { @@ -272,7 +286,7 @@ int ompi_common_ofacm_base_register(mca_base_component_t *base) opal_show_help("help-mpi-common-ofacm-cpc-base.txt", "cpc name not found", true, "include", ompi_process_info.nodename, - "include", cpc_include, temp[j], + "include", ompi_common_ofacm_cpc_include, temp[j], all_cpc_names); opal_argv_free(temp); free(all_cpc_names); @@ -284,9 +298,9 @@ int ompi_common_ofacm_base_register(mca_base_component_t *base) /* Otherwise, if we have an "exclude" list, take all the CPCs that are not in that list and put them in available[] */ - else if (NULL != cpc_exclude) { + else if (NULL != ompi_common_ofacm_cpc_exclude) { cpc_explicitly_defined = true; - temp = opal_argv_split(cpc_exclude, ','); + temp = opal_argv_split(ompi_common_ofacm_cpc_exclude, ','); /* First: error check -- ensure that all the names are valid */ for (j = 0; NULL != temp[j]; ++j) { for (i = 0; NULL != all[i]; ++i) { @@ -298,7 +312,7 @@ int ompi_common_ofacm_base_register(mca_base_component_t *base) opal_show_help("help-mpi-common-ofacm-cpc-base.txt", "cpc name not found", true, "exclude", ompi_process_info.nodename, - "exclude", cpc_exclude, temp[j], + "exclude", ompi_common_ofacm_cpc_exclude, temp[j], all_cpc_names); opal_argv_free(temp); free(all_cpc_names); diff --git a/ompi/mca/common/ofacm/common_ofacm_oob.c b/ompi/mca/common/ofacm/common_ofacm_oob.c index b3d36b57b1..9f00f9f5eb 100644 --- a/ompi/mca/common/ofacm/common_ofacm_oob.c +++ b/ompi/mca/common/ofacm/common_ofacm_oob.c @@ -130,16 +130,13 @@ ompi_common_ofacm_base_component_t ompi_common_ofacm_oob = { /* Open - this functions sets up any oob specific commandline params */ static void oob_component_register(void) { - mca_base_param_reg_int_name("common", - "ofacm_connect_oob_priority", - "The selection method priority for oob", - false, false, oob_priority, &oob_priority); - - if (oob_priority > 100) { - oob_priority = 100; - } else if (oob_priority < -1) { - oob_priority = -1; - } + oob_priority = 50; + (void) mca_base_var_register("ompi", "common", "ofacm", "connect_oob_priority", + "The selection method priority for oob", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &oob_priority); } /* @@ -151,6 +148,12 @@ static int oob_component_query(ompi_common_ofacm_base_dev_desc_t *dev, { int rc; + if (oob_priority > 100) { + oob_priority = 100; + } else if (oob_priority < -1) { + oob_priority = -1; + } + /* If we have the transport_type member, check to ensure we're on IB (this CPC will not work with iWarp). If we do not have the transport_type member, then we must be < OFED v1.2, and diff --git a/ompi/mca/common/ofacm/common_ofacm_xoob.c b/ompi/mca/common/ofacm/common_ofacm_xoob.c index 5508982c59..fc93f53311 100644 --- a/ompi/mca/common/ofacm/common_ofacm_xoob.c +++ b/ompi/mca/common/ofacm/common_ofacm_xoob.c @@ -1378,6 +1378,12 @@ static int xoob_component_query(ompi_common_ofacm_base_dev_desc_t *dev, ompi_common_ofacm_xoob_module_t *xcpc; /* xoob cpc module */ ompi_common_ofacm_base_module_t *bcpc; /* base cpc module */ + if (xoob_priority > 100) { + xoob_priority = 100; + } else if (xoob_priority < -1) { + xoob_priority = -1; + } + if (!(dev->capabilities & OMPI_COMMON_OFACM_XRC_ONLY)) { OFACM_VERBOSE(("openib BTL: xoob CPC only supported with XRC receive queues; skipped on device %s", ibv_get_device_name(dev->ib_dev))); @@ -1444,16 +1450,12 @@ static int xoob_component_query(ompi_common_ofacm_base_dev_desc_t *dev, /* Open - this functions sets up any xoob specific commandline params */ static void xoob_component_register(void) { - mca_base_param_reg_int_name("common", - "ofacm_connect_xoob_priority", - "The selection method priority for xoob", - false, false, xoob_priority, &xoob_priority); - - if (xoob_priority > 100) { - xoob_priority = 100; - } else if (xoob_priority < -1) { - xoob_priority = -1; - } + xoob_priority = 60; + (void) mca_base_var_register("ompi", "common", "ofacm", "connect_xoob_priority", + "The selection method priority for xoob", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &xoob_priority); } /* diff --git a/ompi/mca/common/verbs/common_verbs_mca.c b/ompi/mca/common/verbs/common_verbs_mca.c index 684e69f14a..b633226448 100644 --- a/ompi/mca/common/verbs/common_verbs_mca.c +++ b/ompi/mca/common/verbs/common_verbs_mca.c @@ -10,10 +10,10 @@ #include "ompi_config.h" -#include "opal/mca/base/mca_base_param.h" - #include "common_verbs.h" +#include "opal/mca/base/mca_base_var.h" + /***********************************************************************/ static bool registered = false; @@ -23,34 +23,25 @@ bool ompi_common_verbs_warn_nonexistent_if = true; static void register_internal(void) { - int ival; - + ompi_common_verbs_warn_nonexistent_if = true; warn_nonexistent_if_index = - mca_base_param_reg_int_name("ompi_common_verbs", - "warn_nonexistent_if", - "Warn if non-existent devices and/or ports are specified in device include/exclude MCA parameters " - "(0 = do not warn; any other value = warn)", - false, false, - (int) ompi_common_verbs_warn_nonexistent_if, - &ival); - ompi_common_verbs_warn_nonexistent_if = (bool) ival; + mca_base_var_register("ompi", "ompi_common", "verbs", "warn_nonexistent_if", + "Warn if non-existent devices and/or ports are specified in device include/exclude MCA parameters " + "(0 = do not warn; any other value = warn)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_LOCAL, + &ompi_common_verbs_warn_nonexistent_if); registered = true; } void ompi_common_verbs_mca_register(mca_base_component_t *component) { - int ival; - if (!registered) { register_internal(); } - /* Make synonyms for the common_verbs MCA params. Need to look up - the value again, because a new/different value may have been - set by the new synonym name. */ - mca_base_param_reg_syn(warn_nonexistent_if_index, component, - "warn_nonexistent_if", false); - mca_base_param_lookup_int(warn_nonexistent_if_index, &ival); - ompi_common_verbs_warn_nonexistent_if = (bool) ival; + /* Make synonym for the common_verbs MCA params. */ + mca_base_var_register_synonym(warn_nonexistent_if_index, "ompi", component->mca_type_name, + component->mca_component_name, "warn_nonexistent_if", 0); } diff --git a/ompi/mca/crcp/base/crcp_base_close.c b/ompi/mca/crcp/base/crcp_base_close.c index c994d6442d..c1f0961bc9 100644 --- a/ompi/mca/crcp/base/crcp_base_close.c +++ b/ompi/mca/crcp/base/crcp_base_close.c @@ -19,8 +19,6 @@ #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" - #include "ompi/mca/crcp/crcp.h" #include "ompi/mca/crcp/base/base.h" diff --git a/ompi/mca/crcp/base/crcp_base_fns.c b/ompi/mca/crcp/base/crcp_base_fns.c index 504c3ff62c..c64fc1266b 100644 --- a/ompi/mca/crcp/base/crcp_base_fns.c +++ b/ompi/mca/crcp/base/crcp_base_fns.c @@ -29,7 +29,6 @@ #include "opal/mca/mca.h" #include "opal/mca/base/base.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/mca/crs/crs.h" #include "opal/mca/crs/base/base.h" diff --git a/ompi/mca/crcp/base/crcp_base_open.c b/ompi/mca/crcp/base/crcp_base_open.c index 50e612b0ae..715b6fa178 100644 --- a/ompi/mca/crcp/base/crcp_base_open.c +++ b/ompi/mca/crcp/base/crcp_base_open.c @@ -20,9 +20,6 @@ #include "opal/util/output.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" - - #include "ompi/mca/crcp/crcp.h" #include "ompi/mca/crcp/base/base.h" @@ -45,8 +42,6 @@ ompi_crcp_base_component_t ompi_crcp_base_selected_component; */ int ompi_crcp_base_open(void) { - char *str_value = NULL; - ompi_crcp_base_output = opal_output_open(NULL); /* @@ -57,13 +52,6 @@ int ompi_crcp_base_open(void) * Note: Set the default to NULL here so ompi_info will work correctly, * The 'real' default is set in base_select.c */ - mca_base_param_reg_string_name("crcp", NULL, - "Which CRCP component to use (empty = auto-select)", - false, false, - NULL, &str_value); - if( NULL != str_value ) { - free(str_value); - } /* Open up all available components */ if (OPAL_SUCCESS != diff --git a/ompi/mca/crcp/base/crcp_base_select.c b/ompi/mca/crcp/base/crcp_base_select.c index 54baa6abf6..ceb3a0d051 100644 --- a/ompi/mca/crcp/base/crcp_base_select.c +++ b/ompi/mca/crcp/base/crcp_base_select.c @@ -20,8 +20,6 @@ #include "opal/util/output.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" - #include "ompi/mca/crcp/crcp.h" #include "ompi/mca/crcp/base/base.h" @@ -122,17 +120,27 @@ int ompi_crcp_base_select(void) int ret, exit_status = OMPI_SUCCESS; ompi_crcp_base_component_t *best_component = NULL; ompi_crcp_base_module_t *best_module = NULL; - char *include_list = NULL; + const char *include_list = NULL; + const char **selection_value; + int var_id; /* * Register the framework MCA param and look up include list */ - mca_base_param_reg_string_name("crcp", NULL, - "Which CRCP component to use (empty = auto-select)", - false, false, - strdup("none"), &include_list); + var_id = mca_base_var_find("ompi", "crcp", NULL, NULL); - if(NULL != include_list && 0 == strncmp(include_list, "none", strlen("none")) ){ + /* NTH: The old parameter code here set the selection to none if no file value + or environment value was set. This effectively means include_list is never NULL. */ + selection_value = NULL; + (void) mca_base_var_get_value(var_id, &selection_value, NULL, NULL); + if (NULL == selection_value || NULL == selection_value[0]) { + (void) mca_base_var_set_value(var_id, "none", 5, MCA_BASE_VAR_SOURCE_DEFAULT, NULL); + include_list = "none"; + } else { + include_list = selection_value[0]; + } + + if(0 == strncmp(include_list, "none", strlen("none")) ){ opal_output_verbose(10, ompi_crcp_base_output, "crcp:select: Using %s component", include_list); @@ -172,10 +180,6 @@ int ompi_crcp_base_select(void) } cleanup: - if( NULL != include_list ) { - free(include_list); - include_list = NULL; - } return exit_status; } diff --git a/ompi/mca/crcp/bkmrk/crcp_bkmrk.h b/ompi/mca/crcp/bkmrk/crcp_bkmrk.h index 734dcaac28..fd24331214 100644 --- a/ompi/mca/crcp/bkmrk/crcp_bkmrk.h +++ b/ompi/mca/crcp/bkmrk/crcp_bkmrk.h @@ -45,7 +45,7 @@ BEGIN_C_DECLS /* * Local variables */ - extern int timing_enabled; + extern bool timing_enabled; /* * Module functions diff --git a/ompi/mca/crcp/bkmrk/crcp_bkmrk_btl.c b/ompi/mca/crcp/bkmrk/crcp_bkmrk_btl.c index 58889061c0..2152296ce9 100644 --- a/ompi/mca/crcp/bkmrk/crcp_bkmrk_btl.c +++ b/ompi/mca/crcp/bkmrk/crcp_bkmrk_btl.c @@ -24,7 +24,6 @@ #include "opal/class/opal_bitmap.h" #include "opal/mca/event/event.h" #include "opal/util/opal_environ.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" diff --git a/ompi/mca/crcp/bkmrk/crcp_bkmrk_component.c b/ompi/mca/crcp/bkmrk/crcp_bkmrk_component.c index 62d865b99f..133101efda 100644 --- a/ompi/mca/crcp/bkmrk/crcp_bkmrk_component.c +++ b/ompi/mca/crcp/bkmrk/crcp_bkmrk_component.c @@ -28,11 +28,12 @@ const char *ompi_crcp_bkmrk_component_version_string = "OMPI CRCP bkmrk MCA component version " OMPI_VERSION; -int timing_enabled = 0; +bool timing_enabled; /* * Local functionality */ +static int crcp_bkmrk_register(void); static int crcp_bkmrk_open(void); static int crcp_bkmrk_close(void); @@ -57,7 +58,8 @@ ompi_crcp_bkmrk_component_t mca_crcp_bkmrk_component = { /* Component open and close functions */ crcp_bkmrk_open, crcp_bkmrk_close, - ompi_crcp_bkmrk_component_query + ompi_crcp_bkmrk_component_query, + crcp_bkmrk_register }, { /* The component is checkpoint ready */ @@ -73,27 +75,43 @@ ompi_crcp_bkmrk_component_t mca_crcp_bkmrk_component = { } }; -static int crcp_bkmrk_open(void) +static int crcp_bkmrk_register(void) { - int val; - /* * This should be the last componet to ever get used since * it doesn't do anything. */ - mca_base_param_reg_int(&mca_crcp_bkmrk_component.super.base_version, - "priority", - "Priority of the CRCP bkmrk component", - false, false, - mca_crcp_bkmrk_component.super.priority, - &mca_crcp_bkmrk_component.super.priority); - - mca_base_param_reg_int(&mca_crcp_bkmrk_component.super.base_version, - "verbose", - "Verbose level for the CRCP bkmrk component", - false, false, - mca_crcp_bkmrk_component.super.verbose, - &mca_crcp_bkmrk_component.super.verbose); + mca_crcp_bkmrk_component.super.priority = 20; + (void) mca_base_component_var_register(&mca_crcp_bkmrk_component.super.base_version, + "priority", + "Priority of the CRCP bkmrk component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_crcp_bkmrk_component.super.priority); + + mca_crcp_bkmrk_component.super.verbose = 0; + (void) mca_base_component_var_register(&mca_crcp_bkmrk_component.super.base_version, + "verbose", + "Verbose level for the CRCP bkmrk component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_crcp_bkmrk_component.super.verbose); + + timing_enabled = false; + (void) mca_base_component_var_register(&mca_crcp_bkmrk_component.super.base_version, + "timing", "Enable Performance timing", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &timing_enabled); + + return OMPI_SUCCESS; +} + +static int crcp_bkmrk_open(void) +{ /* If there is a custom verbose level for this component than use it * otherwise take our parents level and output channel */ @@ -105,14 +123,6 @@ static int crcp_bkmrk_open(void) mca_crcp_bkmrk_component.super.output_handle = ompi_crcp_base_output; } - mca_base_param_reg_int(&mca_crcp_bkmrk_component.super.base_version, - "timing", - "Enable Performance timing", - false, false, - 0, - &val); - timing_enabled = val; - /* * Debug Output */ diff --git a/ompi/mca/crcp/bkmrk/crcp_bkmrk_module.c b/ompi/mca/crcp/bkmrk/crcp_bkmrk_module.c index 351203bdfd..9d840626a9 100644 --- a/ompi/mca/crcp/bkmrk/crcp_bkmrk_module.c +++ b/ompi/mca/crcp/bkmrk/crcp_bkmrk_module.c @@ -25,7 +25,6 @@ #include "opal/mca/base/base.h" #include "opal/util/output.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/util/opal_environ.h" diff --git a/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c b/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c index 6a9e542b20..ecba165ac2 100644 --- a/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c +++ b/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c @@ -31,7 +31,6 @@ #include "opal/util/opal_environ.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/request/request.h" #include "ompi/mca/rte/rte.h" diff --git a/ompi/mca/dpm/base/dpm_base_close.c b/ompi/mca/dpm/base/dpm_base_close.c index c4f01d909c..88e117bf81 100644 --- a/ompi/mca/dpm/base/dpm_base_close.c +++ b/ompi/mca/dpm/base/dpm_base_close.c @@ -19,8 +19,6 @@ #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" - #include "ompi/mca/dpm/dpm.h" #include "ompi/mca/dpm/base/base.h" diff --git a/ompi/mca/dpm/base/dpm_base_open.c b/ompi/mca/dpm/base/dpm_base_open.c index a02b1f8651..9e0096678f 100644 --- a/ompi/mca/dpm/base/dpm_base_open.c +++ b/ompi/mca/dpm/base/dpm_base_open.c @@ -20,9 +20,6 @@ #include "opal/util/output.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" - - #include "ompi/mca/dpm/dpm.h" #include "ompi/mca/dpm/base/base.h" diff --git a/ompi/mca/dpm/base/dpm_base_select.c b/ompi/mca/dpm/base/dpm_base_select.c index 09764183cd..b56022d608 100644 --- a/ompi/mca/dpm/base/dpm_base_select.c +++ b/ompi/mca/dpm/base/dpm_base_select.c @@ -21,7 +21,6 @@ #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/mca/base/mca_base_component_repository.h" #include "ompi/mca/dpm/dpm.h" diff --git a/ompi/mca/fbtl/base/fbtl_base_file_select.c b/ompi/mca/fbtl/base/fbtl_base_file_select.c index 47974ea7d7..90d8717bc6 100644 --- a/ompi/mca/fbtl/base/fbtl_base_file_select.c +++ b/ompi/mca/fbtl/base/fbtl_base_file_select.c @@ -70,7 +70,7 @@ int mca_fbtl_base_file_select (struct mca_io_ompio_file_t *file, opal_list_item_t *item; opal_list_item_t *next_item; mca_base_component_priority_list_item_t *selectable_item; - char *names, **name_array; + char **name_array; int num_names; mca_base_component_priority_list_item_t *cpli; mca_fbtl_base_component_t *component; @@ -83,6 +83,7 @@ int mca_fbtl_base_file_select (struct mca_io_ompio_file_t *file, int err = MPI_SUCCESS; int i; bool was_selectable_constructed = false; + const char **names_value, *names; /* Check and see if a preferred component was provided. If it was provided then it should be used (if possible) */ @@ -136,8 +137,9 @@ int mca_fbtl_base_file_select (struct mca_io_ompio_file_t *file, */ /* Check if anything was requested by means on the name parameters */ - names = NULL; - mca_base_param_lookup_string (mca_fbtl_base_param, &names); + names_value = NULL; + mca_base_var_get_value(mca_fbtl_base_param, &names_value, NULL, NULL); + names = names_value ? names_value[0] : NULL; if (NULL != names && 0 < strlen(names)) { name_array = opal_argv_split (names, ','); @@ -167,7 +169,7 @@ int mca_fbtl_base_file_select (struct mca_io_ompio_file_t *file, component->fbtlm_version.mca_type_name, component->fbtlm_version.mca_component_name); - /* check if this name is present in the mca_base_params */ + /* check if this name is present in the mca_base_var */ for (i=0; i < num_names; i++) { if (0 == strcmp(name_array[i], component->fbtlm_version.mca_component_name)) { /* this is present, and should be added o the selectable list */ diff --git a/ompi/mca/fbtl/base/fbtl_base_open.c b/ompi/mca/fbtl/base/fbtl_base_open.c index 009dbbe608..69c7c4291c 100644 --- a/ompi/mca/fbtl/base/fbtl_base_open.c +++ b/ompi/mca/fbtl/base/fbtl_base_open.c @@ -24,7 +24,6 @@ #include "ompi/class/ompi_free_list.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/fbtl/fbtl.h" #include "ompi/mca/fbtl/base/base.h" @@ -74,7 +73,7 @@ int mca_fbtl_base_open(void) /* Find the index of the MCA "fbtl" param for selection */ - mca_fbtl_base_param = mca_base_param_find("fbtl", "base", NULL); + mca_fbtl_base_param = mca_base_var_find("ompi", "fbtl", NULL, NULL); return OMPI_SUCCESS; } diff --git a/ompi/mca/fcoll/base/fcoll_base_file_select.c b/ompi/mca/fcoll/base/fcoll_base_file_select.c index 0fa4823374..33f7d86ff8 100644 --- a/ompi/mca/fcoll/base/fcoll_base_file_select.c +++ b/ompi/mca/fcoll/base/fcoll_base_file_select.c @@ -69,7 +69,7 @@ int mca_fcoll_base_file_select (struct mca_io_ompio_file_t *file, int best_priority; opal_list_item_t *item; opal_list_item_t *next_item; - char *names, **name_array; + char **name_array; int num_names; mca_base_component_priority_list_item_t *cpli; mca_fcoll_base_component_t *component; @@ -82,6 +82,7 @@ int mca_fcoll_base_file_select (struct mca_io_ompio_file_t *file, int err = MPI_SUCCESS; int i; bool was_selectable_constructed = false; + const char **names_value, *names; /* Check and see if a preferred component was provided. If it was provided then it should be used (if possible) */ @@ -134,8 +135,9 @@ int mca_fcoll_base_file_select (struct mca_io_ompio_file_t *file, */ /* Check if anything was requested by means on the name parameters */ - names = NULL; - mca_base_param_lookup_string (mca_fcoll_base_param, &names); + names_value = NULL; + mca_base_var_get_value (mca_fcoll_base_param, &names_value, NULL, NULL); + names = names_value ? names_value[0] : NULL; if (NULL != names && 0 < strlen(names)) { name_array = opal_argv_split (names, ','); @@ -165,7 +167,7 @@ int mca_fcoll_base_file_select (struct mca_io_ompio_file_t *file, component->fcollm_version.mca_type_name, component->fcollm_version.mca_component_name); - /* check if this name is present in the mca_base_params */ + /* check if this name is present in the mca_base_var */ for (i=0; i < num_names; i++) { if (0 == strcmp(name_array[i], component->fcollm_version.mca_component_name)) { /* this is present, and should be added o the selectable list */ diff --git a/ompi/mca/fcoll/base/fcoll_base_open.c b/ompi/mca/fcoll/base/fcoll_base_open.c index 84a92569bc..d2f03ad77a 100644 --- a/ompi/mca/fcoll/base/fcoll_base_open.c +++ b/ompi/mca/fcoll/base/fcoll_base_open.c @@ -24,7 +24,6 @@ #include "ompi/class/ompi_free_list.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/fcoll/fcoll.h" #include "ompi/mca/fcoll/base/base.h" @@ -74,7 +73,7 @@ int mca_fcoll_base_open(void) /* Find the index of the MCA "fcoll" param for selection */ - mca_fcoll_base_param = mca_base_param_find("fcoll", "base", NULL); + mca_fcoll_base_param = mca_base_var_find("ompi", "fcoll", NULL, NULL); return OMPI_SUCCESS; } diff --git a/ompi/mca/fcoll/dynamic/fcoll_dynamic_component.c b/ompi/mca/fcoll/dynamic/fcoll_dynamic_component.c index 7b4b5677bf..20e772aa5d 100644 --- a/ompi/mca/fcoll/dynamic/fcoll_dynamic_component.c +++ b/ompi/mca/fcoll/dynamic/fcoll_dynamic_component.c @@ -81,49 +81,31 @@ mca_fcoll_base_component_2_0_0_t mca_fcoll_dynamic_component = { static int dynamic_register(void) { - int param; - - param = mca_base_param_find ("fcoll", NULL, "dynamic_priority"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_dynamic_priority); - } - param = mca_base_param_find ("fcoll", NULL, "dynamic_num_io_procs"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_dynamic_num_io_procs); - } - param = mca_base_param_find ("fcoll", NULL, "dynamic_constant_cbs"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_dynamic_constant_cbs); - } - param = mca_base_param_find ("fcoll", NULL, "dynamic_cycle_buffer_size"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_dynamic_cycle_buffer_size); - } - - mca_base_param_reg_int (&mca_fcoll_dynamic_component.fcollm_version, - "priority", - "Priority of the dynamic fcoll component", - false, false, mca_fcoll_dynamic_priority, - &mca_fcoll_dynamic_priority); - mca_base_param_reg_int (&mca_fcoll_dynamic_component.fcollm_version, - "num_io_procs", - "Number of writers in the dynamic fcoll component", - false, false, mca_fcoll_dynamic_num_io_procs, - &mca_fcoll_dynamic_num_io_procs); - mca_base_param_reg_int (&mca_fcoll_dynamic_component.fcollm_version, - "constant_cbs", - "wether we are using constant or scaling cycle buffer size in the dynamic fcoll component", - false, false, mca_fcoll_dynamic_constant_cbs, - &mca_fcoll_dynamic_constant_cbs); - mca_base_param_reg_int (&mca_fcoll_dynamic_component.fcollm_version, - "cycle_buffer_size", - "Cycle Buffer Size of the dynamic fcoll component", - false, false, mca_fcoll_dynamic_cycle_buffer_size, - &mca_fcoll_dynamic_cycle_buffer_size); + mca_fcoll_dynamic_priority = 10; + (void) mca_base_component_var_register(&mca_fcoll_dynamic_component.fcollm_version, + "priority", "Priority of the dynamic fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_dynamic_priority); + mca_fcoll_dynamic_num_io_procs = -1; + (void) mca_base_component_var_register(&mca_fcoll_dynamic_component.fcollm_version, + "num_io_procs", "Number of writers in the dynamic fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_dynamic_num_io_procs); + mca_fcoll_dynamic_constant_cbs = 0; + (void) mca_base_component_var_register(&mca_fcoll_dynamic_component.fcollm_version, + "constant_cbs", + "wether we are using constant or scaling cycle buffer size in the dynamic fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_dynamic_constant_cbs); + mca_fcoll_dynamic_cycle_buffer_size = OMPIO_PREALLOC_MAX_BUF_SIZE; + (void) mca_base_component_var_register(&mca_fcoll_dynamic_component.fcollm_version, + "cycle_buffer_size", "Cycle Buffer Size of the dynamic fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_dynamic_cycle_buffer_size); return OMPI_SUCCESS; } diff --git a/ompi/mca/fcoll/dynamic/fcoll_dynamic_module.c b/ompi/mca/fcoll/dynamic/fcoll_dynamic_module.c index 115cb37184..f27bacc82e 100644 --- a/ompi/mca/fcoll/dynamic/fcoll_dynamic_module.c +++ b/ompi/mca/fcoll/dynamic/fcoll_dynamic_module.c @@ -23,7 +23,6 @@ #include #include "mpi.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/fcoll/fcoll.h" #include "ompi/mca/fcoll/base/base.h" diff --git a/ompi/mca/fcoll/individual/fcoll_individual_component.c b/ompi/mca/fcoll/individual/fcoll_individual_component.c index d8f1d6d69c..aa1dee7d5b 100644 --- a/ompi/mca/fcoll/individual/fcoll_individual_component.c +++ b/ompi/mca/fcoll/individual/fcoll_individual_component.c @@ -66,8 +66,10 @@ mca_fcoll_base_component_2_0_0_t mca_fcoll_individual_component = { OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, OMPI_RELEASE_VERSION, - individual_register, - NULL + NULL, + NULL, + NULL, + individual_register }, { /* The component is checkpoint ready */ @@ -83,39 +85,25 @@ mca_fcoll_base_component_2_0_0_t mca_fcoll_individual_component = { static int individual_register(void) { - int param; - - param = mca_base_param_find ("fcoll", NULL, "individual_priority"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_individual_priority); - } - param = mca_base_param_find ("fcoll", NULL, "individual_constant_cbs"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_individual_constant_cbs); - } - param = mca_base_param_find ("fcoll", NULL, "individual_cycle_buffer_size"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_individual_cycle_buffer_size); - } - - mca_base_param_reg_int (&mca_fcoll_individual_component.fcollm_version, - "priority", - "Priority of the individual fcoll component", - false, false, mca_fcoll_individual_priority, - &mca_fcoll_individual_priority); - mca_base_param_reg_int (&mca_fcoll_individual_component.fcollm_version, - "constant_cbs", - "wether we are using constant or scaling cycle buffer size in the individual fcoll component", - false, false, mca_fcoll_individual_constant_cbs, - &mca_fcoll_individual_constant_cbs); - mca_base_param_reg_int (&mca_fcoll_individual_component.fcollm_version, - "cycle_buffer_size", - "Cycle Buffer Size of the individual fcoll component", - false, false, mca_fcoll_individual_cycle_buffer_size, - &mca_fcoll_individual_cycle_buffer_size); + mca_fcoll_individual_priority = 10; + (void) mca_base_component_var_register(&mca_fcoll_individual_component.fcollm_version, + "priority", "Priority of the individual fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_individual_priority); + mca_fcoll_individual_constant_cbs = 0; + (void) mca_base_component_var_register(&mca_fcoll_individual_component.fcollm_version, + "constant_cbs", + "wether we are using constant or scaling cycle buffer size in the individual fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_individual_constant_cbs); + mca_fcoll_individual_cycle_buffer_size = OMPIO_PREALLOC_MAX_BUF_SIZE; + (void) mca_base_component_var_register(&mca_fcoll_individual_component.fcollm_version, + "cycle_buffer_size", "Cycle Buffer Size of the individual fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_individual_cycle_buffer_size); return OMPI_SUCCESS; } diff --git a/ompi/mca/fcoll/individual/fcoll_individual_module.c b/ompi/mca/fcoll/individual/fcoll_individual_module.c index 76a1b5a2b8..677c32c3e2 100644 --- a/ompi/mca/fcoll/individual/fcoll_individual_module.c +++ b/ompi/mca/fcoll/individual/fcoll_individual_module.c @@ -23,7 +23,6 @@ #include #include "mpi.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/fcoll/fcoll.h" #include "ompi/mca/fcoll/base/base.h" diff --git a/ompi/mca/fcoll/static/fcoll_static_component.c b/ompi/mca/fcoll/static/fcoll_static_component.c index 3a0d74e5fa..38ed920312 100644 --- a/ompi/mca/fcoll/static/fcoll_static_component.c +++ b/ompi/mca/fcoll/static/fcoll_static_component.c @@ -84,49 +84,31 @@ mca_fcoll_base_component_2_0_0_t mca_fcoll_static_component = { static int static_register(void) { - int param; - - param = mca_base_param_find ("fcoll", NULL, "static_priority"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_static_priority); - } - param = mca_base_param_find ("fcoll", NULL, "static_num_io_procs"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_static_num_io_procs); - } - param = mca_base_param_find ("fcoll", NULL, "static_constant_cbs"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_static_constant_cbs); - } - param = mca_base_param_find ("fcoll", NULL, "static_cycle_buffer_size"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_static_cycle_buffer_size); - } - - mca_base_param_reg_int (&mca_fcoll_static_component.fcollm_version, - "priority", - "Priority of the static fcoll component", - false, false, mca_fcoll_static_priority, - &mca_fcoll_static_priority); - mca_base_param_reg_int (&mca_fcoll_static_component.fcollm_version, - "num_io_procs", - "Number of writers in the static fcoll component", - false, false, mca_fcoll_static_num_io_procs, - &mca_fcoll_static_num_io_procs); - mca_base_param_reg_int (&mca_fcoll_static_component.fcollm_version, - "constant_cbs", - "wether we are using constant or scaling cycle buffer size in the static fcoll component", - false, false, mca_fcoll_static_constant_cbs, - &mca_fcoll_static_constant_cbs); - mca_base_param_reg_int (&mca_fcoll_static_component.fcollm_version, - "cycle_buffer_size", - "Cycle Buffer Size of the static fcoll component", - false, false, mca_fcoll_static_cycle_buffer_size, - &mca_fcoll_static_cycle_buffer_size); + mca_fcoll_static_priority = 10; + (void) mca_base_component_var_register(&mca_fcoll_static_component.fcollm_version, + "priority", "Priority of the static fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_static_priority); + mca_fcoll_static_num_io_procs = -1; + (void) mca_base_component_var_register(&mca_fcoll_static_component.fcollm_version, + "num_io_procs", "Number of writers in the static fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_static_num_io_procs); + mca_fcoll_static_constant_cbs = 1; + (void) mca_base_component_var_register(&mca_fcoll_static_component.fcollm_version, + "constant_cbs", + "wether we are using constant or scaling cycle buffer size in the static fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_static_constant_cbs); + mca_fcoll_static_cycle_buffer_size = OMPIO_PREALLOC_MAX_BUF_SIZE; + (void) mca_base_component_var_register(&mca_fcoll_static_component.fcollm_version, + "cycle_buffer_size", "Cycle Buffer Size of the static fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_static_cycle_buffer_size); return OMPI_SUCCESS; } diff --git a/ompi/mca/fcoll/static/fcoll_static_module.c b/ompi/mca/fcoll/static/fcoll_static_module.c index 882af338ce..11462bff4b 100644 --- a/ompi/mca/fcoll/static/fcoll_static_module.c +++ b/ompi/mca/fcoll/static/fcoll_static_module.c @@ -23,7 +23,6 @@ #include #include "mpi.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/fcoll/fcoll.h" #include "ompi/mca/fcoll/base/base.h" diff --git a/ompi/mca/fcoll/two_phase/fcoll_two_phase_component.c b/ompi/mca/fcoll/two_phase/fcoll_two_phase_component.c index 1c31a6cfb2..4404c5041a 100644 --- a/ompi/mca/fcoll/two_phase/fcoll_two_phase_component.c +++ b/ompi/mca/fcoll/two_phase/fcoll_two_phase_component.c @@ -67,8 +67,10 @@ mca_fcoll_base_component_2_0_0_t mca_fcoll_two_phase_component = { OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, OMPI_RELEASE_VERSION, - two_phase_register, - NULL + NULL, + NULL, + NULL, + two_phase_register }, { /* The component is checkpoint ready */ @@ -84,49 +86,31 @@ mca_fcoll_base_component_2_0_0_t mca_fcoll_two_phase_component = { static int two_phase_register(void) { - int param; - - param = mca_base_param_find ("fcoll", NULL, "two_phase_priority"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_two_phase_priority); - } - param = mca_base_param_find ("fcoll", NULL, "two_phase_num_io_procs"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_two_phase_num_io_procs); - } - param = mca_base_param_find ("fcoll", NULL, "two_phase_constant_cbs"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_two_phase_constant_cbs); - } - param = mca_base_param_find ("fcoll", NULL, "two_phase_cycle_buffer_size"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_two_phase_cycle_buffer_size); - } - - mca_base_param_reg_int (&mca_fcoll_two_phase_component.fcollm_version, - "priority", - "Priority of the two_phase fcoll component", - false, false, mca_fcoll_two_phase_priority, - &mca_fcoll_two_phase_priority); - mca_base_param_reg_int (&mca_fcoll_two_phase_component.fcollm_version, - "num_io_procs", - "Number of writers in the two_phase fcoll component", - false, false, mca_fcoll_two_phase_num_io_procs, - &mca_fcoll_two_phase_num_io_procs); - mca_base_param_reg_int (&mca_fcoll_two_phase_component.fcollm_version, - "constant_cbs", - "wether we are using constant or scaling cycle buffer size in the two_phase fcoll component", - false, false, mca_fcoll_two_phase_constant_cbs, - &mca_fcoll_two_phase_constant_cbs); - mca_base_param_reg_int (&mca_fcoll_two_phase_component.fcollm_version, - "cycle_buffer_size", - "Cycle Buffer Size of the two_phase fcoll component", - false, false, mca_fcoll_two_phase_cycle_buffer_size, - &mca_fcoll_two_phase_cycle_buffer_size); + mca_fcoll_two_phase_priority = 10; + mca_base_component_var_register(&mca_fcoll_two_phase_component.fcollm_version, + "priority", "Priority of the two_phase fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_two_phase_priority); + mca_fcoll_two_phase_num_io_procs = -1; + mca_base_component_var_register(&mca_fcoll_two_phase_component.fcollm_version, + "num_io_procs", "Number of writers in the two_phase fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_two_phase_num_io_procs); + mca_fcoll_two_phase_constant_cbs = 0; + mca_base_component_var_register(&mca_fcoll_two_phase_component.fcollm_version, + "constant_cbs", + "wether we are using constant or scaling cycle buffer size in the two_phase fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_two_phase_constant_cbs); + mca_fcoll_two_phase_cycle_buffer_size = OMPIO_PREALLOC_MAX_BUF_SIZE; + mca_base_component_var_register(&mca_fcoll_two_phase_component.fcollm_version, + "cycle_buffer_size", "Cycle Buffer Size of the two_phase fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_two_phase_cycle_buffer_size); return OMPI_SUCCESS; } diff --git a/ompi/mca/fcoll/two_phase/fcoll_two_phase_module.c b/ompi/mca/fcoll/two_phase/fcoll_two_phase_module.c index 191ee242f0..4778013648 100644 --- a/ompi/mca/fcoll/two_phase/fcoll_two_phase_module.c +++ b/ompi/mca/fcoll/two_phase/fcoll_two_phase_module.c @@ -23,7 +23,6 @@ #include #include "mpi.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/fcoll/fcoll.h" #include "ompi/mca/fcoll/base/base.h" diff --git a/ompi/mca/fcoll/ylib/fcoll_ylib_component.c b/ompi/mca/fcoll/ylib/fcoll_ylib_component.c index faf7be8d8d..a27d014b39 100644 --- a/ompi/mca/fcoll/ylib/fcoll_ylib_component.c +++ b/ompi/mca/fcoll/ylib/fcoll_ylib_component.c @@ -67,8 +67,10 @@ mca_fcoll_base_component_2_0_0_t mca_fcoll_ylib_component = { OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, OMPI_RELEASE_VERSION, + NULL, + NULL, + NULL, ylib_register, - NULL }, { /* The component is checkpoint ready */ @@ -84,49 +86,30 @@ mca_fcoll_base_component_2_0_0_t mca_fcoll_ylib_component = { static int ylib_register(void) { - int param; - - param = mca_base_param_find ("fcoll", NULL, "ylib_priority"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_ylib_priority); - } - param = mca_base_param_find ("fcoll", NULL, "ylib_num_io_procs"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_ylib_num_io_procs); - } - param = mca_base_param_find ("fcoll", NULL, "ylib_stripe_size"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_ylib_stripe_size); - } - param = mca_base_param_find ("fcoll", NULL, "ylib_blocks_per_cycle"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fcoll_ylib_blocks_per_cycle); - } - - mca_base_param_reg_int (&mca_fcoll_ylib_component.fcollm_version, - "priority", - "Priority of the ylib fcoll component", - false, false, mca_fcoll_ylib_priority, - &mca_fcoll_ylib_priority); - mca_base_param_reg_int (&mca_fcoll_ylib_component.fcollm_version, - "num_io_procs", - "Number of writers in the ylib fcoll component", - false, false, mca_fcoll_ylib_num_io_procs, - &mca_fcoll_ylib_num_io_procs); - mca_base_param_reg_int (&mca_fcoll_ylib_component.fcollm_version, - "stripe_size", - "Stripe Size of the ylib fcoll component", - false, false, mca_fcoll_ylib_stripe_size, - &mca_fcoll_ylib_stripe_size); - mca_base_param_reg_int (&mca_fcoll_ylib_component.fcollm_version, - "blocks_per_cycle", - "Blocks to write per cycle of the ylib fcoll component", - false, false, mca_fcoll_ylib_blocks_per_cycle, - &mca_fcoll_ylib_blocks_per_cycle); + mca_fcoll_ylib_priority = 0; + (void) mca_base_component_var_register(&mca_fcoll_ylib_component.fcollm_version, + "priority", "Priority of the ylib fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_ylib_priority); + mca_fcoll_ylib_num_io_procs = 1; + (void) mca_base_component_var_register(&mca_fcoll_ylib_component.fcollm_version, + "num_io_procs", "Number of writers in the ylib fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_ylib_num_io_procs); + mca_fcoll_ylib_stripe_size = 1048576; + (void) mca_base_component_var_register(&mca_fcoll_ylib_component.fcollm_version, + "stripe_size", "Stripe Size of the ylib fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_ylib_stripe_size); + mca_fcoll_ylib_blocks_per_cycle = 20; + (void) mca_base_component_var_register(&mca_fcoll_ylib_component.fcollm_version, + "blocks_per_cycle", "Blocks to write per cycle of the ylib fcoll component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fcoll_ylib_blocks_per_cycle); return OMPI_SUCCESS; } diff --git a/ompi/mca/fcoll/ylib/fcoll_ylib_module.c b/ompi/mca/fcoll/ylib/fcoll_ylib_module.c index c960a6cffe..5a92ee1886 100644 --- a/ompi/mca/fcoll/ylib/fcoll_ylib_module.c +++ b/ompi/mca/fcoll/ylib/fcoll_ylib_module.c @@ -23,7 +23,6 @@ #include #include "mpi.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/fcoll/fcoll.h" #include "ompi/mca/fcoll/base/base.h" diff --git a/ompi/mca/fs/base/fs_base_file_select.c b/ompi/mca/fs/base/fs_base_file_select.c index ec8b5d0f45..624972e3ae 100644 --- a/ompi/mca/fs/base/fs_base_file_select.c +++ b/ompi/mca/fs/base/fs_base_file_select.c @@ -70,7 +70,7 @@ int mca_fs_base_file_select (struct mca_io_ompio_file_t *file, opal_list_item_t *item; opal_list_item_t *next_item; mca_base_component_priority_list_item_t *selectable_item; - char *names, **name_array; + char **name_array; int num_names; mca_base_component_priority_list_item_t *cpli; mca_fs_base_component_t *component; @@ -83,6 +83,7 @@ int mca_fs_base_file_select (struct mca_io_ompio_file_t *file, int err = MPI_SUCCESS; int i; bool was_selectable_constructed = false; + const char **names_value, *names; /* Check and see if a preferred component was provided. If it was provided then it should be used (if possible) */ @@ -136,8 +137,9 @@ int mca_fs_base_file_select (struct mca_io_ompio_file_t *file, */ /* Check if anything was requested by means on the name parameters */ - names = NULL; - mca_base_param_lookup_string (mca_fs_base_param, &names); + names_value = NULL; + mca_base_var_get_value(mca_fs_base_param, &names_value, NULL, NULL); + names = names_value ? names_value[0] : NULL; if (NULL != names && 0 < strlen(names)) { name_array = opal_argv_split (names, ','); @@ -167,7 +169,7 @@ int mca_fs_base_file_select (struct mca_io_ompio_file_t *file, component->fsm_version.mca_type_name, component->fsm_version.mca_component_name); - /* check if this name is present in the mca_base_params */ + /* check if this name is present in the mca_base_var */ for (i=0; i < num_names; i++) { if (0 == strcmp(name_array[i], component->fsm_version.mca_component_name)) { /* this is present, and should be added o the selectable list */ diff --git a/ompi/mca/fs/base/fs_base_get_parent_dir.c b/ompi/mca/fs/base/fs_base_get_parent_dir.c index ee44564216..20caf27233 100644 --- a/ompi/mca/fs/base/fs_base_get_parent_dir.c +++ b/ompi/mca/fs/base/fs_base_get_parent_dir.c @@ -24,7 +24,6 @@ #include "ompi/class/ompi_free_list.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/fs/fs.h" #include "ompi/mca/fs/base/base.h" diff --git a/ompi/mca/fs/base/fs_base_open.c b/ompi/mca/fs/base/fs_base_open.c index c08c47b22b..99c47df66f 100644 --- a/ompi/mca/fs/base/fs_base_open.c +++ b/ompi/mca/fs/base/fs_base_open.c @@ -24,7 +24,6 @@ #include "ompi/class/ompi_free_list.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/fs/fs.h" #include "ompi/mca/fs/base/base.h" @@ -75,7 +74,7 @@ int mca_fs_base_open(void) /* Find the index of the MCA "fs" param for selection */ - mca_fs_base_param = mca_base_param_find("fs", "base", NULL); + mca_fs_base_param = mca_base_var_find("ompi", "fs", NULL, NULL); return OMPI_SUCCESS; } diff --git a/ompi/mca/fs/lustre/fs_lustre_component.c b/ompi/mca/fs/lustre/fs_lustre_component.c index 417c909591..5690f44f0a 100644 --- a/ompi/mca/fs/lustre/fs_lustre_component.c +++ b/ompi/mca/fs/lustre/fs_lustre_component.c @@ -59,8 +59,10 @@ mca_fs_base_component_2_0_0_t mca_fs_lustre_component = { OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, OMPI_RELEASE_VERSION, - lustre_register, - NULL + NULL, + NULL, + NULL, + lustre_register }, { /* This component is checkpointable */ @@ -74,34 +76,24 @@ mca_fs_base_component_2_0_0_t mca_fs_lustre_component = { static int lustre_register(void) { - int param; - - param = mca_base_param_find ("fs", NULL, "lustre_stripe_size"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fs_lustre_stripe_size); - } - param = mca_base_param_find ("fs", NULL, "lustre_stripe_width"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fs_lustre_stripe_width); - } - - mca_base_param_reg_int (&mca_fs_lustre_component.fsm_version, - "priority", - "Priority of the lustre fs component", - false, false, mca_fs_lustre_priority, - &mca_fs_lustre_priority); - mca_base_param_reg_int (&mca_fs_lustre_component.fsm_version, - "stripe_size", - "stripe size of a file over lustre", - false, false, mca_fs_lustre_stripe_size, - &mca_fs_lustre_stripe_size); - mca_base_param_reg_int (&mca_fs_lustre_component.fsm_version, - "stripe_width", - "stripe width of a file over lustre", - false, false, mca_fs_lustre_stripe_width, - &mca_fs_lustre_stripe_width); + mca_fs_lustre_priority = 20; + (void) mca_base_component_var_register(&mca_fs_lustre_component.fsm_version, + "priority", "Priority of the lustre fs component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fs_lustre_priority); + mca_fs_lustre_stripe_size = 1048576; + (void) mca_base_component_var_register(&mca_fs_lustre_component.fsm_version, + "stripe_size", "stripe size of a file over lustre", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fs_lustre_stripe_size); + mca_fs_lustre_stripe_width = 0; + (void) mca_base_component_var_register(&mca_fs_lustre_component.fsm_version, + "stripe_width", "stripe width of a file over lustre", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fs_lustre_stripe_width); return OMPI_SUCCESS; } diff --git a/ompi/mca/fs/pvfs2/fs_pvfs2_component.c b/ompi/mca/fs/pvfs2/fs_pvfs2_component.c index a9b80eef90..3c447a40a6 100644 --- a/ompi/mca/fs/pvfs2/fs_pvfs2_component.c +++ b/ompi/mca/fs/pvfs2/fs_pvfs2_component.c @@ -57,8 +57,10 @@ mca_fs_base_component_2_0_0_t mca_fs_pvfs2_component = { OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, OMPI_RELEASE_VERSION, - pvfs2_register, - NULL + NULL, + NULL, + NULL, + pvfs2_register }, { /* This component is checkpointable */ @@ -72,34 +74,24 @@ mca_fs_base_component_2_0_0_t mca_fs_pvfs2_component = { static int pvfs2_register(void) { - int param; - - param = mca_base_param_find ("fs", NULL, "pvfs2_stripe_size"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fs_pvfs2_stripe_size); - } - param = mca_base_param_find ("fs", NULL, "pvfs2_stripe_width"); - if (param >= 0) - { - mca_base_param_lookup_int (param, &mca_fs_pvfs2_stripe_width); - } - - mca_base_param_reg_int (&mca_fs_pvfs2_component.fsm_version, - "priority", - "Priority of the pvfs2 fs component", - false, false, mca_fs_pvfs2_priority, - &mca_fs_pvfs2_priority); - mca_base_param_reg_int (&mca_fs_pvfs2_component.fsm_version, - "stripe_size", - "stripe size of a file over pvfs2", - false, false, mca_fs_pvfs2_stripe_size, - &mca_fs_pvfs2_stripe_size); - mca_base_param_reg_int (&mca_fs_pvfs2_component.fsm_version, - "stripe_width", - "stripe width of a file over pvfs2", - false, false, mca_fs_pvfs2_stripe_width, - &mca_fs_pvfs2_stripe_width); + mca_fs_pvfs2_priority = 0; + (void) mca_base_component_var_register (&mca_fs_pvfs2_component.fsm_version, + "priority", "Priority of the pvfs2 fs component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fs_pvfs2_priority); + mca_fs_pvfs2_stripe_size = -1; + (void) mca_base_component_var_register (&mca_fs_pvfs2_component.fsm_version, + "stripe_size", "stripe size of a file over pvfs2", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fs_pvfs2_stripe_size); + mca_fs_pvfs2_stripe_width = -1; + (void) mca_base_component_var_register (&mca_fs_pvfs2_component.fsm_version, + "stripe_width", "stripe width of a file over pvfs2", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_fs_pvfs2_stripe_width); return OMPI_SUCCESS; } diff --git a/ompi/mca/io/base/io_base_delete.c b/ompi/mca/io/base/io_base_delete.c index 1685e409a5..ec175b0af1 100644 --- a/ompi/mca/io/base/io_base_delete.c +++ b/ompi/mca/io/base/io_base_delete.c @@ -76,10 +76,11 @@ static OBJ_CLASS_INSTANCE(avail_io_t, opal_list_item_t, NULL, NULL); int mca_io_base_delete(char *filename, struct ompi_info_t *info) { int err, num_names; - char *names, **name_array; + char **name_array; opal_list_t *selectable; opal_list_item_t *item; avail_io_t *avail, selected; + const char **names_value, *names; /* Announce */ @@ -90,8 +91,9 @@ int mca_io_base_delete(char *filename, struct ompi_info_t *info) /* See if a set of component was requested by the MCA parameter. Don't check for error. */ - names = NULL; - mca_base_param_lookup_string(mca_io_base_param, &names); + names_value = NULL; + (void) mca_base_var_get_value(mca_io_base_param, &names_value, NULL, NULL); + names = names_value ? names_value[0] : NULL; /* Compute the intersection of all of my available components with the components from all the other processes in this file */ diff --git a/ompi/mca/io/base/io_base_file_select.c b/ompi/mca/io/base/io_base_file_select.c index ee94792a58..16eed135e4 100644 --- a/ompi/mca/io/base/io_base_file_select.c +++ b/ompi/mca/io/base/io_base_file_select.c @@ -92,8 +92,9 @@ static OBJ_CLASS_INSTANCE(avail_io_t, opal_list_item_t, NULL, NULL); int mca_io_base_file_select(ompi_file_t *file, mca_base_component_t *preferred) { + const char **names_value, *names; int err, num_names; - char *names, **name_array; + char **name_array; char *str; opal_list_t *selectable; opal_list_item_t *item; @@ -114,8 +115,9 @@ int mca_io_base_file_select(ompi_file_t *file, /* See if a set of component was requested by the MCA parameter. Don't check for error. */ - names = NULL; - mca_base_param_lookup_string(mca_io_base_param, &names); + names_value = NULL; + mca_base_var_get_value(mca_io_base_param, &names_value, NULL, NULL); + names = names_value ? names_value[0] : NULL; /* Compute the intersection of all of my available components with the components from all the other processes in this file */ diff --git a/ompi/mca/io/base/io_base_open.c b/ompi/mca/io/base/io_base_open.c index a3843ff9ef..b06ee3ec73 100644 --- a/ompi/mca/io/base/io_base_open.c +++ b/ompi/mca/io/base/io_base_open.c @@ -23,7 +23,6 @@ #include "opal/mca/mca.h" #include "opal/util/output.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/io/io.h" @@ -55,7 +54,6 @@ opal_list_t mca_io_base_components_opened; bool mca_io_base_components_available_valid = false; opal_list_t mca_io_base_components_available; - /* * Function for finding and opening either all MCA components, or the one * that was specifically requested via a MCA parameter. @@ -66,23 +64,6 @@ int mca_io_base_open(void) mca_io_base_output = opal_output_open(NULL); - /* Create some parameters */ - - if (0 > - mca_base_param_reg_int_name("io","base_freelist_initial_size", - "Initial MPI-2 IO request freelist size", - false, false, 16, NULL) || - 0 > - mca_base_param_reg_int_name("io", "base_freelist_max_size", - "Max size of the MPI-2 IO request freelist", - false, false, 64, NULL) || - 0 > - mca_base_param_reg_int_name("io", "base_freelist_increment", - "Increment size of the MPI-2 IO request freelist", - false, false, 16, NULL)) { - return OMPI_ERROR; - } - /* Open up all available components */ if (OMPI_SUCCESS != @@ -95,7 +76,7 @@ int mca_io_base_open(void) /* Find the index of the MCA "io" param for selection */ - mca_io_base_param = mca_base_param_find("io", "base", NULL); + mca_io_base_param = mca_base_var_find("ompi", "io", NULL, NULL); /* All done */ diff --git a/ompi/mca/io/base/io_base_request.c b/ompi/mca/io/base/io_base_request.c index 62a2759c1a..e0bfee0480 100644 --- a/ompi/mca/io/base/io_base_request.c +++ b/ompi/mca/io/base/io_base_request.c @@ -30,7 +30,6 @@ #include "opal/class/opal_object.h" #include "ompi/file/file.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/io/base/base.h" #include "ompi/mca/io/base/io_base_request.h" diff --git a/ompi/mca/io/ompio/io_ompio_component.c b/ompi/mca/io/ompio/io_ompio_component.c index 318bda9d89..12bcb7a1ad 100644 --- a/ompi/mca/io/ompio/io_ompio_component.c +++ b/ompi/mca/io/ompio/io_ompio_component.c @@ -35,6 +35,7 @@ int mca_io_ompio_coll_timing_info = 0; /* * Private functions */ +static int register_component(void); static int open_component(void); static int close_component(void); static int init_query(bool enable_progress_threads, @@ -100,6 +101,8 @@ mca_io_base_component_2_0_0_t mca_io_ompio_component = { OMPI_RELEASE_VERSION, open_component, close_component, + NULL, + register_component }, { /* The component is checkpoint ready */ @@ -121,73 +124,83 @@ mca_io_base_component_2_0_0_t mca_io_ompio_component = { NULL /* io_register_datarep */ }; - -static int open_component(void) +static int register_component(void) { - int param; + priority_param = 10; + (void) mca_base_component_var_register(&mca_io_ompio_component.io_version, + "priority", "Priority of the io ompio component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &priority_param); + delete_priority_param = 10; + (void) mca_base_component_var_register(&mca_io_ompio_component.io_version, + "delete_priority", "Delete priority of the io ompio component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &delete_priority_param); - param = mca_base_param_find ("io", NULL, "ompio_cycle_buffer_size"); - if (param >= 0) { - mca_base_param_lookup_int (param, &mca_io_ompio_cycle_buffer_size); - } - param = mca_base_param_find ("io", NULL, "ompio_bytes_per_agg"); - if (param >= 0) { - mca_base_param_lookup_int (param, &mca_io_ompio_bytes_per_agg); - } + /* NTH: Don't bother registering a version if there is none */ +/* reg_string(&mca_io_ompio_component.io_version, */ +/* "version", */ +/* "Version of OMPIO", */ +/* false, true, NULL, NULL); */ - priority_param = - mca_base_param_reg_int(&mca_io_ompio_component.io_version, - "priority", - "Priority of the io ompio component", - false, false, priority_param, NULL); - delete_priority_param = - mca_base_param_reg_int(&mca_io_ompio_component.io_version, - "delete_priority", - "Delete priority of the io ompio component", - false, false, delete_priority_param, NULL); + mca_io_ompio_record_offset_info = 0; + (void) mca_base_component_var_register(&mca_io_ompio_component.io_version, + "record_file_offset_info", + "The information of the file offset/length", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_io_ompio_record_offset_info); - mca_base_param_reg_string(&mca_io_ompio_component.io_version, - "version", - "Version of OMPIO", - false, true, NULL, NULL); + mca_io_ompio_coll_timing_info = 0; + (void) mca_base_component_var_register(&mca_io_ompio_component.io_version, + "coll_timing_info", + "Enable collective algorithm timing information", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_io_ompio_coll_timing_info); - mca_base_param_reg_int (&mca_io_ompio_component.io_version, - "record_file_offset_info", - "The information of the file offset/length", - false, false, mca_io_ompio_record_offset_info, - &mca_io_ompio_record_offset_info); + mca_io_ompio_cycle_buffer_size = OMPIO_PREALLOC_MAX_BUF_SIZE; + (void) mca_base_component_var_register(&mca_io_ompio_component.io_version, + "cycle_buffer_size", + "Cycle Buffer Size of individual reads/writes", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_io_ompio_cycle_buffer_size); - mca_base_param_reg_int (&mca_io_ompio_component.io_version, - "coll_timing_info", - "Enable collective algorithm timing information", - false, false, mca_io_ompio_coll_timing_info, - &mca_io_ompio_coll_timing_info); - - - mca_base_param_reg_int (&mca_io_ompio_component.io_version, - "cycle_buffer_size", - "Cycle Buffer Size of individual reads/writes", - false, false, mca_io_ompio_cycle_buffer_size, - &mca_io_ompio_cycle_buffer_size); - - mca_base_param_reg_int (&mca_io_ompio_component.io_version, - "bytes_per_agg", - "Bytes per aggregator process for automatic selection", - false, false, mca_io_ompio_bytes_per_agg, - &mca_io_ompio_bytes_per_agg); + mca_io_ompio_bytes_per_agg = OMPIO_PREALLOC_MAX_BUF_SIZE; + (void) mca_base_component_var_register(&mca_io_ompio_component.io_version, + "bytes_per_agg", + "Bytes per aggregator process for automatic selection", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_io_ompio_bytes_per_agg); /* - mca_base_param_reg_string(&mca_io_ompio_component.io_version, + reg_string(&mca_io_ompio_component.io_version, "user_configure_params", "User-specified command line parameters passed to OMPIO's configure script", false, true, MCA_io_ompio_USER_CONFIGURE_FLAGS, NULL); - mca_base_param_reg_string(&mca_io_ompio_component.io_version, + reg_string(&mca_io_ompio_component.io_version, "complete_configure_params", "Complete set of command line parameters passed to OMPIO's configure script", false, true, MCA_io_ompio_COMPLETE_CONFIGURE_FLAGS, NULL); */ + + return OMPI_SUCCESS; +} + +static int open_component(void) +{ /* Create the mutex */ OBJ_CONSTRUCT(&mca_io_ompio_mutex, opal_mutex_t); @@ -227,12 +240,7 @@ file_query(struct ompi_file_t *file, { mca_io_ompio_data_t *data; - /* Lookup our priority */ - - if (OMPI_SUCCESS != mca_base_param_lookup_int(priority_param, - priority)) { - return NULL; - } + *priority = priority_param; /* Allocate a space for this module to hang private data (e.g., the OMPIO file handle) */ @@ -268,13 +276,7 @@ static int delete_query(char *filename, struct ompi_info_t *info, struct mca_io_base_delete_t **private_data, bool *usable, int *priority) { - /* Lookup our priority */ - - if (OMPI_SUCCESS != mca_base_param_lookup_int(delete_priority_param, - priority)) { - return OMPI_ERROR; - } - + *priority = delete_priority_param; *usable = true; *private_data = NULL; diff --git a/ompi/mca/io/ompio/io_ompio_nbc.c b/ompi/mca/io/ompio/io_ompio_nbc.c index bd9a87ca22..a5a872cec3 100644 --- a/ompi/mca/io/ompio/io_ompio_nbc.c +++ b/ompi/mca/io/ompio/io_ompio_nbc.c @@ -61,9 +61,11 @@ int mca_io_ompio_get_fcoll_dynamic_num_io_procs (int *num_procs) { int param; - param = mca_base_param_find("fcoll", "dynamic", "num_io_procs"); + param = mca_base_var_find("ompi", "fcoll", "dynamic", "num_io_procs"); if (param >= 0){ - mca_base_param_lookup_int(param, num_procs); + const int *value = NULL; + mca_base_var_get_value(param, &value, NULL, NULL); + *num_procs = value[0]; /* printf("num procs : %d\n", num_procs);*/ return OMPI_SUCCESS; } @@ -76,9 +78,11 @@ int mca_io_ompio_get_fcoll_dynamic_constant_cbs (int *constant_cbs) { int param; - param = mca_base_param_find("fcoll", "dynamic", "constant_cbs"); + param = mca_base_var_find("ompi", "fcoll", "dynamic", "constant_cbs"); if (param >= 0){ - mca_base_param_lookup_int(param, constant_cbs); + const int *value = NULL; + mca_base_var_get_value(param, &value, NULL, NULL); + *constant_cbs = value[0]; /* printf ("constant_cbs: %d\n", constant_cbs);*/ return OMPI_SUCCESS; } @@ -94,9 +98,11 @@ int mca_io_ompio_get_fcoll_dynamic_cycle_buffer_size (int *cycle_buffer_size) int param; - param = mca_base_param_find("fcoll", "dynamic", "cycle_buffer_size"); + param = mca_base_var_find("ompi", "fcoll", "dynamic", "cycle_buffer_size"); if (param >= 0){ - mca_base_param_lookup_int(param, cycle_buffer_size); + const int *value = NULL; + mca_base_var_get_value(param, &value, NULL, NULL); + *cycle_buffer_size = value[0]; /* printf ("cycle_buffer_size : %d\n", *cycle_buffer_size);*/ return OMPI_SUCCESS; } diff --git a/ompi/mca/io/romio/src/io_romio_component.c b/ompi/mca/io/romio/src/io_romio_component.c index 9ed7ad7cd3..854ddd34c0 100644 --- a/ompi/mca/io/romio/src/io_romio_component.c +++ b/ompi/mca/io/romio/src/io_romio_component.c @@ -31,6 +31,7 @@ /* * Private functions */ +static int register_component(void); static int open_component(void); static int close_component(void); static int init_query(bool enable_progress_threads, @@ -86,6 +87,8 @@ mca_io_base_component_2_0_0_t mca_io_romio_component = { OMPI_RELEASE_VERSION, open_component, close_component, + NULL, + register_component }, { /* The component is checkpoint ready */ @@ -107,38 +110,50 @@ mca_io_base_component_2_0_0_t mca_io_romio_component = { register_datarep }; +static char *ompi_io_romio_version = ROMIO_VERSION_STRING; +static char *ompi_io_romio_user_configure_params = MCA_io_romio_USER_CONFIGURE_FLAGS; +static char *ompi_io_romio_complete_configure_params = MCA_io_romio_COMPLETE_CONFIGURE_FLAGS; + +static int register_component(void) +{ + /* Use a low priority, but allow other components to be lower */ + priority_param = 10; + (void) mca_base_component_var_register(&mca_io_romio_component.io_version, + "priority", "Priority of the io romio component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &priority_param); + delete_priority_param = 10; + (void) mca_base_component_var_register(&mca_io_romio_component.io_version, + "delete_priority", "Delete priority of the io romio component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &delete_priority_param); + (void) mca_base_component_var_register(&mca_io_romio_component.io_version, + "version", "Version of ROMIO", MCA_BASE_VAR_TYPE_STRING, + NULL, 0, MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &ompi_io_romio_version); + (void) mca_base_component_var_register(&mca_io_romio_component.io_version, + "user_configure_params", + "User-specified command line parameters passed to ROMIO's configure script", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &ompi_io_romio_user_configure_params); + (void) mca_base_component_var_register(&mca_io_romio_component.io_version, + "complete_configure_params", + "Complete set of command line parameters passed to ROMIO's configure script", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &ompi_io_romio_complete_configure_params); + + return OMPI_SUCCESS; +} static int open_component(void) { - /* Use a low priority, but allow other components to be lower */ - - priority_param = - mca_base_param_reg_int(&mca_io_romio_component.io_version, - "priority", - "Priority of the io romio component", - false, false, 10, NULL); - delete_priority_param = - mca_base_param_reg_int(&mca_io_romio_component.io_version, - "delete_priority", - "Delete priority of the io romio component", - false, false, 10, NULL); - - mca_base_param_reg_string(&mca_io_romio_component.io_version, - "version", - "Version of ROMIO", - false, true, ROMIO_VERSION_STRING, NULL); - - mca_base_param_reg_string(&mca_io_romio_component.io_version, - "user_configure_params", - "User-specified command line parameters passed to ROMIO's configure script", - false, true, - MCA_io_romio_USER_CONFIGURE_FLAGS, NULL); - mca_base_param_reg_string(&mca_io_romio_component.io_version, - "complete_configure_params", - "Complete set of command line parameters passed to ROMIO's configure script", - false, true, - MCA_io_romio_COMPLETE_CONFIGURE_FLAGS, NULL); - /* Create the mutex */ OBJ_CONSTRUCT(&mca_io_romio_mutex, opal_mutex_t); @@ -173,12 +188,7 @@ file_query(struct ompi_file_t *file, { mca_io_romio_data_t *data; - /* Lookup our priority */ - - if (OMPI_SUCCESS != mca_base_param_lookup_int(priority_param, - priority)) { - return NULL; - } + *priority = priority_param; /* Allocate a space for this module to hang private data (e.g., the ROMIO file handle) */ @@ -214,13 +224,7 @@ static int delete_query(char *filename, struct ompi_info_t *info, struct mca_io_base_delete_t **private_data, bool *usable, int *priority) { - /* Lookup our priority */ - - if (OMPI_SUCCESS != mca_base_param_lookup_int(delete_priority_param, - priority)) { - return OMPI_ERROR; - } - + *priority = delete_priority_param; *usable = true; *private_data = NULL; diff --git a/ompi/mca/mpool/base/mpool_base_lookup.c b/ompi/mca/mpool/base/mpool_base_lookup.c index 12144609a6..3c67eb1f80 100644 --- a/ompi/mca/mpool/base/mpool_base_lookup.c +++ b/ompi/mca/mpool/base/mpool_base_lookup.c @@ -106,7 +106,7 @@ mca_mpool_base_module_t* mca_mpool_base_module_create( leave_pinned variables may have been set by a user MCA param or elsewhere in the code base). Yes, we could have coded this more succinctly, but this is more clear. */ - if (ompi_mpi_leave_pinned || ompi_mpi_leave_pinned_pipeline) { + if (ompi_mpi_leave_pinned > 0 || ompi_mpi_leave_pinned_pipeline) { use_mem_hooks = 1; } diff --git a/ompi/mca/mpool/base/mpool_base_open.c b/ompi/mca/mpool/base/mpool_base_open.c index 944bc9e6ec..2882f705f4 100644 --- a/ompi/mca/mpool/base/mpool_base_open.c +++ b/ompi/mca/mpool/base/mpool_base_open.c @@ -57,25 +57,36 @@ uint32_t mca_mpool_base_page_size_log; opal_list_t mca_mpool_base_components; opal_list_t mca_mpool_base_modules; +static int ompi_mpool_base_verbose = 0; + +static int mca_mpool_base_register(int flags) +{ + /* Verbose output */ + ompi_mpool_base_verbose = 0; + mca_base_var_register("ompi", "mpool", "base", "verbose", + "Verbosity level for the mpool framework (0 = no verbosity)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &ompi_mpool_base_verbose); + + return OMPI_SUCCESS; +} + /** * Function for finding and opening either all MCA components, or the one * that was specifically requested via a MCA parameter. */ int mca_mpool_base_open(void) { - int value; /* Open up all available components - and populate the mca_mpool_base_components list */ - /* Verbose output */ - mca_base_param_reg_int_name("mpool", - "base_verbose", - "Verbosity level for the mpool framework (0 = no verbosity)", - false, false, - 0, &value); - + (void) mca_mpool_base_register(0); + mca_mpool_base_output = opal_output_open(NULL); - opal_output_set_verbosity(mca_mpool_base_output, value); + opal_output_set_verbosity(mca_mpool_base_output, ompi_mpool_base_verbose); if (OMPI_SUCCESS != mca_base_components_open("mpool", mca_mpool_base_output, mca_mpool_base_static_components, diff --git a/ompi/mca/mpool/gpusm/mpool_gpusm_component.c b/ompi/mca/mpool/gpusm/mpool_gpusm_component.c index 96ee2cfd82..89298f7e51 100644 --- a/ompi/mca/mpool/gpusm/mpool_gpusm_component.c +++ b/ompi/mca/mpool/gpusm/mpool_gpusm_component.c @@ -23,7 +23,6 @@ #define OPAL_DISABLE_ENABLE_MEM_DEBUG 1 #include "ompi_config.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "mpool_gpusm.h" #ifdef HAVE_UNISTD_H #include @@ -78,7 +77,7 @@ static int gpusm_open(void) static int gpusm_register(void) { - return OMPI_SUCCESS; + return mca_common_cuda_register_mca_variables(); } diff --git a/ompi/mca/mpool/grdma/mpool_grdma.h b/ompi/mca/mpool/grdma/mpool_grdma.h index 7e370e860a..f838069318 100644 --- a/ompi/mca/mpool/grdma/mpool_grdma.h +++ b/ompi/mca/mpool/grdma/mpool_grdma.h @@ -53,10 +53,9 @@ OBJ_CLASS_DECLARATION(mca_mpool_grdma_pool_t); struct mca_mpool_grdma_component_t { mca_mpool_base_component_t super; opal_list_t pools; - char* rcache_name; - size_t rcache_size_limit; + char *rcache_name; bool print_stats; - uint32_t leave_pinned; + int leave_pinned; }; typedef struct mca_mpool_grdma_component_t mca_mpool_grdma_component_t; diff --git a/ompi/mca/mpool/grdma/mpool_grdma_component.c b/ompi/mca/mpool/grdma/mpool_grdma_component.c index e2c1a61c30..d936d2bf14 100644 --- a/ompi/mca/mpool/grdma/mpool_grdma_component.c +++ b/ompi/mca/mpool/grdma/mpool_grdma_component.c @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2006 Voltaire. All rights reserved. * Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2012 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights * reserved. * * $COPYRIGHT$ @@ -25,7 +25,6 @@ #define OPAL_DISABLE_ENABLE_MEM_DEBUG 1 #include "ompi_config.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/runtime/params.h" #include "mpool_grdma.h" #ifdef HAVE_UNISTD_H @@ -85,26 +84,22 @@ static int grdma_open(void) static int grdma_register(void) { - int val; + mca_mpool_grdma_component.rcache_name = "vma"; + (void) mca_base_component_var_register(&mca_mpool_grdma_component.super.mpool_version, + "rcache_name", + "The name of the registration cache the mpool should use", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_mpool_grdma_component.rcache_name); - mca_base_param_reg_string(&mca_mpool_grdma_component.super.mpool_version, - "rcache_name", - "The name of the registration cache the mpool should use", - false, false, "vma", &mca_mpool_grdma_component.rcache_name); - - mca_base_param_reg_int(&mca_mpool_grdma_component.super.mpool_version, - "rcache_size_limit", - "the maximum size of registration cache in bytes. " - "0 is unlimited (default 0)", false, false, 0, &val); - - mca_mpool_grdma_component.rcache_size_limit = (size_t)val; - - mca_base_param_reg_int(&mca_mpool_grdma_component.super.mpool_version, - "print_stats", - "print pool usage statistics at the end of the run", - false, false, 0, &val); - - mca_mpool_grdma_component.print_stats = val?true:false; + mca_mpool_grdma_component.print_stats = false; + (void) mca_base_component_var_register(&mca_mpool_grdma_component.super.mpool_version, + "print_stats", "print pool usage statistics at the end of the run", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_mpool_grdma_component.print_stats); return OMPI_SUCCESS; } @@ -114,10 +109,6 @@ static int grdma_close(void) { OBJ_DESTRUCT(&mca_mpool_grdma_component.pools); - if (NULL != mca_mpool_grdma_component.rcache_name) { - free(mca_mpool_grdma_component.rcache_name); - } - return OMPI_SUCCESS; } diff --git a/ompi/mca/mpool/grdma/mpool_grdma_module.c b/ompi/mca/mpool/grdma/mpool_grdma_module.c index 4ab8a9420a..ff709fbf8e 100644 --- a/ompi/mca/mpool/grdma/mpool_grdma_module.c +++ b/ompi/mca/mpool/grdma/mpool_grdma_module.c @@ -252,14 +252,13 @@ int mca_mpool_grdma_register(mca_mpool_base_module_t *mpool, void *addr, *reg = NULL; /* in case previous find found something */ /* If no suitable registration is in cache and leave_pinned isn't - * set and size of registration cache is unlimited don't use the cache. + * set don't use the cache. * This is optimisation in case limit is not set. If limit is set we * have to put registration into the cache to determine when we hit * memory registration limit. * NONE: cache is still used for persistent registrations so previous * find can find something */ - if(!mca_mpool_grdma_component.leave_pinned && - mca_mpool_grdma_component.rcache_size_limit == 0) { + if(!mca_mpool_grdma_component.leave_pinned) { bypass_cache = true; } } diff --git a/ompi/mca/mpool/rgpusm/mpool_rgpusm.h b/ompi/mca/mpool/rgpusm/mpool_rgpusm.h index 853a404698..eda2ac4e04 100644 --- a/ompi/mca/mpool/rgpusm/mpool_rgpusm.h +++ b/ompi/mca/mpool/rgpusm/mpool_rgpusm.h @@ -34,9 +34,9 @@ BEGIN_C_DECLS struct mca_mpool_rgpusm_component_t { mca_mpool_base_component_t super; char* rcache_name; - size_t rcache_size_limit; + unsigned long long rcache_size_limit; bool print_stats; - uint32_t leave_pinned; + int leave_pinned; int output; }; typedef struct mca_mpool_rgpusm_component_t mca_mpool_rgpusm_component_t; diff --git a/ompi/mca/mpool/rgpusm/mpool_rgpusm_component.c b/ompi/mca/mpool/rgpusm/mpool_rgpusm_component.c index 7f376cd3bd..192486890c 100644 --- a/ompi/mca/mpool/rgpusm/mpool_rgpusm_component.c +++ b/ompi/mca/mpool/rgpusm/mpool_rgpusm_component.c @@ -23,7 +23,6 @@ #define OPAL_DISABLE_ENABLE_MEM_DEBUG 1 #include "ompi_config.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "mpool_rgpusm.h" #ifdef HAVE_UNISTD_H #include @@ -40,6 +39,8 @@ static int rgpusm_close(void); static int rgpusm_register(void); static mca_mpool_base_module_t* rgpusm_init(struct mca_mpool_base_resources_t* resources); +static int ompi_mpool_rgpusm_verbose = 0; + mca_mpool_rgpusm_component_t mca_mpool_rgpusm_component = { { /* First, the mca_base_component_t struct containing meta @@ -71,57 +72,66 @@ mca_mpool_rgpusm_component_t mca_mpool_rgpusm_component = { */ static int rgpusm_open(void) { + mca_mpool_rgpusm_component.output = opal_output_open(NULL); + opal_output_set_verbosity(mca_mpool_rgpusm_component.output, ompi_mpool_rgpusm_verbose); + return OMPI_SUCCESS; } static int rgpusm_register(void) { - int val; + mca_mpool_rgpusm_component.rcache_name = "vma"; + (void) mca_base_component_var_register(&mca_mpool_rgpusm_component.super.mpool_version, + "rcache_name", + "The name of the registration cache the mpool should use", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_mpool_rgpusm_component.rcache_name); + mca_mpool_rgpusm_component.rcache_size_limit = 0; + (void) mca_base_component_var_register(&mca_mpool_rgpusm_component.super.mpool_version, + "rcache_size_limit", + "the maximum size of registration cache in bytes. " + "0 is unlimited (default 0)", + MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_mpool_rgpusm_component.rcache_size_limit); - mca_base_param_reg_string(&mca_mpool_rgpusm_component.super.mpool_version, - "rcache_name", - "The name of the registration cache the mpool should use", - false, false, "vma", &mca_mpool_rgpusm_component.rcache_name); + mca_mpool_rgpusm_component.leave_pinned = 1; + (void) mca_base_component_var_register(&mca_mpool_rgpusm_component.super.mpool_version, + "leave_pinned", + "Whether to keep memory handles around or release them when done. ", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_mpool_rgpusm_component.leave_pinned); - mca_base_param_reg_int(&mca_mpool_rgpusm_component.super.mpool_version, - "rcache_size_limit", - "the maximum size of registration cache in bytes. " - "0 is unlimited (default 0)", false, false, 0, &val); - - mca_mpool_rgpusm_component.rcache_size_limit = (size_t)val; - - mca_base_param_reg_int(&mca_mpool_rgpusm_component.super.mpool_version, - "leave_pinned", - "Whether to keep memory handles around or release them when done. ", - false, false, 1, &val); - mca_mpool_rgpusm_component.leave_pinned = (size_t)val; - - mca_base_param_reg_int(&mca_mpool_rgpusm_component.super.mpool_version, - "print_stats", - "print pool usage statistics at the end of the run", - false, false, 0, &val); - - mca_mpool_rgpusm_component.print_stats = val?true:false; + mca_mpool_rgpusm_component.print_stats = false; + (void) mca_base_component_var_register(&mca_mpool_rgpusm_component.super.mpool_version, + "print_stats", + "print pool usage statistics at the end of the run", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_mpool_rgpusm_component.print_stats); /* Set different levels of verbosity in the rgpusm related code. */ - mca_base_param_reg_int(&mca_mpool_rgpusm_component.super.mpool_version, - "verbose", - "Set level of mpool rgpusm verbosity", - false, false, 0, &val); - mca_mpool_rgpusm_component.output = opal_output_open(NULL); - opal_output_set_verbosity(mca_mpool_rgpusm_component.output, val); + ompi_mpool_rgpusm_verbose = 0; + (void) mca_base_component_var_register(&mca_mpool_rgpusm_component.super.mpool_version, + "verbose", "Set level of mpool rgpusm verbosity", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpool_rgpusm_verbose); - return OMPI_SUCCESS; + return mca_common_cuda_register_mca_variables(); } static int rgpusm_close(void) { - if (NULL != mca_mpool_rgpusm_component.rcache_name) { - free(mca_mpool_rgpusm_component.rcache_name); - } - return OMPI_SUCCESS; } diff --git a/ompi/mca/mpool/sm/mpool_sm_component.c b/ompi/mca/mpool/sm/mpool_sm_component.c index 33db630d22..d9ee331397 100644 --- a/ompi/mca/mpool/sm/mpool_sm_component.c +++ b/ompi/mca/mpool/sm/mpool_sm_component.c @@ -11,7 +11,7 @@ * All rights reserved. * Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2010-2012 Los Alamos National Security, LLC. + * Copyright (c) 2010-2013 Los Alamos National Security, LLC. * All rights reserved. * $COPYRIGHT$ * @@ -29,7 +29,6 @@ #endif /* HAVE_STDLIB_H */ #include #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/allocator/base/base.h" #include "mpool_sm.h" @@ -43,6 +42,9 @@ /* * Local functions */ +static int +mca_mpool_sm_register(void); + static int mca_mpool_sm_open(void); @@ -65,7 +67,9 @@ mca_mpool_sm_component_t mca_mpool_sm_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_mpool_sm_open, /* component open */ - mca_mpool_sm_close + mca_mpool_sm_close, + NULL, + mca_mpool_sm_register }, { /* The component is checkpoint ready */ @@ -76,41 +80,50 @@ mca_mpool_sm_component_t mca_mpool_sm_component = { } }; -static char *min_size_param = NULL; -static long default_min; +static long default_min = 67108864; +static unsigned long long ompi_mpool_sm_min_size; +static int ompi_mpool_sm_verbose; + +static int mca_mpool_sm_register(void) +{ + /* register SM component parameters */ + (void) mca_base_var_group_component_register(&mca_mpool_sm_component.super.mpool_version, + "Shared memory pool"); + + mca_mpool_sm_component.sm_allocator_name = "bucket"; + (void) mca_base_component_var_register(&mca_mpool_sm_component.super.mpool_version, + "allocator", "Name of allocator component " + "to use with sm mpool", MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_mpool_sm_component.sm_allocator_name); + + /* register as an unsigned long long to get up to 64 bits for the size */ + ompi_mpool_sm_min_size = default_min; + (void) mca_base_component_var_register(&mca_mpool_sm_component.super.mpool_version, + "min_size", "Minimum size of the sm mpool shared memory file", + MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpool_sm_min_size); + + ompi_mpool_sm_verbose = 0; + (void) mca_base_component_var_register(&mca_mpool_sm_component.super.mpool_version, + "verbose", "Enable verbose output for mpool sm component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpool_sm_verbose); + + return OMPI_SUCCESS; +} /** * component open/close/init function */ static int mca_mpool_sm_open(void) { - int value = 0; - char *size_str = NULL; - - default_min = 67108864; - - /* register SM component parameters */ - mca_base_param_reg_string(&mca_mpool_sm_component.super.mpool_version, - "allocator", - "Name of allocator component " - "to use with sm mpool", false, false, - "bucket", - &mca_mpool_sm_component.sm_allocator_name); - - /* register values as string instead of int. A string-converted - * signed long int allows the min_size or the sm_size - * to be set up to 2GB-1 for 32 bit and much greater for 64 bit. */ - asprintf(&size_str, "%ld", default_min); - mca_base_param_reg_string(&mca_mpool_sm_component.super.mpool_version, - "min_size", - "Minimum size of the sm mpool shared memory file", - false, false, size_str, &min_size_param); - free(size_str); - mca_base_param_reg_int(&mca_mpool_sm_component.super.mpool_version, - "verbose", - "Enable verbose output for mpool sm component", - false, false, 0, &value); - if (value != 0) { + if (ompi_mpool_sm_verbose != 0) { mca_mpool_sm_component.verbose = opal_output_open(NULL); } else { mca_mpool_sm_component.verbose = -1; @@ -121,12 +134,6 @@ static int mca_mpool_sm_open(void) static int mca_mpool_sm_close( void ) { - if (NULL != mca_mpool_sm_component.sm_allocator_name) { - free(mca_mpool_sm_component.sm_allocator_name); - } - if (NULL != min_size_param) { - free(min_size_param); - } return OMPI_SUCCESS; } @@ -135,7 +142,6 @@ mca_mpool_sm_init(struct mca_mpool_base_resources_t *resources) { mca_mpool_sm_module_t *mpool_module; mca_allocator_base_component_t* allocator_component; - long min_size; ompi_proc_t **procs; size_t num_all_procs, i, num_local_procs = 0; @@ -150,20 +156,6 @@ mca_mpool_sm_init(struct mca_mpool_base_resources_t *resources) num_local_procs++; } } - /* parse the min size and validate it */ - /* if other parameters are added, absolutely - * necessary to reset errno each time */ - errno = 0; - min_size = strtol(min_size_param, (char **)NULL, 10); - if (errno == ERANGE) { - opal_output(0, "mca_mpool_sm_init: min_size overflows! " - "set to default (%ld)", default_min); - min_size = default_min; - } else if (errno == EINVAL) { - opal_output(0, "mca_mpool_sm_init: invalid min_size entered. " - "set it to (%ld)", default_min); - min_size = default_min; - } /* Make a new mpool module */ mpool_module = @@ -174,8 +166,8 @@ mca_mpool_sm_init(struct mca_mpool_base_resources_t *resources) mpool_module->sm_size = resources->size; /* clip at the min size */ - if (mpool_module->sm_size < min_size) { - mpool_module->sm_size = min_size; + if (mpool_module->sm_size < (long) ompi_mpool_sm_min_size) { + mpool_module->sm_size = (long) ompi_mpool_sm_min_size; } allocator_component = mca_allocator_component_lookup( diff --git a/ompi/mca/mtl/mx/mtl_mx_component.c b/ompi/mca/mtl/mx/mtl_mx_component.c index 094f3b1050..e04d0387cc 100644 --- a/ompi/mca/mtl/mx/mtl_mx_component.c +++ b/ompi/mca/mtl/mx/mtl_mx_component.c @@ -20,7 +20,6 @@ #include "ompi_config.h" #include "opal/mca/event/event.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/mtl/base/base.h" #include "ompi/mca/common/mx/common_mx.h" @@ -31,6 +30,7 @@ #include "myriexpress.h" #define MCA_MTL_MX_QUEUE_LENGTH_MAX 2*1024*1024 +static int ompi_mtl_mx_component_register(void); static int ompi_mtl_mx_component_open(void); static int ompi_mtl_mx_component_close(void); static int ompi_mtl_mx_component_initialized = 0; @@ -52,7 +52,9 @@ mca_mtl_mx_component_t mca_mtl_mx_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ ompi_mtl_mx_component_open, /* component open */ - ompi_mtl_mx_component_close /* component close */ + ompi_mtl_mx_component_close, /* component close */ + NULL, + ompi_mtl_mx_component_register }, { /* The component is not checkpoint ready */ @@ -63,43 +65,65 @@ mca_mtl_mx_component_t mca_mtl_mx_component = { } }; - +static int +ompi_mtl_mx_component_register(void) +{ + ompi_mtl_mx.mx_filter = 0xaaaaffff; + (void) mca_base_component_var_register(&mca_mtl_mx_component.super.mtl_version, "filter", + "user assigned value used to filter incomming messages", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &ompi_mtl_mx.mx_filter); + + ompi_mtl_mx.mx_timeout = MX_INFINITE; + (void) mca_base_component_var_register(&mca_mtl_mx_component.super.mtl_version, "timeout", + "Timeout for connections", MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &ompi_mtl_mx.mx_timeout); + + ompi_mtl_mx.mx_retries = 20; + (void) mca_base_component_var_register(&mca_mtl_mx_component.super.mtl_version, "retries", + "Number of retries for each new connection before considering the peer as unreacheable", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &ompi_mtl_mx.mx_retries); + + ompi_mtl_mx.mx_support_sharedmem = 1; + (void) mca_base_component_var_register(&mca_mtl_mx_component.super.mtl_version, "shared_mem", + "Enable the MX support for shared memory", MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &ompi_mtl_mx.mx_support_sharedmem); + + ompi_mtl_mx.mx_unexp_queue_max = MCA_MTL_MX_QUEUE_LENGTH_MAX; + (void) mca_base_component_var_register(&mca_mtl_mx_component.super.mtl_version, "unexpected_queue_length", + "Length of MX unexpected message queue", MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &ompi_mtl_mx.mx_unexp_queue_max); + + ompi_mtl_mx.mx_board_num = -1; + (void) mca_base_component_var_register(&mca_mtl_mx_component.super.mtl_version, "board", + "Which MX board number to use (<0 = any)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &ompi_mtl_mx.mx_board_num); + + ompi_mtl_mx.mx_endpoint_num = -1; + (void) mca_base_component_var_register(&mca_mtl_mx_component.super.mtl_version, "endpoint", + "Which MX endpoint number to use (<0 = any)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &ompi_mtl_mx.mx_endpoint_num); + + return OMPI_SUCCESS; +} + static int ompi_mtl_mx_component_open(void) { - - - mca_base_param_reg_int(&mca_mtl_mx_component.super.mtl_version, "filter", - "user assigned value used to filter incomming messages", - false, false, 0xaaaaffff, &ompi_mtl_mx.mx_filter); - - mca_base_param_reg_int(&mca_mtl_mx_component.super.mtl_version, "timeout", - "Timeout for connections", - false, false, MX_INFINITE, &ompi_mtl_mx.mx_timeout); - - mca_base_param_reg_int(&mca_mtl_mx_component.super.mtl_version, "retries", - "Number of retries for each new connection before considering the peer as unreacheable", - false, false, 20, &ompi_mtl_mx.mx_retries); - - mca_base_param_reg_int(&mca_mtl_mx_component.super.mtl_version, "shared_mem", - "Enable the MX support for shared memory", - false, true, 1, &ompi_mtl_mx.mx_support_sharedmem ); - - mca_base_param_reg_int(&mca_mtl_mx_component.super.mtl_version, "unexpected_queue_length", - "Length of MX unexpected message queue", - false, false, MCA_MTL_MX_QUEUE_LENGTH_MAX, &ompi_mtl_mx.mx_unexp_queue_max); - - if(ompi_mtl_mx.mx_unexp_queue_max > MCA_MTL_MX_QUEUE_LENGTH_MAX) { - ompi_mtl_mx.mx_unexp_queue_max = MCA_MTL_MX_QUEUE_LENGTH_MAX; + if(ompi_mtl_mx.mx_unexp_queue_max > MCA_MTL_MX_QUEUE_LENGTH_MAX) { + ompi_mtl_mx.mx_unexp_queue_max = MCA_MTL_MX_QUEUE_LENGTH_MAX; } - mca_base_param_reg_int(&mca_mtl_mx_component.super.mtl_version, "board", - "Which MX board number to use (<0 = any)", - false, false, -1, &ompi_mtl_mx.mx_board_num); - mca_base_param_reg_int(&mca_mtl_mx_component.super.mtl_version, "endpoint", - "Which MX endpoint number to use (<0 = any)", - false, false, -1, &ompi_mtl_mx.mx_endpoint_num); - return OMPI_SUCCESS; } diff --git a/ompi/mca/mtl/mxm/mtl_mxm_component.c b/ompi/mca/mtl/mxm/mtl_mxm_component.c index b59fb8dd8e..39d5b22003 100644 --- a/ompi/mca/mtl/mxm/mtl_mxm_component.c +++ b/ompi/mca/mtl/mxm/mtl_mxm_component.c @@ -10,7 +10,6 @@ #include "ompi_config.h" #include "opal/util/output.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/proc/proc.h" #include "mtl_mxm.h" @@ -63,18 +62,22 @@ static int ompi_mtl_mxm_component_register(void) c = &mca_mtl_mxm_component.super.mtl_version; - mca_base_param_reg_int(c, "verbose", - "Verbose level of the MXM component", - false, false, - 0, - &ompi_mtl_mxm.verbose); + ompi_mtl_mxm.verbose = 0; + (void) mca_base_component_var_register(c, "verbose", + "Verbose level of the MXM component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &ompi_mtl_mxm.verbose); - mca_base_param_reg_int(c, "np", - "[integer] Minimal number of MPI processes in a single job " - "required to activate the MXM transport", - false, false, - 128, - &ompi_mtl_mxm.mxm_np); + ompi_mtl_mxm.mxm_np = 128; + (void) mca_base_component_var_register(c, "np", + "[integer] Minimal number of MPI processes in a single job " + "required to activate the MXM transport", + MCA_BASE_VAR_TYPE_INT, NULL,0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_mxm.mxm_np); return OMPI_SUCCESS; } diff --git a/ompi/mca/mtl/portals4/mtl_portals4.h b/ompi/mca/mtl/portals4/mtl_portals4.h index 22fcf6c6ba..4bfbbd7374 100644 --- a/ompi/mca/mtl/portals4/mtl_portals4.h +++ b/ompi/mca/mtl/portals4/mtl_portals4.h @@ -41,9 +41,9 @@ struct mca_mtl_portals4_module_t { mca_mtl_base_module_t base; /** Eager limit; messages greater than this use a rendezvous protocol */ - size_t eager_limit; + unsigned long long eager_limit; /** Size of short message blocks */ - size_t recv_short_size; + unsigned long long recv_short_size; /** Number of short message blocks which should be created during startup */ int recv_short_num; /** Length of the send event queues */ diff --git a/ompi/mca/mtl/portals4/mtl_portals4_component.c b/ompi/mca/mtl/portals4/mtl_portals4_component.c index 1d322ecd5c..ac25d8ab60 100644 --- a/ompi/mca/mtl/portals4/mtl_portals4_component.c +++ b/ompi/mca/mtl/portals4/mtl_portals4_component.c @@ -21,7 +21,6 @@ #include "opal/mca/event/event.h" #include "opal/util/output.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/runtime/ompi_module_exchange.h" #include "mtl_portals4.h" @@ -29,15 +28,17 @@ #include "mtl_portals4_recv_short.h" #include "mtl_portals4_message.h" +static int ompi_mtl_portals4_component_register(void); static int ompi_mtl_portals4_component_open(void); static int ompi_mtl_portals4_component_close(void); static mca_mtl_base_module_t* ompi_mtl_portals4_component_init(bool enable_progress_threads, bool enable_mpi_threads); - OMPI_MODULE_DECLSPEC extern mca_mtl_base_component_2_0_0_t mca_mtl_portals4_component; +static unsigned int ompi_mtl_portals4_md_size_bit_width; + mca_mtl_base_component_2_0_0_t mca_mtl_portals4_component = { /* First, the mca_base_component_t struct containing meta @@ -51,7 +52,9 @@ mca_mtl_base_component_2_0_0_t mca_mtl_portals4_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ ompi_mtl_portals4_component_open, /* component open */ - ompi_mtl_portals4_component_close /* component close */ + ompi_mtl_portals4_component_close, /* component close */ + NULL, + ompi_mtl_portals4_component_register }, { /* The component is not checkpoint ready */ @@ -61,12 +64,114 @@ mca_mtl_base_component_2_0_0_t mca_mtl_portals4_component = { ompi_mtl_portals4_component_init, /* component init */ }; +static int mca_base_var_enum_value_t long_protocol_values[] = { + {eager, "eager"}, + {rndv, "rndv"}, + {0, NULL} +}; + +static int +ompi_mtl_portals4_component_register(void) +{ + mca_base_var_enum_t *new_enum; + int ret; + + ompi_mtl_portals4.eager_limit = 2 * 1024; + (void) mca_base_component_var_register(&mca_mtl_portals4_component.mtl_version, + "eager_limit", + "Cross-over point from eager to rendezvous sends", + MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, + NULL, + 0, + 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_portals4.eager_limit); + + ompi_mtl_portals4.recv_short_num = 32; + (void) mca_base_component_var_register(&mca_mtl_portals4_component.mtl_version, + "short_recv_num", + "Number of short message receive blocks", + MCA_BASE_VAR_TYPE_INT, + NULL, + 0, + 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_portals4.recv_short_num); + + ompi_mtl_portals4.recv_short_size = 2 * 1024 * 1024; + (void) mca_base_component_var_register(&mca_mtl_portals4_component.mtl_version, + "short_recv_size", + "Size of short message receive blocks", + MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, + NULL, + 0, + 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_portals4.recv_short_size); + + ompi_mtl_portals4.send_queue_size = 1024; + (void) mca_base_component_var_register(&mca_mtl_portals4_component.mtl_version, + "send_event_queue_size", + "Size of the send event queue in entries", + MCA_BASE_VAR_TYPE_INT, + NULL, + 0, + 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_portals4.send_queue_size); + + ompi_mtl_portals4.recv_queue_size = 1024; + (void) mca_base_component_var_register(&mca_mtl_portals4_component.mtl_version, + "recv_event_queue_size", + "Size of the recv event queue in entries", + MCA_BASE_VAR_TYPE_INT, + NULL, + 0, + 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_portals4.recv_queue_size); + + ompi_mtl_portals4_md_size_bit_width = 48; + (void) mca_base_component_var_register(&mca_mtl_portals4_component.mtl_version, + "md_size_bit_width", + "Number of bits used to specify the length of an MD to the portals4 library", + MCA_BASE_VAR_TYPE_UNSIGNED_INT, + NULL, + 0, + 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_portals4_md_size_bit_width); + + ompi_mtl_portals4.protocol = eager; + mca_base_var_enum_create("mtl_portals4_long_protocol", long_protocol_values, &new_enum); + ret = mca_base_component_var_register(&mca_mtl_portals4_component.mtl_version, + "long_protocol", + "Protocol to use for long messages. Valid entries are eager and rndv", + MCA_BASE_VAR_TYPE_INT, + new_enum, + 0, + 0, + OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_portals4.protocol); + OBJ_RELEASE(new_enum); + if (OPAL_SUCCESS != ret) { + opal_output(ompi_mtl_base_output, "Unknown protocol"); + return OMPI_ERR_NOT_SUPPORTED; + } + + return OMPI_SUCCESS; +} static int ompi_mtl_portals4_component_open(void) { - int tmp; - char *tmp_proto; int i; uint64_t fixed_md_nb; @@ -74,80 +179,10 @@ ompi_mtl_portals4_component_open(void) sizeof(ompi_mtl_portals4_request_t) - sizeof(struct mca_mtl_request_t); - mca_base_param_reg_int(&mca_mtl_portals4_component.mtl_version, - "eager_limit", - "Cross-over point from eager to rendezvous sends", - false, - false, - 2 * 1024, - &tmp); - ompi_mtl_portals4.eager_limit = tmp; - - mca_base_param_reg_int(&mca_mtl_portals4_component.mtl_version, - "short_recv_num", - "Number of short message receive blocks", - false, - false, - 32, - &tmp); - ompi_mtl_portals4.recv_short_num = tmp; - - mca_base_param_reg_int(&mca_mtl_portals4_component.mtl_version, - "short_recv_size", - "Size of short message receive blocks", - false, - false, - 2 * 1024 * 1024, - &tmp); - ompi_mtl_portals4.recv_short_size = tmp; - - mca_base_param_reg_int(&mca_mtl_portals4_component.mtl_version, - "send_event_queue_size", - "Size of the send event queue in entries", - false, - false, - 1024, - &tmp); - ompi_mtl_portals4.send_queue_size = tmp; - - mca_base_param_reg_int(&mca_mtl_portals4_component.mtl_version, - "recv_event_queue_size", - "Size of the recv event queue in entries", - false, - false, - 1024, - &tmp); - ompi_mtl_portals4.recv_queue_size = tmp; - - mca_base_param_reg_int(&mca_mtl_portals4_component.mtl_version, - "md_size_bit_width", - "Number of bits used to specify the length of an MD to the portals4 library", - false, - false, - 48, - &tmp); - if (48 < tmp) tmp = 48; - ompi_mtl_portals4.fixed_md_distance = (unsigned long int) 1<= 0x010d +static mca_base_var_enum_value_t path_query_values[] = { + {PSM_PATH_RES_NONE, "none"}, + {PSM_PATH_RES_OPP, "opp"}, + {0, NULL} +}; +#endif static int ompi_mtl_psm_component_register(void) { - int value; - char *service_id = NULL; - char *path_res = NULL; +#if PSM_VERNO >= 0x010d + mca_base_var_enum_t *new_enum; +#endif + int ret; - mca_base_param_reg_int(&mca_mtl_psm_component.super.mtl_version, - "connect_timeout", - "PSM connection timeout value in seconds", - false, false, 180, &ompi_mtl_psm.connect_timeout); - - mca_base_param_reg_int(&mca_mtl_psm_component.super.mtl_version, - "debug", - "PSM debug level", - false, false, 1, - &value); - ompi_mtl_psm.debug_level = value; - - mca_base_param_reg_int(&mca_mtl_psm_component.super.mtl_version, - "ib_unit", - "Truescale unit to use", - false, false, -1, - &ompi_mtl_psm.ib_unit); + ompi_mtl_psm.connect_timeout = 180; + (void) mca_base_component_var_register(&mca_mtl_psm_component.super.mtl_version, + "connect_timeout", + "PSM connection timeout value in seconds", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_psm.connect_timeout); - mca_base_param_reg_int(&mca_mtl_psm_component.super.mtl_version, - "ib_port", - "Truescale port on unit to use", - false, false, 0, - &ompi_mtl_psm.ib_port); + ompi_mtl_psm.debug_level = 1; + (void) mca_base_component_var_register(&mca_mtl_psm_component.super.mtl_version, + "debug", "PSM debug level", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_psm.debug_level); - mca_base_param_reg_int(&mca_mtl_psm_component.super.mtl_version, - "ib_service_level", - "Infiniband service level" - "(0 <= SL <= 15)", - false, false, 0, &ompi_mtl_psm.ib_service_level); + ompi_mtl_psm.ib_unit = -1; + (void) mca_base_component_var_register(&mca_mtl_psm_component.super.mtl_version, + "ib_unit", "Truescale unit to use", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_psm.ib_unit); + + ompi_mtl_psm.ib_port = 0; + (void) mca_base_component_var_register(&mca_mtl_psm_component.super.mtl_version, + "ib_port", "Truescale port on unit to use", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_psm.ib_port); + + ompi_mtl_psm.ib_service_level = 0; + (void) mca_base_component_var_register(&mca_mtl_psm_component.super.mtl_version, + "ib_service_level", "Infiniband service level" + "(0 <= SL <= 15)", MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_psm.ib_service_level); ompi_mtl_psm.ib_pkey = 0x7fffUL; - mca_base_param_reg_int(&mca_mtl_psm_component.super.mtl_version, - "ib_pkey", - "Infiniband partition key", - false, false, 0x7fffUL, - &value); - ompi_mtl_psm.ib_pkey = value; + (void) mca_base_component_var_register(&mca_mtl_psm_component.super.mtl_version, + "ib_pkey", "Infiniband partition key", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_psm.ib_pkey); #if PSM_VERNO >= 0x010d - mca_base_param_reg_string(&mca_mtl_psm_component.super.mtl_version, - "ib_service_id", - "Infiniband service ID to use for application (default is 0)", - false, false, "0x1000117500000000", - &service_id); - ompi_mtl_psm.ib_service_id = (uint64_t) strtoull(service_id, NULL, 0); - - mca_base_param_reg_string(&mca_mtl_psm_component.super.mtl_version, - "path_query", - "Path record query mechanisms (valid values: opp, none)", - false, false, NULL, &path_res); - if ((NULL != path_res) && strcasecmp(path_res, "none")) { - if (!strcasecmp(path_res, "opp")) - ompi_mtl_psm.path_res_type = PSM_PATH_RES_OPP; - else { - opal_show_help("help-mtl-psm.txt", - "path query mechanism unknown", true, - path_res, "OfedPlus (opp) | Static Routes (none)"); - return OMPI_ERR_NOT_FOUND; - } - } - else { - /* Default is "static/none" path record queries */ - ompi_mtl_psm.path_res_type = PSM_PATH_RES_NONE; - } + ompi_mtl_psm.ib_service_id = 0x1000117500000000ull; + (void) mca_base_component_var_register(&mca_mtl_psm_component.super.mtl_version, + "ib_service_id", + "Infiniband service ID to use for application (default is 0)", + MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_psm.ib_service_id); + + ompi_mtl_psm.path_res_type = PSM_PATH_RES_NONE; + mca_base_var_enum_create("mtl_psm_path_query", path_query_values, &new_enum); + ret = mca_base_component_var_register(&mca_mtl_psm_component.super.mtl_version, + "path_query", + "Path record query mechanisms", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mtl_psm.path_res_type); + OBJ_RELEASE(new_enum); #endif - - if (ompi_mtl_psm.ib_service_level < 0) { - ompi_mtl_psm.ib_service_level = 0; - } else if (ompi_mtl_psm.ib_service_level > 15) { - ompi_mtl_psm.ib_service_level = 15; - } - - return OMPI_SUCCESS; - + + return OMPI_SUCCESS; } static int @@ -160,6 +165,12 @@ ompi_mtl_psm_component_open(void) { struct stat st; + if (ompi_mtl_psm.ib_service_level < 0) { + ompi_mtl_psm.ib_service_level = 0; + } else if (ompi_mtl_psm.ib_service_level > 15) { + ompi_mtl_psm.ib_service_level = 15; + } + /* Component available only if Truescale hardware is present */ if (0 == stat("/dev/ipath", &st)) { return OMPI_SUCCESS; diff --git a/ompi/mca/mtl/psm/mtl_psm_types.h b/ompi/mca/mtl/psm/mtl_psm_types.h index 094a148c13..734825ce60 100644 --- a/ompi/mca/mtl/psm/mtl_psm_types.h +++ b/ompi/mca/mtl/psm/mtl_psm_types.h @@ -42,15 +42,17 @@ struct mca_mtl_psm_module_t { int32_t connect_timeout; - uint32_t debug_level; + int32_t debug_level; int32_t ib_unit; int32_t ib_port; int32_t ib_service_level; uint64_t ib_pkey; #if PSM_VERNO >= 0x010d - uint64_t ib_service_id; - psm_path_res_t path_res_type; + unsigned long long ib_service_id; + /* use int instead of psm_path_res_t so we can register this with + the MCA variable system */ + int path_res_type; #endif psm_ep_t ep; diff --git a/ompi/mca/op/base/op_base_open.c b/ompi/mca/op/base/op_base_open.c index 898c42c6b5..adbfa1b9aa 100644 --- a/ompi/mca/op/base/op_base_open.c +++ b/ompi/mca/op/base/op_base_open.c @@ -27,7 +27,6 @@ #include "opal/util/output.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/constants.h" #include "ompi/mca/op/op.h" @@ -49,6 +48,11 @@ int ompi_op_base_output = -1; bool ompi_op_base_components_opened_valid = false; opal_list_t ompi_op_base_components_opened; +/* + * Locals + */ +static int ompi_op_base_verbose; + static void module_constructor(ompi_op_base_module_t *m) { m->opm_enable = NULL; @@ -70,20 +74,29 @@ OBJ_CLASS_INSTANCE(ompi_op_base_module_t, opal_object_t, OBJ_CLASS_INSTANCE(ompi_op_base_module_1_0_0_t, opal_object_t, module_constructor_1_0_0, NULL); +static int ompi_op_base_register(int flags) +{ + /* Debugging / verbose output */ + ompi_op_base_verbose = 0; + (void) mca_base_var_register("ompi", "op", "base", "verbose", + "Verbosity level of the op framework", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_op_base_verbose); + + return OMPI_SUCCESS; +} + /* * Function for finding and opening either all MCA components, or the one * that was specifically requested via a MCA parameter. */ int ompi_op_base_open(void) { - int value; + (void) ompi_op_base_register(0); - /* Debugging / verbose output */ - - mca_base_param_reg_int_name("op", "base_verbose", - "Verbosity level of the op framework", - false, false, 0, &value); - if (0 != value) { + if (0 != ompi_op_base_verbose) { ompi_op_base_output = opal_output_open(NULL); } else { ompi_op_base_output = -1; diff --git a/ompi/mca/op/example/op_example_component.c b/ompi/mca/op/example/op_example_component.c index 286148f09f..ee7f1c630b 100644 --- a/ompi/mca/op/example/op_example_component.c +++ b/ompi/mca/op/example/op_example_component.c @@ -27,8 +27,6 @@ #include "ompi_config.h" -#include "opal/mca/base/mca_base_param.h" - #include "ompi/constants.h" #include "ompi/op/op.h" #include "ompi/mca/op/op.h" @@ -113,6 +111,7 @@ static int example_component_close(void) return OMPI_SUCCESS; } +static char *example_component_version; /* * Register MCA params. @@ -136,10 +135,16 @@ static int example_component_register(void) OP_EXAMPLE_LIBFOO_VERSION_MAJOR, OP_EXAMPLE_LIBFOO_VERSION_MINOR, OP_EXAMPLE_LIBFOO_VERSION_RELEASE); - mca_base_param_reg_string(&mca_op_example_component.super.opc_version, - "libfoo_version", - "Version of the libfoo support library that this component was built against.", - false, true, str, NULL); + example_component_version = str; + (void) mca_base_component_var_register(&mca_op_example_component.super.opc_version, + "libfoo_version", + "Version of the libfoo support library that this component was built against.", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_CONSTANT, + &example_component_version); + /* The variable system duplicated the string. */ free(str); /* Additionally, since this component is simulating hardware, @@ -148,17 +153,23 @@ static int example_component_register(void) types are supported. This allows you to change the behavior of this component at run-time (by setting these MCA params at run-time), simulating different kinds of hardware. */ - mca_base_param_reg_int(&mca_op_example_component.super.opc_version, - "hardware_available", - "Whether the hardware is available or not", - false, false, 1, &val); - mca_op_example_component.hardware_available = OPAL_INT_TO_BOOL(val); + mca_op_example_component.hardware_available = false; + (void) mca_base_component_var_register(&mca_op_example_component.super.opc_version, + "hardware_available", + "Whether the hardware is available or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_op_example_component.hardware_available); - mca_base_param_reg_int(&mca_op_example_component.super.opc_version, - "double_supported", - "Whether the double precision data types are supported or not", - false, false, 1, &val); - mca_op_example_component.double_supported = OPAL_INT_TO_BOOL(val); + mca_op_example_component.double_supported = true; + (void) mca_base_component_var_register(&mca_op_example_component.super.opc_version, + "double_supported", + "Whether the double precision data types are supported or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_op_example_component.double_supported); return OMPI_SUCCESS; } diff --git a/ompi/mca/op/x86/op_x86_component.c b/ompi/mca/op/x86/op_x86_component.c index 6ae83d6006..4d25d15329 100644 --- a/ompi/mca/op/x86/op_x86_component.c +++ b/ompi/mca/op/x86/op_x86_component.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -27,8 +27,8 @@ #include "ompi_config.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/util/output.h" +#include "opal/mca/base/mca_base_var.h" #include "ompi/constants.h" #include "ompi/op/op.h" @@ -123,6 +123,12 @@ static void hardware_probe(void) /* ... JMS fill in here ... */ } +static bool x86_mmx_available; +static bool x86_mmx2_available; +static bool x86_sse_available; +static bool x86_sse2_available; +static bool x86_sse3_available; + /* * Register MCA params. */ @@ -135,36 +141,50 @@ static int x86_component_register(void) /* Probe the hardware and see what we have */ hardware_probe(); - val = (0 != (mca_op_x86_component.oxc_hw_flags & OP_X86_HW_FLAGS_MMX)); - mca_base_param_reg_int(&mca_op_x86_component.super.opc_version, - "mmx_available", - "Whether the hardware supports MMX or not", - false, false, val, NULL); + x86_mmx_available = (0 != (mca_op_x86_component.oxc_hw_flags & OP_X86_HW_FLAGS_MMX)); + (void) mca_base_component_var_register(&mca_op_x86_component.super.opc_version, + "mmx_available", "Whether the hardware supports MMX or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &x86_mmx_available); - val = (0 != (mca_op_x86_component.oxc_hw_flags & OP_X86_HW_FLAGS_MMX2)); - mca_base_param_reg_int(&mca_op_x86_component.super.opc_version, - "mmx2_available", - "Whether the hardware supports MMX2 or not", - false, false, val, NULL); - - val = (0 != (mca_op_x86_component.oxc_hw_flags & OP_X86_HW_FLAGS_SSE)); - mca_base_param_reg_int(&mca_op_x86_component.super.opc_version, - "sse_available", - "Whether the hardware supports SSE or not", - false, false, val, NULL); - - val = (0 != (mca_op_x86_component.oxc_hw_flags & OP_X86_HW_FLAGS_SSE2)); - mca_base_param_reg_int(&mca_op_x86_component.super.opc_version, - "sse2_available", - "Whether the hardware supports SSE2 or not", - false, false, val, NULL); - - val = (0 != (mca_op_x86_component.oxc_hw_flags & OP_X86_HW_FLAGS_SSE3)); - mca_base_param_reg_int(&mca_op_x86_component.super.opc_version, - "sse3_available", - "Whether the hardware supports SSE3 or not", - false, false, val, NULL); - + x86_mmx2_available = (0 != (mca_op_x86_component.oxc_hw_flags & OP_X86_HW_FLAGS_MMX2)); + (void) mca_base_component_var_register(&mca_op_x86_component.super.opc_version, + "mmx2_available", "Whether the hardware supports MMX2 or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &x86_mmx2_available); + + x86_sse_available = (0 != (mca_op_x86_component.oxc_hw_flags & OP_X86_HW_FLAGS_SSE)); + (void) mca_base_component_var_register(&mca_op_x86_component.super.opc_version, + "sse_available", "Whether the hardware supports SSE or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &x86_sse_available); + + x86_sse2_available = (0 != (mca_op_x86_component.oxc_hw_flags & OP_X86_HW_FLAGS_SSE2)); + (void) mca_base_component_var_register(&mca_op_x86_component.super.opc_version, + "sse2_available", "Whether the hardware supports SSE2 or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &x86_sse2_available); + + x86_sse3_available = (0 != (mca_op_x86_component.oxc_hw_flags & OP_X86_HW_FLAGS_SSE3)); + (void) mca_base_component_var_register(&mca_op_x86_component.super.opc_version, + "sse3_available", "Whether the hardware supports SSE3 or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &x86_sse3_available); return OMPI_SUCCESS; } diff --git a/ompi/mca/osc/base/osc_base_init.c b/ompi/mca/osc/base/osc_base_init.c index b373a884c2..6dd26eb444 100644 --- a/ompi/mca/osc/base/osc_base_init.c +++ b/ompi/mca/osc/base/osc_base_init.c @@ -19,7 +19,6 @@ #include "ompi/constants.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/osc/osc.h" #include "ompi/mca/osc/base/base.h" #include "ompi/info/info.h" diff --git a/ompi/mca/osc/base/osc_base_open.c b/ompi/mca/osc/base/osc_base_open.c index 4419cf9645..2a5e482632 100644 --- a/ompi/mca/osc/base/osc_base_open.c +++ b/ompi/mca/osc/base/osc_base_open.c @@ -20,7 +20,6 @@ #include "opal/mca/mca.h" #include "opal/util/output.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/osc/osc.h" diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt.h b/ompi/mca/osc/pt2pt/osc_pt2pt.h index 931bcbb80f..48e9455d80 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt.h +++ b/ompi/mca/osc/pt2pt/osc_pt2pt.h @@ -40,7 +40,7 @@ struct ompi_osc_pt2pt_component_t { ompi_osc_base_component_t super; /** max size of eager message */ - size_t p2p_c_eager_size; + unsigned long long p2p_c_eager_size; /** free list of ompi_osc_pt2pt_sendreq_t structures */ opal_free_list_t p2p_c_sendreqs; diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt_component.c b/ompi/mca/osc/pt2pt/osc_pt2pt_component.c index 90123ab71b..c58af5017e 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt_component.c +++ b/ompi/mca/osc/pt2pt/osc_pt2pt_component.c @@ -40,7 +40,7 @@ #include "ompi/mca/osc/base/osc_base_obj_convert.h" #include "ompi/mca/pml/pml.h" -static int component_open(void); +static int component_register(void); static int component_fragment_cb(ompi_request_t *request); ompi_osc_pt2pt_component_t mca_osc_pt2pt_component = { @@ -51,8 +51,10 @@ ompi_osc_pt2pt_component_t mca_osc_pt2pt_component = { OMPI_MAJOR_VERSION, /* MCA component major version */ OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ - component_open, - NULL + NULL, + NULL, + NULL, + component_register }, { /* mca_base_component_data */ MCA_BASE_METADATA_PARAM_CHECKPOINT @@ -88,16 +90,16 @@ ompi_osc_pt2pt_module_t ompi_osc_pt2pt_module_template = { static int -component_open(void) +component_register(void) { - int tmp; - - mca_base_param_reg_int(&mca_osc_pt2pt_component.super.osc_version, - "eager_limit", - "Max size of eagerly sent data", - false, false, 16 * 1024, - &tmp); - mca_osc_pt2pt_component.p2p_c_eager_size = tmp; + mca_osc_pt2pt_component.p2p_c_eager_size = 16 * 1024; + (void) mca_base_component_var_register(&mca_osc_pt2pt_component.super.osc_version, + "eager_limit", + "Max size of eagerly sent data", + MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_osc_pt2pt_component.p2p_c_eager_size); return OMPI_SUCCESS; } diff --git a/ompi/mca/osc/rdma/osc_rdma_component.c b/ompi/mca/osc/rdma/osc_rdma_component.c index f3f588dc84..7f518732d4 100644 --- a/ompi/mca/osc/rdma/osc_rdma_component.c +++ b/ompi/mca/osc/rdma/osc_rdma_component.c @@ -46,7 +46,7 @@ #include "ompi/mca/bml/base/base.h" #include "ompi/mca/pml/pml.h" -static int component_open(void); +static int component_register(void); static void component_fragment_cb(struct mca_btl_base_module_t *btl, mca_btl_base_tag_t tag, mca_btl_base_descriptor_t *descriptor, @@ -61,8 +61,10 @@ ompi_osc_rdma_component_t mca_osc_rdma_component = { OMPI_MAJOR_VERSION, /* MCA component major version */ OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ - component_open, - NULL + NULL, + NULL, + NULL, + component_register }, { /* mca_base_component_data */ /* The component is not checkpoint ready */ @@ -106,6 +108,7 @@ check_config_value_bool(char *key, ompi_info_t *info) { char *value_string; int value_len, ret, flag, param; + const bool *flag_value; bool result; ret = ompi_info_get_valuelen(info, key, &value_len, &flag); @@ -128,57 +131,81 @@ check_config_value_bool(char *key, ompi_info_t *info) return result; info_not_found: - param = mca_base_param_find("osc", "rdma", key); + param = mca_base_var_find("ompi", "osc", "rdma", key); if (0 > param) return false; - ret = mca_base_param_lookup_int(param, &flag); + ret = mca_base_var_get_value(param, &flag_value, NULL, NULL); if (OMPI_SUCCESS != ret) return false; - return OPAL_INT_TO_BOOL(flag); + return flag_value[0]; } +static bool ompi_osc_rdma_eager_send; +static bool ompi_osc_rdma_use_buffers; +static bool ompi_osc_rdma_use_rdma; +static bool ompi_osc_rdma_rdma_completion_wait; +static bool ompi_osc_rdma_no_locks; static int -component_open(void) +component_register(void) { - mca_base_param_reg_int(&mca_osc_rdma_component.super.osc_version, - "eager_send", - "Attempt to start data movement during communication " - "call, instead of at synchrnoization time. " - "Info key of same name overrides this value.", - false, false, 1, NULL); + ompi_osc_rdma_eager_send = true; + (void) mca_base_component_var_register(&mca_osc_rdma_component.super.osc_version, + "eager_send", + "Attempt to start data movement during communication " + "call, instead of at synchrnoization time. " + "Info key of same name overrides this value.", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_osc_rdma_eager_send); - mca_base_param_reg_int(&mca_osc_rdma_component.super.osc_version, - "use_buffers", - "Coalesce messages during an epoch to reduce " - "network utilization. Info key of same name " - "overrides this value.", - false, false, 1, NULL); + ompi_osc_rdma_use_buffers = true; + (void) mca_base_component_var_register(&mca_osc_rdma_component.super.osc_version, + "use_buffers", + "Coalesce messages during an epoch to reduce " + "network utilization. Info key of same name " + "overrides this value.", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_osc_rdma_use_buffers); - mca_base_param_reg_int(&mca_osc_rdma_component.super.osc_version, - "use_rdma", - "Use real RDMA operations to transfer data. " - "Info key of same name overrides this value.", - false, false, 0, NULL); + ompi_osc_rdma_use_rdma = false; + (void) mca_base_component_var_register(&mca_osc_rdma_component.super.osc_version, + "use_rdma", + "Use real RDMA operations to transfer data. " + "Info key of same name overrides this value.", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_osc_rdma_use_rdma); - mca_base_param_reg_int(&mca_osc_rdma_component.super.osc_version, - "rdma_completion_wait", - "Wait for all completion of rdma events before " - "sending acknowledgment. Info key of same name " - "overrides this value.", - false, false, 1, NULL); + ompi_osc_rdma_rdma_completion_wait = true; + (void) mca_base_component_var_register(&mca_osc_rdma_component.super.osc_version, + "rdma_completion_wait", + "Wait for all completion of rdma events before " + "sending acknowledgment. Info key of same name " + "overrides this value.", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_osc_rdma_rdma_completion_wait); - mca_base_param_reg_int(&mca_osc_rdma_component.super.osc_version, - "no_locks", - "Enable optimizations available only if MPI_LOCK is " - "not used. " - "Info key of same name overrides this value.", - false, false, 0, NULL); + ompi_osc_rdma_no_locks = false; + (void) mca_base_component_var_register(&mca_osc_rdma_component.super.osc_version, + "no_locks", + "Enable optimizations available only if MPI_LOCK is " + "not used. " + "Info key of same name overrides this value.", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_osc_rdma_no_locks); return OMPI_SUCCESS; } - int ompi_osc_rdma_component_init(bool enable_progress_threads, bool enable_mpi_threads) diff --git a/ompi/mca/pml/base/pml_base_bsend.c b/ompi/mca/pml/base/pml_base_bsend.c index 38a985301f..050c8a6525 100644 --- a/ompi/mca/pml/base/pml_base_bsend.c +++ b/ompi/mca/pml/base/pml_base_bsend.c @@ -23,7 +23,6 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/mca/allocator/base/base.h" #include "ompi/mca/allocator/allocator.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/pml/pml.h" #include "ompi/mca/pml/base/pml_base_request.h" #include "ompi/mca/pml/base/pml_base_sendreq.h" @@ -48,7 +47,8 @@ static size_t mca_pml_bsend_pagesz; /* mmap page size */ static int mca_pml_bsend_pagebits; /* number of bits in pagesz */ static int32_t mca_pml_bsend_init = 0; - +/* defined in pml_base_open.c */ +extern char *ompi_pml_base_bsend_allocator_name; /* * Routine to return pages to sub-allocator as needed @@ -72,13 +72,11 @@ static void* mca_pml_bsend_alloc_segment( return addr; } - /* * One time initialization at startup */ int mca_pml_base_bsend_init(bool thread_safe) { - char *name; size_t tmp; if(OPAL_THREAD_ADD32(&mca_pml_bsend_init, 1) > 1) @@ -89,14 +87,9 @@ int mca_pml_base_bsend_init(bool thread_safe) OBJ_CONSTRUCT(&mca_pml_bsend_condition, opal_condition_t); /* lookup name of the allocator to use for buffered sends */ - (void) mca_base_param_reg_string_name ("pml", "base_bsend_allocator", NULL, false, false, - "basic", &name); - - if(NULL == (mca_pml_bsend_allocator_component = mca_allocator_component_lookup(name))) { - free(name); + if(NULL == (mca_pml_bsend_allocator_component = mca_allocator_component_lookup(ompi_pml_base_bsend_allocator_name))) { return OMPI_ERR_BUFFER; } - free(name); /* determine page size */ tmp = mca_pml_bsend_pagesz = sysconf(_SC_PAGESIZE); diff --git a/ompi/mca/pml/base/pml_base_open.c b/ompi/mca/pml/base/pml_base_open.c index f7de621cbd..adf35a0e6b 100644 --- a/ompi/mca/pml/base/pml_base_open.c +++ b/ompi/mca/pml/base/pml_base_open.c @@ -83,6 +83,48 @@ mca_pml_base_module_t mca_pml = { opal_list_t mca_pml_base_components_available; mca_pml_base_component_t mca_pml_base_selected_component; opal_pointer_array_t mca_pml_base_pml; +char *ompi_pml_base_bsend_allocator_name; + +static int ompi_pml_base_verbose = 0; + +#if !MCA_ompi_pml_DIRECT_CALL && OPAL_ENABLE_FT_CR == 1 +static char *ompi_pml_base_wrapper = NULL; +#endif + +static int pml_base_register(int flags) +{ +#if !MCA_ompi_pml_DIRECT_CALL && OPAL_ENABLE_FT_CR == 1 + int var_id; +#endif + + ompi_pml_base_bsend_allocator_name = "basic"; + (void) mca_base_var_register("ompi", "pml", "base", "bsend_allocator", NULL, + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_pml_base_bsend_allocator_name); + + ompi_pml_base_verbose = 0; + (void) mca_base_var_register("ompi", "pml", "base", "verbose", + "Verbosity level of the PML framework", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_pml_base_verbose); + +#if !MCA_ompi_pml_DIRECT_CALL && OPAL_ENABLE_FT_CR == 1 + ompi_pml_base_wrapper = NULL; + var_id = mca_base_var_register("ompi", "pml", "base", "wrapper", + "Use a Wrapper component around the selected PML component", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_pml_base_wrapper); + (void) mca_base_var_register_synonym(var_id, "ompi", "pml", NULL, "wrapper", 0); +#endif + + return OMPI_SUCCESS; +} /** * Function for finding and opening either all MCA components, or the one @@ -90,23 +132,19 @@ opal_pointer_array_t mca_pml_base_pml; */ int mca_pml_base_open(void) { - int value; #if OPAL_ENABLE_FT_CR == 1 char* wrapper_pml = NULL; #endif + (void) pml_base_register(0); + /* * Register some MCA parameters */ /* Debugging/Verbose output */ - mca_base_param_reg_int_name("pml", - "base_verbose", - "Verbosity level of the PML framework", - false, false, - 0, &value); mca_pml_base_output = opal_output_open(NULL); - opal_output_set_verbosity(mca_pml_base_output, value); + opal_output_set_verbosity(mca_pml_base_output, ompi_pml_base_verbose); /** * Construct the send and receive request queues. There are 2 reasons to do it @@ -147,20 +185,19 @@ int mca_pml_base_open(void) strdup(stringify(MCA_ompi_pml_DIRECT_CALL_COMPONENT))); #else { - char* default_pml = NULL; + const char **default_pml = NULL; + int var_id; - mca_base_param_reg_string_name("pml", NULL, - "Specify a specific PML to use", - false, false, "", &default_pml); + var_id = mca_base_var_find("ompi", "pml", NULL, NULL); + mca_base_var_get_value(var_id, &default_pml, NULL, NULL); - if( (0 == strlen(default_pml)) || (default_pml[0] == '^') ) { + if( (NULL == default_pml || NULL == default_pml[0] || + 0 == strlen(default_pml[0])) || (default_pml[0][0] == '^') ) { opal_pointer_array_add(&mca_pml_base_pml, strdup("ob1")); opal_pointer_array_add(&mca_pml_base_pml, strdup("cm")); } else { - opal_pointer_array_add(&mca_pml_base_pml, strdup(default_pml)); + opal_pointer_array_add(&mca_pml_base_pml, strdup(default_pml[0])); } - - free (default_pml); } #if OPAL_ENABLE_FT_CR == 1 /* @@ -168,12 +205,8 @@ int mca_pml_base_open(void) * - NULL or "" = No wrapper * - ow. select that specific wrapper component */ - mca_base_param_reg_string_name("pml", "wrapper", - "Use a Wrapper component around the selected PML component", - false, false, - NULL, &wrapper_pml); - if( NULL != wrapper_pml ) { - opal_pointer_array_add(&mca_pml_base_pml, wrapper_pml); + if( NULL != ompi_pml_base_wrapper) { + opal_pointer_array_add(&mca_pml_base_pml, ompi_pml_base_wrapper); } #endif diff --git a/ompi/mca/pml/bfo/pml_bfo.h b/ompi/mca/pml/bfo/pml_bfo.h index 73300b9e4b..c61de81f93 100644 --- a/ompi/mca/pml/bfo/pml_bfo.h +++ b/ompi/mca/pml/bfo/pml_bfo.h @@ -50,9 +50,9 @@ struct mca_pml_bfo_t { int free_list_num; /* initial size of free list */ int free_list_max; /* maximum size of free list */ int free_list_inc; /* number of elements to grow free list */ - size_t send_pipeline_depth; - size_t recv_pipeline_depth; - size_t rdma_put_retries_limit; + unsigned int send_pipeline_depth; + unsigned int recv_pipeline_depth; + unsigned int rdma_put_retries_limit; int max_rdma_per_request; int max_send_per_range; bool leave_pinned; @@ -78,7 +78,7 @@ struct mca_pml_bfo_t { bool enabled; char* allocator_name; mca_allocator_base_module_t* allocator; - uint32_t unexpected_limit; + unsigned int unexpected_limit; }; typedef struct mca_pml_bfo_t mca_pml_bfo_t; diff --git a/ompi/mca/pml/bfo/pml_bfo_component.c b/ompi/mca/pml/bfo/pml_bfo_component.c index c9902e3aa8..7742a652bd 100644 --- a/ompi/mca/pml/bfo/pml_bfo_component.c +++ b/ompi/mca/pml/bfo/pml_bfo_component.c @@ -24,7 +24,6 @@ #include "mpi.h" #include "ompi/runtime/params.h" #include "ompi/mca/pml/pml.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/pml/base/pml_base_bsend.h" #include "pml_bfo.h" #include "pml_bfo_hdr.h" @@ -41,6 +40,7 @@ OBJ_CLASS_INSTANCE( mca_pml_bfo_pckt_pending_t, NULL, NULL ); +static int mca_pml_bfo_component_register(void); static int mca_pml_bfo_component_open(void); static int mca_pml_bfo_component_close(void); static mca_pml_base_module_t* @@ -48,6 +48,7 @@ mca_pml_bfo_component_init( int* priority, bool enable_progress_threads, bool enable_mpi_threads ); static int mca_pml_bfo_component_fini(void); int mca_pml_bfo_output = 0; +static int mca_pml_bfo_verbose = 0; mca_pml_base_component_2_0_0_t mca_pml_bfo_component = { @@ -62,7 +63,9 @@ mca_pml_base_component_2_0_0_t mca_pml_bfo_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_pml_bfo_component_open, /* component open */ - mca_pml_bfo_component_close /* component close */ + mca_pml_bfo_component_close, /* component close */ + NULL, + mca_pml_bfo_component_register }, { /* The component is checkpoint ready */ @@ -83,57 +86,73 @@ void mca_pml_bfo_seg_free( struct mca_mpool_base_module_t* mpool, static inline int mca_pml_bfo_param_register_int( const char* param_name, - int default_value) + int default_value, + int *storage) { - int param_value = default_value; + *storage = default_value; + (void) mca_base_component_var_register(&mca_pml_bfo_component.pmlm_version, param_name, + NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); - (void) mca_base_param_reg_int (&mca_pml_bfo_component.pmlm_version, param_name, - NULL, false, false, default_value, ¶m_value); + return *storage; +} - return param_value; +static inline unsigned int mca_pml_bfo_param_register_uint( + const char* param_name, + unsigned int default_value, + unsigned int *storage) +{ + *storage = default_value; + (void) mca_base_component_var_register(&mca_pml_bfo_component.pmlm_version, param_name, + NULL, MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + + return *storage; +} + +static int mca_pml_bfo_component_register(void) +{ + int default_priority; + +#if PML_BFO + default_priority = 5; +#else /* PML_BFO */ + default_priority = 20; + mca_pml_bfo_param_register_int("priority", 20); +#endif /* PML_BFO */ + + (void) mca_pml_bfo_param_register_int("verbose", 0, &mca_pml_bfo_verbose); + (void) mca_pml_bfo_param_register_int("free_list_num", 4, &mca_pml_bfo.free_list_num); + (void) mca_pml_bfo_param_register_int("free_list_max", -1, &mca_pml_bfo.free_list_max); + (void) mca_pml_bfo_param_register_int("free_list_inc", 64, &mca_pml_bfo.free_list_inc); + (void) mca_pml_bfo_param_register_int("priority", default_priority, &mca_pml_bfo.priority); + (void) mca_pml_bfo_param_register_uint("send_pipeline_depth", 3, &mca_pml_bfo.send_pipeline_depth); + (void) mca_pml_bfo_param_register_uint("recv_pipeline_depth", 4, &mca_pml_bfo.recv_pipeline_depth); + (void) mca_pml_bfo_param_register_uint("rdma_put_retries_limit", 5, &mca_pml_bfo.rdma_put_retries_limit); + (void) mca_pml_bfo_param_register_int("max_rdma_per_request", 4, &mca_pml_bfo.max_rdma_per_request); + (void) mca_pml_bfo_param_register_int("max_send_per_range", 4, &mca_pml_bfo.max_send_per_range); + (void) mca_pml_bfo_param_register_uint("unexpected_limit", 128, &mca_pml_bfo.unexpected_limit); + + mca_pml_bfo.allocator_name = "bucket"; + (void) mca_base_component_var_register(&mca_pml_bfo_component.pmlm_version, + "allocator", + "Name of allocator component for unexpected messages", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_pml_bfo.allocator_name); + + return OMPI_SUCCESS; } static int mca_pml_bfo_component_open(void) { - int value; mca_allocator_base_component_t* allocator_component; - value = mca_pml_bfo_param_register_int("verbose", 0); mca_pml_bfo_output = opal_output_open(NULL); - opal_output_set_verbosity(mca_pml_bfo_output, value); - - mca_pml_bfo.free_list_num = - mca_pml_bfo_param_register_int("free_list_num", 4); - mca_pml_bfo.free_list_max = - mca_pml_bfo_param_register_int("free_list_max", -1); - mca_pml_bfo.free_list_inc = - mca_pml_bfo_param_register_int("free_list_inc", 64); - mca_pml_bfo.priority = -#if PML_BFO - mca_pml_bfo_param_register_int("priority", 5); -#else /* PML_BFO */ - mca_pml_bfo_param_register_int("priority", 20); -#endif /* PML_BFO */ - mca_pml_bfo.send_pipeline_depth = - mca_pml_bfo_param_register_int("send_pipeline_depth", 3); - mca_pml_bfo.recv_pipeline_depth = - mca_pml_bfo_param_register_int("recv_pipeline_depth", 4); - mca_pml_bfo.rdma_put_retries_limit = - mca_pml_bfo_param_register_int("rdma_put_retries_limit", 5); - mca_pml_bfo.max_rdma_per_request = - mca_pml_bfo_param_register_int("max_rdma_per_request", 4); - mca_pml_bfo.max_send_per_range = - mca_pml_bfo_param_register_int("max_send_per_range", 4); - - mca_pml_bfo.unexpected_limit = - mca_pml_bfo_param_register_int("unexpected_limit", 128); - - mca_base_param_reg_string(&mca_pml_bfo_component.pmlm_version, - "allocator", - "Name of allocator component for unexpected messages", - false, false, - "bucket", - &mca_pml_bfo.allocator_name); + opal_output_set_verbosity(mca_pml_bfo_output, mca_pml_bfo_verbose); allocator_component = mca_allocator_component_lookup( mca_pml_bfo.allocator_name ); if(NULL == allocator_component) { @@ -161,9 +180,6 @@ static int mca_pml_bfo_component_close(void) if (OMPI_SUCCESS != (rc = mca_bml_base_close())) { return rc; } - if (NULL != mca_pml_bfo.allocator_name) { - free(mca_pml_bfo.allocator_name); - } opal_output_close(mca_pml_bfo_output); return OMPI_SUCCESS; diff --git a/ompi/mca/pml/cm/pml_cm_component.c b/ompi/mca/pml/cm/pml_cm_component.c index df39300a21..1d41a7c3c0 100644 --- a/ompi/mca/pml/cm/pml_cm_component.c +++ b/ompi/mca/pml/cm/pml_cm_component.c @@ -19,7 +19,6 @@ #include "pml_cm.h" #include "opal/mca/event/event.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/mtl/mtl.h" #include "ompi/mca/mtl/base/base.h" #include "ompi/mca/pml/base/pml_base_bsend.h" @@ -77,37 +76,37 @@ static int mca_pml_cm_component_register(void) { - mca_base_param_reg_int(&mca_pml_cm_component.pmlm_version, - "free_list_num", - "Initial size of request free lists", - false, - false, - 4, - &ompi_pml_cm.free_list_num); + ompi_pml_cm.free_list_num = 4; + (void) mca_base_component_var_register(&mca_pml_cm_component.pmlm_version, "free_list_num", + "Initial size of request free lists", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_pml_cm.free_list_num); - mca_base_param_reg_int(&mca_pml_cm_component.pmlm_version, - "free_list_max", - "Maximum size of request free lists", - false, - false, - -1, - &ompi_pml_cm.free_list_max); + ompi_pml_cm.free_list_max = -1; + (void) mca_base_component_var_register(&mca_pml_cm_component.pmlm_version, "free_list_max", + "Maximum size of request free lists", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_pml_cm.free_list_max); - mca_base_param_reg_int(&mca_pml_cm_component.pmlm_version, - "free_list_inc", - "Number of elements to add when growing request free lists", - false, - false, - 64, - &ompi_pml_cm.free_list_inc); + ompi_pml_cm.free_list_inc = 64; + (void) mca_base_component_var_register(&mca_pml_cm_component.pmlm_version, "free_list_inc", + "Number of elements to add when growing request free lists", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_pml_cm.free_list_inc); - mca_base_param_reg_int(&mca_pml_cm_component.pmlm_version, - "priority", - "CM PML selection priority", - false, - false, - 10, - &ompi_pml_cm.default_priority); + ompi_pml_cm.default_priority = 10; + (void) mca_base_component_var_register(&mca_pml_cm_component.pmlm_version, "priority", + "CM PML selection priority", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_pml_cm.default_priority); return OPAL_SUCCESS; } diff --git a/ompi/mca/pml/crcpw/pml_crcpw_component.c b/ompi/mca/pml/crcpw/pml_crcpw_component.c index 2b2784a182..b926e9edf9 100644 --- a/ompi/mca/pml/crcpw/pml_crcpw_component.c +++ b/ompi/mca/pml/crcpw/pml_crcpw_component.c @@ -26,11 +26,11 @@ #include "mpi.h" #include "ompi/mca/pml/pml.h" #include "ompi/mca/btl/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/pml/base/pml_base_bsend.h" #include "ompi/mca/pml/crcpw/pml_crcpw.h" #include "ompi/mca/bml/base/base.h" +static int mca_pml_crcpw_component_register(void); mca_pml_crcpw_component_t mca_pml_crcpw_component = { { @@ -45,7 +45,9 @@ mca_pml_crcpw_component_t mca_pml_crcpw_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_pml_crcpw_component_open, /* component open */ - mca_pml_crcpw_component_close /* component close */ + mca_pml_crcpw_component_close, /* component close */ + NULL, + mca_pml_crcpw_component_register }, { /* The component is checkpoint ready */ @@ -66,28 +68,35 @@ mca_pml_crcpw_component_t mca_pml_crcpw_component = { ompi_free_list_t pml_state_list; bool pml_crcpw_is_finalized = false; +static int mca_pml_crcpw_component_register(void) +{ + /* + * Register some MCA parameters + */ + mca_pml_crcpw_component.priority = PML_SELECT_WRAPPER_PRIORITY; + (void) mca_base_component_var_register(&mca_pml_crcpw_component.super.pmlm_version, "priority", + "Priority of the PML crcpw component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_pml_crcpw_component.priority); + + mca_pml_crcpw_component.verbose = 0; + (void) mca_base_component_var_register(&mca_pml_crcpw_component.super.pmlm_version, "verbose", + "Verbose level for the PML crcpw component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_pml_crcpw_component.verbose); + + return OMPI_SUCCESS; +} + int mca_pml_crcpw_component_open(void) { opal_output_verbose( 10, mca_pml_crcpw_component.output_handle, "pml:crcpw: component_open: Open"); - /* - * Register some MCA parameters - */ - mca_base_param_reg_int(&mca_pml_crcpw_component.super.pmlm_version, - "priority", - "Priority of the PML crcpw component", - false, false, - mca_pml_crcpw_component.priority, - &mca_pml_crcpw_component.priority); - - mca_base_param_reg_int(&mca_pml_crcpw_component.super.pmlm_version, - "verbose", - "Verbose level for the PML crcpw component", - false, false, - mca_pml_crcpw_component.verbose, - &mca_pml_crcpw_component.verbose); - mca_pml_crcpw_component.output_handle = opal_output_open(NULL); if ( 0 != mca_pml_crcpw_component.verbose) { opal_output_set_verbosity(mca_pml_crcpw_component.output_handle, diff --git a/ompi/mca/pml/dr/pml_dr.h b/ompi/mca/pml/dr/pml_dr.h index 0fc00ca449..b04ac709e7 100644 --- a/ompi/mca/pml/dr/pml_dr.h +++ b/ompi/mca/pml/dr/pml_dr.h @@ -47,8 +47,8 @@ struct mca_pml_dr_t { int free_list_num; /* initial size of free list */ int free_list_max; /* maximum size of free list */ int free_list_inc; /* number of elements to grow free list */ - size_t eager_limit; /* maximum eager limit size - overrides btl setting */ - size_t send_pipeline_depth; + unsigned int eager_limit; /* maximum eager limit size - overrides btl setting */ + unsigned int send_pipeline_depth; bool enabled; /* lock queue accesses */ diff --git a/ompi/mca/pml/dr/pml_dr_component.c b/ompi/mca/pml/dr/pml_dr_component.c index ad6e4f5a6b..740e050759 100644 --- a/ompi/mca/pml/dr/pml_dr_component.c +++ b/ompi/mca/pml/dr/pml_dr_component.c @@ -22,7 +22,6 @@ #include "mpi.h" #include "ompi/mca/pml/pml.h" #include "ompi/mca/btl/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/pml/base/pml_base_bsend.h" #include "pml_dr.h" #include "pml_dr_hdr.h" @@ -33,6 +32,7 @@ #include "ompi/mca/bml/base/base.h" #include "pml_dr_component.h" +static int mca_pml_dr_component_register(void); static int mca_pml_dr_component_open(void); static int mca_pml_dr_component_close(void); static mca_pml_base_module_t* @@ -41,6 +41,12 @@ mca_pml_dr_component_init( int* priority, bool enable_mpi_threads ); static int mca_pml_dr_component_fini(void); +static unsigned int mca_pml_dr_wdog_timer_sec; +static unsigned int mca_pml_dr_wdog_timer_usec; + +static unsigned int mca_pml_dr_ack_timer_sec; +static unsigned int mca_pml_dr_ack_timer_usec; + mca_pml_base_component_2_0_0_t mca_pml_dr_component = { /* First, the mca_base_component_t struct containing meta @@ -54,7 +60,9 @@ mca_pml_base_component_2_0_0_t mca_pml_dr_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_pml_dr_component_open, /* component open */ - mca_pml_dr_component_close /* component close */ + mca_pml_dr_component_close, /* component close */ + NULL, + mca_pml_dr_component_register }, { /* This component is not checkpoint ready */ @@ -68,51 +76,61 @@ mca_pml_base_component_2_0_0_t mca_pml_dr_component = { static inline int mca_pml_dr_param_register_int( const char* param_name, - int default_value ) + int default_value, int *storage) { - int param_value = default_value; + *storage = default_value; + (void) mca_base_component_var_register(&mca_pml_dr_component.pmlm_version, param_name, + NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); - (void) mca_base_param_reg_int (&mca_pml_dr_component.pmlm_version, param_name, - NULL, false, false, default_value, ¶m_value); + return *storage; +} - return param_value; +static inline unsigned int +mca_pml_dr_param_register_uint( const char* param_name, + unsigned int default_value, + unsigned int *storage) +{ + *storage = default_value; + (void) mca_base_component_var_register(&mca_pml_dr_component.pmlm_version, param_name, + NULL, MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + + return *storage; +} + +static int mca_pml_dr_component_register(void) +{ + (void) mca_pml_dr_param_register_int("free_list_num", 4, &mca_pml_dr.free_list_num); + (void) mca_pml_dr_param_register_int("free_list_max", -1, &mca_pml_dr.free_list_max); + (void) mca_pml_dr_param_register_int("free_list_inc", 64, &mca_pml_dr.free_list_inc); + (void) mca_pml_dr_param_register_int("priority", 10, &mca_pml_dr.priority); + (void) mca_pml_dr_param_register_uint("eager_limit", 128 * 1024, &mca_pml_dr.eager_limit); + (void) mca_pml_dr_param_register_uint("send_pipeline_depth", 3, &mca_pml_dr.send_pipeline_depth); + (void) mca_pml_dr_param_register_int("wdog_timer_sec", 5, (int *) &mca_pml_dr_wdog_timer_sec); + (void) mca_pml_dr_param_register_int("wdog_timer_usec", 0, (int *) &mca_pml_dr_wdog_timer_usec); + (void) mca_pml_dr_param_register_int("wdog_timer_multiplier", 1, &mca_pml_dr.wdog_timer_multiplier); + (void) mca_pml_dr_param_register_int("wdog_retry_max", 1, &mca_pml_dr.wdog_retry_max); + (void) mca_pml_dr_param_register_int("ack_timer_sec", 10, (int *) &mca_pml_dr_ack_timer_sec); + (void) mca_pml_dr_param_register_int("ack_timer_usec", 0, (int *) &mca_pml_dr_ack_timer_usec); + (void) mca_pml_dr_param_register_int("ack_timer_multiplier", 1, &mca_pml_dr.ack_timer_multiplier); + (void) mca_pml_dr_param_register_int("ack_retry_max", 3, &mca_pml_dr.ack_retry_max); + + /* default is to csum all data */ + (void) mca_pml_dr_param_register_int("enable_csum", 1, &mca_pml_dr.enable_csum); + + return OMPI_SUCCESS; } int mca_pml_dr_component_open(void) { - mca_pml_dr.free_list_num = - mca_pml_dr_param_register_int("free_list_num", 4); - mca_pml_dr.free_list_max = - mca_pml_dr_param_register_int("free_list_max", -1); - mca_pml_dr.free_list_inc = - mca_pml_dr_param_register_int("free_list_inc", 64); - mca_pml_dr.priority = - mca_pml_dr_param_register_int("priority", 10); - mca_pml_dr.eager_limit = - mca_pml_dr_param_register_int("eager_limit", 128 * 1024); - mca_pml_dr.send_pipeline_depth = - mca_pml_dr_param_register_int("send_pipeline_depth", 3); - mca_pml_dr.wdog_timer.tv_sec = - mca_pml_dr_param_register_int("wdog_timer_sec", 5); - mca_pml_dr.wdog_timer.tv_usec = - mca_pml_dr_param_register_int("wdog_timer_usec", 0); - mca_pml_dr.wdog_timer_multiplier = - mca_pml_dr_param_register_int("wdog_timer_multiplier", 1); - mca_pml_dr.wdog_retry_max = - mca_pml_dr_param_register_int("wdog_retry_max", 1); - - mca_pml_dr.ack_timer.tv_sec = - mca_pml_dr_param_register_int("ack_timer_sec", 10); - mca_pml_dr.ack_timer.tv_usec = - mca_pml_dr_param_register_int("ack_timer_usec", 0); - mca_pml_dr.ack_timer_multiplier = - mca_pml_dr_param_register_int("ack_timer_multiplier", 1); - mca_pml_dr.ack_retry_max = - mca_pml_dr_param_register_int("ack_retry_max", 3); - - /* default is to csum all data */ - mca_pml_dr.enable_csum = - mca_pml_dr_param_register_int("enable_csum", 1); + mca_pml_dr.wdog_timer.tv_sec = mca_pml_dr_wdog_timer_sec; + mca_pml_dr.wdog_timer.tv_usec = mca_pml_dr_wdog_timer_usec; + + mca_pml_dr.ack_timer.tv_sec = mca_pml_dr_ack_timer_sec; + mca_pml_dr.ack_timer.tv_usec = mca_pml_dr_ack_timer_usec; mca_pml_dr.enabled = false; return mca_bml_base_open(); diff --git a/ompi/mca/pml/example/pml_example_component.c b/ompi/mca/pml/example/pml_example_component.c index 99f9688c24..30733b3609 100644 --- a/ompi/mca/pml/example/pml_example_component.c +++ b/ompi/mca/pml/example/pml_example_component.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology @@ -16,14 +17,16 @@ #include "opal/mca/event/event.h" #include "pml_example.h" -#include "opal/mca/base/mca_base_param.h" +static int mca_pml_example_component_register(void); static int mca_pml_example_component_open(void); static int mca_pml_example_component_close(void); static mca_pml_base_module_t* mca_pml_example_component_init( int* priority, bool *allow_multi_user_threads, bool *have_hidden_threads ); static int mca_pml_example_component_fini(void); +static int mca_pml_example_priority = 0; + mca_pml_base_component_2_0_0_t mca_pml_example_component = { /* First, the mca_base_component_t struct containing meta @@ -37,7 +40,9 @@ mca_pml_base_component_2_0_0_t mca_pml_example_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_pml_example_component_open, /* component open */ - mca_pml_example_component_close /* component close */ + mca_pml_example_component_close, /* component close */ + NULL, + mca_pml_example_component_register }, { /* The component is checkpoint ready */ @@ -48,15 +53,17 @@ mca_pml_base_component_2_0_0_t mca_pml_example_component = { mca_pml_example_component_fini /* component finalize */ }; -static inline int mca_pml_example_param_register_int( const char* param_name, - int default_value ) +static int mca_pml_example_component_register(void) { - int param_value = default_value; + mca_pml_example_priority = 0; + (void) mca_base_component_var_register(&mca_pml_example_component.pmlm_version, + "priority", "Priority of the pml example component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_pml_example_priority); - (void) mca_base_param_reg_int (&mca_pml_example_component.pmlm_version, param_name, - NULL, false, false, default_value, ¶m_value); - - return param_value; + return OMPI_SUCCESS; } static int mca_pml_example_component_open(void) @@ -74,7 +81,7 @@ mca_pml_example_component_init( int* priority, bool *allow_multi_user_threads, bool *have_hidden_threads ) { - *priority = mca_pml_example_param_register_int( "priority", 0 ); + *priority = mca_pml_example_priority; *have_hidden_threads = false; *allow_multi_user_threads &= true; return &mca_pml_example.super; diff --git a/ompi/mca/pml/ob1/pml_ob1.h b/ompi/mca/pml/ob1/pml_ob1.h index 496ef6058a..46e95a7b35 100644 --- a/ompi/mca/pml/ob1/pml_ob1.h +++ b/ompi/mca/pml/ob1/pml_ob1.h @@ -81,7 +81,7 @@ struct mca_pml_ob1_t { bool enabled; char* allocator_name; mca_allocator_base_module_t* allocator; - uint32_t unexpected_limit; + unsigned int unexpected_limit; }; typedef struct mca_pml_ob1_t mca_pml_ob1_t; diff --git a/ompi/mca/pml/ob1/pml_ob1_component.c b/ompi/mca/pml/ob1/pml_ob1_component.c index 152ba1ec34..c9ff6f86ea 100644 --- a/ompi/mca/pml/ob1/pml_ob1_component.c +++ b/ompi/mca/pml/ob1/pml_ob1_component.c @@ -24,7 +24,6 @@ #include "mpi.h" #include "ompi/runtime/params.h" #include "ompi/mca/pml/pml.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/pml/base/pml_base_bsend.h" #include "pml_ob1.h" #include "pml_ob1_hdr.h" @@ -41,6 +40,7 @@ OBJ_CLASS_INSTANCE( mca_pml_ob1_pckt_pending_t, NULL, NULL ); +static int mca_pml_ob1_component_register(void); static int mca_pml_ob1_component_open(void); static int mca_pml_ob1_component_close(void); static mca_pml_base_module_t* @@ -48,6 +48,7 @@ mca_pml_ob1_component_init( int* priority, bool enable_progress_threads, bool enable_mpi_threads ); static int mca_pml_ob1_component_fini(void); int mca_pml_ob1_output = 0; +static int mca_pml_ob1_verbose = 0; mca_pml_base_component_2_0_0_t mca_pml_ob1_component = { @@ -62,7 +63,9 @@ mca_pml_base_component_2_0_0_t mca_pml_ob1_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_pml_ob1_component_open, /* component open */ - mca_pml_ob1_component_close /* component close */ + mca_pml_ob1_component_close, /* component close */ + NULL, + mca_pml_ob1_component_register }, { /* The component is checkpoint ready */ @@ -83,59 +86,82 @@ void mca_pml_ob1_seg_free( struct mca_mpool_base_module_t* mpool, static inline int mca_pml_ob1_param_register_int( const char* param_name, - int default_value) + int default_value, + int *storage) { - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_pml_ob1_component.pmlm_version, param_name, - NULL, false, false, default_value, ¶m_value); - - return param_value; + *storage = default_value; + (void) mca_base_component_var_register(&mca_pml_ob1_component.pmlm_version, param_name, + NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; } -static int mca_pml_ob1_component_open(void) +static inline unsigned int mca_pml_ob1_param_register_uint( + const char* param_name, + unsigned int default_value, + unsigned int *storage) { - int value; - mca_allocator_base_component_t* allocator_component; + *storage = default_value; + (void) mca_base_component_var_register(&mca_pml_ob1_component.pmlm_version, param_name, + NULL, MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; +} - value = mca_pml_ob1_param_register_int("verbose", 0); - mca_pml_ob1_output = opal_output_open(NULL); - opal_output_set_verbosity(mca_pml_ob1_output, value); +static inline size_t mca_pml_ob1_param_register_sizet( + const char* param_name, + size_t default_value, + size_t *storage) +{ + *storage = default_value; + (void) mca_base_component_var_register(&mca_pml_ob1_component.pmlm_version, param_name, + NULL, MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + return *storage; +} - mca_pml_ob1.free_list_num = - mca_pml_ob1_param_register_int("free_list_num", 4); - mca_pml_ob1.free_list_max = - mca_pml_ob1_param_register_int("free_list_max", -1); - mca_pml_ob1.free_list_inc = - mca_pml_ob1_param_register_int("free_list_inc", 64); - mca_pml_ob1.priority = - mca_pml_ob1_param_register_int("priority", 20); - mca_pml_ob1.send_pipeline_depth = - mca_pml_ob1_param_register_int("send_pipeline_depth", 3); - mca_pml_ob1.recv_pipeline_depth = - mca_pml_ob1_param_register_int("recv_pipeline_depth", 4); +static int mca_pml_ob1_component_register(void) +{ + mca_pml_ob1_param_register_int("verbose", 0, &mca_pml_ob1_verbose); + + mca_pml_ob1_param_register_int("free_list_num", 4, &mca_pml_ob1.free_list_num); + mca_pml_ob1_param_register_int("free_list_max", -1, &mca_pml_ob1.free_list_max); + mca_pml_ob1_param_register_int("free_list_inc", 64, &mca_pml_ob1.free_list_inc); + mca_pml_ob1_param_register_int("priority", 20, &mca_pml_ob1.priority); + mca_pml_ob1_param_register_sizet("send_pipeline_depth", 3, &mca_pml_ob1.send_pipeline_depth); + mca_pml_ob1_param_register_sizet("recv_pipeline_depth", 4, &mca_pml_ob1.recv_pipeline_depth); /* NTH: we can get into a live-lock situation in the RDMA failure path so disable RDMA retries for now. Falling back to send may suck but it is better than hanging */ mca_pml_ob1.rdma_retries_limit = 0; -/* mca_pml_ob1.rdma_retries_limit = */ -/* mca_pml_ob1_param_register_int("rdma_retries_limit", 5); */ + /* mca_pml_ob1_param_register_sizet("rdma_retries_limit", 5, &mca_pml_ob1.rdma_retries_limit); */ - mca_pml_ob1.max_rdma_per_request = - mca_pml_ob1_param_register_int("max_rdma_per_request", 4); - mca_pml_ob1.max_send_per_range = - mca_pml_ob1_param_register_int("max_send_per_range", 4); + mca_pml_ob1_param_register_int("max_rdma_per_request", 4, &mca_pml_ob1.max_rdma_per_request); + mca_pml_ob1_param_register_int("max_send_per_range", 4, &mca_pml_ob1.max_send_per_range); - mca_pml_ob1.unexpected_limit = - mca_pml_ob1_param_register_int("unexpected_limit", 128); + mca_pml_ob1_param_register_uint("unexpected_limit", 128, &mca_pml_ob1.unexpected_limit); - mca_base_param_reg_string(&mca_pml_ob1_component.pmlm_version, - "allocator", - "Name of allocator component for unexpected messages", - false, false, - "bucket", - &mca_pml_ob1.allocator_name); + mca_pml_ob1.allocator_name = "bucket"; + (void) mca_base_component_var_register(&mca_pml_ob1_component.pmlm_version, "allocator", + "Name of allocator component for unexpected messages", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_pml_ob1.allocator_name); + + return OMPI_SUCCESS; +} + +static int mca_pml_ob1_component_open(void) +{ + mca_allocator_base_component_t* allocator_component; + + mca_pml_ob1_output = opal_output_open(NULL); + opal_output_set_verbosity(mca_pml_ob1_output, mca_pml_ob1_verbose); allocator_component = mca_allocator_component_lookup( mca_pml_ob1.allocator_name ); if(NULL == allocator_component) { @@ -163,9 +189,6 @@ static int mca_pml_ob1_component_close(void) if (OMPI_SUCCESS != (rc = mca_bml_base_close())) { return rc; } - if (NULL != mca_pml_ob1.allocator_name) { - free(mca_pml_ob1.allocator_name); - } opal_output_close(mca_pml_ob1_output); return OMPI_SUCCESS; diff --git a/ompi/mca/pml/v/pml_v_component.c b/ompi/mca/pml/v/pml_v_component.c index c66be25cea..dfeaac1832 100644 --- a/ompi/mca/pml/v/pml_v_component.c +++ b/ompi/mca/pml/v/pml_v_component.c @@ -11,7 +11,6 @@ #include "ompi_config.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/mca/base/base.h" #include "opal/mca/base/mca_base_component_repository.h" #include "ompi/constants.h" @@ -21,6 +20,7 @@ #include "pml_v_output.h" #include "pml_v.h" +static int mca_pml_v_component_register(void); static int mca_pml_v_component_open(void); static int mca_pml_v_component_close(void); static int mca_pml_v_component_parasite_close(void); @@ -31,9 +31,6 @@ static int mca_pml_v_component_parasite_finalize(void); static int mca_pml_v_enable(bool enable); -static inline int mca_pml_v_param_register_int( const char* param_name, int default_value); -static inline char *mca_pml_v_param_register_string( const char* param_name, char *default_value); - mca_pml_base_component_2_0_0_t mca_pml_v_component = { /* First, the mca_base_component_t struct containing meta @@ -45,7 +42,9 @@ mca_pml_base_component_2_0_0_t mca_pml_v_component = OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_pml_v_component_open, - mca_pml_v_component_close + mca_pml_v_component_close, + NULL, + mca_pml_v_component_register }, { MCA_BASE_METADATA_PARAM_NONE /* Component is not checkpointable */ @@ -58,37 +57,54 @@ mca_pml_base_component_2_0_0_t mca_pml_v_component = static bool pml_v_enable_progress_treads = OMPI_ENABLE_PROGRESS_THREADS; static bool pml_v_enable_mpi_thread_multiple = OMPI_ENABLE_THREAD_MULTIPLE; +static char *ompi_pml_vprotocol_include_list; +static char *ompi_pml_v_output; +static int ompi_pml_v_verbose; + /******************************************************************************* * MCA level functions - parasite setup */ +static int mca_pml_v_component_register(void) +{ + int var_id; + + ompi_pml_v_output = "stderr"; + (void) mca_base_component_var_register(&mca_pml_v_component.pmlm_version, + "output", NULL, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_pml_v_output); + + ompi_pml_v_verbose = 0; + (void) mca_base_component_var_register(&mca_pml_v_component.pmlm_version, + "verbose", "Verbosity of the pml v component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_pml_v_verbose); + + ompi_pml_vprotocol_include_list = ""; + /* This parameter needs to go away if pml/v is unloaded so register it with a pml/v name */ + var_id = mca_base_component_var_register(&mca_pml_v_component.pmlm_version, + "vprotocol", "Specify a specific vprotocol to use", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_pml_vprotocol_include_list); + (void) mca_base_var_register_synonym(var_id, "ompi", "vprotocol", NULL, NULL, 0); + + return OMPI_SUCCESS; +} + static int mca_pml_v_component_open(void) { - char *output; - int verbose; - int priority; - char *vprotocol_include_list; int rc; - - priority = mca_pml_v_param_register_int("priority", -1); - output = mca_pml_v_param_register_string("output", "stderr"); - verbose = mca_pml_v_param_register_int("verbose", 0); - mca_base_param_reg_string_name("vprotocol", NULL, - "Specify a specific vprotocol to use", - false, false, "", &vprotocol_include_list); - - pml_v_output_open(output, verbose); - free(output); - - if(-1 != priority) - V_OUTPUT_ERR("pml_v: Overriding priority setting (%d) with -1. The PML V should NEVER be the selected component; even when enabling fault tolerance.", priority); + pml_v_output_open(ompi_pml_v_output, ompi_pml_v_verbose); V_OUTPUT_VERBOSE(500, "loaded"); - rc = mca_vprotocol_base_open(vprotocol_include_list); - if (NULL != vprotocol_include_list) { - free (vprotocol_include_list); - } + rc = mca_vprotocol_base_open(ompi_pml_vprotocol_include_list); return rc; } @@ -238,29 +254,3 @@ static int mca_pml_v_enable(bool enable) ompi_request_functions = mca_pml_v.host_request_fns; return OMPI_SUCCESS; } - - -/******************************************************************************* - * utilities - */ -static inline int mca_pml_v_param_register_int( const char* param_name, - int default_value ) -{ - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_pml_v_component.pmlm_version, param_name, - NULL, false, false, default_value, ¶m_value); - - return param_value; -} - -static inline char *mca_pml_v_param_register_string( const char* param_name, - char *default_value ) -{ - char *param_value = default_value; - - (void) mca_base_param_reg_string (&mca_pml_v_component.pmlm_version, param_name, - NULL, false, false, default_value, ¶m_value); - - return param_value; -} diff --git a/ompi/mca/pubsub/base/pubsub_base_close.c b/ompi/mca/pubsub/base/pubsub_base_close.c index bc39ec8c82..1d76726883 100644 --- a/ompi/mca/pubsub/base/pubsub_base_close.c +++ b/ompi/mca/pubsub/base/pubsub_base_close.c @@ -19,8 +19,6 @@ #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" - #include "ompi/mca/pubsub/pubsub.h" #include "ompi/mca/pubsub/base/base.h" #include "opal/util/output.h" diff --git a/ompi/mca/pubsub/base/pubsub_base_open.c b/ompi/mca/pubsub/base/pubsub_base_open.c index 92c5af1a2d..f676eadd97 100644 --- a/ompi/mca/pubsub/base/pubsub_base_open.c +++ b/ompi/mca/pubsub/base/pubsub_base_open.c @@ -20,8 +20,6 @@ #include "opal/util/output.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" - #include "ompi/mca/pubsub/pubsub.h" #include "ompi/mca/pubsub/base/base.h" diff --git a/ompi/mca/pubsub/base/pubsub_base_select.c b/ompi/mca/pubsub/base/pubsub_base_select.c index 301e0110d7..146c60acc2 100644 --- a/ompi/mca/pubsub/base/pubsub_base_select.c +++ b/ompi/mca/pubsub/base/pubsub_base_select.c @@ -21,7 +21,6 @@ #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/mca/base/mca_base_component_repository.h" #include "ompi/mca/pubsub/pubsub.h" diff --git a/ompi/mca/pubsub/orte/pubsub_orte_component.c b/ompi/mca/pubsub/orte/pubsub_orte_component.c index 1b29660ff3..bb679c2989 100644 --- a/ompi/mca/pubsub/orte/pubsub_orte_component.c +++ b/ompi/mca/pubsub/orte/pubsub_orte_component.c @@ -21,6 +21,7 @@ #include "pubsub_orte.h" +static int pubsub_orte_component_register(void); static int pubsub_orte_component_open(void); static int pubsub_orte_component_close(void); static int pubsub_orte_component_query(mca_base_module_t **module, int *priority); @@ -41,7 +42,8 @@ ompi_pubsub_orte_component_t mca_pubsub_orte_component = { OMPI_RELEASE_VERSION, /* MCA component release version */ pubsub_orte_component_open, /* component open */ pubsub_orte_component_close, /* component close */ - pubsub_orte_component_query /* component query */ + pubsub_orte_component_query, /* component query */ + pubsub_orte_component_register /* component register */ }, { /* This component is checkpoint ready */ @@ -50,36 +52,39 @@ ompi_pubsub_orte_component_t mca_pubsub_orte_component = { } }; +static int pubsub_orte_component_register(void) +{ + my_priority = 50; + (void) mca_base_component_var_register(&mca_pubsub_orte_component.super.base_version, + "priority", "Priority of the pubsub pmi component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &my_priority); + + mca_pubsub_orte_component.server_uri = NULL; + (void) mca_base_component_var_register(&mca_pubsub_orte_component.super.base_version, + "server", "Contact info for ompi_server for publish/subscribe operations", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_pubsub_orte_component.server_uri); + + return OMPI_SUCCESS; +} static int pubsub_orte_component_open(void) { - mca_base_component_t *c = &mca_pubsub_orte_component.super.base_version; - - mca_base_param_reg_int(c, "priority", - "Priority of the pubsub pmi component", - false, false, my_priority, - &my_priority); return OMPI_SUCCESS; } static int pubsub_orte_component_close(void) { - if (NULL != mca_pubsub_orte_component.server_uri) { - free(mca_pubsub_orte_component.server_uri); - mca_pubsub_orte_component.server_uri = NULL; - } return OMPI_SUCCESS; } static int pubsub_orte_component_query(mca_base_module_t **module, int *priority) { - mca_base_component_t *comp = &mca_pubsub_orte_component.super.base_version; - - mca_base_param_reg_string(comp, "server", - "Contact info for ompi_server for publish/subscribe operations", - false, false, NULL, - &mca_pubsub_orte_component.server_uri); - mca_pubsub_orte_component.server_found = false; *priority = my_priority; diff --git a/ompi/mca/pubsub/pmi/pubsub_pmi_component.c b/ompi/mca/pubsub/pmi/pubsub_pmi_component.c index a9e1a2e550..5a55decbdb 100644 --- a/ompi/mca/pubsub/pmi/pubsub_pmi_component.c +++ b/ompi/mca/pubsub/pmi/pubsub_pmi_component.c @@ -22,6 +22,7 @@ #include "pubsub_pmi.h" +static int pubsub_pmi_component_register(void); static int pubsub_pmi_component_open(void); static int pubsub_pmi_component_close(void); static int pubsub_pmi_component_query(mca_base_module_t **module, int *priority); @@ -38,7 +39,8 @@ ompi_pubsub_base_component_t mca_pubsub_pmi_component = { OMPI_RELEASE_VERSION, /* MCA component release version */ pubsub_pmi_component_open, /* component open */ pubsub_pmi_component_close, /* component close */ - pubsub_pmi_component_query /* component query */ + pubsub_pmi_component_query, /* component query */ + pubsub_pmi_component_register /* component register */ }, { /* This component is checkpoint ready */ @@ -46,15 +48,21 @@ ompi_pubsub_base_component_t mca_pubsub_pmi_component = { } }; +static int pubsub_pmi_component_register(void) +{ + my_priority = 100; + (void) mca_base_component_var_register(&mca_pubsub_pmi_component.base_version, + "priority", "Priority of the pubsub pmi component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &my_priority); + + return OMPI_SUCCESS; +} static int pubsub_pmi_component_open(void) { - mca_base_component_t *c = &mca_pubsub_pmi_component.base_version; - - mca_base_param_reg_int(c, "priority", - "Priority of the pubsub pmi component", - false, false, my_priority, - &my_priority); return OMPI_SUCCESS; } diff --git a/ompi/mca/rcache/rb/rcache_rb_component.c b/ompi/mca/rcache/rb/rcache_rb_component.c index 3c11067cd7..d3035d76a5 100644 --- a/ompi/mca/rcache/rb/rcache_rb_component.c +++ b/ompi/mca/rcache/rb/rcache_rb_component.c @@ -17,10 +17,10 @@ */ #include "ompi_config.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/rcache/rcache.h" #include "rcache_rb.h" +static int mca_rcache_rb_component_register(void); static int mca_rcache_rb_component_open(void); static mca_rcache_base_module_t* mca_rcache_rb_component_init( void ); @@ -35,7 +35,9 @@ mca_rcache_rb_component_t mca_rcache_rb_component = { OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_rcache_rb_component_open, /* component open */ - NULL + NULL, /* component close */ + NULL, /* component query */ + mca_rcache_rb_component_register }, { /* The component is checkpoint ready */ @@ -45,6 +47,31 @@ mca_rcache_rb_component_t mca_rcache_rb_component = { } }; +static int ompi_rcache_rb_reg_mru_len; +static int ompi_rcache_rb_mru_size; + +static int mca_rcache_rb_component_register(void) +{ + ompi_rcache_rb_reg_mru_len = 256; + (void) mca_base_component_var_register(&mca_rcache_rb_component.super.rcache_version, + "mru_len", + "The maximum size IN ENTRIES of the MRU (most recently used) rcache list", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_rcache_rb_reg_mru_len); + + ompi_rcache_rb_mru_size = 1*1024*1024*1024; /* default to 1GB? */ + (void) mca_base_component_var_register(&mca_rcache_rb_component.super.rcache_version, + "mru_size", + "The maximum size IN BYTES of the MRU (most recently used) rcache list", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_rcache_rb_mru_size); + + return OMPI_SUCCESS; +} static int mca_rcache_rb_component_open(void) { @@ -57,22 +84,8 @@ mca_rcache_base_module_t* mca_rcache_rb_component_init(void) { rcache = (mca_rcache_rb_module_t*) malloc(sizeof(mca_rcache_rb_module_t)); mca_rcache_rb_module_init(rcache); - mca_base_param_reg_int(&mca_rcache_rb_component.super.rcache_version, - "mru_len", - "The maximum size IN ENTRIES of the MRU (most recently used) rcache list", - false, - false, - 256, - (int*)&(rcache->reg_mru_len)); - - mca_base_param_reg_int(&mca_rcache_rb_component.super.rcache_version, - "mru_size", - "The maximum size IN BYTES of the MRU (most recently used) rcache list", - false, - false, - 1*1024*1024*1024, /* default to 1GB? */ - (int*)&(rcache->reg_max_mru_size)); - + rcache->reg_mru_len = (size_t) ompi_rcache_rb_reg_mru_len; + rcache->reg_max_mru_size = (size_t) ompi_rcache_rb_mru_size; return &rcache->base; } diff --git a/ompi/mca/rcache/vma/rcache_vma_component.c b/ompi/mca/rcache/vma/rcache_vma_component.c index 9a84d0baa0..6cb240a627 100644 --- a/ompi/mca/rcache/vma/rcache_vma_component.c +++ b/ompi/mca/rcache/vma/rcache_vma_component.c @@ -13,7 +13,6 @@ #include "ompi_config.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/rcache/rcache.h" #include "rcache_vma.h" diff --git a/ompi/mca/rte/base/rte_base_open.c b/ompi/mca/rte/base/rte_base_open.c index 5da362068c..c298b612ad 100644 --- a/ompi/mca/rte/base/rte_base_open.c +++ b/ompi/mca/rte/base/rte_base_open.c @@ -15,7 +15,6 @@ #include "opal/util/output.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/rte/rte.h" #include "ompi/mca/rte/base/base.h" @@ -36,20 +35,34 @@ int ompi_rte_base_output = -1; opal_list_t ompi_rte_components; int ompi_rte_base_inited = 0; +static int ompi_rte_base_verbose; + +static int ompi_rte_base_register(int flags) +{ + /* Debugging / verbose output */ + ompi_rte_base_verbose = 0; + (void) mca_base_var_register("ompi", "rte", "base", "verbose", + "Verbosity level of the rte framework", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &ompi_rte_base_verbose); + + return OMPI_SUCCESS; +} + int ompi_rte_base_open(void) { - int value, rc = OMPI_SUCCESS; + int rc = OMPI_SUCCESS; if( ompi_rte_base_inited++ < 0 ) { return OMPI_SUCCESS; } - /* Debugging / verbose output */ - mca_base_param_reg_int_name("rte", "base_verbose", - "Verbosity level of the rte framework", - false, false, - 0, &value); - if (0 != value) { + (void) ompi_rte_base_register(0); + + if (0 != ompi_rte_base_verbose) { ompi_rte_base_output = opal_output_open(NULL); } else { ompi_rte_base_output = -1; diff --git a/ompi/mca/sbgp/base/sbgp_base_open.c b/ompi/mca/sbgp/base/sbgp_base_open.c index 69b026ab5f..d56d45cf86 100644 --- a/ompi/mca/sbgp/base/sbgp_base_open.c +++ b/ompi/mca/sbgp/base/sbgp_base_open.c @@ -39,6 +39,8 @@ opal_list_t mca_sbgp_base_components_in_use; int mca_sbgp_base_components_in_use_inited=0; OMPI_DECLSPEC char *ompi_sbgp_subgroups_string; +static int ompi_sbgp_base_verbose; + static void mca_sbgp_base_destruct (mca_sbgp_base_module_t *module) { /* free the list of ranks */ @@ -198,27 +200,47 @@ error: return rc; } +static int mca_sbgp_base_register(int flags) +{ + /* Debugging/Verbose output */ + ompi_sbgp_base_verbose = 0; + (void) mca_base_var_register("ompi", "sbgp", "base", "verbose", + "Verbosity level of SBGP framework", + MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &ompi_sbgp_base_verbose); + + /* get list of sub-grouping functions to use */ + ompi_sbgp_subgroups_string = "basesmsocket,basesmuma,ibnet,p2p"; + (void) mca_base_var_register("ompi", "sbgp", "base", "subgroups_string", + "Default set of subgroup operations to apply ", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_LOCAL, + &ompi_sbgp_subgroups_string); + + return OMPI_SUCCESS; +} + /** * Function for finding and opening either all MCA components, or the one * that was specifically requested via a MCA parameter. */ int mca_sbgp_base_open(void) { - int value, ret = OMPI_SUCCESS; + int ret = OMPI_SUCCESS; /*_sbgp_base_components_available * Register some MCA parameters */ - /* Debugging/Verbose output */ - mca_base_param_reg_int_name("sbgp", - "base_verbose", - "Verbosity level of SBGP framework", - false, false, - 0, &value); + + (void) mca_sbgp_base_register(0); /* get fraemwork id */ mca_sbgp_base_output = opal_output_open(NULL); - opal_output_set_verbosity(mca_sbgp_base_output, value); + opal_output_set_verbosity(mca_sbgp_base_output, ompi_sbgp_base_verbose); /* Open up all available components */ ret = mca_base_components_open("sbgp", mca_sbgp_base_output, mca_sbgp_base_static_components, @@ -228,11 +250,6 @@ int mca_sbgp_base_open(void) return OMPI_ERROR; } - /* get list of sub-grouping functions to use */ - mca_base_param_reg_string_name("sbgp","base_subgroups_string", - "Default set of subgroup operations to apply ", - false,false,"basesmsocket,basesmuma,ibnet,p2p",&ompi_sbgp_subgroups_string); - ret = ompi_sbgp_set_components_to_use(&mca_sbgp_base_components_opened, &mca_sbgp_base_components_in_use); diff --git a/ompi/mca/sbgp/basesmsocket/sbgp_basesmsocket_component.c b/ompi/mca/sbgp/basesmsocket/sbgp_basesmsocket_component.c index cfea0c71dd..467aa191bb 100644 --- a/ompi/mca/sbgp/basesmsocket/sbgp_basesmsocket_component.c +++ b/ompi/mca/sbgp/basesmsocket/sbgp_basesmsocket_component.c @@ -49,6 +49,7 @@ const char *mca_sbgp_basesmsocket_component_version_string = * Local functions */ +static int basesmsocket_register(void); static int basesmsocket_open(void); static int basesmsocket_close(void); static mca_sbgp_base_module_t *mca_sbgp_basesmsocket_select_procs(struct ompi_proc_t ** procs, @@ -61,18 +62,6 @@ static int mca_sbgp_basesmsocket_init_query(bool enable_progress_threads, bool enable_mpi_threads); /*----end local functions ----*/ -static inline int mca_sbgp_basesmsocket_param_register_int( - const char* param_name, int default_value) -{ - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_sbgp_basesmsocket_component.super.sbgp_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; -} - /* * Instantiate the public struct with all of our public information * and pointers to our public functions in it @@ -100,6 +89,8 @@ mca_sbgp_basesmsocket_component_t mca_sbgp_basesmsocket_component = { basesmsocket_open, basesmsocket_close, + NULL, + basesmsocket_register }, mca_sbgp_basesmsocket_init_query, @@ -111,19 +102,28 @@ mca_sbgp_basesmsocket_component_t mca_sbgp_basesmsocket_component = { }; +/* + * Register the component + */ +static int basesmsocket_register(void) +{ + mca_sbgp_basesmsocket_component_t *cs = &mca_sbgp_basesmsocket_component; + + cs->super.priority = 90; + (void) mca_base_component_var_register(&mca_sbgp_basesmsocket_component.super.sbgp_version, + "priority", "Priority for the sbgp basesmsocket component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &cs->super.priority); + + return OMPI_SUCCESS; +} + /* * Open the component */ static int basesmsocket_open(void) { - - /* local variables */ - mca_sbgp_basesmsocket_component_t *cs = &mca_sbgp_basesmsocket_component; - - /* set component priority */ - cs->super.priority= - mca_sbgp_basesmsocket_param_register_int("priority",90); - return OMPI_SUCCESS; } diff --git a/ompi/mca/sbgp/basesmuma/sbgp_basesmuma_component.c b/ompi/mca/sbgp/basesmuma/sbgp_basesmuma_component.c index 8dbb993d9e..0532d8e1a3 100644 --- a/ompi/mca/sbgp/basesmuma/sbgp_basesmuma_component.c +++ b/ompi/mca/sbgp/basesmuma/sbgp_basesmuma_component.c @@ -39,6 +39,7 @@ const char *mca_sbgp_basesmuma_component_version_string = * Local functions */ +static int basesmuma_register(void); static int basesmuma_open(void); static int basesmuma_close(void); static mca_sbgp_base_module_t *mca_sbgp_basesmuma_select_procs(struct ompi_proc_t ** procs, @@ -47,19 +48,6 @@ static mca_sbgp_base_module_t *mca_sbgp_basesmuma_select_procs(struct ompi_proc_ static int mca_sbgp_basesmuma_init_query(bool enable_progress_threads, bool enable_mpi_threads); - -static inline int mca_sbgp_basesmuma_param_register_int( - const char* param_name, int default_value) -{ - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_sbgp_basesmuma_component.super.sbgp_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; -} - /* * Instantiate the public struct with all of our public information * and pointers to our public functions in it @@ -83,10 +71,12 @@ mca_sbgp_basesmuma_component_t mca_sbgp_basesmuma_component = { OMPI_MINOR_VERSION, OMPI_RELEASE_VERSION, - /* Component open and close functions */ + /* Component open, close, and register functions */ basesmuma_open, basesmuma_close, + NULL, + basesmuma_register }, mca_sbgp_basesmuma_init_query, mca_sbgp_basesmuma_select_procs, @@ -98,19 +88,29 @@ mca_sbgp_basesmuma_component_t mca_sbgp_basesmuma_component = { }; +/* + * Register the component + */ +static int basesmuma_register(void) +{ + mca_sbgp_basesmuma_component_t *cs = &mca_sbgp_basesmuma_component; + + /* set component priority */ + cs->super.priority = 90; + (void) mca_base_component_var_register(&cs->super.sbgp_version, + "priority", "Priority of the sbgp basesmuma", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cs->super.priority); + return OMPI_SUCCESS; +} + /* * Open the component */ static int basesmuma_open(void) { - - /* local variables */ - mca_sbgp_basesmuma_component_t *cs = &mca_sbgp_basesmuma_component; - - /* set component priority */ - cs->super.priority= - mca_sbgp_basesmuma_param_register_int("priority",90); - return OMPI_SUCCESS; } diff --git a/ompi/mca/sbgp/ibnet/sbgp_ibnet.h b/ompi/mca/sbgp/ibnet/sbgp_ibnet.h index 9c246ca2a2..414a4bb2f4 100644 --- a/ompi/mca/sbgp/ibnet/sbgp_ibnet.h +++ b/ompi/mca/sbgp/ibnet/sbgp_ibnet.h @@ -58,7 +58,7 @@ struct mca_sbgp_ibnet_component_t { /* IB MTU requested by user */ int mtu; /** MTU on this port */ /** IB partition definition */ - uint32_t pkey_val; + int pkey_val; /* Keeping hca data */ char *if_include; char **if_include_list; diff --git a/ompi/mca/sbgp/ibnet/sbgp_ibnet_component.c b/ompi/mca/sbgp/ibnet/sbgp_ibnet_component.c index 179c9260eb..1b82e6f163 100644 --- a/ompi/mca/sbgp/ibnet/sbgp_ibnet_component.c +++ b/ompi/mca/sbgp/ibnet/sbgp_ibnet_component.c @@ -126,17 +126,13 @@ static int mca_sbgp_ibnet_open(void) int rc; mca_sbgp_ibnet_component_t *cs = &mca_sbgp_ibnet_component; + mca_sbgp_ibnet_component.pkey_val &= SBGP_IBNET_IB_PKEY_MASK; + cs->total_active_ports = 0; cs->curr_max_group_id = 100; OBJ_CONSTRUCT(&cs->devices, opal_list_t); - /* register all parameters including priority */ - rc = mca_sbgp_ibnet_register_params(); - if (OMPI_SUCCESS != rc) { - return rc; - } - return OMPI_SUCCESS; } @@ -433,7 +429,7 @@ static mca_sbgp_ibnet_device_t* ibnet_load_ports(struct ibv_device *ib_dev, int } pkey = ntohs(pkey) & MCA_SBGP_IBNET_PKEY_MASK; - if (pkey == mca_sbgp_ibnet_component.pkey_val){ + if (pkey == (uint32_t) mca_sbgp_ibnet_component.pkey_val){ ret = ibnet_init_port(device, p, &ib_port_attr, ib_dev_context); if (OMPI_SUCCESS != ret) { IBNET_ERROR(("Device %s " diff --git a/ompi/mca/sbgp/ibnet/sbgp_ibnet_mca.c b/ompi/mca/sbgp/ibnet/sbgp_ibnet_mca.c index e1e9cd992b..921e4634df 100644 --- a/ompi/mca/sbgp/ibnet/sbgp_ibnet_mca.c +++ b/ompi/mca/sbgp/ibnet/sbgp_ibnet_mca.c @@ -41,94 +41,106 @@ enum { REGSTR_MAX = 0x88 }; +static mca_base_var_enum_value_t mtu_values[] = { + {IBV_MTU_512, "256B"}, + {IBV_MTU_512, "512B"}, + {IBV_MTU_1024, "1k"}, + {IBV_MTU_2048, "2k"}, + {IBV_MTU_4096, "4k"}, + {0, NULL} +}; + /* * utility routine for string parameter registration */ static int reg_string(const char* param_name, const char* deprecated_param_name, const char* param_desc, - const char* default_value, char **out_value, + const char* default_value, char **storage, int flags) { int index; - char *value; - index = mca_base_param_reg_string(&mca_sbgp_ibnet_component.super.sbgp_version, - param_name, param_desc, false, false, - default_value, &value); + + *storage = default_value; + index = mca_base_component_var_register(&mca_sbgp_ibnet_component.super.sbgp_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_STRING, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); if (NULL != deprecated_param_name) { - mca_base_param_reg_syn(index, - &mca_sbgp_ibnet_component.super.sbgp_version, - deprecated_param_name, true); + (void) mca_base_var_register_synonym(index, "ompi", "sbgp", "ibnet", deprecated_param_name, + MCA_BASE_SYN_FLAG_DEPRECATED); } - mca_base_param_lookup_string(index, &value); - - if (0 != (flags & REGSTR_EMPTY_OK) && 0 == strlen(value)) { + if (0 != (flags & REGSTR_EMPTY_OK) && (NULL == *storage || 0 == strlen(*storage))) { opal_output(0, "Bad parameter value for parameter \"%s\"", param_name); return OMPI_ERR_BAD_PARAM; } - *out_value = value; return OMPI_SUCCESS; } -static int mca_sbgp_ibnet_ini_intify(char *str) -{ - while (isspace(*str)) { - ++str; - } - - /* If it's hex, use sscanf() */ - if (strlen(str) > 3 && 0 == strncasecmp("0x", str, 2)) { - unsigned int i; - sscanf(str, "%X", &i); - return (int) i; - } - - /* Nope -- just decimal, so use atoi() */ - return atoi(str); -} - /* * utility routine for integer parameter registration */ static int reg_int(const char* param_name, const char* deprecated_param_name, const char* param_desc, - int default_value, int *out_value, int flags) + int default_value, int *storage, int flags) { - int index, value; - index = mca_base_param_reg_int(&mca_sbgp_ibnet_component.super.sbgp_version, - param_name, param_desc, false, false, - default_value, NULL); + int index; + + *storage = default_value; + index = mca_base_component_var_register(&mca_sbgp_ibnet_component.super.sbgp_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); if (NULL != deprecated_param_name) { - mca_base_param_reg_syn(index, - &mca_sbgp_ibnet_component.super.sbgp_version, - deprecated_param_name, true); + (void) mca_base_var_register_synonym(index, "ompi", "sbgp", "ibnet", deprecated_param_name, + MCA_BASE_SYN_FLAG_DEPRECATED); } - mca_base_param_lookup_int(index, &value); - - if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == value) { - *out_value = value; + if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == *storage) { return OMPI_SUCCESS; } - if ((0 != (flags & REGINT_GE_ZERO) && value < 0) || - (0 != (flags & REGINT_GE_ONE) && value < 1) || - (0 != (flags & REGINT_NONZERO) && 0 == value)) { + if ((0 != (flags & REGINT_GE_ZERO) && *storage < 0) || + (0 != (flags & REGINT_GE_ONE) && *storage < 1) || + (0 != (flags & REGINT_NONZERO) && 0 == *storage)) { opal_output(0, "Bad parameter value for parameter \"%s\"", param_name); return OMPI_ERR_BAD_PARAM; } - *out_value = value; + return OMPI_SUCCESS; +} + +/* + * utility routine for boolean parameter registration + */ +static int reg_int(const char* param_name, + const char* deprecated_param_name, + const char* param_desc, + bool default_value, bool *storage) +{ + int index; + + *storage = default_value; + index = mca_base_component_var_register(&mca_sbgp_ibnet_component.super.sbgp_version, + param_name, param_desc, MCA_BASE_VAR_TYPE_BOOL, + NULL, 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, storage); + if (NULL != deprecated_param_name) { + (void) mca_base_var_register_synonym(index, "ompi", "sbgp", "ibnet", deprecated_param_name, + MCA_BASE_SYN_FLAG_DEPRECATED); + } + return OMPI_SUCCESS; } int mca_sbgp_ibnet_register_params(void) { + mca_base_var_enum_t *new_enum; char *msg, *pkey; int ival, ret, tmp; @@ -143,35 +155,28 @@ int mca_sbgp_ibnet_register_params(void) CHECK(reg_int("priority", NULL, "IB offload component priority" - "(from 0(low) to 90 (high))", 90, &ival, 0)); - mca_sbgp_ibnet_component.super.priority = ival; + "(from 0(low) to 90 (high))", 90, &mca_sbgp_ibnet_component.super.priority, 0)); CHECK(reg_int("verbose", NULL, "Output some verbose IB offload BTL information " - "(0 = no output, nonzero = output)", 0, &ival, 0)); - mca_sbgp_ibnet_component.verbose = ival; + "(0 = no output, nonzero = output)", 0, &mca_sbgp_ibnet_component.verbose, 0)); - CHECK(reg_int("warn_default_gid_prefix", NULL, - "Warn when there is more than one active ports and at least one of them connected to the network with only default GID prefix configured (0 = do not warn; any other value = warn)", - 1, &ival, 0)); - mca_sbgp_ibnet_component.warn_default_gid_prefix = (0 != ival); - CHECK(reg_int("warn_nonexistent_if", NULL, + CHECK(reg_bool("warn_default_gid_prefix", NULL, + "Warn when there is more than one active ports and at least one of them connected to the network with only default GID prefix configured (0 = do not warn; any other value = warn)", + true, &mca_sbgp_ibnet_component.warn_default_gid_prefix)); + CHECK(reg_bool("warn_nonexistent_if", NULL, "Warn if non-existent devices and/or ports are specified in the sbgp_ibnet_if_[in|ex]clude MCA parameters (0 = do not warn; any other value = warn)", - 1, &ival, 0)); - mca_sbgp_ibnet_component.warn_nonexistent_if = (0 != ival); + true, &mca_sbgp_ibnet_component.warn_nonexistent_if)); CHECK(reg_int("max_sbgps", NULL, "Maximum allowed number of subroups", 100, &mca_sbgp_ibnet_component.max_sbgps, 0)); - CHECK(reg_string("pkey", "ib_pkey_val", - "OpenFabrics partition key (pkey) value. " - "Unsigned integer decimal or hex values are allowed (e.g., \"3\" or \"0x3f\") and will be masked against the maximum allowable IB paritition key value (0x7fff)", - "0", &pkey, 0)); - - mca_sbgp_ibnet_component.pkey_val = - mca_sbgp_ibnet_ini_intify(pkey) & SBGP_IBNET_IB_PKEY_MASK; - free(pkey); + CHECK(reg_int("pkey", "ib_pkey_val", + "OpenFabrics partition key (pkey) value. " + "Unsigned integer decimal or hex values are allowed (e.g., \"3\" or \"0x3f\") and will be masked against the maximum allowable IB paritition key value (0x7fff)", + 0, &mca_sbgp_ibnet_component.pkey_val, 0)); + mca_sbgp_ibnet_component.pkey_val &= SBGP_IBNET_IB_PKEY_MASK; asprintf(&msg, "OpenFabrics MTU, in bytes (if not specified in INI files). Valid values are: %d=256 bytes, %d=512 bytes, %d=1024 bytes, %d=2048 bytes, %d=4096 bytes", IBV_MTU_256, @@ -184,18 +189,25 @@ int mca_sbgp_ibnet_register_params(void) return OMPI_ERR_OUT_OF_RESOURCE; } - CHECK(reg_int("mtu", "ib_mtu", msg, IBV_MTU_1024, &ival, 0)); + CHECK(mca_base_var_enum_create("sbgp_ibnet_mtu", mtu_values, &new_enum)); + if (OPAL_SUCCESS != ret) { + return OMPI_ERR_OUT_OF_RESOURCE; + } + + ret = mca_base_component_var_register(&mca_sbgp_ibnet_component.super.sbgp_version, + "mtu", msg, MCA_BASE_VAR_TYPE_INT, new_enum, + 0, 0, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &mca_sbgp_ibnet_component.mtu); + OBJ_RELEASE(new_enum); free(msg); - if (ival < IBV_MTU_1024 || ival > IBV_MTU_4096) { - opal_show_help("help-mpi-bcol-iboffload.txt", "invalid mca param value", - true, "invalid value for btl_openib_ib_mtu", - "btl_openib_ib_mtu reset to 1024"); - mca_sbgp_ibnet_component.mtu = IBV_MTU_1024; - } else { - mca_sbgp_ibnet_component.mtu = (uint32_t) ival; + if (0 > ret) { + return ret; } + (void) mca_base_var_register_synonym(ret, "ompi", "sbgp", "ibnet", "ib_mtu", + MCA_BASE_SYN_FLAG_DEPRECATED); + CHECK(reg_string("if_include", NULL, "Comma-delimited list of devices/ports to be used (e.g. \"mthca0,mthca1:2\"; empty value means to use all ports found). Mutually exclusive with sbgp_ibnet_if_exclude.", NULL, &mca_sbgp_ibnet_component.if_include, diff --git a/ompi/mca/sbgp/p2p/sbgp_p2p_component.c b/ompi/mca/sbgp/p2p/sbgp_p2p_component.c index fc37a1f4a5..b2dc1db3e5 100644 --- a/ompi/mca/sbgp/p2p/sbgp_p2p_component.c +++ b/ompi/mca/sbgp/p2p/sbgp_p2p_component.c @@ -40,6 +40,7 @@ const char *mca_sbgp_p2p_component_version_string = * Local functions */ +static int p2p_register(void); static int p2p_open(void); static int p2p_close(void); static mca_sbgp_base_module_t * mca_sbgp_p2p_select_procs(struct ompi_proc_t ** procs, @@ -48,18 +49,6 @@ static mca_sbgp_base_module_t * mca_sbgp_p2p_select_procs(struct ompi_proc_t ** static int mca_sbgp_p2p_init_query(bool enable_progress_threads, bool enable_mpi_threads); -static inline int mca_sbgp_p2p_param_register_int( - const char* param_name, int default_value) -{ - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_sbgp_p2p_component.super.sbgp_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; -} - /* * Instantiate the public struct with all of our public information * and pointers to our public functions in it @@ -86,7 +75,7 @@ mca_sbgp_p2p_component_t mca_sbgp_p2p_component = { p2p_open, p2p_close, NULL, - NULL + p2p_register }, mca_sbgp_p2p_init_query, @@ -99,19 +88,25 @@ mca_sbgp_p2p_component_t mca_sbgp_p2p_component = { }; +static int p2p_register(void) +{ + mca_sbgp_p2p_component_t *cs = &mca_sbgp_p2p_component; + cs->super.priority = 90; + (void) mca_base_component_var_register(&cs->super.sbgp_version, + "priority", "Priority for the sbgp p2p component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &cs->super.priority); + + return OMPI_SUCCESS; +} + /* * Open the component */ static int p2p_open(void) { - - /* local variables */ - mca_sbgp_p2p_component_t *cs = &mca_sbgp_p2p_component; - - /* set component priority */ - cs->super.priority= - mca_sbgp_p2p_param_register_int("priority",90); - return OMPI_SUCCESS; } diff --git a/ompi/mca/sharedfp/base/sharedfp_base_file_select.c b/ompi/mca/sharedfp/base/sharedfp_base_file_select.c index 3954db7bf1..cde256a11a 100644 --- a/ompi/mca/sharedfp/base/sharedfp_base_file_select.c +++ b/ompi/mca/sharedfp/base/sharedfp_base_file_select.c @@ -70,7 +70,8 @@ int mca_sharedfp_base_file_select (struct mca_io_ompio_file_t *file, opal_list_item_t *item; opal_list_item_t *next_item; mca_base_component_priority_list_item_t *selectable_item; - char *names, **name_array; + char **name_array; + const char **names_value, *names; int num_names; mca_base_component_priority_list_item_t *cpli; mca_sharedfp_base_component_t *component; @@ -136,8 +137,9 @@ int mca_sharedfp_base_file_select (struct mca_io_ompio_file_t *file, */ /* Check if anything was requested by means on the name parameters */ - names = NULL; - mca_base_param_lookup_string (mca_sharedfp_base_param, &names); + names_value = NULL; + mca_base_var_get_value(mca_sharedfp_base_param, &names_value, NULL, NULL); + names = names_value ? names_value[0] : NULL; if (NULL != names && 0 < strlen(names)) { name_array = opal_argv_split (names, ','); @@ -167,7 +169,7 @@ int mca_sharedfp_base_file_select (struct mca_io_ompio_file_t *file, component->sharedfpm_version.mca_type_name, component->sharedfpm_version.mca_component_name); - /* check if this name is present in the mca_base_params */ + /* check if this name is present in the mca_base_var */ for (i=0; i < num_names; i++) { if (0 == strcmp(name_array[i], component->sharedfpm_version.mca_component_name)) { /* this is present, and should be added o the selectable list */ diff --git a/ompi/mca/sharedfp/base/sharedfp_base_open.c b/ompi/mca/sharedfp/base/sharedfp_base_open.c index f4a1e7dfdf..1668593e65 100644 --- a/ompi/mca/sharedfp/base/sharedfp_base_open.c +++ b/ompi/mca/sharedfp/base/sharedfp_base_open.c @@ -24,7 +24,6 @@ #include "ompi/class/ompi_free_list.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/sharedfp/sharedfp.h" #include "ompi/mca/sharedfp/base/base.h" @@ -74,8 +73,8 @@ int mca_sharedfp_base_open(void) mca_sharedfp_base_components_opened_valid = true; /* Find the index of the MCA "sharedfp" param for selection */ - - mca_sharedfp_base_param = mca_base_param_find("sharedfp", "base", NULL); + + mca_sharedfp_base_param = mca_base_var_find("ompi", "sharedfp", NULL, NULL); return OMPI_SUCCESS; } diff --git a/ompi/mca/topo/base/topo_base_comm_select.c b/ompi/mca/topo/base/topo_base_comm_select.c index f054ad8be9..14b3651c59 100644 --- a/ompi/mca/topo/base/topo_base_comm_select.c +++ b/ompi/mca/topo/base/topo_base_comm_select.c @@ -79,7 +79,8 @@ int mca_topo_base_comm_select (struct ompi_communicator_t *comm, opal_list_item_t *item; opal_list_item_t *next_item; mca_base_component_priority_list_item_t *selectable_item; - char *names, **name_array; + char **name_array; + const char **names_value, *names; int num_names; mca_base_component_priority_list_item_t *cpli; mca_topo_base_component_t *component; @@ -96,7 +97,7 @@ int mca_topo_base_comm_select (struct ompi_communicator_t *comm, /* Announce */ /* ANJU: - * check for names array .... mca_base_param_ */ + * check for names array .... mca_base_var_ */ snprintf(name, sizeof(name), "%s (cid %d)", comm->c_name, comm->c_contextid); @@ -160,8 +161,10 @@ int mca_topo_base_comm_select (struct ompi_communicator_t *comm, */ /* Check if anything was requested by means on the name parameters */ - names = NULL; - mca_base_param_lookup_string (mca_topo_base_param, &names); + names_value = NULL; + mca_base_var_get_value(mca_topo_base_param, &names_value, NULL, NULL); + names = names_value ? names_value[0] : NULL; + if (NULL != names && 0 < strlen(names)) { name_array = opal_argv_split (names, ','); @@ -191,7 +194,7 @@ int mca_topo_base_comm_select (struct ompi_communicator_t *comm, component->topom_version.mca_type_name, component->topom_version.mca_component_name); - /* check if this name is present in the mca_base_params */ + /* check if this name is present in the mca_base_var */ for (i=0; i < num_names; i++) { if (0 == strcmp(name_array[i], component->topom_version.mca_component_name)) { /* this is present, and should be added o the selectable list */ diff --git a/ompi/mca/topo/base/topo_base_open.c b/ompi/mca/topo/base/topo_base_open.c index 8193cd6d79..599b79c375 100644 --- a/ompi/mca/topo/base/topo_base_open.c +++ b/ompi/mca/topo/base/topo_base_open.c @@ -70,9 +70,9 @@ int mca_topo_base_open(void) } mca_topo_base_components_opened_valid = true; - - /* Find the index of the "topo" param for selection */ - mca_topo_base_param = mca_base_param_find("topo", "base", NULL); + + /* Find selection variable */ + mca_topo_base_param = mca_base_var_find("ompi", "topo", NULL, NULL); /* All done */ diff --git a/ompi/mca/vprotocol/example/vprotocol_example_component.c b/ompi/mca/vprotocol/example/vprotocol_example_component.c index b461ee7708..9a72fee047 100644 --- a/ompi/mca/vprotocol/example/vprotocol_example_component.c +++ b/ompi/mca/vprotocol/example/vprotocol_example_component.c @@ -11,15 +11,10 @@ #include "ompi_config.h" #include "opal/mca/mca.h" -#include "opal/mca/base/mca_base_param.h" #include "../pml_v.h" #include "../pml_v_protocol_base.h" #include "vprotocol_example.h" - -static inline int mca_param_register_int( const char* param_name, int default_value); - - static int mca_vprotocol_example_component_open(void); static int mca_vprotocol_example_component_close(void); @@ -106,19 +101,3 @@ int mca_vprotocol_example_component_finalize(void) return OMPI_SUCCESS; } - -/** - * Helper function to set int type mca parameter - */ -static inline int mca_param_register_int( const char* param_name, - int default_value ) -{ - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_vprotocol_example_component.pmlm_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; -} - diff --git a/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_component.c b/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_component.c index 915802a9e0..6ffeddd929 100644 --- a/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_component.c +++ b/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_component.c @@ -11,12 +11,9 @@ #include "ompi_config.h" #include "opal/mca/mca.h" -#include "opal/mca/base/mca_base_param.h" #include "vprotocol_pessimist.h" -static inline int mca_param_register_int( const char* param_name, int default_value); -static inline char *mca_param_register_string(const char* param_name, char *default_value); - +static int mca_vprotocol_pessimist_component_register(void); static int mca_vprotocol_pessimist_component_open(void); static int mca_vprotocol_pessimist_component_close(void); @@ -43,7 +40,9 @@ mca_vprotocol_base_component_2_0_0_t mca_vprotocol_pessimist_component = OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ mca_vprotocol_pessimist_component_open, /* component open */ - mca_vprotocol_pessimist_component_close /* component close */ + mca_vprotocol_pessimist_component_close, /* component close */ + NULL, + mca_vprotocol_pessimist_component_register }, { /* component is not checkpointable */ @@ -56,15 +55,48 @@ mca_vprotocol_base_component_2_0_0_t mca_vprotocol_pessimist_component = /** MCA level functions */ +static int mca_vprotocol_pessimist_component_register(void) +{ + _priority = 30; + (void) mca_base_component_var_register(&mca_vprotocol_pessimist_component.pmlm_version, + "priority", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &_priority);\ + _free_list_num = 16; + (void) mca_base_component_var_register(&mca_vprotocol_pessimist_component.pmlm_version, + "free_list_num", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &_free_list_num); + _free_list_max = -1; + (void) mca_base_component_var_register(&mca_vprotocol_pessimist_component.pmlm_version, + "free_list_max", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &_free_list_max); + _free_list_inc = 64; + (void) mca_base_component_var_register(&mca_vprotocol_pessimist_component.pmlm_version, + "free_list_inc", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &_free_list_inc); + _sender_based_size = 256 * 1024 * 1024; + (void) mca_base_component_var_register(&mca_vprotocol_pessimist_component.pmlm_version, + "sender_based_chunk", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &_sender_based_size); + _event_buffer_size = 1024; + (void) mca_base_component_var_register(&mca_vprotocol_pessimist_component.pmlm_version, + "event_buffer_size", NULL, MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &_event_buffer_size); + _mmap_file_name = "vprotocol_pessimist-senderbased"; + (void) mca_base_component_var_register(&mca_vprotocol_pessimist_component.pmlm_version, + "sender_based_file", NULL, MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &_mmap_file_name); + return OMPI_SUCCESS; +} + static int mca_vprotocol_pessimist_component_open(void) { - _priority = mca_param_register_int("priority", 30); - _free_list_num = mca_param_register_int("free_list_num", 16); - _free_list_max = mca_param_register_int("free_list_max", -1); - _free_list_inc = mca_param_register_int("free_list_inc", 64); - _sender_based_size = mca_param_register_int("sender_based_chunk", 256 * 1024 * 1024); - _event_buffer_size = mca_param_register_int("event_buffer_size", 1024); - _mmap_file_name = mca_param_register_string("sender_based_file", "vprotocol_pessimist-senderbased"); V_OUTPUT_VERBOSE(500, "vprotocol_pessimist: component_open: read priority %d", _priority); return OMPI_SUCCESS; } @@ -138,28 +170,3 @@ int mca_vprotocol_pessimist_enable(bool enable) { } return OMPI_SUCCESS; } - - -static inline int mca_param_register_int( const char* param_name, - int default_value ) -{ - int param_value = default_value; - - (void) mca_base_param_reg_int (&mca_vprotocol_pessimist_component.pmlm_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; -} - -static inline char *mca_param_register_string( const char* param_name, - char *default_value ) -{ - char *param_value = default_value; - - (void) mca_base_param_reg_string (&mca_vprotocol_pessimist_component.pmlm_version, - param_name, NULL, false, false, default_value, - ¶m_value); - - return param_value; -} diff --git a/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_event.h b/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_event.h index f42a1d05d3..558bb9263b 100644 --- a/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_event.h +++ b/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_event.h @@ -9,7 +9,6 @@ */ #include "ompi_config.h" -#include "opal/mca/base/mca_base_param.h" #include "ompi/mca/pml/base/pml_base_request.h" #include "opal_stdint.h" diff --git a/ompi/patterns/net/netpatterns_base.c b/ompi/patterns/net/netpatterns_base.c index c7b7fd930c..078bb1a4fc 100644 --- a/ompi/patterns/net/netpatterns_base.c +++ b/ompi/patterns/net/netpatterns_base.c @@ -10,7 +10,6 @@ */ #include -#include "opal/mca/base/mca_base_param.h" #include "ompi/include/ompi/constants.h" #include "netpatterns.h" @@ -18,12 +17,13 @@ int netpatterns_base_verbose = 0; /* disabled by default */ int netpatterns_register_mca_params(void) { - mca_base_param_reg_int_name("common", - "netpatterns_base_verbose", - "Verbosity level of the NETPATTERNS framework", - false, false, - 0, - &netpatterns_base_verbose); + netpatterns_base_verbose = 0; + mca_base_var_register("ompi", "common", "netpatterns", "base_verbose", + "Verbosity level of the NETPATTERNS framework", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &netpatterns_base_verbose); return OMPI_SUCCESS; } diff --git a/ompi/runtime/ompi_cr.c b/ompi/runtime/ompi_cr.c index 137d4455ed..85dbaa6756 100644 --- a/ompi/runtime/ompi_cr.c +++ b/ompi/runtime/ompi_cr.c @@ -90,6 +90,7 @@ static int ompi_cr_coord_post_continue(void); static opal_cr_coord_callback_fn_t prev_coord_callback = NULL; int ompi_cr_output = -1; +int ompi_cr_verbosity = 0; #define NUM_COLLECTIVES 16 @@ -157,19 +158,19 @@ notify_collectives(int msg) */ int ompi_cr_init(void) { - int val; - /* - * Register some MCA parameters + * Register some MCA variables */ - mca_base_param_reg_int_name("ompi_cr", "verbose", - "Verbose output for the OMPI Checkpoint/Restart functionality", - false, false, - 0, - &val); - if(0 != val) { + ompi_cr_verbosity = 0; + (void) mca_base_var_register("ompi", "ompi", "cr", "verbose", + "Verbose output for the OMPI Checkpoint/Restart functionality", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_cr_verbosity); + if(0 != ompi_cr_verbosity) { ompi_cr_output = opal_output_open(NULL); - opal_output_set_verbosity(ompi_cr_output, val); + opal_output_set_verbosity(ompi_cr_output, ompi_cr_verbosity); } else { ompi_cr_output = opal_cr_output; } diff --git a/ompi/runtime/ompi_mpi_finalize.c b/ompi/runtime/ompi_mpi_finalize.c index 8ae04477ac..3c1139cf6e 100644 --- a/ompi/runtime/ompi_mpi_finalize.c +++ b/ompi/runtime/ompi_mpi_finalize.c @@ -81,6 +81,7 @@ #endif #include "ompi/runtime/ompi_cr.h" +extern bool ompi_enable_timing; int ompi_mpi_finalize(void) { @@ -88,7 +89,6 @@ int ompi_mpi_finalize(void) static int32_t finalize_has_already_started = 0; opal_list_item_t *item; struct timeval ompistart, ompistop; - bool timing = false; ompi_rte_collective_t *coll; /* Be a bit social if an erroneous program calls MPI_FINALIZE in @@ -141,11 +141,7 @@ int ompi_mpi_finalize(void) opal_progress_event_users_increment(); /* check to see if we want timing information */ - mca_base_param_reg_int_name("ompi", "timing", - "Request that critical timing loops be measured", - false, false, 0, &value); - if (value != 0 && 0 == OMPI_PROC_MY_NAME->vpid) { - timing = true; + if (ompi_enable_timing != 0 && 0 == OMPI_PROC_MY_NAME->vpid) { gettimeofday(&ompistart, NULL); } @@ -224,7 +220,7 @@ int ompi_mpi_finalize(void) /* check for timing request - get stop time and report elapsed time if so */ - if (timing && 0 == OMPI_PROC_MY_NAME->vpid) { + if (ompi_enable_timing && 0 == OMPI_PROC_MY_NAME->vpid) { gettimeofday(&ompistop, NULL); opal_output(0, "ompi_mpi_finalize[%ld]: time to execute barrier %ld usec", (long)OMPI_PROC_MY_NAME->vpid, @@ -403,12 +399,6 @@ int ompi_mpi_finalize(void) return ret; } - /* Free some OMPI MCA string params */ - if (NULL != ompi_mpi_show_mca_params_file) { - free(ompi_mpi_show_mca_params_file); - } - - /* Leave the RTE */ if (OMPI_SUCCESS != (ret = ompi_rte_finalize())) { diff --git a/ompi/runtime/ompi_mpi_init.c b/ompi/runtime/ompi_mpi_init.c index 5ca3489310..86c00bae4f 100644 --- a/ompi/runtime/ompi_mpi_init.c +++ b/ompi/runtime/ompi_mpi_init.c @@ -310,6 +310,30 @@ opal_hash_table_t ompi_mpi_f90_complex_hashtable; */ opal_list_t ompi_registered_datareps; +bool ompi_enable_timing; +extern bool ompi_mpi_yield_when_idle; +extern int ompi_mpi_event_tick_rate; + +static int ompi_register_mca_variables(void) +{ + int ret; + + /* Register MPI variables */ + if (OMPI_SUCCESS != (ret = ompi_mpi_register_params())) { + return ret; + } + + /* check to see if we want timing information */ + ompi_enable_timing = false; + (void) mca_base_var_register("ompi", "ompi", NULL, "timing", + "Request that critical timing loops be measured", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_enable_timing); + + return OMPI_SUCCESS; +} int ompi_mpi_init(int argc, char **argv, int requested, int *provided) { @@ -317,8 +341,6 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) ompi_proc_t** procs; size_t nprocs; char *error = NULL; - bool timing = false; - int param, value; struct timeval ompistart, ompistop; char *event_val = NULL; bool rte_setup = false; @@ -341,6 +363,12 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) goto error; } + /* Register MCA variables */ + if (OPAL_SUCCESS != (ret = ompi_register_mca_variables())) { + error = "ompi_mpi_init: ompi_register_mca_variables failed"; + goto error; + } + if (OPAL_SUCCESS != (ret = opal_arch_set_fortran_logical_size(sizeof(ompi_fortran_logical_t)))) { error = "ompi_mpi_init: opal_arch_set_fortran_logical_size failed"; goto error; @@ -379,15 +407,10 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) event_val = NULL; } - /* check to see if we want timing information */ - param = mca_base_param_reg_int_name("ompi", "timing", - "Request that critical timing loops be measured", - false, false, 0, &value); - if (value != 0) { - timing = true; + if (ompi_enable_timing && 0 == OMPI_PROC_MY_NAME->vpid) { gettimeofday(&ompistart, NULL); } - + /* if we were not externally started, then we need to setup * some envars so the MPI_INFO_ENV can get the cmd name * and argv (but only if the user supplied a non-NULL argv!), and @@ -413,7 +436,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) rte_setup = true; /* check for timing request - get stop time and report elapsed time if so */ - if (timing && 0 == OMPI_PROC_MY_NAME->vpid) { + if (ompi_enable_timing && 0 == OMPI_PROC_MY_NAME->vpid) { gettimeofday(&ompistop, NULL); opal_output(0, "ompi_mpi_init [%ld]: time from start to completion of rte_init %ld usec", (long)OMPI_PROC_MY_NAME->vpid, @@ -480,14 +503,6 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) goto error; } - /* Once we've joined the RTE, see if any MCA parameters were - passed to the MPI level */ - - if (OMPI_SUCCESS != (ret = ompi_mpi_register_params())) { - error = "mca_mpi_register_params() failed"; - goto error; - } - /* initialize datatypes. This step should be done early as it will * create the local convertor and local arch used in the proc * init. @@ -580,7 +595,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) } /* check for timing request - get stop time and report elapsed time if so */ - if (timing && 0 == OMPI_PROC_MY_NAME->vpid) { + if (ompi_enable_timing && 0 == OMPI_PROC_MY_NAME->vpid) { gettimeofday(&ompistop, NULL); opal_output(0, "ompi_mpi_init[%ld]: time from completion of rte_init to modex %ld usec", (long)OMPI_PROC_MY_NAME->vpid, @@ -607,7 +622,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) } OBJ_RELEASE(coll); - if (timing && 0 == OMPI_PROC_MY_NAME->vpid) { + if (ompi_enable_timing && 0 == OMPI_PROC_MY_NAME->vpid) { gettimeofday(&ompistop, NULL); opal_output(0, "ompi_mpi_init[%ld]: time to execute modex %ld usec", (long)OMPI_PROC_MY_NAME->vpid, @@ -772,7 +787,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) /* check for timing request - get stop time and report elapsed time if so, then start the clock again */ - if (timing && 0 == OMPI_PROC_MY_NAME->vpid) { + if (ompi_enable_timing && 0 == OMPI_PROC_MY_NAME->vpid) { gettimeofday(&ompistop, NULL); opal_output(0, "ompi_mpi_init[%ld]: time from modex to first barrier %ld usec", (long)OMPI_PROC_MY_NAME->vpid, @@ -796,7 +811,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) /* check for timing request - get stop time and report elapsed time if so, then start the clock again */ - if (timing && 0 == OMPI_PROC_MY_NAME->vpid) { + if (ompi_enable_timing && 0 == OMPI_PROC_MY_NAME->vpid) { gettimeofday(&ompistop, NULL); opal_output(0, "ompi_mpi_init[%ld]: time to execute barrier %ld usec", (long)OMPI_PROC_MY_NAME->vpid, @@ -900,21 +915,11 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) opal_progress_event_users_decrement(); /* see if yield_when_idle was specified - if so, use it */ - param = mca_base_param_find("mpi", NULL, "yield_when_idle"); - mca_base_param_lookup_int(param, &value); - if (value < 0) { - /* if no info is provided, just default to conservative */ - opal_progress_set_yield_when_idle(true); - } else { - /* info was provided, so set idle accordingly */ - opal_progress_set_yield_when_idle(value == 0 ? false : true); - } + opal_progress_set_yield_when_idle(ompi_mpi_yield_when_idle); - param = mca_base_param_find("mpi", NULL, "event_tick_rate"); - mca_base_param_lookup_int(param, &value); /* negative value means use default - just don't do anything */ - if (value >= 0) { - opal_progress_set_event_poll_rate(value); + if (ompi_mpi_event_tick_rate >= 0) { + opal_progress_set_event_poll_rate(ompi_mpi_event_tick_rate); } /* At this point, we are fully configured and in MPI mode. Any @@ -967,7 +972,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided) ompi_mpi_initialized = true; /* check for timing request - get stop time and report elapsed time if so */ - if (timing && 0 == OMPI_PROC_MY_NAME->vpid) { + if (ompi_enable_timing && 0 == OMPI_PROC_MY_NAME->vpid) { gettimeofday(&ompistop, NULL); opal_output(0, "ompi_mpi_init[%ld]: time from barrier to complete mpi_init %ld usec", (long)OMPI_PROC_MY_NAME->vpid, diff --git a/ompi/runtime/ompi_mpi_params.c b/ompi/runtime/ompi_mpi_params.c index 960a277e76..f6f956fbad 100644 --- a/ompi/runtime/ompi_mpi_params.c +++ b/ompi/runtime/ompi_mpi_params.c @@ -35,7 +35,6 @@ #include "ompi/runtime/params.h" #include "ompi/mca/rte/rte.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/util/argv.h" #include "opal/util/output.h" #include "opal/util/show_help.h" @@ -65,6 +64,12 @@ bool ompi_have_sparse_group_storage = OPAL_INT_TO_BOOL(OMPI_GROUP_SPARSE); bool ompi_use_sparse_group_storage = OPAL_INT_TO_BOOL(OMPI_GROUP_SPARSE); bool ompi_mpi_cuda_support = OPAL_INT_TO_BOOL(OMPI_CUDA_SUPPORT); +bool ompi_mpi_yield_when_idle = true; +int ompi_mpi_event_tick_rate = -1; +char *ompi_mpi_show_mca_params_string = NULL; +bool ompi_mpi_have_sparse_group_storage = !!(OMPI_GROUP_SPARSE); +bool ompi_mpi_preconnect_mpi = false; + static bool show_default_mca_params = false; static bool show_file_mca_params = false; static bool show_enviro_mca_params = false; @@ -73,25 +78,21 @@ static bool show_override_mca_params = false; int ompi_mpi_register_params(void) { int value; - char *param; /* Whether we want MPI API function parameter checking or not */ - mca_base_param_reg_int_name("mpi", "param_check", - "Whether you want MPI API parameters checked at run-time or not. Possible values are 0 (no checking) and 1 (perform checking at run-time)", - false, false, MPI_PARAM_CHECK, &value); - ompi_mpi_param_check = OPAL_INT_TO_BOOL(value); - if (ompi_mpi_param_check) { - value = 0; - if (MPI_PARAM_CHECK) { - value = 1; - } - if (0 == value) { - opal_show_help("help-mpi-runtime.txt", - "mpi-param-check-enabled-but-compiled-out", - true); - ompi_mpi_param_check = false; - } + ompi_mpi_param_check = false; + (void) mca_base_var_register("ompi", "mpi", NULL, "param_check", + "Whether you want MPI API parameters checked at run-time or not. Possible values are 0 (no checking) and 1 (perform checking at run-time)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_param_check); + if (ompi_mpi_param_check && !MPI_PARAM_CHECK) { + opal_show_help("help-mpi-runtime.txt", + "mpi-param-check-enabled-but-compiled-out", + true); + ompi_mpi_param_check = false; } /* @@ -100,37 +101,44 @@ int ompi_mpi_register_params(void) */ /* JMS: Need ORTE data here -- set this to 0 when exactly/under-subscribed, or 1 when oversubscribed */ - mca_base_param_reg_int_name("mpi", "yield_when_idle", - "Yield the processor when waiting for MPI communication (for MPI processes, will default to 1 when oversubscribing nodes)", - false, false, -1, NULL); - mca_base_param_reg_int_name("mpi", "event_tick_rate", - "How often to progress TCP communications (0 = never, otherwise specified in microseconds)", - false, false, -1, NULL); + ompi_mpi_yield_when_idle = true; + (void) mca_base_var_register("ompi", "mpi", NULL, "yield_when_idle", + "Yield the processor when waiting for MPI communication (for MPI processes, will default to 1 when oversubscribing nodes)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_yield_when_idle); + + ompi_mpi_event_tick_rate = -1; + (void) mca_base_var_register("ompi", "mpi", NULL, "event_tick_rate", + "How often to progress TCP communications (0 = never, otherwise specified in microseconds)", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_event_tick_rate); /* Whether or not to show MPI handle leaks */ - - mca_base_param_reg_int_name("mpi", "show_handle_leaks", - "Whether MPI_FINALIZE shows all MPI handles that were not freed or not", - false, false, - (int) ompi_debug_show_handle_leaks, &value); - ompi_debug_show_handle_leaks = OPAL_INT_TO_BOOL(value); + ompi_debug_show_handle_leaks = false; + (void) mca_base_var_register("ompi", "mpi", NULL, "show_handle_leaks", + "Whether MPI_FINALIZE shows all MPI handles that were not freed or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_debug_show_handle_leaks); /* Whether or not to free MPI handles. Useless without run-time param checking, so implicitly set that to true if we don't want to free the handles. */ - - mca_base_param_reg_int_name("mpi", "no_free_handles", - "Whether to actually free MPI objects when their handles are freed", - false, false, - (int) ompi_debug_no_free_handles, &value); - ompi_debug_no_free_handles = OPAL_INT_TO_BOOL(value); + ompi_debug_no_free_handles = false; + (void) mca_base_var_register("ompi", "mpi", NULL, "no_free_handles", + "Whether to actually free MPI objects when their handles are freed", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_debug_no_free_handles); if (ompi_debug_no_free_handles) { ompi_mpi_param_check = true; - value = 0; - if (MPI_PARAM_CHECK) { - value = 1; - } - if (0 == value) { + if (!MPI_PARAM_CHECK) { opal_output(0, "WARNING: MCA parameter mpi_no_free_handles set to true, but MPI"); opal_output(0, "WARNING: parameter checking has been compiled out of Open MPI."); opal_output(0, "WARNING: mpi_no_free_handles is therefore only partially effective!"); @@ -138,25 +146,30 @@ int ompi_mpi_register_params(void) } /* Whether or not to show MPI_ALLOC_MEM leaks */ - - mca_base_param_reg_int_name("mpi", "show_mpi_alloc_mem_leaks", - "If >0, MPI_FINALIZE will show up to this many instances of memory allocated by MPI_ALLOC_MEM that was not freed by MPI_FREE_MEM", - false, false, - ompi_debug_show_mpi_alloc_mem_leaks, - &ompi_debug_show_mpi_alloc_mem_leaks); + ompi_debug_show_mpi_alloc_mem_leaks = 0; + (void) mca_base_var_register("ompi", "mpi", NULL, "show_mpi_alloc_mem_leaks", + "If >0, MPI_FINALIZE will show up to this many instances of memory allocated by MPI_ALLOC_MEM that was not freed by MPI_FREE_MEM", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_debug_show_mpi_alloc_mem_leaks); /* Whether or not to print all MCA parameters in MPI_INIT */ - mca_base_param_reg_string_name("mpi", "show_mca_params", - "Whether to show all MCA parameter values during MPI_INIT or not (good for reproducability of MPI jobs " - "for debug purposes). Accepted values are all, default, file, api, and enviro - or a comma " - "delimited combination of them", - false, false, NULL, ¶m); - if (NULL != param) { + ompi_mpi_show_mca_params_string = NULL; + (void) mca_base_var_register("ompi", "mpi", NULL, "show_mca_params", + "Whether to show all MCA parameter values during MPI_INIT or not (good for reproducability of MPI jobs " + "for debug purposes). Accepted values are all, default, file, api, and enviro - or a comma " + "delimited combination of them", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_show_mca_params_string); + if (NULL != ompi_mpi_show_mca_params_string) { char **args; int i; ompi_mpi_show_mca_params = true; - args = opal_argv_split(param, ','); + args = opal_argv_split(ompi_mpi_show_mca_params_string, ','); if (NULL == args) { opal_output(0, "WARNING: could not parse mpi_show_mca_params request - defaulting to show \"all\""); show_default_mca_params = true; @@ -182,78 +195,88 @@ int ompi_mpi_register_params(void) } opal_argv_free(args); } - free(param); } /* File to use when dumping the parameters */ - mca_base_param_reg_string_name("mpi", "show_mca_params_file", - "If mpi_show_mca_params is true, setting this string to a valid filename tells Open MPI to dump all the MCA parameter values into a file suitable for reading via the mca_param_files parameter (good for reproducability of MPI jobs)", - false, false, - "", &ompi_mpi_show_mca_params_file); + ompi_mpi_show_mca_params_file = ""; + (void) mca_base_var_register("ompi", "mpi", NULL, "show_mca_params_file", + "If mpi_show_mca_params is true, setting this string to a valid filename tells Open MPI to dump all the MCA parameter values into a file suitable for reading via the mca_param_files parameter (good for reproducability of MPI jobs)", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_show_mca_params_file); /* User-level process pinning controls */ /* Do we want to save hostnames for debugging messages? This can eat quite a bit of memory... */ - - mca_base_param_reg_int_name("mpi", "keep_peer_hostnames", - "If nonzero, save the string hostnames of all MPI peer processes (mostly for error / debugging output messages). This can add quite a bit of memory usage to each MPI process.", - false, false, 1, &value); - ompi_mpi_keep_peer_hostnames = OPAL_INT_TO_BOOL(value); + ompi_mpi_keep_peer_hostnames = true; + (void) mca_base_var_register("ompi", "mpi", NULL, "keep_peer_hostnames", + "If nonzero, save the string hostnames of all MPI peer processes (mostly for error / debugging output messages). This can add quite a bit of memory usage to each MPI process.", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_keep_peer_hostnames); /* MPI_ABORT controls */ - - mca_base_param_reg_int_name("mpi", "abort_delay", + ompi_mpi_abort_delay = 0; + (void) mca_base_var_register("ompi", "mpi", NULL, "abort_delay", "If nonzero, print out an identifying message when MPI_ABORT is invoked (hostname, PID of the process that called MPI_ABORT) and delay for that many seconds before exiting (a negative delay value means to never abort). This allows attaching of a debugger before quitting the job.", - false, false, - ompi_mpi_abort_delay, - &ompi_mpi_abort_delay); - - mca_base_param_reg_int_name("mpi", "abort_print_stack", - "If nonzero, print out a stack trace when MPI_ABORT is invoked", - false, - /* If we do not have stack trace - capability, make this a read-only - MCA param */ -#if OPAL_WANT_PRETTY_PRINT_STACKTRACE && defined(HAVE_BACKTRACE) - false, -#else - true, -#endif - (int) ompi_mpi_abort_print_stack, - &value); -#if OPAL_WANT_PRETTY_PRINT_STACKTRACE && defined(HAVE_BACKTRACE) - /* Only take the value if we have stack trace capability */ - ompi_mpi_abort_print_stack = OPAL_INT_TO_BOOL(value); -#else - /* If we do not have stack trace capability, ensure that this is - hard-coded to false */ + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_abort_delay); + ompi_mpi_abort_print_stack = false; + (void) mca_base_var_register("ompi", "mpi", NULL, "abort_print_stack", + "If nonzero, print out a stack trace when MPI_ABORT is invoked", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + /* If we do not have stack trace + capability, make this a constant + MCA variable */ +#if OPAL_WANT_PRETTY_PRINT_STACKTRACE && defined(HAVE_BACKTRACE) + 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, +#else + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_CONSTANT, #endif + &ompi_mpi_abort_print_stack); + + ompi_mpi_preconnect_mpi = false; + value = mca_base_var_register("ompi", "mpi", NULL, "preconnect_mpi", + "Whether to force MPI processes to fully " + "wire-up the MPI connections between MPI " + "processes during " + "MPI_INIT (vs. making connections lazily -- " + "upon the first MPI traffic between each " + "process peer pair)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_INTERNAL, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_preconnect_mpi); + mca_base_var_register_synonym(value, "ompi", "mpi", NULL, "preconnect_all", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); - value = mca_base_param_reg_int_name("mpi", "preconnect_mpi", - "Whether to force MPI processes to fully " - "wire-up the MPI connections between MPI " - "processes during " - "MPI_INIT (vs. making connections lazily -- " - "upon the first MPI traffic between each " - "process peer pair)", - true, false, 0, NULL); - mca_base_param_reg_syn_name(value, "mpi", "preconnect_all", true); - /* Leave pinned parameter */ + ompi_mpi_leave_pinned = -1; + (void) mca_base_var_register("ompi", "mpi", NULL, "leave_pinned", + "Whether to use the \"leave pinned\" protocol or not. Enabling this setting can help bandwidth performance when repeatedly sending and receiving large messages with the same buffers over RDMA-based networks (0 = do not use \"leave pinned\" protocol, 1 = use \"leave pinned\" protocol, -1 = allow network to choose at runtime).", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_leave_pinned); - mca_base_param_reg_int_name("mpi", "leave_pinned", - "Whether to use the \"leave pinned\" protocol or not. Enabling this setting can help bandwidth performance when repeatedly sending and receiving large messages with the same buffers over RDMA-based networks (0 = do not use \"leave pinned\" protocol, 1 = use \"leave pinned\" protocol, -1 = allow network to choose at runtime).", - false, false, - ompi_mpi_leave_pinned, &value); - ompi_mpi_leave_pinned = (value >= 1) ? true: false; - - mca_base_param_reg_int_name("mpi", "leave_pinned_pipeline", + ompi_mpi_leave_pinned_pipeline = false; + (void) mca_base_var_register("ompi", "mpi", NULL, "leave_pinned_pipeline", "Whether to use the \"leave pinned pipeline\" protocol or not.", - false, false, - (int) ompi_mpi_leave_pinned_pipeline, &value); - ompi_mpi_leave_pinned_pipeline = OPAL_INT_TO_BOOL(value); + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_mpi_leave_pinned_pipeline); if (ompi_mpi_leave_pinned && ompi_mpi_leave_pinned_pipeline) { ompi_mpi_leave_pinned_pipeline = 0; @@ -262,65 +285,62 @@ int ompi_mpi_register_params(void) true); } - mca_base_param_reg_int_name("mpi", "warn_on_fork", - "If nonzero, issue a warning if program forks under conditions that could cause system errors", - false, false, - (int) true, &value); - ompi_warn_on_fork = OPAL_INT_TO_BOOL(value); + ompi_warn_on_fork = true; + (void) mca_base_var_register("ompi", "mpi", NULL, "warn_on_fork", + "If nonzero, issue a warning if program forks under conditions that could cause system errors", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_warn_on_fork); /* Sparse group storage support */ + (void) mca_base_var_register("ompi", "mpi", NULL, "have_sparse_group_storage", + "Whether this Open MPI installation supports storing of data in MPI groups in \"sparse\" formats (good for extremely large process count MPI jobs that create many communicators/groups)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_CONSTANT, + &ompi_mpi_have_sparse_group_storage); - mca_base_param_reg_int_name("mpi", "have_sparse_group_storage", - "Whether this Open MPI installation supports storing of data in MPI groups in \"sparse\" formats (good for extremely large process count MPI jobs that create many communicators/groups)", - false, true, (int) OMPI_GROUP_SPARSE, NULL); - mca_base_param_reg_int_name("mpi", "use_sparse_group_storage", - "Whether to use \"sparse\" storage formats for MPI groups (only relevant if mpi_have_sparse_group_storage is 1)", - false, false, OMPI_GROUP_SPARSE, &value); - ompi_use_sparse_group_storage = OPAL_INT_TO_BOOL(value); - if (ompi_use_sparse_group_storage) { - value = 0; - if (OMPI_GROUP_SPARSE) { - value = 1; - } - if (0 == value) { - opal_show_help("help-mpi-runtime.txt", - "sparse groups enabled but compiled out", - true); - ompi_use_sparse_group_storage = false; - } + ompi_use_sparse_group_storage = ompi_mpi_have_sparse_group_storage; + (void) mca_base_var_register("ompi", "mpi", NULL, "use_sparse_group_storage", + "Whether to use \"sparse\" storage formats for MPI groups (only relevant if mpi_have_sparse_group_storage is 1)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + ompi_mpi_have_sparse_group_storage ? 0 : MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + ompi_mpi_have_sparse_group_storage ? MCA_BASE_VAR_SCOPE_READONLY : MCA_BASE_VAR_SCOPE_CONSTANT, + &ompi_use_sparse_group_storage); + if (ompi_use_sparse_group_storage && !ompi_mpi_have_sparse_group_storage) { + opal_show_help("help-mpi-runtime.txt", + "sparse groups enabled but compiled out", + true); + ompi_use_sparse_group_storage = false; } - mca_base_param_reg_int_name("mpi", "cuda_support", - "Whether CUDA GPU buffer support is enabled or not", - false, false, OMPI_CUDA_SUPPORT, &value); - ompi_mpi_cuda_support = OPAL_INT_TO_BOOL(value); - if (ompi_mpi_cuda_support) { - value = 0; - if (OMPI_CUDA_SUPPORT) { - value = 1; - } - if (0 == value) { - opal_show_help("help-mpi-runtime.txt", "no cuda support", - true); - ompi_mpi_cuda_support = false; - } + ompi_mpi_cuda_support = !!(OMPI_CUDA_SUPPORT); + (void) mca_base_var_register("ompi", "mpi", NULL, "cuda_support", + "Whether CUDA GPU buffer support is enabled or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, + !!(OMPI_CUDA_SUPPORT) ? 0 : MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_9, + !!(OMPI_CUDA_SUPPORT) ? MCA_BASE_VAR_SCOPE_READONLY : MCA_BASE_VAR_SCOPE_CONSTANT, + &ompi_mpi_cuda_support); + if (ompi_mpi_cuda_support && !(OMPI_CUDA_SUPPORT)) { + opal_show_help("help-mpi-runtime.txt", "no cuda support", + true); + ompi_mpi_cuda_support = false; } return OMPI_SUCCESS; } int ompi_show_all_mca_params(int32_t rank, int requested, char *nodename) { - opal_list_t *info; - opal_list_item_t *i; - mca_base_param_info_t *item; - char *value_string; - int value_int; + const mca_base_var_t *var; + int var_count, i, ret; FILE *fp = NULL; time_t timestamp; - mca_base_param_source_t source; - char *src_file; - char *src_string; - + char **var_dump; + if (rank != 0) { return OMPI_SUCCESS; } @@ -338,108 +358,67 @@ int ompi_show_all_mca_params(int32_t rank, int requested, char *nodename) { fprintf(fp, "# by MPI_COMM_WORLD rank %d (out of a total of %d) on %s\n", rank, requested, nodename ); fprintf(fp, "#\n"); } - - mca_base_param_dump(&info, false); - for (i = opal_list_get_first(info); - i != opal_list_get_last(info); - i = opal_list_get_next(i)) { - item = (mca_base_param_info_t*) i; - /* If this is an internal param, don't print it */ - if (item->mbpp_internal) { + var_count = mca_base_var_get_count (); + for (i = 0 ; i < var_count ; ++i) { + ret = mca_base_var_get (i, &var); + if (OPAL_SUCCESS != ret) { continue; } - - /* get the source - where the param was last set */ - if (OPAL_SUCCESS != - mca_base_param_lookup_source(item->mbpp_index, &source, &src_file)) { + + /* If this is an internal param, don't print it */ + if (MCA_BASE_VAR_FLAG_INTERNAL & var->mbv_flags) { continue; } /* is this a default value and we are not displaying * defaults, ignore this one */ - if (MCA_BASE_PARAM_SOURCE_DEFAULT == source && !show_default_mca_params) { + if (MCA_BASE_VAR_SOURCE_DEFAULT == var->mbv_source && !show_default_mca_params) { continue; } /* is this a file value and we are not displaying files, * ignore it */ - if (MCA_BASE_PARAM_SOURCE_FILE == source && !show_file_mca_params) { + if ((MCA_BASE_VAR_SOURCE_FILE == var->mbv_source || + MCA_BASE_VAR_SOURCE_OVERRIDE) && !show_file_mca_params) { continue; } /* is this an enviro value and we are not displaying enviros, * ignore it */ - if (MCA_BASE_PARAM_SOURCE_ENV == source && !show_enviro_mca_params) { + if (MCA_BASE_VAR_SOURCE_ENV == var->mbv_source && !show_enviro_mca_params) { continue; } /* is this an API value and we are not displaying APIs, * ignore it */ - if (MCA_BASE_PARAM_SOURCE_OVERRIDE == source && !show_override_mca_params) { + if (MCA_BASE_VAR_SOURCE_OVERRIDE == var->mbv_source && !show_override_mca_params) { continue; } - /* Get the parameter name, and convert it to a printable string */ - if (MCA_BASE_PARAM_TYPE_STRING == item->mbpp_type) { - mca_base_param_lookup_string(item->mbpp_index, &value_string); - if (NULL == value_string) { - value_string = strdup(""); - } - } else { - mca_base_param_lookup_int(item->mbpp_index, &value_int); - asprintf(&value_string, "%d", value_int); + ret = mca_base_var_dump (i, &var_dump, MCA_BASE_VAR_DUMP_SIMPLE); + if (OPAL_SUCCESS != ret) { + continue; } - - switch(source) { - case MCA_BASE_PARAM_SOURCE_DEFAULT: - src_string = "default value"; - break; - case MCA_BASE_PARAM_SOURCE_ENV: - src_string = "environment or cmdline"; - break; - case MCA_BASE_PARAM_SOURCE_FILE: - src_string = "file"; - break; - case MCA_BASE_PARAM_SOURCE_OVERRIDE: - src_string = "API override"; - break; - default: - src_string = NULL; - break; - } - + /* Print the parameter */ if (0 != strlen(ompi_mpi_show_mca_params_file)) { - if (NULL == src_file) { - fprintf(fp, "%s=%s (%s)\n", item->mbpp_full_name, value_string, - (NULL != src_string ? src_string : "unknown")); - } else { - fprintf(fp, "%s=%s (%s:%s)\n", item->mbpp_full_name, value_string, - (NULL != src_string ? src_string : "unknown"), src_file); - } + fprintf(fp, "%s\n", var_dump[0]); } else { - if (NULL == src_file) { - opal_output(0, "%s=%s (%s)\n", item->mbpp_full_name, value_string, - (NULL != src_string ? src_string : "unknown")); - } else { - opal_output(0, "%s=%s (%s:%s)\n", item->mbpp_full_name, value_string, - (NULL != src_string ? src_string : "unknown"), src_file); - } + opal_output(0, "%s\n", var_dump[0]); } - - free(value_string); + free (var_dump[0]); + free (var_dump); } /* Close file, cleanup allocated memory*/ if (0 != strlen(ompi_mpi_show_mca_params_file)) { fclose(fp); } - mca_base_param_dump_release(info); return OMPI_SUCCESS; } diff --git a/ompi/runtime/ompi_mpi_preconnect.c b/ompi/runtime/ompi_mpi_preconnect.c index 73345309e3..12960b1b52 100644 --- a/ompi/runtime/ompi_mpi_preconnect.c +++ b/ompi/runtime/ompi_mpi_preconnect.c @@ -29,14 +29,15 @@ ompi_init_preconnect_mpi(void) { int comm_size = ompi_comm_size(MPI_COMM_WORLD); int comm_rank = ompi_comm_rank(MPI_COMM_WORLD); - int param, value, next, prev, i, ret = OMPI_SUCCESS; + int param, next, prev, i, ret = OMPI_SUCCESS; struct ompi_request_t * requests[2]; char inbuf[1], outbuf[1]; + const bool *value; - param = mca_base_param_find("mpi", NULL, "preconnect_mpi"); + param = mca_base_var_find("ompi", "mpi", NULL, "preconnect_mpi"); if (0 > param) return OMPI_SUCCESS; - ret = mca_base_param_lookup_int(param, &value); - if (OMPI_SUCCESS != ret || 0 == value) { + ret = mca_base_var_get_value(param, &value, NULL, NULL); + if (OMPI_SUCCESS != ret || 0 == value[0]) { return OMPI_SUCCESS; } diff --git a/ompi/tools/ompi_info/param.c b/ompi/tools/ompi_info/param.c index 8211a0431e..c8e1bb2be9 100644 --- a/ompi/tools/ompi_info/param.c +++ b/ompi/tools/ompi_info/param.c @@ -38,7 +38,6 @@ #include "opal/class/opal_pointer_array.h" #include "opal/util/printf.h" #include "opal/memoryhooks/memory.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/runtime/opal_info_support.h" #if OMPI_RTE_ORTE diff --git a/opal/datatype/opal_datatype_copy.c b/opal/datatype/opal_datatype_copy.c index 8f9f3af4ce..79a2f63fdf 100644 --- a/opal/datatype/opal_datatype_copy.c +++ b/opal/datatype/opal_datatype_copy.c @@ -36,7 +36,7 @@ #if OPAL_ENABLE_DEBUG -extern int opal_copy_debug; +extern bool opal_copy_debug; #define DO_DEBUG(INST) if( opal_copy_debug ) { INST } #else #define DO_DEBUG(INST) diff --git a/opal/datatype/opal_datatype_cuda.c b/opal/datatype/opal_datatype_cuda.c index 6f23374988..2e862c9bfe 100755 --- a/opal/datatype/opal_datatype_cuda.c +++ b/opal/datatype/opal_datatype_cuda.c @@ -13,14 +13,13 @@ #include #include "opal/align.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/util/output.h" #include "orte/util/show_help.h" #include "opal/datatype/opal_convertor.h" #include "opal/datatype/opal_datatype_cuda.h" static bool initialized = false; -static int opal_cuda_verbose; +int opal_cuda_verbose = 0; static int opal_cuda_enabled = 0; /* Starts out disabled */ static int opal_cuda_output = 0; static void opal_cuda_support_init(void); @@ -155,9 +154,6 @@ static void opal_cuda_support_init(void) } /* Set different levels of verbosity in the cuda related code. */ - id = mca_base_param_reg_int_name("opal", "cuda_verbose", - "Set level of opal cuda verbosity", - false, false, 0, &opal_cuda_verbose); opal_cuda_output = opal_output_open(NULL); opal_output_set_verbosity(opal_cuda_output, opal_cuda_verbose); diff --git a/opal/datatype/opal_datatype_module.c b/opal/datatype/opal_datatype_module.c index 8ba0aa7590..e3981da722 100644 --- a/opal/datatype/opal_datatype_module.c +++ b/opal/datatype/opal_datatype_module.c @@ -28,15 +28,16 @@ #include "opal/datatype/opal_datatype_internal.h" #include "opal/datatype/opal_datatype.h" #include "opal/datatype/opal_convertor_internal.h" -#include "opal/mca/base/mca_base_param.h" +#include "opal/mca/base/mca_base_var.h" /* by default the debuging is turned off */ int opal_datatype_dfd = -1; -int opal_unpack_debug = 0; -int opal_pack_debug = 0; -int opal_position_debug = 0; -int opal_copy_debug = 0; +bool opal_unpack_debug = false; +bool opal_pack_debug = false; +bool opal_position_debug = false; +bool opal_copy_debug = false; +extern int opal_cuda_verbose; /* Using this macro implies that at this point _all_ informations needed * to fill up the datatype are known. @@ -139,23 +140,50 @@ OPAL_DECLSPEC const opal_datatype_t* opal_datatype_basicDatatypes[OPAL_DATATYPE_ int opal_datatype_register_params(void) { #if OPAL_ENABLE_DEBUG - mca_base_param_reg_int_name( "mpi", "ddt_unpack_debug", - "Whether to output debugging information in the ddt unpack functions (nonzero = enabled)", - false, false, - opal_unpack_debug, &opal_unpack_debug ); - mca_base_param_reg_int_name( "mpi", "ddt_pack_debug", - "Whether to output debugging information in the ddt pack functions (nonzero = enabled)", - false, false, - opal_pack_debug, &opal_pack_debug ); - mca_base_param_reg_int_name( "mpi", "ddt_position_debug", - "Non zero lead to output generated by the datatype position functions", - false, false, 0, &opal_position_debug ); + int ret; - mca_base_param_reg_int_name( "mpi", "ddt_copy_debug", - "Whether to output debugging information in the ddt copy functions (nonzero = enabled)", - false, false, - opal_copy_debug, &opal_copy_debug ); + ret = mca_base_var_register ("opal", "mpi", NULL, "ddt_unpack_debug", + "Whether to output debugging information in the ddt unpack functions (nonzero = enabled)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_LOCAL, &opal_unpack_debug); + if (0 > ret) { + return ret; + } + + ret = mca_base_var_register ("opal", "mpi", NULL, "ddt_pack_debug", + "Whether to output debugging information in the ddt pack functions (nonzero = enabled)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_LOCAL, &opal_pack_debug); + if (0 > ret) { + return ret; + } + + ret = mca_base_var_register ("opal", "mpi", NULL, "ddt_position_debug", + "Non zero lead to output generated by the datatype position functions", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_LOCAL, &opal_position_debug); + if (0 > ret) { + return ret; + } + + ret = mca_base_var_register ("opal", "mpi", NULL, "ddt_copy_debug", + "Whether to output debugging information in the ddt copy functions (nonzero = enabled)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_LOCAL, &opal_copy_debug); + if (0 > ret) { + return ret; + } #endif /* OPAL_ENABLE_DEBUG */ + +#if OPAL_CUDA_SUPPORT + /* Set different levels of verbosity in the cuda related code. */ + ret = mca_base_var_register ("opal", "opal", NULL, "cuda_verbose", + "Set level of opal cuda verbosity", + MCA_BASE_VAR_TYPE_INT, NULL, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_LOCAL, + &opal_cuda_verbose); +#endif + return OPAL_SUCCESS; } diff --git a/opal/datatype/opal_datatype_pack.c b/opal/datatype/opal_datatype_pack.c index e572019bc5..d7e01ebf26 100644 --- a/opal/datatype/opal_datatype_pack.c +++ b/opal/datatype/opal_datatype_pack.c @@ -29,7 +29,7 @@ #include "opal/util/output.h" -extern int opal_pack_debug; +extern bool opal_pack_debug; #define DO_DEBUG(INST) if( opal_pack_debug ) { INST } #else #define DO_DEBUG(INST) diff --git a/opal/datatype/opal_datatype_position.c b/opal/datatype/opal_datatype_position.c index 2c5b900152..9fb3765d2c 100644 --- a/opal/datatype/opal_datatype_position.c +++ b/opal/datatype/opal_datatype_position.c @@ -34,7 +34,7 @@ #if OPAL_ENABLE_DEBUG #include "opal/util/output.h" -extern int opal_position_debug; +extern bool opal_position_debug; #define DO_DEBUG(INST) if( opal_position_debug ) { INST } #else #define DO_DEBUG(INST) diff --git a/opal/datatype/opal_datatype_unpack.c b/opal/datatype/opal_datatype_unpack.c index 9e61fb3da5..7319526e3c 100644 --- a/opal/datatype/opal_datatype_unpack.c +++ b/opal/datatype/opal_datatype_unpack.c @@ -30,7 +30,7 @@ #if OPAL_ENABLE_DEBUG #include "opal/util/output.h" -extern int opal_unpack_debug; +extern bool opal_unpack_debug; #define DO_DEBUG(INST) if( opal_unpack_debug ) { INST } #else #define DO_DEBUG(INST) diff --git a/opal/dss/dss.h b/opal/dss/dss.h index b72a9e6808..e26f32c753 100644 --- a/opal/dss/dss.h +++ b/opal/dss/dss.h @@ -320,6 +320,13 @@ typedef int (*opal_dss_load_fn_t)(opal_buffer_t *buffer, typedef int (*opal_dss_copy_payload_fn_t)(opal_buffer_t *dest, opal_buffer_t *src); +/** + * DSS register function + * + * This function registers variables associated with the DSS system. + */ +OPAL_DECLSPEC int opal_dss_register_vars (void); + /** * DSS initialization function. * diff --git a/opal/dss/dss_open_close.c b/opal/dss/dss_open_close.c index c7dbcb496d..b51b29a571 100644 --- a/opal/dss/dss_open_close.c +++ b/opal/dss/dss_open_close.c @@ -22,7 +22,7 @@ */ #include "opal_config.h" -#include "opal/mca/base/mca_base_param.h" +#include "opal/mca/base/mca_base_var.h" #include "opal/dss/dss_internal.h" @@ -35,7 +35,16 @@ int opal_dss_initial_size; int opal_dss_threshold_size; opal_pointer_array_t opal_dss_types; opal_data_type_t opal_dss_num_reg_types; -opal_dss_buffer_type_t default_buf_type; +opal_dss_buffer_type_t default_buf_type = OPAL_DSS_BUFFER_NON_DESC; + +/* variable group id */ +static int opal_dss_group_id = -1; + +mca_base_var_enum_value_t buffer_type_values[] = { + {OPAL_DSS_BUFFER_NON_DESC, "non-described"}, + {OPAL_DSS_BUFFER_FULLY_DESC, "described"}, + {0, NULL} +}; opal_dss_t opal_dss = { opal_dss_pack, @@ -209,47 +218,77 @@ OBJ_CLASS_INSTANCE(opal_node_stats_t, opal_object_t, opal_node_stats_destruct); -int opal_dss_open(void) +int opal_dss_register_vars (void) { + mca_base_var_enum_t *new_enum; char *enviro_val; - int rc; - opal_data_type_t tmp; - int def_type; - - if (opal_dss_initialized) { - return OPAL_SUCCESS; - } + int ret; enviro_val = getenv("OPAL_dss_debug"); if (NULL != enviro_val) { /* debug requested */ opal_dss_verbose = 0; } + opal_dss_group_id = mca_base_var_group_register ("opal", "dss", NULL, NULL); + /** set the default buffer type. If we are in debug mode, then we default * to fully described buffers. Otherwise, we default to non-described for brevity * and performance */ #if OPAL_ENABLE_DEBUG - def_type = OPAL_DSS_BUFFER_FULLY_DESC; + default_buf_type = OPAL_DSS_BUFFER_FULLY_DESC; #else - def_type = OPAL_DSS_BUFFER_NON_DESC; + default_buf_type = OPAL_DSS_BUFFER_NON_DESC; #endif - (void) mca_base_param_reg_int_name ("dss", "buffer_type", - "Set the default mode for OpenRTE buffers (0=non-described, 1=described)", - false, false, def_type, &rc); - default_buf_type = rc; + ret = mca_base_var_enum_create ("buffer types", buffer_type_values, &new_enum); + if (OPAL_SUCCESS != ret) { + fprintf (stderr, "Fail A\n"); + return ret; + } + + ret = mca_base_var_register ("opal", "dss", NULL, "buffer_type", + "Set the default mode for OpenRTE buffers (0=non-described, 1=described)", + MCA_BASE_VAR_TYPE_INT, new_enum, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_ALL_EQ, + &default_buf_type); + OBJ_RELEASE(new_enum); + if (0 > ret) { + return ret; + } /* setup the initial size of the buffer. */ - (void) mca_base_param_reg_int_name ("dss", "buffer_initial_size", NULL, - false, false, OPAL_DSS_DEFAULT_INITIAL_SIZE, - &opal_dss_initial_size); + opal_dss_initial_size = OPAL_DSS_DEFAULT_INITIAL_SIZE; + ret = mca_base_var_register ("opal", "dss", NULL, "buffer_initial_size", NULL, + MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_ALL_EQ, + &opal_dss_initial_size); + if (0 > ret) { + return ret; + } /* the threshold as to where to stop doubling the size of the buffer * allocated memory and start doing additive increases */ - (void) mca_base_param_reg_int_name ("dss", "buffer_threshold_size", NULL, - false, false, OPAL_DSS_DEFAULT_THRESHOLD_SIZE, - &opal_dss_threshold_size); + opal_dss_threshold_size = OPAL_DSS_DEFAULT_THRESHOLD_SIZE; + ret = mca_base_var_register ("opal", "dss", NULL, "buffer_threshold_size", NULL, + MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_ALL_EQ, + &opal_dss_threshold_size); + + return (0 > ret) ? ret : OPAL_SUCCESS; +} + +int opal_dss_open(void) +{ + int rc; + opal_data_type_t tmp; + + if (opal_dss_initialized) { + return OPAL_SUCCESS; + } + + /* Lock DSS MCA variables */ + mca_base_var_group_set_var_flag (opal_dss_group_id, MCA_BASE_VAR_FLAG_SETTABLE, false); /* Setup the types array */ OBJ_CONSTRUCT(&opal_dss_types, opal_pointer_array_t); diff --git a/opal/dss/dss_types.h b/opal/dss/dss_types.h index 17a60346ad..b125fef9a2 100644 --- a/opal/dss/dss_types.h +++ b/opal/dss/dss_types.h @@ -199,9 +199,12 @@ OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_node_stats_t); /** * buffer type */ -typedef uint8_t opal_dss_buffer_type_t; -#define OPAL_DSS_BUFFER_NON_DESC 0x00 -#define OPAL_DSS_BUFFER_FULLY_DESC 0x01 +enum opal_dss_buffer_type_t { + OPAL_DSS_BUFFER_NON_DESC = 0x00, + OPAL_DSS_BUFFER_FULLY_DESC = 0x01 +}; + +typedef enum opal_dss_buffer_type_t opal_dss_buffer_type_t; #define OPAL_DSS_BUFFER_TYPE_HTON(h); #define OPAL_DSS_BUFFER_TYPE_NTOH(h); diff --git a/opal/mca/backtrace/base/backtrace_component.c b/opal/mca/backtrace/base/backtrace_component.c index ec064bf640..e43c3afe05 100644 --- a/opal/mca/backtrace/base/backtrace_component.c +++ b/opal/mca/backtrace/base/backtrace_component.c @@ -22,7 +22,6 @@ #include "opal/constants.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/mca/backtrace/backtrace.h" #include "opal/mca/backtrace/base/base.h" diff --git a/opal/mca/base/Makefile.am b/opal/mca/base/Makefile.am index 888e5b8ccb..126c457ff2 100644 --- a/opal/mca/base/Makefile.am +++ b/opal/mca/base/Makefile.am @@ -25,13 +25,16 @@ AM_CPPFLAGS = \ noinst_LTLIBRARIES = libmca_base.la -dist_pkgdata_DATA = help-mca-base.txt help-mca-param.txt +dist_pkgdata_DATA = help-mca-base.txt help-mca-var.txt # Source code files headers = \ base.h \ mca_base_component_repository.h \ + mca_base_var.h \ + mca_base_var_enum.h \ + mca_base_vari.h \ mca_base_param.h \ mca_base_param_internal.h @@ -50,7 +53,10 @@ libmca_base_la_SOURCES = \ mca_base_list.c \ mca_base_open.c \ mca_base_param.c \ - mca_base_parse_paramfile.c + mca_base_var.c \ + mca_base_var_enum.c \ + mca_base_parse_paramfile.c \ + mca_base_components_register.c # Conditionally install the header files diff --git a/opal/mca/base/base.h b/opal/mca/base/base.h index c9c01fede7..2cd9539fae 100644 --- a/opal/mca/base/base.h +++ b/opal/mca/base/base.h @@ -30,6 +30,7 @@ */ #include "opal/mca/mca.h" #include "opal/mca/base/mca_base_param.h" +#include "opal/mca/base/mca_base_var.h" #include "opal/util/cmd_line.h" BEGIN_C_DECLS @@ -59,9 +60,12 @@ OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_base_component_priority_list_item_t); /* * Public variables */ -OPAL_DECLSPEC extern int mca_base_param_component_path; +OPAL_DECLSPEC extern char *mca_base_component_path; +OPAL_DECLSPEC extern bool mca_base_opened; OPAL_DECLSPEC extern char *mca_base_system_default_path; OPAL_DECLSPEC extern char *mca_base_user_default_path; +OPAL_DECLSPEC extern bool mca_base_component_show_load_errors; +OPAL_DECLSPEC extern bool mca_base_component_disable_dlopen; /* * Public functions @@ -160,6 +164,9 @@ OPAL_DECLSPEC int mca_base_components_open(const char *type_name, int output_id, /* mca_base_components_close.c */ +int mca_base_component_release (int output_id, const mca_base_component_t *component, + bool opened); + OPAL_DECLSPEC int mca_base_components_close(int output_id, opal_list_t *components_available, const mca_base_component_t *skip); diff --git a/opal/mca/base/help-mca-var.txt b/opal/mca/base/help-mca-var.txt new file mode 100644 index 0000000000..2b1eb2670d --- /dev/null +++ b/opal/mca/base/help-mca-var.txt @@ -0,0 +1,111 @@ +# -*- text -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2013 Los Alamos National Security, LLC. All rights +# reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# +# This is the US/English help file for Open MPI MCA error messages. +# +[invalid-flag-combination] +ERROR: An invalid combination of flags was passed to mca_base_var_register. + + Variable: %s + Flags: %s %s +# +[default-only-param-set] +WARNING: A user-supplied value attempted to override the default-only MCA +variable named "%s". + +The user-supplied value was ignored. +# +[missing-param-file] +Process %d Unable to locate the variable file "%s" in the following search path: + %s +# +[deprecated-mca-env] +A deprecated MCA variable value was specified in the environment or +on the command line. Deprecated MCA variables should be avoided; +they may disappear in future releases. + + Deprecated variable: %s +# +[deprecated-mca-cli] +A deprecated MCA variable value was specified on the command line. Deprecated +MCA variables should be avoided; they may disappear in future releases. + + Deprecated variable: %s +# +[deprecated-mca-file] +A deprecated MCA variable value was specified in an MCA variable +file. Deprecated MCA variables should be avoided; they may disappear +in future releases. + + Deprecated variable: %s + Source file: %s +# +[mutually-exclusive-vars] +Two mutually-exclusive MCA variables were specified. This can result +in undefined behavior, such as ignoring the components that the MCA +variables are supposed to affect. + + 1st MCA variable: %s + Source of value: %s + 2nd MCA variable: %s + Source of value: %s +# +[re-register-with-different-type] +An MCA variable was re-registered with a different type (i.e., it was +either originally registered as an INT and re-registered as a STRING, +or it was originially registered as a STRING and re-registered as an +INT). This a developer error; your job may abort. + + MCA variable name: %s +# +[overridden-param-set] +WARNING: A user-supplied value attempted to set a variable that is set +in the override variable file (openmpi-mca-params-override.conf). + + Variable: %s + +The user-supplied value was ignored. +# +[invalid-value] +An invalid value was supplied for an enum variable. + + Variable : %s + Value : %s +# +[invalid-value-enum] +An invalid value was supplied for an enum variable. + + Variable : %s + Value : %s + Valid values : %s +# +[environment-only-param] +WARNING: The special MCA parameter "%s" was set in +an unexpected way, and is likely not working the way you want it to. + +Specifically, this MCA parameter is "special" in that it can *only* be +set in the environment. Setting this value in a file -- and sometimes +even on the command line -- will not work as intended. The *only* way +to set this value is to set "OMPI_MCA_%s" in the environment before +starting your job. + + Value: %s + Source: %s diff --git a/opal/mca/base/mca_base_cmd_line.c b/opal/mca/base/mca_base_cmd_line.c index 10877fdcd9..6cad1490ed 100644 --- a/opal/mca/base/mca_base_cmd_line.c +++ b/opal/mca/base/mca_base_cmd_line.c @@ -171,7 +171,7 @@ static void add_to_env(char **params, char **values, char ***env) vars of the form OMPI_MCA_*=value. */ for (i = 0; NULL != params && NULL != params[i]; ++i) { - name = mca_base_param_env_var (params[i]); + (void) mca_base_var_env_name (params[i], &name); opal_setenv(name, values[i], true, env); free(name); } diff --git a/opal/mca/base/mca_base_component_find.c b/opal/mca/base/mca_base_component_find.c index e7521cfc34..dba5c3edae 100644 --- a/opal/mca/base/mca_base_component_find.c +++ b/opal/mca/base/mca_base_component_find.c @@ -173,16 +173,10 @@ int mca_base_component_find(const char *directory, const char *type, #if OPAL_WANT_LIBLTDL /* Find any available dynamic components in the specified directory */ - if (open_dso_components) { - int param, param_disable_dlopen; - param = mca_base_param_find("mca", NULL, "component_disable_dlopen"); - mca_base_param_lookup_int(param, ¶m_disable_dlopen); - - if (0 == param_disable_dlopen) { - find_dyn_components(directory, type, - (const char**)requested_component_names, - include_mode, found_components); - } + if (open_dso_components && !mca_base_component_disable_dlopen) { + find_dyn_components(directory, type, + (const char**)requested_component_names, + include_mode, found_components); } else { opal_output_verbose(40, 0, "mca: base: component_find: dso loading for %s MCA components disabled", @@ -262,13 +256,18 @@ static void find_dyn_components(const char *path, const char *type_name, use that as the path. */ if (NULL == path) { - mca_base_param_lookup_string(mca_base_param_component_path, - &path_to_use); - if (NULL == path_to_use) { + if (NULL != mca_base_component_path) { + path_to_use = strdup(mca_base_component_path); + } else { /* If there's no path, then there's nothing to search -- we're done */ return; } + + if (NULL == path_to_use) { + /* out of memory */ + return; + } } else { path_to_use = strdup(path); } @@ -431,7 +430,6 @@ static int file_exists(const char *filename, const char *ext) static int open_component(component_file_item_t *target_file, opal_list_t *found_components) { - int show_errors, param; lt_dlhandle component_handle; mca_base_component_t *component_struct; char *struct_name, *err; @@ -445,9 +443,7 @@ static int open_component(component_file_item_t *target_file, opal_output_verbose(40, 0, "mca: base: component_find: examining dyanmic %s MCA component \"%s\"", target_file->type, target_file->name); opal_output_verbose(40, 0, "mca: base: component_find: %s", target_file->filename); - param = mca_base_param_find("mca", NULL, "component_show_load_errors"); - mca_base_param_lookup_int(param, &show_errors); - vl = show_errors ? 0 : 40; + vl = mca_base_component_show_load_errors ? 0 : 40; /* Was this component already loaded (e.g., via dependency)? */ diff --git a/opal/mca/base/mca_base_component_repository.c b/opal/mca/base/mca_base_component_repository.c index 1367ff8e9a..d7f0737e81 100644 --- a/opal/mca/base/mca_base_component_repository.c +++ b/opal/mca/base/mca_base_component_repository.c @@ -375,6 +375,13 @@ static void ri_destructor(opal_object_t *obj) repository_item_t *ri = (repository_item_t *) obj; dependency_item_t *di; opal_list_item_t *item; + int group_id; + + group_id = mca_base_var_group_find (NULL, ri->ri_type, + ri->ri_component_struct->mca_component_name); + if (0 <= group_id) { + mca_base_var_group_deregister (group_id); + } /* Close the component (and potentially unload it from memory */ lt_dlclose(ri->ri_dlhandle); diff --git a/opal/mca/base/mca_base_components_close.c b/opal/mca/base/mca_base_components_close.c index 52d8704f2e..b243435f5b 100644 --- a/opal/mca/base/mca_base_components_close.c +++ b/opal/mca/base/mca_base_components_close.c @@ -25,6 +25,34 @@ #include "opal/mca/base/mca_base_component_repository.h" #include "opal/constants.h" +int mca_base_component_release (int output_id, const mca_base_component_t *component, + bool opened) +{ + int group_id; + + /* Close */ + if (opened && NULL != component->mca_close_component) { + component->mca_close_component(); + opal_output_verbose(10, output_id, + "mca: base: close: component %s closed", + component->mca_component_name); + } + + /* Unload */ + + /* Deregister this group before the component goes away */ + group_id = mca_base_var_group_find (NULL, component->mca_type_name, + component->mca_component_name); + mca_base_var_group_deregister (group_id); + + opal_output_verbose(10, output_id, + "mca: base: close: unloading component %s", + component->mca_component_name); + mca_base_component_repository_release((mca_base_component_t *) component); + + return OPAL_SUCCESS; +} + int mca_base_components_close(int output_id, opal_list_t *components_available, const mca_base_component_t *skip) @@ -45,26 +73,10 @@ int mca_base_components_close(int output_id, component = pcli->super.cli_component; if (component != skip) { - - /* Close */ - - - if (NULL != component->mca_close_component) { - component->mca_close_component(); - opal_output_verbose(10, output_id, - "mca: base: close: component %s closed", - component->mca_component_name); - } - - /* Unload */ - - opal_output_verbose(10, output_id, - "mca: base: close: unloading component %s", - component->mca_component_name); - mca_base_component_repository_release((mca_base_component_t *) component); - free(pcli); + mca_base_component_release (output_id, component, true); + free(pcli); } else { - skipped_pcli = pcli; + skipped_pcli = pcli; } } diff --git a/opal/mca/base/mca_base_components_open.c b/opal/mca/base/mca_base_components_open.c index 3c87a743d7..e40fdb1d14 100644 --- a/opal/mca/base/mca_base_components_open.c +++ b/opal/mca/base/mca_base_components_open.c @@ -459,49 +459,18 @@ static int open_components(const char *type_name, int output_id, /* If it didn't open, close it out and get rid of it */ if (!opened) { - char *name; - if (called_open) { - if (NULL != component->mca_close_component) { - component->mca_close_component(); - } - opal_output_verbose(10, output_id, - "mca: base: components_open: component %s closed", - component->mca_component_name); - called_open = false; - } - name = strdup(component->mca_component_name); - mca_base_component_repository_release(component); - opal_output_verbose(10, output_id, - "mca: base: components_open: component %s unloaded", - name); - free(name); + mca_base_component_release (output_id, component, called_open); + continue; } - - /* If it did open, register its "priority" MCA parameter (if - it doesn't already have one) and save it in the - opened_components list */ - - else { - if (0 > mca_base_param_find(type_name, - component->mca_component_name, - "priority")) { - char *tmp_name; - asprintf (&tmp_name, "%s_priority", component->mca_component_name); - if (NULL != tmp_name) { - (void) mca_base_param_reg_int_name (type_name, tmp_name, NULL, - false, false, 0, NULL); - free (tmp_name); - } - } + /* Not all components register a priority. Do not register one here. */ - cli = OBJ_NEW(mca_base_component_list_item_t); - if (NULL == cli) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - cli->cli_component = component; - opal_list_append(dest, (opal_list_item_t *) cli); + cli = OBJ_NEW(mca_base_component_list_item_t); + if (NULL == cli) { + return OPAL_ERR_OUT_OF_RESOURCE; } + cli->cli_component = component; + opal_list_append(dest, (opal_list_item_t *) cli); } /* All done */ diff --git a/opal/mca/base/mca_base_open.c b/opal/mca/base/mca_base_open.c index 2baa3af618..23dc96cd46 100644 --- a/opal/mca/base/mca_base_open.c +++ b/opal/mca/base/mca_base_open.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -40,10 +41,14 @@ /* * Public variables */ -int mca_base_param_component_path = -1; +char *mca_base_component_path = NULL; bool mca_base_opened = false; -char *mca_base_system_default_path=NULL; -char *mca_base_user_default_path=NULL; +char *mca_base_system_default_path = NULL; +char *mca_base_user_default_path = NULL; +bool mca_base_component_show_load_errors = true; +bool mca_base_component_disable_dlopen = false; + +static char *mca_base_verbose = NULL; /* * Private functions @@ -57,15 +62,16 @@ static void parse_verbose(char *e, opal_output_stream_t *lds); */ int mca_base_open(void) { - char *value; - opal_output_stream_t lds; - char hostname[64]; + char *value; + opal_output_stream_t lds; + char hostname[64]; + int var_id; - if (!mca_base_opened) { - mca_base_opened = true; - } else { - return OPAL_SUCCESS; - } + if (!mca_base_opened) { + mca_base_opened = true; + } else { + return OPAL_SUCCESS; + } /* define the system and user default paths */ #if OPAL_WANT_HOME_CONFIG_FILES @@ -82,41 +88,64 @@ int mca_base_open(void) asprintf(&value, "%s%c%s", mca_base_system_default_path, OPAL_ENV_SEP, mca_base_user_default_path); } - mca_base_param_component_path = - mca_base_param_reg_string_name("mca", "component_path", - "Path where to look for Open MPI and ORTE components", - false, false, value, NULL); - free(value); - - mca_base_param_reg_int_name("mca", "component_show_load_errors", - "Whether to show errors for components that failed to load or not", - false, false, 1, NULL); - mca_base_param_reg_int_name("mca", "component_disable_dlopen", - "Whether to attempt to disable opening dynamic components or not", - false, false, 0, NULL); - - /* What verbosity level do we want for the default 0 stream? */ - - mca_base_param_reg_string_name("mca", "verbose", - "Specifies where the default error output stream goes (this is separate from distinct help messages). Accepts a comma-delimited list of: stderr, stdout, syslog, syslogpri:, syslogid: (where str is the prefix string for all syslog notices), file[:filename] (if filename is not specified, a default filename is used), fileappend (if not specified, the file is opened for truncation), level[:N] (if specified, integer verbose level; otherwise, 0 is implied)", - false, false, "stderr", &value); - memset(&lds, 0, sizeof(lds)); - if (NULL != value) { - parse_verbose(value, &lds); + mca_base_component_path = value; + var_id = mca_base_var_register("opal", "mca", "base", "component_path", + "Path where to look for Open MPI and ORTE components", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_base_component_path); + (void) mca_base_var_register_synonym(var_id, "opal", "mca", NULL, "component_path", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); free(value); - } else { - set_defaults(&lds); - } - gethostname(hostname, 64); - asprintf(&lds.lds_prefix, "[%s:%05d] ", hostname, getpid()); - opal_output_reopen(0, &lds); - opal_output_verbose(5, 0, "mca: base: opening components"); - free(lds.lds_prefix); - /* Open up the component repository */ + mca_base_component_show_load_errors = true; + var_id = mca_base_var_register("opal", "mca", "base", "component_show_load_errors", + "Whether to show errors for components that failed to load or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_base_component_show_load_errors); + (void) mca_base_var_register_synonym(var_id, "opal", "mca", NULL, "component_show_load_errors", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); - return mca_base_component_repository_init(); + mca_base_component_disable_dlopen = false; + var_id = mca_base_var_register("opal", "mca", "base", "component_disable_dlopen", + "Whether to attempt to disable opening dynamic components or not", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_base_component_disable_dlopen); + (void) mca_base_var_register_synonym(var_id, "opal", "mca", NULL, "component_disable_dlopen", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + + /* What verbosity level do we want for the default 0 stream? */ + mca_base_verbose = "stderr"; + var_id = mca_base_var_register("opal", "mca", "base", "verbose", + "Specifies where the default error output stream goes (this is separate from distinct help messages). Accepts a comma-delimited list of: stderr, stdout, syslog, syslogpri:, syslogid: (where str is the prefix string for all syslog notices), file[:filename] (if filename is not specified, a default filename is used), fileappend (if not specified, the file is opened for truncation), level[:N] (if specified, integer verbose level; otherwise, 0 is implied)", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &mca_base_verbose); + (void) mca_base_var_register_synonym(var_id, "opal", "mca", NULL, "verbose", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + + memset(&lds, 0, sizeof(lds)); + if (NULL != mca_base_verbose) { + parse_verbose(mca_base_verbose, &lds); + } else { + set_defaults(&lds); + } + gethostname(hostname, 64); + asprintf(&lds.lds_prefix, "[%s:%05d] ", hostname, getpid()); + opal_output_reopen(0, &lds); + opal_output_verbose(5, 0, "mca: base: opening components"); + free(lds.lds_prefix); + + /* Open up the component repository */ + + return mca_base_component_repository_init(); } diff --git a/opal/mca/base/mca_base_param.c b/opal/mca/base/mca_base_param.c index 94c0ef033d..5730bb2030 100644 --- a/opal/mca/base/mca_base_param.c +++ b/opal/mca/base/mca_base_param.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana * University Research and Technology @@ -47,249 +48,147 @@ #include "opal/util/opal_environ.h" #include "opal/runtime/opal.h" -/* - * Local types - */ - -typedef struct { - /* Base class */ - opal_list_item_t super; - - /* String of the type name or NULL */ - char *si_type_name; - /* String of the component name */ - char *si_component_name; - /* String of the param name */ - char *si_param_name; - /* Full name of the synonym */ - char *si_full_name; - /* Name of the synonym's corresponding environment variable */ - char *si_env_var_name; - - /* Whether this synonym is a deprecated name or not */ - bool si_deprecated; - /* Whether we've shown a warning that this synonym has been - displayed or not */ - bool si_deprecated_warning_shown; -} syn_info_t; - - -/* - * Public variables - * - * This variable is public, but not advertised in mca_base_param.h. - * It's only public so that the file parser can see it. - */ -opal_list_t mca_base_param_file_values; +#include "opal/mca/base/mca_base_var.h" /* * local variables */ static opal_value_array_t mca_base_params; static const char *mca_prefix = "OMPI_MCA_"; -static char *home = NULL; -static char *cwd = NULL; static bool initialized = false; -static char * force_agg_path = NULL; /* * local functions */ -static int fixup_files(char **file_list, char * path, bool rel_path_search); -static int read_files(char *file_list); -static int param_register(const char *type_name, - const char *component_name, - const char *param_name, - const char *help_msg, - mca_base_param_type_t type, - bool internal, - bool read_only, - mca_base_param_storage_t *default_value, - mca_base_param_storage_t *file_value, - mca_base_param_storage_t *override_value, - mca_base_param_storage_t *current_value); -static int syn_register(int index_orig, const char *syn_type_name, - const char *syn_component_name, - const char *syn_param_name, bool deprecated); -static bool param_lookup(size_t index, mca_base_param_storage_t *storage, - mca_base_param_source_t *source, - char **source_file); -static bool param_set_override(size_t index, - mca_base_param_storage_t *storage, - mca_base_param_type_t type); -static bool lookup_override(mca_base_param_t *param, - mca_base_param_storage_t *storage); -static bool lookup_env(mca_base_param_t *param, - mca_base_param_storage_t *storage); -static bool lookup_file(mca_base_param_t *param, - mca_base_param_storage_t *storage, - char **source_file); -static bool lookup_default(mca_base_param_t *param, - mca_base_param_storage_t *storage); -static bool set(mca_base_param_type_t type, - mca_base_param_storage_t *dest, mca_base_param_storage_t *src); static void param_constructor(mca_base_param_t *p); static void param_destructor(mca_base_param_t *p); -static void fv_constructor(mca_base_param_file_value_t *p); -static void fv_destructor(mca_base_param_file_value_t *p); static void info_constructor(mca_base_param_info_t *p); static void info_destructor(mca_base_param_info_t *p); -static void syn_info_constructor(syn_info_t *si); -static void syn_info_destructor(syn_info_t *si); -static mca_base_param_type_t param_type_from_index (size_t index); /* * Make the class instance for mca_base_param_t */ OBJ_CLASS_INSTANCE(mca_base_param_t, opal_object_t, param_constructor, param_destructor); -OBJ_CLASS_INSTANCE(mca_base_param_file_value_t, opal_list_item_t, - fv_constructor, fv_destructor); OBJ_CLASS_INSTANCE(mca_base_param_info_t, opal_list_item_t, info_constructor, info_destructor); -OBJ_CLASS_INSTANCE(syn_info_t, opal_list_item_t, - syn_info_constructor, syn_info_destructor); /* * Set it up */ int mca_base_param_init(void) { - if (!initialized) { + int ret; - /* Init the value array for the param storage */ + if (!initialized) { + initialized = true; OBJ_CONSTRUCT(&mca_base_params, opal_value_array_t); - opal_value_array_init(&mca_base_params, sizeof(mca_base_param_t)); + opal_value_array_init (&mca_base_params, sizeof (mca_base_param_t)); - /* Init the file param value list */ - - OBJ_CONSTRUCT(&mca_base_param_file_values, opal_list_t); - - /* Set this before we register the parameter, below */ - - initialized = true; - - mca_base_param_recache_files(false); + ret = mca_base_var_init (); + if (OPAL_SUCCESS != ret) { + return ret; + } } return OPAL_SUCCESS; } +/* Leave file caching up to the variable system */ int mca_base_param_recache_files(bool rel_path_search) { - int id; - char *files, *new_files = NULL, *new_agg_files = NULL; - char * new_agg_path = NULL, *agg_default_path = NULL; - - (void)id; /* prevent "set but not used" compiler complaints */ - /* We may need this later */ - home = (char*)opal_home_directory(); - - if(NULL == cwd) { - cwd = (char *) malloc(sizeof(char) * MAXPATHLEN); - if( NULL == (cwd = getcwd(cwd, MAXPATHLEN) )) { - opal_output(0, "Error: Unable to get the current working directory\n"); - cwd = strdup("."); - } - } - -#if OPAL_WANT_HOME_CONFIG_FILES - asprintf(&files, - "%s"OPAL_PATH_SEP".openmpi"OPAL_PATH_SEP"mca-params.conf%c%s"OPAL_PATH_SEP"openmpi-mca-params.conf", - home, OPAL_ENV_SEP, opal_install_dirs.sysconfdir); -#else - asprintf(&files, - "%s"OPAL_PATH_SEP"openmpi-mca-params.conf", - opal_install_dirs.sysconfdir); -#endif - - /* Initialize a parameter that says where MCA param files can - be found */ - - id = mca_base_param_reg_string_name("mca", "param_files", - "Path for MCA configuration files containing default parameter values", - false, false, files, &new_files); - - /* Aggregate MCA parameter files - * A prefix search path to look up aggregate MCA parameter file - * requests that do not specify an absolute path - */ - id = mca_base_param_reg_string_name("mca", "base_param_file_prefix", - "Aggregate MCA parameter file sets", - false, false, NULL, &new_agg_files); - - asprintf(&agg_default_path, - "%s"OPAL_PATH_SEP"amca-param-sets%c%s", - opal_install_dirs.pkgdatadir, OPAL_ENV_SEP, cwd); - id = mca_base_param_reg_string_name("mca", "base_param_file_path", - "Aggregate MCA parameter Search path", - false, false, agg_default_path, &new_agg_path); - - id = mca_base_param_reg_string_name("mca", "base_param_file_path_force", - "Forced Aggregate MCA parameter Search path", - false, false, NULL, &force_agg_path); - - if( NULL != force_agg_path ) { - char *tmp_str = NULL; - if( NULL == new_agg_path ) { - new_agg_path = strdup(force_agg_path); - } - else { - tmp_str = strdup(new_agg_path); - free(new_agg_path); - asprintf(&new_agg_path, "%s%c%s", force_agg_path, OPAL_ENV_SEP, tmp_str); - free(tmp_str); - } - } - - if( NULL != new_agg_files ) { - char *tmp_str = NULL; - - /* - * Resolve all relative paths. - * the file list returned will contain only absolute paths - */ - if( OPAL_SUCCESS != fixup_files(&new_agg_files, new_agg_path, rel_path_search) ) { -#if 0 - /* JJH We need to die! */ - abort(); -#else - ; -#endif - } - else { - /* Prepend the files to the search list */ - asprintf(&tmp_str, "%s%c%s", new_agg_files, OPAL_ENV_SEP, new_files); - free(new_files); - new_files = strdup(tmp_str); - free(tmp_str); - } - } - - read_files(new_files); - free(files); - free(new_files); - if( NULL != new_agg_files ) { - free(new_agg_files); - new_agg_files = NULL; - } - if( NULL != agg_default_path ) { - free(agg_default_path); - agg_default_path = NULL; - } - if( NULL != new_agg_path ) { - free(new_agg_path); - new_agg_path = NULL; - } - return OPAL_SUCCESS; } - /* - * Register an integer MCA parameter + * Register an MCA parameter */ +static int register_param (const char *type_name, const char *component_name, + const char *param_name, const char *help_msg, + bool internal, bool read_only, mca_base_param_type_t type, + void *default_value, void *current_value) +{ + mca_base_var_flag_t flags = 0; + mca_base_var_type_t var_type; + mca_base_param_t param; + int ret, var_index; + + if (!initialized) { + mca_base_param_init (); + } + + OBJ_CONSTRUCT(¶m, mca_base_param_t); + + if (internal) { + flags |= MCA_BASE_VAR_FLAG_INTERNAL; + } + if (read_only) { + flags |= MCA_BASE_VAR_FLAG_DEFAULT_ONLY; + } + + /* Create a backing store for this parameter (needs to be malloc since the param + will be memcpy'd into the parameter list) */ + param.param_value = calloc (1, sizeof (*param.param_value)); + if (NULL == param.param_value) { + OBJ_DESTRUCT(¶m); + return OPAL_ERR_OUT_OF_RESOURCE; + } + + switch (type) { + case MCA_BASE_PARAM_TYPE_INT: + var_type = MCA_BASE_VAR_TYPE_INT; + param.param_value->intval = ((int *)default_value)[0]; + break; + case MCA_BASE_PARAM_TYPE_STRING: + var_type = MCA_BASE_VAR_TYPE_STRING; + if (default_value) { + param.param_value->stringval = (char *) default_value; + } + break; + case MCA_BASE_PARAM_TYPE_MAX: + OBJ_DESTRUCT(¶m); + return OPAL_ERROR; + } + + var_index = mca_base_var_register (NULL, type_name, component_name, + param_name, help_msg, var_type, NULL, + 0, flags, OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + param.param_value); + + param.var_index = var_index; + + if (0 > var_index) { + return OPAL_ERROR; + } + + ret = opal_value_array_append_item (&mca_base_params, ¶m); + if (OPAL_SUCCESS != ret) { + return ret; + } + + if (current_value) { + switch (type) { + case MCA_BASE_PARAM_TYPE_INT: + ((int *) current_value)[0] = param.param_value->intval; + break; + case MCA_BASE_PARAM_TYPE_STRING: + + if (NULL != param.param_value->stringval) { + ((char **) current_value)[0] = strdup (param.param_value->stringval); + } else { + ((char **) current_value)[0] = NULL; + } + case MCA_BASE_PARAM_TYPE_MAX: + /* Impossible */ + break; + } + } + + return var_index; +} + int mca_base_param_reg_int(const mca_base_component_t *component, const char *param_name, const char *help_msg, @@ -298,23 +197,12 @@ int mca_base_param_reg_int(const mca_base_component_t *component, int default_value, int *current_value) { - int ret; - mca_base_param_storage_t storage; - mca_base_param_storage_t lookup; - - storage.intval = default_value; - ret = param_register(component->mca_type_name, - component->mca_component_name, - param_name, help_msg, - MCA_BASE_PARAM_TYPE_INT, internal, read_only, - &storage, NULL, NULL, &lookup); - if (ret >= 0 && NULL != current_value) { - *current_value = lookup.intval; - } - return ret; + return register_param (component->mca_type_name, component->mca_component_name, + param_name, help_msg, internal, read_only, + MCA_BASE_PARAM_TYPE_INT, (void *) &default_value, + (void *) current_value); } - /* * Register an integer MCA parameter that is not associated with a * component @@ -327,24 +215,11 @@ int mca_base_param_reg_int_name(const char *type, int default_value, int *current_value) { - int ret; - mca_base_param_storage_t storage; - mca_base_param_storage_t lookup; - - storage.intval = default_value; - ret = param_register(type, NULL, param_name, help_msg, - MCA_BASE_PARAM_TYPE_INT, internal, read_only, - &storage, NULL, NULL, &lookup); - if (ret >= 0 && NULL != current_value) { - *current_value = lookup.intval; - } - return ret; + return register_param (type, NULL, param_name, help_msg, internal, read_only, + MCA_BASE_PARAM_TYPE_INT, (void *) &default_value, + (void *) current_value); } - -/* - * Register a string MCA parameter. - */ int mca_base_param_reg_string(const mca_base_component_t *component, const char *param_name, const char *help_msg, @@ -353,28 +228,12 @@ int mca_base_param_reg_string(const mca_base_component_t *component, const char *default_value, char **current_value) { - int ret; - mca_base_param_storage_t storage; - mca_base_param_storage_t lookup; - - if (NULL != default_value) { - storage.stringval = (char *) default_value; - } else { - storage.stringval = NULL; - } - ret = param_register(component->mca_type_name, - component->mca_component_name, - param_name, help_msg, - MCA_BASE_PARAM_TYPE_STRING, internal, read_only, - &storage, NULL, NULL, - (NULL != current_value) ? &lookup : NULL); - if (ret >= 0 && NULL != current_value) { - *current_value = lookup.stringval; - } - return ret; + return register_param (component->mca_type_name, component->mca_component_name, + param_name, help_msg, internal, read_only, + MCA_BASE_PARAM_TYPE_STRING, (void *) default_value, + (void *) current_value); } - /* * Register a string MCA parameter that is not associated with a * component @@ -387,37 +246,29 @@ int mca_base_param_reg_string_name(const char *type, const char *default_value, char **current_value) { - int ret; - mca_base_param_storage_t storage; - mca_base_param_storage_t lookup; - - if (NULL != default_value) { - storage.stringval = (char *) default_value; - } else { - storage.stringval = NULL; - } - ret = param_register(type, NULL, param_name, help_msg, - MCA_BASE_PARAM_TYPE_STRING, internal, read_only, - &storage, NULL, NULL, - (NULL != current_value) ? &lookup : NULL); - if (ret >= 0 && NULL != current_value) { - *current_value = lookup.stringval; - } - return ret; + return register_param (type, NULL, param_name, help_msg, internal, read_only, + MCA_BASE_PARAM_TYPE_STRING, (void *) default_value, + (void *) current_value); } - /* * Register a synonym name for an existing MCA parameter */ +static int reg_syn (int index_orig, const char *type_name, const char *component_name, + const char *syn_param_name, bool deprecated) +{ + return mca_base_var_register_synonym (index_orig, NULL, type_name, + component_name, syn_param_name, + deprecated ? MCA_BASE_VAR_SYN_FLAG_DEPRECATED : 0); +} + int mca_base_param_reg_syn(int index_orig, const mca_base_component_t *syn_component, const char *syn_param_name, bool deprecated) { - return syn_register(index_orig, - syn_component->mca_type_name, - syn_component->mca_component_name, - syn_param_name, deprecated); + return reg_syn (index_orig, syn_component->mca_type_name, + syn_component->mca_component_name, syn_param_name, + deprecated); } /* @@ -427,8 +278,8 @@ int mca_base_param_reg_syn_name(int index_orig, const char *syn_type_name, const char *syn_param_name, bool deprecated) { - return syn_register(index_orig, syn_type_name, NULL, - syn_param_name, deprecated); + return reg_syn (index_orig, syn_type_name, NULL, syn_param_name, + deprecated); } /* @@ -436,13 +287,31 @@ int mca_base_param_reg_syn_name(int index_orig, */ int mca_base_param_lookup_int(int index, int *value) { - mca_base_param_storage_t storage; - - if (param_lookup(index, &storage, NULL, NULL)) { - *value = storage.intval; + const mca_base_var_t *var; + const mca_base_var_storage_t *tmp; + int ret; + + ret = mca_base_var_get (index, &var); + if (OPAL_SUCCESS != ret) { + return ret; + } + + ret = mca_base_var_get_value (index, &tmp, NULL, NULL); + if (OPAL_SUCCESS != ret) { + return ret; + } + + if (MCA_BASE_VAR_TYPE_BOOL == var->mbv_type) { + *value = tmp->boolval; + } else if (MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG == var->mbv_type) { + *value = (int) tmp->ullval; + } else if (MCA_BASE_VAR_TYPE_SIZE_T == var->mbv_type) { + *value = (int) tmp->sizetval; + } else { + *value = tmp->intval; + } + return OPAL_SUCCESS; - } - return OPAL_ERROR; } @@ -451,12 +320,28 @@ int mca_base_param_lookup_int(int index, int *value) */ int mca_base_param_set_int(int index, int value) { - mca_base_param_storage_t storage; + const mca_base_var_t *var; + mca_base_var_storage_t tmp; - mca_base_param_unset(index); - storage.intval = value; - param_set_override(index, &storage, MCA_BASE_PARAM_TYPE_INT); - return OPAL_SUCCESS; + int ret; + + ret = mca_base_var_get (index, &var); + if (OPAL_SUCCESS != ret) { + return ret; + } + + if (MCA_BASE_VAR_TYPE_BOOL == var->mbv_type) { + tmp.boolval = !!value; + } else if (MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG == var->mbv_type) { + tmp.ullval = (unsigned long long) value; + } else if (MCA_BASE_VAR_TYPE_SIZE_T == var->mbv_type) { + tmp.sizetval = (size_t) value; + } else { + tmp.intval = value; + } + + return mca_base_var_set_value (index, &tmp, sizeof (tmp), + MCA_BASE_VAR_SOURCE_SET, NULL); } /* @@ -464,23 +349,7 @@ int mca_base_param_set_int(int index, int value) */ int mca_base_param_deregister(int index) { - mca_base_param_t *array; - size_t size; - - /* Lookup the index and see if the index and parameter are valid */ - size = opal_value_array_get_size(&mca_base_params); - array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t); - if (index < 0 || ((size_t) index) > size || - MCA_BASE_PARAM_TYPE_MAX >= array[index].mbp_type) { - return OPAL_ERROR; - } - - /* Do not remove this item from the array otherwise we will change - all the indices of parameters with a larger index. The destructor - will mark this parameter as invalid. */ - OBJ_DESTRUCT(&array[index]); - - return OPAL_SUCCESS; + return mca_base_var_deregister (index); } /* @@ -488,13 +357,25 @@ int mca_base_param_deregister(int index) */ int mca_base_param_lookup_string(int index, char **value) { - mca_base_param_storage_t storage; - - if (param_lookup(index, &storage, NULL, NULL)) { - *value = storage.stringval; + const char **tmp; + int ret; + + *value = NULL; + + ret = mca_base_var_get_value (index, &tmp, NULL, NULL); + if (OPAL_SUCCESS != ret) { + return ret; + } + + /* MCA param users expect us to return a copy of the string */ + if (tmp && tmp[0]) { + *value = strdup (tmp[0]); + if (NULL == *value) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + } + return OPAL_SUCCESS; - } - return OPAL_ERROR; } @@ -503,32 +384,46 @@ int mca_base_param_lookup_string(int index, char **value) */ int mca_base_param_set_string(int index, char *value) { - mca_base_param_storage_t storage; - - mca_base_param_unset(index); - storage.stringval = value; - param_set_override(index, &storage, MCA_BASE_PARAM_TYPE_STRING); - return OPAL_SUCCESS; + return mca_base_var_set_value (index, value, value ? strlen (value) : 0, + MCA_BASE_VAR_SOURCE_SET, NULL); } /* * Lookup the source of an MCA param's value */ -int mca_base_param_lookup_source(int index, mca_base_param_source_t *source, char **source_file) +int mca_base_param_lookup_source(int index, mca_base_param_source_t *source, const char **source_file) { - mca_base_param_storage_t storage; - int rc; + mca_base_var_source_t var_source; + int ret; - storage.stringval = NULL; - - rc = param_lookup(index, &storage, source, source_file); - if (MCA_BASE_PARAM_TYPE_STRING == param_type_from_index (index) && - NULL != storage.stringval) { - free (storage.stringval); + ret = mca_base_var_get_value (index, NULL, &var_source, source_file); + if (OPAL_SUCCESS != ret) { + return ret; } - return rc ? OPAL_SUCCESS : OPAL_ERROR; + if (NULL != source) { + switch (var_source) { + case MCA_BASE_VAR_SOURCE_ENV: + case MCA_BASE_VAR_SOURCE_COMMAND_LINE: + *source = MCA_BASE_PARAM_SOURCE_ENV; + break; + case MCA_BASE_VAR_SOURCE_FILE: + case MCA_BASE_VAR_SOURCE_OVERRIDE: + *source = MCA_BASE_PARAM_SOURCE_FILE; + break; + case MCA_BASE_VAR_SOURCE_SET: + *source = MCA_BASE_PARAM_SOURCE_OVERRIDE; + break; + case MCA_BASE_VAR_SOURCE_DEFAULT: + *source = MCA_BASE_PARAM_SOURCE_DEFAULT; + break; + case MCA_BASE_VAR_SOURCE_MAX: + return OPAL_ERROR; + } + } + + return OPAL_SUCCESS; } /* @@ -536,43 +431,32 @@ int mca_base_param_lookup_source(int index, mca_base_param_source_t *source, cha */ int mca_base_param_unset(int index) { - size_t len; - mca_base_param_t *array; - - if (!initialized) { - return OPAL_ERROR; - } - - len = opal_value_array_get_size(&mca_base_params); - array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t); - if (index < 0 || ((size_t) index) > len || - MCA_BASE_PARAM_TYPE_MAX <= array[index].mbp_type) { - return OPAL_ERROR; - } - - /* We have a valid entry so save the internal flag */ - if (array[index].mbp_override_value_set) { - if (MCA_BASE_PARAM_TYPE_STRING == array[index].mbp_type && - NULL != array[index].mbp_override_value.stringval) { - free(array[index].mbp_override_value.stringval); - array[index].mbp_override_value.stringval = NULL; - } - } - array[index].mbp_override_value_set = false; - - /* All done */ - - return OPAL_SUCCESS; + /* It is possible to support the semantics of unset by: + * 1) When registering the parameter, save the default. + * 2) On calling unset, lookup the default (can only be done for + * parameters that use the old system). + * 3) Deregister the parameter + * 4) Set the default + * 5) Register the parameter. + * + * The mca_base_var system will ensure the parameter keeps the + * same index and will do the lookup (env, file, default) again. + */ + return OPAL_ERR_NOT_SUPPORTED; } char *mca_base_param_env_var(const char *param_name) { - char *name; + char *var_name; + int ret; - asprintf(&name, "%s%s", mca_prefix, param_name); + ret = mca_base_var_env_name (param_name, &var_name); + if (OPAL_SUCCESS != ret) { + return NULL; + } - return name; + return var_name; } @@ -582,147 +466,124 @@ char *mca_base_param_env_var(const char *param_name) int mca_base_param_find(const char *type_name, const char *component_name, const char *param_name) { - size_t i, size; - mca_base_param_t *array; - - /* Check for bozo cases */ - - if (!initialized) { - return OPAL_ERROR; - } - - /* Loop through looking for a parameter of a given - type/component/param */ - - size = opal_value_array_get_size(&mca_base_params); - array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t); - for (i = 0; i < size; ++i) { - if (((NULL == type_name && NULL == array[i].mbp_type_name) || - (NULL != type_name && NULL != array[i].mbp_type_name && - (0 == strcmp(type_name, array[i].mbp_type_name)))) && - ((NULL == component_name && NULL == array[i].mbp_component_name) || - (NULL != component_name && NULL != array[i].mbp_component_name && - 0 == strcmp(component_name, array[i].mbp_component_name))) && - ((NULL == param_name && NULL == array[i].mbp_param_name) || - (NULL != param_name && NULL != array[i].mbp_param_name && - 0 == strcmp(param_name, array[i].mbp_param_name)))) { - return (int)i; - } - } - - /* Didn't find it */ - - return OPAL_ERROR; + return mca_base_var_find (NULL, type_name, component_name, param_name); } - -int mca_base_param_set_internal(int index, bool internal) +int mca_base_param_set_internal (int index, bool internal) { - size_t len; - mca_base_param_t *array; - - /* Check for bozo cases */ - - if (!initialized) { - return OPAL_ERROR; - } - - len = opal_value_array_get_size(&mca_base_params); - if (((size_t) index) > len) { - return OPAL_ERROR; - } - - /* We have a valid entry (remember that we never delete MCA - parameters, so if the index is >0 and array[i].mbp_type) { + const mca_base_var_t *var, *syn; + + ret = mca_base_var_get (i, &var); + if (OPAL_SUCCESS != ret) { + continue; + } + + /* Dump this variable only if it is not a synonym and either it + is not internal or internal variables were requested */ + if ((internal || !(var->mbv_flags & MCA_BASE_VAR_FLAG_INTERNAL)) && + 0 > var->mbv_synonym_for) { + const mca_base_var_group_t *group; + + ret = mca_base_var_group_get (var->mbv_group_index, &group); + if (OPAL_SUCCESS != ret) { + continue; + } + p = OBJ_NEW(mca_base_param_info_t); if (NULL == p) { return OPAL_ERR_OUT_OF_RESOURCE; } - p->mbpp_index = (int)i; - p->mbpp_type_name = array[i].mbp_type_name; - p->mbpp_component_name = array[i].mbp_component_name; - p->mbpp_param_name = array[i].mbp_param_name; - p->mbpp_full_name = array[i].mbp_full_name; - p->mbpp_deprecated = array[i].mbp_deprecated; - p->mbpp_internal = array[i].mbp_internal; - p->mbpp_read_only = array[i].mbp_read_only; - p->mbpp_type = array[i].mbp_type; - p->mbpp_help_msg = array[i].mbp_help_msg; + + p->mbpp_index = i; + p->mbpp_type_name = group->group_framework; + p->mbpp_component_name = group->group_component; + p->mbpp_param_name = var->mbv_variable_name; + p->mbpp_full_name = var->mbv_full_name; + p->mbpp_deprecated = !!(var->mbv_flags & MCA_BASE_VAR_FLAG_DEPRECATED); + p->mbpp_internal = !!(var->mbv_flags & MCA_BASE_VAR_FLAG_INTERNAL); + p->mbpp_read_only = !!(var->mbv_flags & MCA_BASE_VAR_FLAG_DEFAULT_ONLY); + if (var->mbv_type == MCA_BASE_VAR_TYPE_INT || + var->mbv_type == MCA_BASE_VAR_TYPE_UNSIGNED_INT || + var->mbv_type == MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG || + var->mbv_type == MCA_BASE_VAR_TYPE_SIZE_T || + var->mbv_type == MCA_BASE_VAR_TYPE_BOOL) { + p->mbpp_type = MCA_BASE_PARAM_TYPE_INT; + } else { + p->mbpp_type = MCA_BASE_PARAM_TYPE_STRING; + } + p->mbpp_help_msg = var->mbv_description; /* Save this entry to the list */ - opal_list_append(*info, (opal_list_item_t*) p); + opal_list_append(*info, &p->super); - /* If this param has synonyms, add them too */ - if (NULL != array[i].mbp_synonyms && - !opal_list_is_empty(array[i].mbp_synonyms)) { - p->mbpp_synonyms_len = - (int) opal_list_get_size(array[i].mbp_synonyms); - p->mbpp_synonyms = malloc(sizeof(mca_base_param_info_t*) * - p->mbpp_synonyms_len); + p->mbpp_synonyms_len = opal_value_array_get_size ((opal_value_array_t *) &var->mbv_synonyms); + + if (p->mbpp_synonyms_len) { + p->mbpp_synonyms = calloc(p->mbpp_synonyms_len, + sizeof (mca_base_param_info_t *)); if (NULL == p->mbpp_synonyms) { - p->mbpp_synonyms_len = 0; return OPAL_ERR_OUT_OF_RESOURCE; } - - for (j = 0, item = opal_list_get_first(array[i].mbp_synonyms); - opal_list_get_end(array[i].mbp_synonyms) != item; - ++j, item = opal_list_get_next(item)) { - si = (syn_info_t*) item; + + synonyms = OPAL_VALUE_ARRAY_GET_BASE(&var->mbv_synonyms, int); + + for (j = 0 ; j < (size_t) p->mbpp_synonyms_len ; ++j) { + ret = mca_base_var_get (synonyms[j], &syn); + if (OPAL_SUCCESS != ret) { + p->mbpp_synonyms[j] = NULL; + continue; + } + + ret = mca_base_var_group_get (syn->mbv_group_index, &group); + if (OPAL_SUCCESS != ret) { + continue; + } + q = OBJ_NEW(mca_base_param_info_t); if (NULL == q) { + p->mbpp_synonyms_len = j; return OPAL_ERR_OUT_OF_RESOURCE; } - q->mbpp_index = (int)i; - q->mbpp_type_name = si->si_type_name; - q->mbpp_component_name = si->si_component_name; - q->mbpp_param_name = si->si_param_name; - q->mbpp_full_name = si->si_full_name; - q->mbpp_deprecated = si->si_deprecated || - array[i].mbp_deprecated; - q->mbpp_internal = array[i].mbp_internal; - q->mbpp_read_only = array[i].mbp_read_only; - q->mbpp_type = array[i].mbp_type; - q->mbpp_help_msg = array[i].mbp_help_msg; + + q->mbpp_index = (int) i; + q->mbpp_type_name = group->group_framework; + q->mbpp_component_name = group->group_component; + q->mbpp_param_name = syn->mbv_variable_name; + q->mbpp_full_name = syn->mbv_full_name; + q->mbpp_deprecated = !!(syn->mbv_flags & MCA_BASE_VAR_FLAG_DEPRECATED); + q->mbpp_internal = !!(syn->mbv_flags & MCA_BASE_VAR_FLAG_INTERNAL); + q->mbpp_read_only = !!(syn->mbv_flags & MCA_BASE_VAR_FLAG_DEFAULT_ONLY); + q->mbpp_type = syn->mbv_type; + q->mbpp_help_msg = syn->mbv_description; /* Let this one point to the original */ q->mbpp_synonym_parent = p; @@ -731,7 +592,7 @@ int mca_base_param_dump(opal_list_t **info, bool internal) p->mbpp_synonyms[j] = q; /* Save this entry to the list */ - opal_list_append(*info, (opal_list_item_t*) q); + opal_list_append(*info, &q->super); } } } @@ -748,64 +609,7 @@ int mca_base_param_dump(opal_list_t **info, bool internal) */ int mca_base_param_build_env(char ***env, int *num_env, bool internal) { - size_t i, len; - mca_base_param_t *array; - char *str; - mca_base_param_storage_t storage; - - /* Check for bozo cases */ - - if (!initialized) { - return OPAL_ERROR; - } - - /* Iterate through all the registered parameters */ - - len = opal_value_array_get_size(&mca_base_params); - array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t); - for (i = 0; i < len; ++i) { - /* Don't output read-only values */ - if (array[i].mbp_read_only) { - continue; - } - - if (array[i].mbp_internal == internal || internal) { - if (param_lookup(i, &storage, NULL, NULL)) { - if (MCA_BASE_PARAM_TYPE_INT == array[i].mbp_type) { - asprintf(&str, "%s=%d", array[i].mbp_env_var_name, - storage.intval); - opal_argv_append(num_env, env, str); - free(str); - } else if (MCA_BASE_PARAM_TYPE_STRING == array[i].mbp_type) { - if (NULL != storage.stringval) { - asprintf(&str, "%s=%s", array[i].mbp_env_var_name, - storage.stringval); - free(storage.stringval); - opal_argv_append(num_env, env, str); - free(str); - } - } else { - goto cleanup; - } - } else { - goto cleanup; - } - } - } - - /* All done */ - - return OPAL_SUCCESS; - - /* Error condition */ - - cleanup: - if (*num_env > 0) { - opal_argv_free(*env); - *num_env = 0; - *env = NULL; - } - return OPAL_ERR_NOT_FOUND; + return mca_base_var_build_env (env, num_env, internal); } @@ -817,10 +621,10 @@ int mca_base_param_dump_release(opal_list_t *info) { opal_list_item_t *item; - for (item = opal_list_remove_first(info); NULL != item; - item = opal_list_remove_first(info)) { + while (NULL != (item = opal_list_remove_first(info))) { OBJ_RELEASE(item); } + OBJ_RELEASE(info); return OPAL_SUCCESS; @@ -833,37 +637,23 @@ int mca_base_param_dump_release(opal_list_t *info) */ int mca_base_param_finalize(void) { - opal_list_item_t *item; mca_base_param_t *array; + size_t size, i; + int ret; if (initialized) { - int size, i; + ret = mca_base_var_finalize (); + if (OPAL_SUCCESS != ret) { + return ret; + } size = opal_value_array_get_size(&mca_base_params); array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t); for (i = 0 ; i < size ; ++i) { - if (MCA_BASE_PARAM_TYPE_MAX > array[i].mbp_type) { - OBJ_DESTRUCT(&array[i]); - } + OBJ_DESTRUCT(&array[i]); } OBJ_DESTRUCT(&mca_base_params); - while (NULL != - (item = opal_list_remove_first(&mca_base_param_file_values))) { - OBJ_RELEASE(item); - } - OBJ_DESTRUCT(&mca_base_param_file_values); - - if( NULL != cwd ) { - free(cwd); - cwd = NULL; - } - - if( NULL != force_agg_path ) { - free(force_agg_path); - force_agg_path = NULL; - } - initialized = false; } @@ -872,961 +662,12 @@ int mca_base_param_finalize(void) return OPAL_SUCCESS; } - -/*************************************************************************/ -static int fixup_files(char **file_list, char * path, bool rel_path_search) { - int exit_status = OPAL_SUCCESS; - char **files = NULL; - char **search_path = NULL; - char * tmp_file = NULL; - char **argv = NULL; - int mode = R_OK; /* The file exists, and we can read it */ - int count, i, argc = 0; - - search_path = opal_argv_split(path, OPAL_ENV_SEP); - files = opal_argv_split(*file_list, OPAL_ENV_SEP); - count = opal_argv_count(files); - - /* Read in reverse order, so we can preserve the original ordering */ - for (i = 0 ; i < count; ++i) { - /* Absolute paths preserved */ - if ( opal_path_is_absolute(files[i]) ) { - if( NULL == opal_path_access(files[i], NULL, mode) ) { - opal_show_help("help-mca-param.txt", "missing-param-file", - true, getpid(), files[i], path); - exit_status = OPAL_ERROR; - goto cleanup; - } - else { - opal_argv_append(&argc, &argv, files[i]); - } - } - /* Resolve all relative paths: - * - If filename contains a "/" (e.g., "./foo" or "foo/bar") - * - look for it relative to cwd - * - if exists, use it - * - ow warn/error - */ - else if (!rel_path_search && NULL != strchr(files[i], OPAL_PATH_SEP[0]) ) { - if( NULL != force_agg_path ) { - tmp_file = opal_path_access(files[i], force_agg_path, mode); - } - else { - tmp_file = opal_path_access(files[i], cwd, mode); - } - - if( NULL == tmp_file ) { - opal_show_help("help-mca-param.txt", "missing-param-file", - true, getpid(), files[i], cwd); - exit_status = OPAL_ERROR; - goto cleanup; - } - else { - opal_argv_append(&argc, &argv, tmp_file); - } - } - /* Resolve all relative paths: - * - Use path resolution - * - if found and readable, use it - * - otherwise, warn/error - */ - else { - if( NULL != (tmp_file = opal_path_find(files[i], search_path, mode, NULL)) ) { - opal_argv_append(&argc, &argv, tmp_file); - free(tmp_file); - tmp_file = NULL; - } - else { - opal_show_help("help-mca-param.txt", "missing-param-file", - true, getpid(), files[i], path); - exit_status = OPAL_ERROR; - goto cleanup; - } - } - } - - free(*file_list); - *file_list = opal_argv_join(argv, OPAL_ENV_SEP); - - cleanup: - if( NULL != files ) { - opal_argv_free(files); - files = NULL; - } - if( NULL != argv ) { - opal_argv_free(argv); - argv = NULL; - } - if( NULL != search_path ) { - opal_argv_free(search_path); - search_path = NULL; - } - if( NULL != tmp_file ) { - free(tmp_file); - tmp_file = NULL; - } - - return exit_status; -} - -static int read_files(char *file_list) -{ - int i, count; - char **files; - - /* Iterate through all the files passed in -- read them in reverse - order so that we preserve unix/shell path-like semantics (i.e., - the entries farthest to the left get precedence) */ - - files = opal_argv_split(file_list, OPAL_ENV_SEP); - count = opal_argv_count(files); - - for (i = count - 1; i >= 0; --i) { - mca_base_parse_paramfile(files[i]); - } - opal_argv_free(files); - - return OPAL_SUCCESS; -} - -/******************************************************************************/ - - -static int param_register(const char *type_name, - const char *component_name, - const char *param_name, - const char *help_msg, - mca_base_param_type_t type, - bool internal, - bool read_only, - mca_base_param_storage_t *default_value, - mca_base_param_storage_t *file_value, - mca_base_param_storage_t *override_value, - mca_base_param_storage_t *current_value) -{ - int ret; - size_t i, len; - mca_base_param_t param, *array; - - /* There are data holes in the param struct */ - OPAL_DEBUG_ZERO(param); - - /* Initialize the array if it has never been initialized */ - - if (!initialized) { - mca_base_param_init(); - } - - /* Create a parameter entry */ - - OBJ_CONSTRUCT(¶m, mca_base_param_t); - param.mbp_type = type; - param.mbp_internal = internal; - param.mbp_read_only = read_only; - if (NULL != help_msg) { - param.mbp_help_msg = strdup(help_msg); - } - - if (NULL != type_name) { - param.mbp_type_name = strdup(type_name); - if (NULL == param.mbp_type_name) { - OBJ_DESTRUCT(¶m); - return OPAL_ERR_OUT_OF_RESOURCE; - } - } - if (NULL != component_name) { - param.mbp_component_name = strdup(component_name); - if (NULL == param.mbp_component_name) { - OBJ_DESTRUCT(¶m); - return OPAL_ERR_OUT_OF_RESOURCE; - } - } - param.mbp_param_name = NULL; - if (NULL != param_name) { - param.mbp_param_name = strdup(param_name); - if (NULL == param.mbp_param_name) { - OBJ_DESTRUCT(¶m); - return OPAL_ERR_OUT_OF_RESOURCE; - } - } - - /* Build up the full name */ - len = 16; - if (NULL != type_name) { - len += strlen(type_name); - } - if (NULL != param.mbp_component_name) { - len += strlen(param.mbp_component_name); - } - if (NULL != param.mbp_param_name) { - len += strlen(param.mbp_param_name); - } - - param.mbp_full_name = (char*)malloc(len); - if (NULL == param.mbp_full_name) { - OBJ_DESTRUCT(¶m); - return OPAL_ERROR; - } - - /* Copy the name over in parts */ - - param.mbp_full_name[0] = '\0'; - if (NULL != type_name) { - strncat(param.mbp_full_name, type_name, len); - } - if (NULL != component_name) { - if ('\0' != param.mbp_full_name[0]) { - strcat(param.mbp_full_name, "_"); - } - strcat(param.mbp_full_name, component_name); - } - if (NULL != param_name) { - if ('\0' != param.mbp_full_name[0]) { - strcat(param.mbp_full_name, "_"); - } - strcat(param.mbp_full_name, param_name); - } - - /* Create the environment name */ - - len = strlen(param.mbp_full_name) + strlen(mca_prefix) + 16; - param.mbp_env_var_name = (char*)malloc(len); - if (NULL == param.mbp_env_var_name) { - OBJ_DESTRUCT(¶m); - return OPAL_ERROR; - } - snprintf(param.mbp_env_var_name, len, "%s%s", mca_prefix, - param.mbp_full_name); - - /* Figure out the default value; zero it out if a default is not - provided */ - - if (NULL != default_value) { - if (MCA_BASE_PARAM_TYPE_STRING == param.mbp_type && - NULL != default_value->stringval) { - param.mbp_default_value.stringval = strdup(default_value->stringval); - } else { - param.mbp_default_value = *default_value; - } - } else { - memset(¶m.mbp_default_value, 0, sizeof(param.mbp_default_value)); - } - - /* Figure out the file value; zero it out if a file is not - provided */ - - if (NULL != file_value) { - if (MCA_BASE_PARAM_TYPE_STRING == param.mbp_type && - NULL != file_value->stringval) { - param.mbp_file_value.stringval = strdup(file_value->stringval); - } else { - param.mbp_file_value = *file_value; - } - param.mbp_file_value_set = true; - } else { - memset(¶m.mbp_file_value, 0, sizeof(param.mbp_file_value)); - param.mbp_file_value_set = false; - } - - /* Figure out the override value; zero it out if a override is not - provided */ - - if (NULL != override_value) { - if (MCA_BASE_PARAM_TYPE_STRING == param.mbp_type && - NULL != override_value->stringval) { - param.mbp_override_value.stringval = strdup(override_value->stringval); - } else { - param.mbp_override_value = *override_value; - } - param.mbp_override_value_set = true; - } else { - memset(¶m.mbp_override_value, 0, sizeof(param.mbp_override_value)); - param.mbp_override_value_set = false; - } - - /* See if this entry is already in the array */ - - len = opal_value_array_get_size(&mca_base_params); - array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t); - for (i = 0; i < len; ++i) { - if (0 == strcmp(param.mbp_full_name, array[i].mbp_full_name)) { - - /* We found an entry with the same param name. Check to - ensure that we're not changing types */ - /* Easy case: both are INT */ - - if (MCA_BASE_PARAM_TYPE_INT == array[i].mbp_type && - MCA_BASE_PARAM_TYPE_INT == param.mbp_type) { - if (NULL != default_value) { - array[i].mbp_default_value.intval = - param.mbp_default_value.intval; - } - if (NULL != file_value) { - array[i].mbp_file_value.intval = - param.mbp_file_value.intval; - array[i].mbp_file_value_set = true; - } - if (NULL != override_value) { - array[i].mbp_override_value.intval = - param.mbp_override_value.intval; - array[i].mbp_override_value_set = true; - } - } - - /* Both are STRING */ - - else if (MCA_BASE_PARAM_TYPE_STRING == array[i].mbp_type && - MCA_BASE_PARAM_TYPE_STRING == param.mbp_type) { - if (NULL != default_value) { - if (NULL != array[i].mbp_default_value.stringval) { - free(array[i].mbp_default_value.stringval); - array[i].mbp_default_value.stringval = NULL; - } - if (NULL != param.mbp_default_value.stringval) { - array[i].mbp_default_value.stringval = - strdup(param.mbp_default_value.stringval); - } - } - - if (NULL != file_value) { - if (NULL != array[i].mbp_file_value.stringval) { - free(array[i].mbp_file_value.stringval); - array[i].mbp_file_value.stringval = NULL; - } - if (NULL != param.mbp_file_value.stringval) { - array[i].mbp_file_value.stringval = - strdup(param.mbp_file_value.stringval); - } - array[i].mbp_file_value_set = true; - } - - if (NULL != override_value) { - if (NULL != array[i].mbp_override_value.stringval) { - free(array[i].mbp_override_value.stringval); - array[i].mbp_override_value.stringval = NULL; - } - if (NULL != param.mbp_override_value.stringval) { - array[i].mbp_override_value.stringval = - strdup(param.mbp_override_value.stringval); - } - array[i].mbp_override_value_set = true; - } - } - - /* If the original is INT and the new is STRING, or the original - is STRING and the new is INT, this is an OMPI developer - error. */ - - else if ((MCA_BASE_PARAM_TYPE_INT == array[i].mbp_type && - MCA_BASE_PARAM_TYPE_STRING == param.mbp_type) || - (MCA_BASE_PARAM_TYPE_STRING == array[i].mbp_type && - MCA_BASE_PARAM_TYPE_INT == param.mbp_type)) { -#if OPAL_ENABLE_DEBUG - opal_show_help("help-mca-param.txt", - "re-register with different type", - true, array[i].mbp_full_name); -#endif - /* Return an error code and hope for the best. */ - OBJ_DESTRUCT(¶m); - return OPAL_ERR_VALUE_OUT_OF_BOUNDS; - } - - /* Now delete the newly-created entry (since we just saved the - value in the old entry) */ - - OBJ_DESTRUCT(¶m); - - /* Finally, if we have a lookup value, look it up */ - - if (NULL != current_value) { - if (!param_lookup(i, current_value, NULL, NULL)) { - return OPAL_ERR_NOT_FOUND; - } - } - - /* Return the new index */ - - return (int)i; - } - } - - /* Add it to the array. Note that we copy the mca_param_t by value, - so the entire contents of the struct is copied. The synonym list - will always be empty at this point, so there's no need for an - extra RETAIN or RELEASE. */ - if (OPAL_SUCCESS != - (ret = opal_value_array_append_item(&mca_base_params, ¶m))) { - return ret; - } - ret = (int)opal_value_array_get_size(&mca_base_params) - 1; - - /* Finally, if we have a lookup value, look it up */ - - if (NULL != current_value) { - if (!param_lookup(ret, current_value, NULL, NULL)) { - return OPAL_ERR_NOT_FOUND; - } - } - - /* All done */ - - return ret; -} - - -/* - * Back-end for registering a synonym - */ -static int syn_register(int index_orig, const char *syn_type_name, - const char *syn_component_name, - const char *syn_param_name, bool deprecated) -{ - size_t len; - syn_info_t *si; - mca_base_param_t *array; - - if (!initialized) { - return OPAL_ERROR; - } - - /* Sanity check index param */ - len = opal_value_array_get_size(&mca_base_params); - if (index_orig < 0 || ((size_t) index_orig) > len) { - return OPAL_ERR_BAD_PARAM; - } - - /* Make the synonym info object */ - si = OBJ_NEW(syn_info_t); - if (NULL == si) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - - /* Note that the following logic likely could have been combined - into more compact code. However, keeping it separate made it - much easier to read / maintain (IMHO). This is not a high - performance section of the code, so a premium was placed on - future readability / maintenance. */ - - /* Save the function parameters */ - si->si_deprecated = deprecated; - if (NULL != syn_type_name) { - si->si_type_name = strdup(syn_type_name); - if (NULL == si->si_type_name) { - OBJ_RELEASE(si); - return OPAL_ERR_OUT_OF_RESOURCE; - } - } - - if (NULL != syn_component_name) { - si->si_component_name = strdup(syn_component_name); - if (NULL == si->si_component_name) { - OBJ_RELEASE(si); - return OPAL_ERR_OUT_OF_RESOURCE; - } - } - - if (NULL != syn_param_name) { - si->si_param_name = strdup(syn_param_name); - if (NULL == si->si_param_name) { - OBJ_RELEASE(si); - return OPAL_ERR_OUT_OF_RESOURCE; - } - } - - /* Build up the full name */ - len = 16; - if (NULL != syn_type_name) { - len += strlen(syn_type_name); - } - if (NULL != syn_component_name) { - len += strlen(syn_component_name); - } - if (NULL != syn_param_name) { - len += strlen(syn_param_name); - } - si->si_full_name = (char*) malloc(len); - if (NULL == si->si_full_name) { - OBJ_RELEASE(si); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - /* Copy the name over in parts */ - si->si_full_name[0] = '\0'; - if (NULL != syn_type_name) { - strncat(si->si_full_name, syn_type_name, len); - } - if (NULL != syn_component_name) { - if ('\0' != si->si_full_name[0]) { - strcat(si->si_full_name, "_"); - } - strcat(si->si_full_name, syn_component_name); - } - if (NULL != syn_param_name) { - if ('\0' != si->si_full_name[0]) { - strcat(si->si_full_name, "_"); - } - strcat(si->si_full_name, syn_param_name); - } - - /* Create the environment name */ - len = strlen(si->si_full_name) + strlen(mca_prefix) + 16; - si->si_env_var_name = (char*) malloc(len); - if (NULL == si->si_env_var_name) { - OBJ_RELEASE(si); - return OPAL_ERR_OUT_OF_RESOURCE; - } - snprintf(si->si_env_var_name, len, "%s%s", mca_prefix, - si->si_full_name); - - /* Find the param entry; add this syn_info to its list of - synonyms */ - array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t); - - /* Sanity check. Is this a valid parameter? */ - if (MCA_BASE_PARAM_TYPE_MAX <= array[index_orig].mbp_type) { - OBJ_RELEASE(si); - return OPAL_ERROR; - } - - if (NULL == array[index_orig].mbp_synonyms) { - array[index_orig].mbp_synonyms = OBJ_NEW(opal_list_t); - } - opal_list_append(array[index_orig].mbp_synonyms, &(si->super)); - - /* All done */ - - return OPAL_SUCCESS; -} - - -/* - * Set an override - */ -static bool param_set_override(size_t index, - mca_base_param_storage_t *storage, - mca_base_param_type_t type) -{ - size_t size; - mca_base_param_t *array; - - /* Lookup the index and see if it's valid */ - - if (!initialized) { - return false; - } - size = opal_value_array_get_size(&mca_base_params); - if (index > size) { - return false; - } - - array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t); - if (MCA_BASE_PARAM_TYPE_INT == type) { - array[index].mbp_override_value.intval = storage->intval; - } else if (MCA_BASE_PARAM_TYPE_STRING == type) { - if (NULL != storage->stringval) { - array[index].mbp_override_value.stringval = - strdup(storage->stringval); - } else { - array[index].mbp_override_value.stringval = NULL; - } - } else { - return false; - } - - array[index].mbp_override_value_set = true; - - return true; -} - -/* - * Lookup the type of a parameter from an index - */ -static mca_base_param_type_t param_type_from_index (size_t index) -{ - mca_base_param_t *array; - size_t size; - - /* Lookup the index and see if it's valid */ - - if (!initialized) { - return false; - } - size = opal_value_array_get_size(&mca_base_params); - if (index > size) { - return false; - } - array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t); - - return array[index].mbp_type; -} - -/* - * Lookup a parameter in multiple places - */ -static bool param_lookup(size_t index, mca_base_param_storage_t *storage, - mca_base_param_source_t *source_param, - char **source_file) -{ - size_t size; - mca_base_param_t *array; - char *p, *q; - mca_base_param_source_t source = MCA_BASE_PARAM_SOURCE_MAX; - - /* default the value */ - if (NULL != source_file) { - *source_file = NULL; - } - - /* Lookup the index and see if it's valid */ - - if (!initialized) { - return false; - } - size = opal_value_array_get_size(&mca_base_params); - if (index > size) { - return false; - } - array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t); - - /* Ensure that MCA param has a good type */ - - if (MCA_BASE_PARAM_TYPE_INT != array[index].mbp_type && - MCA_BASE_PARAM_TYPE_STRING != array[index].mbp_type) { - return false; - } - - /* Check all the places that the param may be hiding, in priority - order -- but if read_only is true, then only look at the - default location. */ - - if (array[index].mbp_read_only) { - if (lookup_override(&array[index], storage) || - lookup_env(&array[index], storage) || - lookup_file(&array[index], storage, source_file)) { - opal_show_help("help-mca-param.txt", "read-only-param-set", - true, array[index].mbp_full_name); - } - - /* First look at the "real" name of this param */ - if (lookup_default(&array[index], storage)) { - source = MCA_BASE_PARAM_SOURCE_DEFAULT; - } - } else { - if (lookup_override(&array[index], storage)) { - source = MCA_BASE_PARAM_SOURCE_OVERRIDE; - } else if (lookup_env(&array[index], storage)) { - source = MCA_BASE_PARAM_SOURCE_ENV; - } else if (lookup_file(&array[index], storage, source_file)) { - source = MCA_BASE_PARAM_SOURCE_FILE; - } else if (lookup_default(&array[index], storage)) { - source = MCA_BASE_PARAM_SOURCE_DEFAULT; - } - } - if (MCA_BASE_PARAM_SOURCE_MAX != source) { - if (NULL != source_param) { - *source_param = source; - } - - /* If we're returning a string, replace all instances of "~/" - with the user's home directory */ - - if (MCA_BASE_PARAM_TYPE_STRING == array[index].mbp_type && - NULL != storage->stringval) { - if (0 == strncmp(storage->stringval, "~/", 2)) { - if( NULL == home ) { - asprintf(&p, "%s", storage->stringval + 2); - } else { - p = opal_os_path( false, home, storage->stringval + 2, NULL ); - } - free(storage->stringval); - storage->stringval = p; - } - - p = strstr(storage->stringval, ":~/"); - while (NULL != p) { - *p = '\0'; - if( NULL == home ) { - asprintf(&q, "%s:%s", storage->stringval, p + 2); - } else { - asprintf(&q, "%s:%s%s", storage->stringval, home, p + 2); - } - free(storage->stringval); - storage->stringval = q; - p = strstr(storage->stringval, ":~/"); - } - } - - return true; - } - - /* Didn't find it. Doh! */ - - return false; -} - - -/* - * Lookup a param in the overrides section - */ -static bool lookup_override(mca_base_param_t *param, - mca_base_param_storage_t *storage) -{ - if (param->mbp_override_value_set) { - if (MCA_BASE_PARAM_TYPE_INT == param->mbp_type) { - storage->intval = param->mbp_override_value.intval; - } else if (MCA_BASE_PARAM_TYPE_STRING == param->mbp_type) { - storage->stringval = strdup(param->mbp_override_value.stringval); - } - - return true; - } - - /* Don't have an override */ - - return false; -} - - -/* - * Lookup a param in the environment - */ -static bool lookup_env(mca_base_param_t *param, - mca_base_param_storage_t *storage) -{ - char *env = NULL; - opal_list_item_t *item; - syn_info_t *si; - char *deprecated_name = NULL; - bool print_deprecated_warning = false; - - /* Look for the primary param name */ - if (NULL != param->mbp_env_var_name) { - env = getenv(param->mbp_env_var_name); - print_deprecated_warning = - param->mbp_deprecated & !param->mbp_deprecated_warning_shown; - deprecated_name = param->mbp_full_name; - /* Regardless of whether we want to show the deprecated - warning or not, we can skip this check the next time - through on this parameter */ - param->mbp_deprecated_warning_shown = true; - } - - /* If we didn't find the primary name, look in all the synonyms */ - if (NULL == env && NULL != param->mbp_synonyms && - !opal_list_is_empty(param->mbp_synonyms)) { - for (item = opal_list_get_first(param->mbp_synonyms); - NULL == env && opal_list_get_end(param->mbp_synonyms) != item; - item = opal_list_get_next(item)) { - si = (syn_info_t*) item; - env = getenv(si->si_env_var_name); - if (NULL != env && - ((si->si_deprecated && - !si->si_deprecated_warning_shown) || - (param->mbp_deprecated && - !param->mbp_deprecated_warning_shown))) { - print_deprecated_warning = - si->si_deprecated_warning_shown = - param->mbp_deprecated_warning_shown = true; - deprecated_name = si->si_full_name; - } - } - } - - /* If we found it, react */ - if (NULL != env) { - if (MCA_BASE_PARAM_TYPE_INT == param->mbp_type) { - storage->intval = (int)strtol(env,(char**)NULL,0); - } else if (MCA_BASE_PARAM_TYPE_STRING == param->mbp_type) { - storage->stringval = strdup(env); - } - - if (print_deprecated_warning) { - opal_show_help("help-mca-param.txt", "deprecated mca param env", - true, deprecated_name); - } - return true; - } - - /* Didn't find it */ - return false; -} - - -/* - * Lookup a param in the files - */ -static bool lookup_file(mca_base_param_t *param, - mca_base_param_storage_t *storage, - char **source_file) -{ - bool found = false; - syn_info_t *si; - char *deprecated_name = NULL; - opal_list_item_t *item, *in_item; - mca_base_param_file_value_t *fv; - bool print_deprecated_warning = false; - - /* See if we previously found a match from a file. If so, just - return that */ - - if (param->mbp_file_value_set) { - if (NULL != source_file) { - *source_file = param->mbp_source_file; - } - return set(param->mbp_type, storage, ¶m->mbp_file_value); - } - - /* Scan through the list of values read in from files and try to - find a match. If we do, cache it on the param (for future - lookups) and save it in the storage. */ - - for (item = opal_list_get_first(&mca_base_param_file_values); - opal_list_get_end(&mca_base_param_file_values) != item; - item = opal_list_get_next(item)) { - fv = (mca_base_param_file_value_t *) item; - /* If it doesn't match the parameter's real name, check its - synonyms */ - if (0 == strcmp(fv->mbpfv_param, param->mbp_full_name)) { - found = true; - print_deprecated_warning = - param->mbp_deprecated & !param->mbp_deprecated_warning_shown; - deprecated_name = param->mbp_full_name; - /* Regardless of whether we want to show the deprecated - warning or not, we can skip this check the next time - through on this parameter */ - param->mbp_deprecated_warning_shown = true; - } else if (NULL != param->mbp_synonyms && - !opal_list_is_empty(param->mbp_synonyms)) { - /* Check all the synonyms on this parameter and see if the - file value matches */ - for (in_item = opal_list_get_first(param->mbp_synonyms); - opal_list_get_end(param->mbp_synonyms) != in_item; - in_item = opal_list_get_next(in_item)) { - si = (syn_info_t*) in_item; - if (0 == strcmp(fv->mbpfv_param, si->si_full_name)) { - found = true; - if ((si->si_deprecated && - !si->si_deprecated_warning_shown) || - (param->mbp_deprecated && - !param->mbp_deprecated_warning_shown)) { - print_deprecated_warning = - si->si_deprecated_warning_shown = - param->mbp_deprecated_warning_shown = true; - deprecated_name = si->si_full_name; - } - } - } - } - - /* Did we find it? */ - if (found) { - if (MCA_BASE_PARAM_TYPE_INT == param->mbp_type) { - if (NULL != fv->mbpfv_value) { - param->mbp_file_value.intval = - (int)strtol(fv->mbpfv_value,(char**)NULL,0); - } else { - param->mbp_file_value.intval = 0; - } - } else { - param->mbp_file_value.stringval = fv->mbpfv_value; - fv->mbpfv_value = NULL; - } - if (NULL != fv->mbpfv_file) { - param->mbp_source_file = strdup(fv->mbpfv_file); - } - param->mbp_file_value_set = true; - - /* If the caller requested to know what file we found the - value in, give them a copy of the filename pointer */ - if (NULL != source_file) { - *source_file = param->mbp_source_file; - } - - /* Since this is now cached on the param, we might as well - remove it from the list and make future file lookups - faster */ - - opal_list_remove_item(&mca_base_param_file_values, - (opal_list_item_t *) fv); - OBJ_RELEASE(fv); - - /* Print the deprecated warning, if applicable */ - if (print_deprecated_warning) { - opal_show_help("help-mca-param.txt", - "deprecated mca param file", - true, deprecated_name); - } - - return set(param->mbp_type, storage, ¶m->mbp_file_value); - } - } - - return false; -} - - -/* - * Return the default value for a param - */ -static bool lookup_default(mca_base_param_t *param, - mca_base_param_storage_t *storage) -{ - return set(param->mbp_type, storage, ¶m->mbp_default_value); -} - - -static bool set(mca_base_param_type_t type, - mca_base_param_storage_t *dest, mca_base_param_storage_t *src) -{ - switch (type) { - case MCA_BASE_PARAM_TYPE_INT: - dest->intval = src->intval; - break; - - case MCA_BASE_PARAM_TYPE_STRING: - if (NULL != src->stringval) { - dest->stringval = strdup(src->stringval); - } else { - dest->stringval = NULL; - } - break; - - default: - return false; - break; - } - - return true; -} - - /* * Create an empty param container */ static void param_constructor(mca_base_param_t *p) { - p->mbp_type = MCA_BASE_PARAM_TYPE_MAX; - p->mbp_internal = false; - p->mbp_read_only = false; - p->mbp_deprecated = false; - p->mbp_deprecated_warning_shown = false; - - p->mbp_type_name = NULL; - p->mbp_component_name = NULL; - p->mbp_param_name = NULL; - p->mbp_full_name = NULL; - p->mbp_help_msg = NULL; - - p->mbp_env_var_name = NULL; - - p->mbp_default_value.stringval = NULL; - p->mbp_file_value_set = false; - p->mbp_file_value.stringval = NULL; - p->mbp_source_file = NULL; - p->mbp_override_value_set = false; - p->mbp_override_value.stringval = NULL; - - p->mbp_synonyms = NULL; + memset ((char *) p + sizeof (p->super), 0, sizeof (*p) - sizeof (p->super)); } @@ -1835,55 +676,9 @@ static void param_constructor(mca_base_param_t *p) */ static void param_destructor(mca_base_param_t *p) { - opal_list_item_t *item; - - if (NULL != p->mbp_type_name) { - free(p->mbp_type_name); + if (NULL != p->param_value) { + free (p->param_value); } - if (NULL != p->mbp_component_name) { - free(p->mbp_component_name); - } - if (NULL != p->mbp_param_name) { - free(p->mbp_param_name); - } - if (NULL != p->mbp_env_var_name) { - free(p->mbp_env_var_name); - } - if (NULL != p->mbp_full_name) { - free(p->mbp_full_name); - } - if (NULL != p->mbp_help_msg) { - free(p->mbp_help_msg); - } - if (MCA_BASE_PARAM_TYPE_STRING == p->mbp_type) { - if (NULL != p->mbp_default_value.stringval) { - free(p->mbp_default_value.stringval); - } - if (p->mbp_file_value_set) { - if (NULL != p->mbp_file_value.stringval) { - free(p->mbp_file_value.stringval); - } - if (NULL != p->mbp_source_file) { - free(p->mbp_source_file); - } - } - if (p->mbp_override_value_set && - NULL != p->mbp_override_value.stringval) { - free(p->mbp_override_value.stringval); - } - } - - /* Destroy any synonyms that are on the list */ - if (NULL != p->mbp_synonyms) { - for (item = opal_list_remove_first(p->mbp_synonyms); - NULL != item; item = opal_list_remove_first(p->mbp_synonyms)) { - OBJ_RELEASE(item); - } - OBJ_RELEASE(p->mbp_synonyms); - } - - /* mark this parameter as invalid */ - p->mbp_type = MCA_BASE_PARAM_TYPE_MAX; #if OPAL_ENABLE_DEBUG /* Cheap trick to reset everything to NULL */ @@ -1891,29 +686,6 @@ static void param_destructor(mca_base_param_t *p) #endif } - -static void fv_constructor(mca_base_param_file_value_t *f) -{ - f->mbpfv_param = NULL; - f->mbpfv_value = NULL; - f->mbpfv_file = NULL; -} - - -static void fv_destructor(mca_base_param_file_value_t *f) -{ - if (NULL != f->mbpfv_param) { - free(f->mbpfv_param); - } - if (NULL != f->mbpfv_value) { - free(f->mbpfv_value); - } - if (NULL != f->mbpfv_file) { - free(f->mbpfv_file); - } - fv_constructor(f); -} - static void info_constructor(mca_base_param_info_t *p) { p->mbpp_index = -1; @@ -1930,7 +702,6 @@ static void info_constructor(mca_base_param_info_t *p) p->mbpp_synonyms_len = 0; p->mbpp_synonym_parent = NULL; - p->mbpp_read_only = false; p->mbpp_help_msg = NULL; } @@ -1945,34 +716,6 @@ static void info_destructor(mca_base_param_info_t *p) info_constructor(p); } -static void syn_info_constructor(syn_info_t *si) -{ - si->si_type_name = si->si_component_name = si->si_param_name = - si->si_full_name = si->si_env_var_name = NULL; - si->si_deprecated = si->si_deprecated_warning_shown = false; -} - -static void syn_info_destructor(syn_info_t *si) -{ - if (NULL != si->si_type_name) { - free(si->si_type_name); - } - if (NULL != si->si_component_name) { - free(si->si_component_name); - } - if (NULL != si->si_param_name) { - free(si->si_param_name); - } - if (NULL != si->si_full_name) { - free(si->si_full_name); - } - if (NULL != si->si_env_var_name) { - free(si->si_env_var_name); - } - - syn_info_constructor(si); -} - int mca_base_param_find_int(const mca_base_component_t *component, const char *param_name, char **env, @@ -2087,35 +830,6 @@ int mca_base_param_find_string_name(const char *type, return rc; } -static char *source_name(mca_base_param_source_t source, - const char *filename) -{ - char *ret; - - switch (source) { - case MCA_BASE_PARAM_SOURCE_DEFAULT: - return strdup("default value"); - break; - - case MCA_BASE_PARAM_SOURCE_ENV: - return strdup("command line or environment variable"); - break; - - case MCA_BASE_PARAM_SOURCE_FILE: - asprintf(&ret, "file (%s)", filename); - return ret; - break; - - case MCA_BASE_PARAM_SOURCE_OVERRIDE: - return strdup("internal override"); - break; - - default: - return strdup("unknown (!)"); - break; - } -} - int mca_base_param_check_exclusive_string(const char *type_a, const char *component_a, const char *param_a, @@ -2123,81 +837,7 @@ int mca_base_param_check_exclusive_string(const char *type_a, const char *component_b, const char *param_b) { - int i, ret; - mca_base_param_source_t source_a, source_b; - char *filename_a, *filename_b; - - i = mca_base_param_find(type_a, component_a, param_a); - if (i < 0) { - return OPAL_ERR_NOT_FOUND; - } - ret = mca_base_param_lookup_source(i, &source_a, &filename_a); - if (OPAL_SUCCESS != ret) { - return ret; - } - - i = mca_base_param_find(type_b, component_b, param_b); - if (i < 0) { - return OPAL_ERR_NOT_FOUND; - } - ret = mca_base_param_lookup_source(i, &source_b, &filename_b); - if (OPAL_SUCCESS != ret) { - return ret; - } - - if (MCA_BASE_PARAM_SOURCE_DEFAULT != source_a && - MCA_BASE_PARAM_SOURCE_DEFAULT != source_b) { - size_t len; - char *str_a, *str_b, *name_a, *name_b; - - /* Form cosmetic string names for A */ - str_a = source_name(source_a, filename_a); - len = 5; - if (NULL != type_a) len += strlen(type_a); - if (NULL != component_a) len += strlen(component_a); - if (NULL != param_a) len += strlen(param_a); - name_a = calloc(1, len); - if (NULL == name_a) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - if (NULL != type_a) { - strncat(name_a, type_a, len); - strncat(name_a, "_", len); - } - if (NULL != component_a) strncat(name_a, component_a, len); - strncat(name_a, "_", len); - strncat(name_a, param_a, len); - - /* Form cosmetic string names for B */ - str_b = source_name(source_b, filename_b); - len = 5; - if (NULL != type_b) len += strlen(type_b); - if (NULL != component_b) len += strlen(component_b); - if (NULL != param_b) len += strlen(param_b); - name_b = calloc(1, len); - if (NULL == name_b) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - if (NULL != type_b) { - strncat(name_b, type_b, len); - strncat(name_b, "_", len); - } - if (NULL != component_b) strncat(name_b, component_b, len); - strncat(name_b, "_", len); - strncat(name_b, param_b, len); - - /* Print it all out */ - opal_show_help("help-mca-param.txt", - "mutually exclusive params", - true, name_a, str_a, name_b, str_b); - - /* Free the temp strings */ - free(str_a); - free(name_a); - free(str_b); - free(name_b); - return OPAL_ERR_BAD_PARAM; - } - - return OPAL_SUCCESS; + return mca_base_var_check_exclusive (NULL, type_a, component_a, + param_a, type_b, component_b, + param_b); } diff --git a/opal/mca/base/mca_base_param.h b/opal/mca/base/mca_base_param.h index ee2bb8f459..1bf0d35226 100644 --- a/opal/mca/base/mca_base_param.h +++ b/opal/mca/base/mca_base_param.h @@ -18,6 +18,9 @@ */ /** @file + * \deprecated The entire mca_base_param system has been deprectated for + * 1.7 (removed in 1.9). Please use the mca_base_var system instead. + * * This file presents the MCA parameter interface. * * Note that there are two scopes for MCA parameters: "normal" and @@ -108,13 +111,13 @@ struct mca_base_param_info_t { mca_base_param_type_t mbpp_type; /** String name of the type of this component */ - char *mbpp_type_name; + const char *mbpp_type_name; /** String name of the component of the parameter */ - char *mbpp_component_name; + const char *mbpp_component_name; /** String name of the parameter of the parameter */ - char *mbpp_param_name; + const char *mbpp_param_name; /** Full, assembled parameter name */ - char *mbpp_full_name; + const char *mbpp_full_name; /** Is this parameter deprecated? */ bool mbpp_deprecated; @@ -132,7 +135,7 @@ struct mca_base_param_info_t { /** Is this parameter changable? */ bool mbpp_read_only; /** Help message associated with this parameter */ - char *mbpp_help_msg; + const char *mbpp_help_msg; }; /** * Convenience typedef @@ -159,7 +162,7 @@ BEGIN_C_DECLS * invoked internally (by mca_base_open()) and is only documented * here for completeness. */ - OPAL_DECLSPEC int mca_base_param_init(void); + OPAL_DECLSPEC int mca_base_param_init(void) __opal_attribute_deprecated__; /** * Recache the MCA param files @@ -169,7 +172,7 @@ BEGIN_C_DECLS * @retval OPAL_SUCCESS * */ - OPAL_DECLSPEC int mca_base_param_recache_files(bool rel_path_search); + OPAL_DECLSPEC int mca_base_param_recache_files(bool rel_path_search) __opal_attribute_deprecated__; /** * Register an integer MCA parameter. @@ -229,7 +232,7 @@ BEGIN_C_DECLS bool internal, bool read_only, int default_value, - int *current_value); + int *current_value) __opal_attribute_deprecated__; /** * Register an integer MCA parameter that is not associated with a @@ -291,7 +294,7 @@ BEGIN_C_DECLS bool internal, bool read_only, int default_value, - int *current_value); + int *current_value) __opal_attribute_deprecated__; /** * Register a string MCA parameter. @@ -335,7 +338,7 @@ BEGIN_C_DECLS bool internal, bool read_only, const char *default_value, - char **current_value); + char **current_value) __opal_attribute_deprecated__; /** @@ -402,7 +405,7 @@ BEGIN_C_DECLS bool internal, bool read_only, const char *default_value, - char **current_value); + char **current_value) __opal_attribute_deprecated__; /** * Register a synonym name for an MCA parameter. @@ -441,7 +444,7 @@ BEGIN_C_DECLS OPAL_DECLSPEC int mca_base_param_reg_syn(int orignal_index, const mca_base_component_t *syn_component, const char *syn_param_name, - bool deprecated); + bool deprecated) __opal_attribute_deprecated__; /** * Register an MCA parameter synonym that is not associated with a @@ -467,7 +470,7 @@ BEGIN_C_DECLS OPAL_DECLSPEC int mca_base_param_reg_syn_name(int orignal_index, const char *syn_type, const char *syn_param_name, - bool deprecated); + bool deprecated) __opal_attribute_deprecated__; /** * Deregister a MCA parameter @@ -475,7 +478,7 @@ BEGIN_C_DECLS * @param index Index returned from mca_base_param_register_init() * */ - OPAL_DECLSPEC int mca_base_param_deregister(int index); + OPAL_DECLSPEC int mca_base_param_deregister(int index) __opal_attribute_deprecated__; /** * Look up an integer MCA parameter. @@ -493,7 +496,7 @@ BEGIN_C_DECLS * The value of a specific MCA parameter can be looked up using the * return value from mca_base_param_reg_int(). */ - OPAL_DECLSPEC int mca_base_param_lookup_int(int index, int *value); +OPAL_DECLSPEC int mca_base_param_lookup_int(int index, int *value) __opal_attribute_deprecated__; /** * Look up a string MCA parameter. @@ -518,7 +521,7 @@ BEGIN_C_DECLS * The value of a specific MCA parameter can be looked up using the * return value from mca_base_param_reg_string(). */ - OPAL_DECLSPEC int mca_base_param_lookup_string(int index, char **value); +OPAL_DECLSPEC int mca_base_param_lookup_string(int index, char **value) __opal_attribute_deprecated__; /** * Lookup the source of an MCA parameter's value @@ -538,7 +541,7 @@ BEGIN_C_DECLS */ OPAL_DECLSPEC int mca_base_param_lookup_source(int index, mca_base_param_source_t *source, - char **source_file); + const char **source_file) __opal_attribute_deprecated__; /** * Sets an "override" value for an integer MCA parameter. @@ -558,7 +561,7 @@ BEGIN_C_DECLS * This function may be invoked multiple times; each time, the * last "set" value is replaced with the newest value. */ - OPAL_DECLSPEC int mca_base_param_set_int(int index, int value); + OPAL_DECLSPEC int mca_base_param_set_int(int index, int value) __opal_attribute_deprecated__; /** * Sets an "override" value for an string MCA parameter. @@ -582,7 +585,7 @@ BEGIN_C_DECLS * last "set" value is replaced with the newest value (the old * value is discarded). */ - OPAL_DECLSPEC int mca_base_param_set_string(int index, char *value); + OPAL_DECLSPEC int mca_base_param_set_string(int index, char *value) __opal_attribute_deprecated__; /** * Unset a parameter that was previously set by @@ -596,7 +599,7 @@ BEGIN_C_DECLS * Resets previous value that was set (if any) on the given MCA * parameter. */ - OPAL_DECLSPEC int mca_base_param_unset(int index); + OPAL_DECLSPEC int mca_base_param_unset(int index) __opal_attribute_deprecated__; /** * Get the string name corresponding to the MCA parameter @@ -611,7 +614,7 @@ BEGIN_C_DECLS * The string that is returned is owned by the caller; if * appropriate, it must be eventually freed by the caller. */ - OPAL_DECLSPEC char *mca_base_param_env_var(const char *param_name); + OPAL_DECLSPEC char *mca_base_param_env_var(const char *param_name) __opal_attribute_deprecated__; /** * Find the index for an MCA parameter based on its names. @@ -633,7 +636,7 @@ BEGIN_C_DECLS */ OPAL_DECLSPEC int mca_base_param_find(const char *type, const char *component, - const char *param); + const char *param) __opal_attribute_deprecated__; /** * Find an MCA parameter in an env array based on its names. @@ -652,7 +655,7 @@ BEGIN_C_DECLS OPAL_DECLSPEC int mca_base_param_find_int(const mca_base_component_t *component, const char *param_name, char **env, - int *current_value); + int *current_value) __opal_attribute_deprecated__; /** * Find an MCA parameter (in an env array) that is not associated with a @@ -673,7 +676,7 @@ OPAL_DECLSPEC int mca_base_param_find_int(const mca_base_component_t *component, OPAL_DECLSPEC int mca_base_param_find_int_name(const char *type, const char *param_name, char **env, - int *current_value); + int *current_value) __opal_attribute_deprecated__; /** * Find a string MCA parameter in an env array based on its names. * @@ -691,7 +694,7 @@ OPAL_DECLSPEC int mca_base_param_find_int_name(const char *type, OPAL_DECLSPEC int mca_base_param_find_string(const mca_base_component_t *component, const char *param_name, char **env, - char **current_value); + char **current_value) __opal_attribute_deprecated__; /** * Find a string MCA parameter (in an env array) that is not associated with a @@ -712,7 +715,7 @@ OPAL_DECLSPEC int mca_base_param_find_string(const mca_base_component_t *compone OPAL_DECLSPEC int mca_base_param_find_string_name(const char *type, const char *param_name, char **env, - char **current_value); + char **current_value) __opal_attribute_deprecated__; /** * Check that two MCA parameters were not both set to non-default @@ -747,7 +750,7 @@ OPAL_DECLSPEC int mca_base_param_check_exclusive_string(const char *type_a, const char *param_a, const char *type_b, const char *component_b, - const char *param_b); + const char *param_b) __opal_attribute_deprecated__; /** * Set the "internal" flag on an MCA parameter to true or false. @@ -768,7 +771,7 @@ OPAL_DECLSPEC int mca_base_param_check_exclusive_string(const char *type_a, * MPI_INIT (at least, they're not displayed by default), thus * keeping them away from prying user eyes. */ - OPAL_DECLSPEC int mca_base_param_set_internal(int index, bool internal); + OPAL_DECLSPEC int mca_base_param_set_internal(int index, bool internal) __opal_attribute_deprecated__; /** * Obtain a list of all the MCA parameters currently defined as @@ -794,7 +797,7 @@ OPAL_DECLSPEC int mca_base_param_check_exclusive_string(const char *type_a, * mca_base_param_dump_release() when finished with the returned * info list to release all associated memory. */ - OPAL_DECLSPEC int mca_base_param_dump(opal_list_t **info, bool internal); + OPAL_DECLSPEC int mca_base_param_dump(opal_list_t **info, bool internal) __opal_attribute_deprecated__; /** * Obtain a list of all the MCA parameters currently defined as @@ -815,7 +818,7 @@ OPAL_DECLSPEC int mca_base_param_check_exclusive_string(const char *type_a, * strings, suitable for using in an environment. */ OPAL_DECLSPEC int mca_base_param_build_env(char ***env, int *num_env, - bool internal); + bool internal) __opal_attribute_deprecated__; /** * Release the memory associated with the info list returned from @@ -834,7 +837,7 @@ OPAL_DECLSPEC int mca_base_param_check_exclusive_string(const char *type_a, * the caller is finished with the info list, invoke this * function and all memory associated with the list will be freed. */ - OPAL_DECLSPEC int mca_base_param_dump_release(opal_list_t *info); + OPAL_DECLSPEC int mca_base_param_dump_release(opal_list_t *info) __opal_attribute_deprecated__; /** * Shut down the MCA parameter system (normally only invoked by the @@ -850,7 +853,7 @@ OPAL_DECLSPEC int mca_base_param_check_exclusive_string(const char *type_a, * when the process is shutting down (e.g., during MPI_FINALIZE). It * is only documented here for completeness. */ - OPAL_DECLSPEC int mca_base_param_finalize(void); + OPAL_DECLSPEC int mca_base_param_finalize(void) __opal_attribute_deprecated__; END_C_DECLS diff --git a/opal/mca/base/mca_base_param_internal.h b/opal/mca/base/mca_base_param_internal.h index 1984662e58..6f5adfd233 100644 --- a/opal/mca/base/mca_base_param_internal.h +++ b/opal/mca/base/mca_base_param_internal.h @@ -10,6 +10,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2012 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -37,7 +39,9 @@ #include "opal/class/opal_object.h" #include "opal/class/opal_list.h" +#include "opal/class/opal_value_array.h" #include "opal/mca/base/mca_base_param.h" +#include "opal/mca/base/mca_base_var.h" BEGIN_C_DECLS @@ -53,7 +57,6 @@ typedef union { char *stringval; } mca_base_param_storage_t; - /** * \internal * @@ -62,62 +65,13 @@ typedef union { */ struct mca_base_param_t { /** Allow this to be an OPAL OBJ */ - opal_object_t mbp_super; + opal_object_t super; - /** Enum indicating the type of the parameter (integer or string) */ - mca_base_param_type_t mbp_type; - /** String of the type name, or NULL */ - char *mbp_type_name; - /** String of the component name */ - char *mbp_component_name; - /** String of the parameter name */ - char *mbp_param_name; - /** Full parameter name, in case it is not - __ */ - char *mbp_full_name; + /* Backing store for the variable value */ + mca_base_param_storage_t *param_value; - /** List of synonym names for this parameter. This *must* be a - pointer (vs. a plain opal_list_t) because we copy this whole - struct into a new param for permanent storage - (opal_vale_array_append_item()), and the internal pointers in - the opal_list_t will be invalid when that happens. Hence, we - simply keep a pointer to an external opal_list_t. Synonyms - are uncommon enough that this is not a big performance hit. */ - opal_list_t *mbp_synonyms; - - /** Whether this is internal (not meant to be seen / modified by - users) or not */ - bool mbp_internal; - /** Whether this value is changable from the default value that - was registered (e.g., when true, useful for reporting values, - like the value of the GM library that was linked against) */ - bool mbp_read_only; - /** Whether this MCA parameter (*and* all of its synonyms) is - deprecated or not */ - bool mbp_deprecated; - /** Whether the warning message for the deprecated MCA param has - been shown already or not */ - bool mbp_deprecated_warning_shown; - /** Help message associated with this parameter */ - char *mbp_help_msg; - - /** Environment variable name */ - char *mbp_env_var_name; - - /** Default value of the parameter */ - mca_base_param_storage_t mbp_default_value; - - /** Whether or not we have a file value */ - bool mbp_file_value_set; - /** Value of the parameter found in a file */ - mca_base_param_storage_t mbp_file_value; - /** File the value came from */ - char *mbp_source_file; - - /** Whether or not we have an override value */ - bool mbp_override_value_set; - /** Value of the parameter override set via API */ - mca_base_param_storage_t mbp_override_value; + /* For debugging purposes */ + int var_index; }; /** * \internal @@ -134,35 +88,6 @@ typedef struct mca_base_param_t mca_base_param_t; OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_base_param_t); -/** - * \internal - * - * Structure for holding param names and values read in from files. - */ -struct mca_base_param_file_value_t { - /** Allow this to be an OPAL OBJ */ - opal_list_item_t super; - - /** Parameter name */ - char *mbpfv_param; - /** Parameter value */ - char *mbpfv_value; - /** File it came from */ - char *mbpfv_file; -}; -/** - * \internal - * - * Convenience typedef - */ -typedef struct mca_base_param_file_value_t mca_base_param_file_value_t; - -/** - * Object declaration for mca_base_param_file_value_t - */ -OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_base_param_file_value_t); - - /** * \internal * @@ -175,7 +100,7 @@ OPAL_DECLSPEC extern opal_list_t mca_base_param_file_values; * * Parse a parameter file. */ -OPAL_DECLSPEC int mca_base_parse_paramfile(const char *paramfile); +OPAL_DECLSPEC int mca_base_parse_paramfile(const char *paramfile, opal_list_t *list); END_C_DECLS diff --git a/opal/mca/base/mca_base_parse_paramfile.c b/opal/mca/base/mca_base_parse_paramfile.c index f089b31153..e74159f971 100644 --- a/opal/mca/base/mca_base_parse_paramfile.c +++ b/opal/mca/base/mca_base_parse_paramfile.c @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -24,58 +26,53 @@ #include "opal/class/opal_list.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param_internal.h" +#include "opal/mca/base/mca_base_vari.h" #include "opal/util/keyval_parse.h" static void save_value(const char *name, const char *value); static char * file_being_read; +static opal_list_t * _param_list; -int mca_base_parse_paramfile(const char *paramfile) +int mca_base_parse_paramfile(const char *paramfile, opal_list_t *list) { file_being_read = (char*)paramfile; - + _param_list = list; + return opal_util_keyval_parse(paramfile, save_value); } static void save_value(const char *name, const char *value) { - opal_list_item_t *item; - mca_base_param_file_value_t *fv; + mca_base_var_file_value_t *fv; + bool found = false; /* First traverse through the list and ensure that we don't already have a param of this name. If we do, just replace the value. */ - for (item = opal_list_get_first(&mca_base_param_file_values); - opal_list_get_end(&mca_base_param_file_values) != item; - item = opal_list_get_next(item)) { - fv = (mca_base_param_file_value_t *) item; - if (0 == strcmp(name, fv->mbpfv_param)) { - if (NULL != fv->mbpfv_value ) { - free(fv->mbpfv_value); + OPAL_LIST_FOREACH(fv, _param_list, mca_base_var_file_value_t) { + if (0 == strcmp(name, fv->mbvfv_var)) { + if (NULL != fv->mbvfv_value) { + free (fv->mbvfv_value); } - if (NULL != value) { - fv->mbpfv_value = strdup(value); - } else { - fv->mbpfv_value = NULL; - } - fv->mbpfv_file = strdup(file_being_read); + free (fv->mbvfv_file); + found = true; + break; + } + } + + if (!found) { + /* We didn't already have the param, so append it to the list */ + fv = OBJ_NEW(mca_base_var_file_value_t); + if (NULL == fv) { return; } + + fv->mbvfv_var = strdup(name); + opal_list_append(_param_list, &fv->super); } - /* We didn't already have the param, so append it to the list */ - - fv = OBJ_NEW(mca_base_param_file_value_t); - if (NULL != fv) { - fv->mbpfv_param = strdup(name); - if (NULL != value) { - fv->mbpfv_value = strdup(value); - } else { - fv->mbpfv_value = NULL; - } - fv->mbpfv_file = strdup(file_being_read); - opal_list_append(&mca_base_param_file_values, (opal_list_item_t*) fv); - } + fv->mbvfv_value = value ? strdup(value) : NULL; + fv->mbvfv_file = file_being_read; } diff --git a/opal/mca/base/mca_base_var.c b/opal/mca/base/mca_base_var.c new file mode 100644 index 0000000000..5bc1df95c3 --- /dev/null +++ b/opal/mca/base/mca_base_var.c @@ -0,0 +1,2227 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2012 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" + +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#include + +#include "opal/include/opal_stdint.h" +#include "opal/mca/installdirs/installdirs.h" +#include "opal/util/os_path.h" +#include "opal/util/path.h" +#include "opal/class/opal_value_array.h" +#include "opal/class/opal_pointer_array.h" +#include "opal/util/show_help.h" +#include "opal/util/printf.h" +#include "opal/util/argv.h" +#include "opal/mca/mca.h" +#include "opal/mca/base/mca_base_vari.h" +#include "opal/constants.h" +#include "opal/util/output.h" +#include "opal/util/opal_environ.h" +#include "opal/runtime/opal.h" + +/* + * local variables + */ +static opal_pointer_array_t mca_base_vars; +static opal_pointer_array_t mca_base_var_groups; +static int mca_base_var_groups_timestamp = 0; +static const char *mca_prefix = "OMPI_MCA_"; +static char *home = NULL; +static char *cwd = NULL; +static bool initialized = false; +static char * force_agg_path = NULL; +static char *mca_base_var_files = NULL; +static char **mca_base_var_file_list = NULL; +static char *mca_base_var_override_file = NULL; +static char *mca_base_var_file_prefix = NULL; +static char *mca_base_param_file_path = NULL; +static bool mca_base_var_suppress_override_warning = false; +static opal_list_t mca_base_var_file_values; +static opal_list_t mca_base_var_override_values; + +static int mca_base_var_count = 0; +static int mca_base_var_group_count = 0; + +/* + * local functions + */ +static int fixup_files(char **file_list, char * path, bool rel_path_search); +static int read_files (char *file_list, opal_list_t *file_values); +static int mca_base_var_cache_files (bool rel_path_search); +static int var_set_initial (mca_base_var_t *var); +static int var_get (int index, mca_base_var_t **var_out, bool original); + +/* + * classes + */ +static void var_constructor (mca_base_var_t *p); +static void var_destructor (mca_base_var_t *p); +OBJ_CLASS_INSTANCE(mca_base_var_t, opal_object_t, + var_constructor, var_destructor); + +static void fv_constructor (mca_base_var_file_value_t *p); +static void fv_destructor (mca_base_var_file_value_t *p); +OBJ_CLASS_INSTANCE(mca_base_var_file_value_t, opal_list_item_t, + fv_constructor, fv_destructor); + +static void mca_base_var_group_constructor (mca_base_var_group_t *group); +static void mca_base_var_group_destructor (mca_base_var_group_t *group); +OBJ_CLASS_INSTANCE(mca_base_var_group_t, opal_object_t, + mca_base_var_group_constructor, + mca_base_var_group_destructor); + +/* + * Generate a full name from three names + */ +static int mca_base_var_generate_full_name4 (const char *project, const char *framework, const char *component, + const char *variable, char **full_name) +{ + const char * const names[] = {project, framework, component, variable}; + char *name, *tmp; + size_t i, len; + + *full_name = NULL; + + for (i = 0, len = 0 ; i < 4 ; ++i) { + if (NULL != names[i]) { + /* Add space for the string + _ or \0 */ + len += strlen (names[i]) + 1; + } + } + + name = calloc (1, len); + if (NULL == name) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + for (i = 0, tmp = name ; i < 4 ; ++i) { + if (NULL != names[i]) { + if (name != tmp) { + *tmp++ = '_'; + } + strncat (name, names[i], len - (size_t)(uintptr_t)(tmp - name)); + tmp += strlen (names[i]); + } + } + + *full_name = name; + return OPAL_SUCCESS; +} + +static int compare_strings (const char *str1, const char *str2) { + if ((NULL != str1 && 0 == strcmp (str1, "*")) || + (NULL == str1 && NULL == str2)) { + return 0; + } + + if (NULL != str1 && NULL != str2) { + return strcmp (str1, str2); + } + + return 1; +} + +/* + * Append a filename to the file list if it does not exist and return a + * pointer to the filename in the list. + */ +static char *append_filename_to_list(const char *filename) +{ + int i, count; + + (void) opal_argv_append_unique_nosize(&mca_base_var_file_list, filename, false); + + count = opal_argv_count(mca_base_var_file_list); + + for (i = count - 1; i >= 0; --i) { + if (0 == strcmp (mca_base_var_file_list[i], filename)) { + return mca_base_var_file_list[i]; + } + } + + /* *#@*? */ + return NULL; +} + +/* + * Set it up + */ +int mca_base_var_init(void) +{ + if (!initialized) { + /* Init the value array for the param storage */ + + OBJ_CONSTRUCT(&mca_base_vars, opal_pointer_array_t); + /* These values are arbitrary */ + opal_pointer_array_init (&mca_base_vars, 128, 16384, 128); + + OBJ_CONSTRUCT(&mca_base_var_groups, opal_pointer_array_t); + /* These values are arbitrary */ + opal_pointer_array_init (&mca_base_var_groups, 128, 16384, 128); + + mca_base_var_count = 0; + mca_base_var_group_count = 0; + + /* Init the file param value list */ + + OBJ_CONSTRUCT(&mca_base_var_file_values, opal_list_t); + + OBJ_CONSTRUCT(&mca_base_var_override_values, opal_list_t); + + /* Set this before we register the parameter, below */ + + initialized = true; + + mca_base_var_cache_files(false); + } + + return OPAL_SUCCESS; +} + +static int mca_base_var_cache_files(bool rel_path_search) +{ + char *tmp; + int ret; + + /* We may need this later */ + home = (char*)opal_home_directory(); + + if(NULL == cwd) { + cwd = (char *) malloc(sizeof(char) * MAXPATHLEN); + if( NULL == (cwd = getcwd(cwd, MAXPATHLEN) )) { + opal_output(0, "Error: Unable to get the current working directory\n"); + cwd = strdup("."); + } + } + +#if OPAL_WANT_HOME_CONFIG_FILES + asprintf(&mca_base_var_files, "%s"OPAL_PATH_SEP".openmpi" OPAL_PATH_SEP + "mca-params.conf%c%s" OPAL_PATH_SEP "openmpi-mca-params.conf", + home, OPAL_ENV_SEP, opal_install_dirs.sysconfdir); +#else + asprintf(&mca_base_var_files, "%s" OPAL_PATH_SEP "openmpi-mca-params.conf", + opal_install_dirs.sysconfdir); +#endif + + /* Initialize a parameter that says where MCA param files can be found. + We may change this value so set the scope to MCA_BASE_VAR_SCOPE_READONLY */ + tmp = mca_base_var_files; + ret = mca_base_var_register ("opal", "mca", "base", "param_files", "Path for MCA " + "configuration files containing variable values", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_2, + MCA_BASE_VAR_SCOPE_READONLY, &mca_base_var_files); + free (tmp); + if (OPAL_SUCCESS != ret) { + return ret; + } + + (void) mca_base_var_register_synonym (ret, "opal", "mca", NULL, "param_files", + MCA_BASE_VAR_SYN_FLAG_DEPRECATED); + + ret = asprintf(&mca_base_var_override_file, "%s" OPAL_PATH_SEP "openmpi-mca-params-override.conf", + opal_install_dirs.sysconfdir); + if (0 > ret) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + tmp = mca_base_var_override_file; + ret = mca_base_var_register ("opal", "mca", "base", "override_param_file", + "Variables set in this file will override any value set in" + "the environment or another configuration file", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_DEFAULT_ONLY, + OPAL_INFO_LVL_2, MCA_BASE_VAR_SCOPE_CONSTANT, + &mca_base_var_override_file); + free (tmp); + if (0 > ret) { + return ret; + } + + /* Disable reading MCA parameter files. */ + if (0 == strcmp (mca_base_var_files, "none")) { + return OPAL_SUCCESS; + } + + mca_base_var_suppress_override_warning = false; + ret = mca_base_var_register ("opal", "mca", "base", "suppress_override_warning", + "Suppress warnings when attempting to set an overridden value (default: false)", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, OPAL_INFO_LVL_2, + MCA_BASE_VAR_SCOPE_LOCAL, &mca_base_var_suppress_override_warning); + + /* Aggregate MCA parameter files + * A prefix search path to look up aggregate MCA parameter file + * requests that do not specify an absolute path + */ + mca_base_var_file_prefix = NULL; + ret = mca_base_var_register ("opal", "mca", "base", "param_file_prefix", + "Aggregate MCA parameter file sets", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_READONLY, &mca_base_var_file_prefix); + + ret = asprintf(&mca_base_param_file_path, "%s" OPAL_PATH_SEP "amca-param-sets%c%s", + opal_install_dirs.pkgdatadir, OPAL_ENV_SEP, cwd); + if (0 > ret) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + tmp = mca_base_param_file_path; + ret = mca_base_var_register ("opal", "mca", "base", "param_file_path", + "Aggregate MCA parameter Search path", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_READONLY, &mca_base_param_file_path); + free (tmp); + if (0 > ret) { + return ret; + } + + force_agg_path = NULL; + ret = mca_base_var_register ("opal", "mca", "base", "param_file_path_force", + "Forced Aggregate MCA parameter Search path", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_READONLY, &force_agg_path); + if (0 > ret) { + return ret; + } + + if (NULL != force_agg_path) { + if (NULL != mca_base_param_file_path) { + char *tmp_str = mca_base_param_file_path; + + asprintf(&mca_base_param_file_path, "%s%c%s", force_agg_path, OPAL_ENV_SEP, tmp_str); + free(tmp_str); + } else { + mca_base_param_file_path = strdup(force_agg_path); + } + } + + if (NULL != mca_base_var_file_prefix) { + char *tmp_str; + + /* + * Resolve all relative paths. + * the file list returned will contain only absolute paths + */ + if( OPAL_SUCCESS != fixup_files(&mca_base_var_file_prefix, mca_base_param_file_path, rel_path_search) ) { +#if 0 + /* JJH We need to die! */ + abort(); +#else + ; +#endif + } + else { + /* Prepend the files to the search list */ + asprintf(&tmp_str, "%s%c%s", mca_base_var_file_prefix, OPAL_ENV_SEP, mca_base_var_files); + free (mca_base_var_files); + mca_base_var_files = tmp_str; + } + } + + read_files (mca_base_var_files, &mca_base_var_file_values); + + if (0 == access(mca_base_var_override_file, F_OK)) { + read_files (mca_base_var_override_file, &mca_base_var_override_values); + } + + return OPAL_SUCCESS; +} + +static int group_get (const int group_index, mca_base_var_group_t **group, bool invalidok) +{ + if (group_index < 0) { + return OPAL_ERR_NOT_FOUND; + } + + *group = (mca_base_var_group_t *) opal_pointer_array_get_item (&mca_base_var_groups, + group_index); + if (NULL == *group || (!invalidok && !(*group)->group_isvalid)) { + *group = NULL; + return OPAL_ERR_NOT_FOUND; + } + + return OPAL_SUCCESS; +} + +static int group_find (const char *project_name, const char *framework_name, + const char *component_name, bool invalidok) +{ + size_t size, i; + + size = opal_pointer_array_get_size (&mca_base_var_groups); + for (i = 0 ; i < size ; ++i) { + mca_base_var_group_t *group = opal_pointer_array_get_item (&mca_base_var_groups, + i); + + if (NULL != group && 0 == compare_strings (project_name, group->group_project) && + 0 == compare_strings (framework_name, group->group_framework) && + 0 == compare_strings (component_name, group->group_component) && + (group->group_isvalid || invalidok)) { + return (int) i; + } + } + + return OPAL_ERR_NOT_FOUND; +} + +static int group_register (const char *project_name, const char *framework_name, + const char *component_name, const char *description) +{ + mca_base_var_group_t *group; + int group_id, parent_id = -1; + int ret; + + if (NULL == project_name && NULL == framework_name && NULL == component_name) { + /* don't create a group with no name (maybe we should create a generic group?) */ + return -1; + } + + /* XXX -- remove this once the project name is available in the component structure */ + if (framework_name || component_name) { + project_name = NULL; + } + + group_id = group_find (project_name, framework_name, component_name, true); + if (0 <= group_id) { + (void) group_get (group_id, &group, true); + group->group_isvalid = true; + mca_base_var_groups_timestamp++; + + /* group already exists. return it's index */ + return group_id; + } + + group = OBJ_NEW(mca_base_var_group_t); + + group->group_isvalid = true; + + if (NULL != project_name) { + group->group_project = strdup (project_name); + if (NULL == group->group_project) { + OBJ_RELEASE(group); + return OPAL_ERR_OUT_OF_RESOURCE; + } + } + if (NULL != framework_name) { + group->group_framework = strdup (framework_name); + if (NULL == group->group_framework) { + OBJ_RELEASE(group); + return OPAL_ERR_OUT_OF_RESOURCE; + } + } + if (NULL != component_name) { + group->group_component = strdup (component_name); + if (NULL == group->group_component) { + OBJ_RELEASE(group); + return OPAL_ERR_OUT_OF_RESOURCE; + } + } + if (NULL != description) { + group->group_description = strdup (description); + if (NULL == group->group_description) { + OBJ_RELEASE(group); + return OPAL_ERR_OUT_OF_RESOURCE; + } + } + + if (NULL != framework_name && NULL != component_name) { + if (component_name) { + parent_id = group_register (project_name, framework_name, NULL, NULL); + } else if (framework_name && project_name) { + parent_id = group_register (project_name, NULL, NULL, NULL); + } + } + + /* avoid groups of the form opal_opal, ompi_ompi, etc */ + if (NULL != project_name && NULL != framework_name && + (0 == strcmp (project_name, framework_name))) { + project_name = NULL; + } + + /* build the group name */ + ret = mca_base_var_generate_full_name4 (NULL, project_name, framework_name, component_name, + &group->group_full_name); + if (OPAL_SUCCESS != ret) { + OBJ_RELEASE(group); + return ret; + } + + group_id = opal_pointer_array_add (&mca_base_var_groups, group); + if (0 > group_id) { + OBJ_RELEASE(group); + return OPAL_ERROR; + } + + mca_base_var_group_count++; + mca_base_var_groups_timestamp++; + + if (0 <= parent_id) { + mca_base_var_group_t *parent_group; + + (void) group_get(parent_id, &parent_group, false); + opal_value_array_append_item (&parent_group->group_subgroups, &group_id); + } + + return group_id; +} + +int mca_base_var_group_register (const char *project_name, const char *framework_name, + const char *component_name, const char *description) +{ + return group_register (project_name, framework_name, component_name, description); +} + +int mca_base_var_group_component_register (const mca_base_component_t *component, + const char *description) +{ + /* 1.7 components do not store the project */ + return group_register (NULL, component->mca_type_name, + component->mca_component_name, description); +} + + +int mca_base_var_group_deregister (int group_index) +{ + mca_base_var_group_t *group; + int size, i, ret; + int *params, *subgroups; + + ret = group_get (group_index, &group, false); + if (OPAL_SUCCESS != ret) { + return ret; + } + + group->group_isvalid = false; + + /* deregister all associated mca parameters */ + size = opal_value_array_get_size(&group->group_vars); + params = OPAL_VALUE_ARRAY_GET_BASE(&group->group_vars, int); + + for (i = 0 ; i < size ; ++i) { + (void) mca_base_var_deregister (params[i]); + } + OBJ_DESTRUCT(&group->group_vars); + OBJ_CONSTRUCT(&group->group_vars, opal_value_array_t); + + size = opal_value_array_get_size(&group->group_subgroups); + subgroups = OPAL_VALUE_ARRAY_GET_BASE(&group->group_subgroups, int); + for (i = 0 ; i < size ; ++i) { + (void) mca_base_var_group_deregister (subgroups[i]); + } + OBJ_DESTRUCT(&group->group_subgroups); + OBJ_CONSTRUCT(&group->group_subgroups, opal_value_array_t); + + mca_base_var_groups_timestamp++; + + return OPAL_SUCCESS; +} + +int mca_base_var_group_find (const char *project_name, + const char *framework_name, + const char *component_name) +{ + return group_find (project_name, framework_name, component_name, false); +} + +static int mca_base_var_group_add_var (const int group_index, const int param_index) +{ + mca_base_var_group_t *group; + int size, i, ret; + int *params; + + ret = group_get (group_index, &group, false); + if (OPAL_SUCCESS != ret) { + return ret; + } + + size = opal_value_array_get_size(&group->group_vars); + params = OPAL_VALUE_ARRAY_GET_BASE(&group->group_vars, int); + for (i = 0 ; i < size ; ++i) { + if (params[i] == param_index) { + return i; + } + } + + if (OPAL_SUCCESS != + (ret = opal_value_array_append_item (&group->group_vars, ¶m_index))) { + return ret; + } + + mca_base_var_groups_timestamp++; + + /* return the group index */ + return (int) opal_value_array_get_size (&group->group_vars) - 1; +} + +int mca_base_var_group_get (const int group_index, const mca_base_var_group_t **group) +{ + return group_get (group_index, (mca_base_var_group_t **) group, false); +} + +int mca_base_var_group_set_var_flag (const int group_index, mca_base_var_flag_t flags, bool set) +{ + mca_base_var_group_t *group; + int size, i, ret; + int *vars; + + ret = group_get (group_index, &group, false); + if (OPAL_SUCCESS != ret) { + return ret; + } + + /* set the flag on each valid variable */ + size = opal_value_array_get_size(&group->group_vars); + vars = OPAL_VALUE_ARRAY_GET_BASE(&group->group_vars, int); + + for (i = 0 ; i < size ; ++i) { + if (0 <= vars[i]) { + (void) mca_base_var_set_flag (vars[i], flags, set); + } + } + + return OPAL_SUCCESS; +} + + +/* + * Look up an integer MCA parameter. + */ +int mca_base_var_get_value (int index, const void *value, + mca_base_var_source_t *source, + const char **source_file) +{ + mca_base_var_t *var; + void **tmp = (void **) value; + int ret; + + ret = var_get (index, &var, true); + if (OPAL_SUCCESS != ret) { + return ret; + } + + if (!VAR_IS_VALID(var[0])) { + return OPAL_ERR_BAD_PARAM; + } + + if (NULL != value) { + /* Return a poiner to our backing store (either a char **, int *, + or bool *) */ + *tmp = var->mbv_storage; + } + + if (NULL != source) { + *source = var->mbv_source; + } + + if (NULL != source_file) { + *source_file = var->mbv_source_file; + } + + return OPAL_SUCCESS; +} + +static int var_set_unsigned_long_long (mca_base_var_t *var, unsigned long long value) +{ + var->mbv_storage->ullval = value; + return OPAL_SUCCESS; +} + +static int var_set_size_t (mca_base_var_t *var, size_t value) +{ + var->mbv_storage->sizetval = value; + return OPAL_SUCCESS; +} + +static int var_set_int (mca_base_var_t *var, int value) +{ + var->mbv_storage->intval = value; + return OPAL_SUCCESS; +} + +static int var_set_bool (mca_base_var_t *var, bool value) +{ + var->mbv_storage->boolval = value; + return OPAL_SUCCESS; +} + +static int var_set_string (mca_base_var_t *var, char *value) +{ + char *tmp, *p; + int ret; + + if (NULL != var->mbv_storage->stringval) { + free (var->mbv_storage->stringval); + } + + var->mbv_storage->stringval = NULL; + + if (NULL == value || 0 == strlen (value)) { + return OPAL_SUCCESS; + } + + /* Replace all instances of ~/ in a path-style string with the + user's home directory. This may be handled by the enumerator + in the future. */ + if (0 == strncmp (value, "~/", 2)) { + if (NULL != home) { + ret = asprintf (&value, "%s/%s", home, value + 2); + if (0 > ret) { + return OPAL_ERROR; + } + } else { + value = strdup (value + 2); + } + } else { + value = strdup (value); + } + + if (NULL == value) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + while (NULL != (tmp = strstr (value, ":~/"))) { + tmp[0] = '\0'; + tmp += 3; + + ret = asprintf (&tmp, "%s:%s%s%s", p, home ? home : "", home ? "/" : "", tmp); + + free (value); + + if (0 > ret) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + value = tmp; + } + + var->mbv_storage->stringval = value; + + return OPAL_SUCCESS; +} + +static int int_from_string(const char *src, mca_base_var_enum_t *enumerator, uint64_t *value_out) +{ + uint64_t value; + bool is_int; + char *tmp; + + if (NULL == src || 0 == strlen (src)) { + if (NULL == enumerator) { + *value_out = 0; + } + + return OPAL_SUCCESS; + } + + if (enumerator) { + int int_val, ret; + ret = enumerator->value_from_string(enumerator, src, &int_val); + if (OPAL_SUCCESS != ret) { + return ret; + } + *value_out = (uint64_t) int_val; + + return OPAL_SUCCESS; + } + + /* Check for an integer value */ + value = strtoull (src, &tmp, 0); + is_int = tmp[0] == '\0'; + + if (0 == strcasecmp (src, "true")) { + value = 1; + } else if (0 == strcasecmp (src, "false")) { + value = 0; + } else if (!is_int && tmp != src) { + switch (tmp[0]) { + case 'G': + case 'g': + value <<= 10; + case 'M': + case 'm': + value <<= 10; + case 'K': + case 'k': + value <<= 10; + break; + default: + break; + } + } + + *value_out = value; + + return OPAL_SUCCESS; +} + +static int var_set_from_string (mca_base_var_t *var, char *src) +{ + mca_base_var_storage_t *dst = var->mbv_storage; + uint64_t int_value; + int ret; + + switch (var->mbv_type) { + case MCA_BASE_VAR_TYPE_INT: + case MCA_BASE_VAR_TYPE_UNSIGNED_INT: + case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: + case MCA_BASE_VAR_TYPE_BOOL: + case MCA_BASE_VAR_TYPE_SIZE_T: + ret = int_from_string(src, var->mbv_enumerator, &int_value); + if (OPAL_ERR_VALUE_OUT_OF_BOUNDS == ret || + (MCA_BASE_VAR_TYPE_INT == var->mbv_type && + (sizeof(int) < 8 && (int_value & 0xffffffff00000000ull)))) { + if (var->mbv_enumerator) { + char *valid_values; + (void) var->mbv_enumerator->dump(var->mbv_enumerator, &valid_values); + opal_show_help("help-mca-var.txt", "invalid-value-enum", + true, var->mbv_full_name, src, valid_values); + free(valid_values); + } else { + opal_show_help("help-mca-var.txt", "invalid-value", + true, var->mbv_full_name, src); + } + + return OPAL_ERR_VALUE_OUT_OF_BOUNDS; + } + + if (MCA_BASE_VAR_TYPE_INT == var->mbv_type || + MCA_BASE_VAR_TYPE_UNSIGNED_INT == var->mbv_type) { + dst->intval = (int) int_value; + } else if (MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG == var->mbv_type) { + dst->ullval = (unsigned long long) int_value; + } else if (MCA_BASE_VAR_TYPE_SIZE_T == var->mbv_type) { + dst->sizetval = (size_t) int_value; + } else if (MCA_BASE_VAR_TYPE_BOOL == var->mbv_type) { + dst->boolval = !!int_value; + } + + return ret; + case MCA_BASE_VAR_TYPE_STRING: + var_set_string (var, src); + break; + case MCA_BASE_VAR_TYPE_MAX: + return OPAL_ERROR; + } + + return OPAL_SUCCESS; +} + +/* + * Set a variable + */ +int mca_base_var_set_value (int index, void *value, size_t size, mca_base_var_source_t source, + const char *source_file) +{ + mca_base_var_t *var; + int ret; + + ret = var_get (index, &var, true); + if (OPAL_SUCCESS != ret) { + return ret; + } + + if (!VAR_IS_VALID(var[0])) { + return OPAL_ERR_BAD_PARAM; + } + + if (!VAR_IS_SETTABLE(var[0])) { + return OPAL_ERR_PERM; + } + + /* Does index represent a synonym */ + if (var->mbv_index != index) { + } + + + switch (var->mbv_type) { + case MCA_BASE_VAR_TYPE_INT: + case MCA_BASE_VAR_TYPE_UNSIGNED_INT: + if (NULL != var->mbv_enumerator) { + /* Validate */ + ret = var->mbv_enumerator->string_from_value(var->mbv_enumerator, + ((int *) value)[0], NULL); + if (OPAL_SUCCESS != ret) { + return ret; + } + } + + var_set_int (var, ((int *) value)[0]); + + break; + case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: + var_set_unsigned_long_long(var, ((unsigned long long *) value)[0]); + break; + case MCA_BASE_VAR_TYPE_SIZE_T: + var_set_size_t(var, ((size_t *) value)[0]); + break; + case MCA_BASE_VAR_TYPE_BOOL: + var_set_bool (var, ((bool *) value)[0]); + break; + case MCA_BASE_VAR_TYPE_STRING: + var_set_string (var, (char *) value); + break; + case MCA_BASE_VAR_TYPE_MAX: + return OPAL_ERR_BAD_PARAM; + } + + var->mbv_source = source; + + if (MCA_BASE_VAR_SOURCE_FILE == source && NULL != source_file) { + var->mbv_source_file = append_filename_to_list(source_file); + } + + return OPAL_SUCCESS; +} + +/* + * Deregister a parameter + */ +int mca_base_var_deregister(int index) +{ + mca_base_var_t *var; + int ret; + + ret = var_get (index, &var, false); + if (OPAL_SUCCESS != ret) { + return ret; + } + + if (!VAR_IS_VALID(var[0])) { + return OPAL_ERR_BAD_PARAM; + } + + /* Mark this parameter as invalid but keep its info in case this + parameter is reregistered later */ + var->mbv_flags &= ~MCA_BASE_VAR_FLAG_VALID; + + /* Done deregistering synonym */ + if (MCA_BASE_VAR_FLAG_SYNONYM & var->mbv_flags) { + return OPAL_SUCCESS; + } + + /* Release the current value if it is a string. */ + if (MCA_BASE_VAR_TYPE_STRING == var->mbv_type && + var->mbv_storage->stringval) { + free (var->mbv_storage->stringval); + var->mbv_storage->stringval = NULL; + } else if (NULL != var->mbv_enumerator) { + OBJ_RELEASE(var->mbv_enumerator); + var->mbv_enumerator = NULL; + } + + var->mbv_storage = NULL; + + return OPAL_SUCCESS; +} + +static int var_get (int index, mca_base_var_t **var_out, bool original) +{ + mca_base_var_t *var; + + if (var_out) { + *var_out = NULL; + } + + /* Check for bozo cases */ + if (!initialized) { + return OPAL_ERROR; + } + + if (index < 0) { + return OPAL_ERR_BAD_PARAM; + } + + var = opal_pointer_array_get_item (&mca_base_vars, index); + if (NULL == var) { + return OPAL_ERR_BAD_PARAM; + } + + if (VAR_IS_SYNONYM(var[0]) && original) { + return var_get(var->mbv_synonym_for, var_out, false); + } + + if (var_out) { + *var_out = var; + } + + return OPAL_SUCCESS; +} + +int mca_base_var_env_name(const char *param_name, + char **env_name) +{ + int ret; + + assert (NULL != env_name); + + ret = asprintf(env_name, "%s%s", mca_prefix, param_name); + if (0 > ret) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + return OPAL_SUCCESS; +} + +/* + * Find the index for an MCA parameter based on its names. + */ +static int var_find (const char *project_name, const char *framework_name, + const char *component_name, const char *variable_name, + bool invalidok) +{ + mca_base_var_group_t *group; + size_t i, size; + int group_id; + int *vars; + + /* Check for bozo cases */ + if (!initialized) { + return OPAL_ERROR; + } + + /* XXX -- CHANGE -- remove this after component update */ + project_name = NULL; + + /* Loop through looking for a parameter of a given framework/component/variable */ + group_id = group_find (project_name, framework_name, component_name, false); + if (0 > group_id) { + return OPAL_ERR_NOT_FOUND; + } + + (void) group_get (group_id, &group, false); + + vars = OPAL_VALUE_ARRAY_GET_BASE(&group->group_vars, int); + size = opal_value_array_get_size(&group->group_vars); + + for (i = 0 ; i < size ; ++i) { + mca_base_var_t *var = NULL; + + (void) var_get (vars[i], &var, false); + if (NULL == var) { + continue; + } + + if ((invalidok || VAR_IS_VALID(var[0])) && + 0 == compare_strings (variable_name, var->mbv_variable_name)) { + return vars[i]; + } + } + + /* Didn't find it */ + return OPAL_ERROR; +} + +/* + * Find the index for an MCA parameter based on its names. + */ +int mca_base_var_find (const char *project_name, const char *framework_name, + const char *component_name, const char *variable_name) +{ + return var_find (project_name, framework_name, component_name, variable_name, false); +} + +int mca_base_var_set_flag (int index, mca_base_var_flag_t flag, bool set) +{ + mca_base_var_t *var; + int ret; + + ret = var_get (index, &var, true); + if (OPAL_SUCCESS != ret || VAR_IS_SYNONYM(var[0])) { + return OPAL_ERR_BAD_PARAM; + } + + var->mbv_flags = (var->mbv_flags & ~flag) | (set ? flag : 0); + + /* All done */ + return OPAL_SUCCESS; +} + +/* + * Return info on a parameter at an index + */ +int mca_base_var_get (int index, const mca_base_var_t **var) +{ + return var_get (index, (mca_base_var_t **) var, false); +} + +/* + * Make an argv-style list of strings suitable for an environment + */ +int mca_base_var_build_env(char ***env, int *num_env, bool internal) +{ + mca_base_var_t *var; + size_t i, len; + + /* Check for bozo cases */ + + if (!initialized) { + return OPAL_ERROR; + } + + /* Iterate through all the registered parameters */ + + len = opal_pointer_array_get_size(&mca_base_vars); + for (i = 0; i < len; ++i) { + char *str = NULL; + + var = opal_pointer_array_get_item (&mca_base_vars, i); + if (NULL == var) { + continue; + } + + /* Don't output default values or internal variables (unless + requested) */ + if (MCA_BASE_VAR_SOURCE_DEFAULT == var->mbv_source || + (!internal && VAR_IS_INTERNAL(var[0]))) { + continue; + } + + switch (var->mbv_type) { + case MCA_BASE_VAR_TYPE_INT: + asprintf(&str, "%s%s=%d", mca_prefix, var->mbv_full_name, + var->mbv_storage->intval); + break; + case MCA_BASE_VAR_TYPE_UNSIGNED_INT: + asprintf(&str, "%s%s=%u", mca_prefix, var->mbv_full_name, + var->mbv_storage->uintval); + break; + case MCA_BASE_VAR_TYPE_BOOL: + asprintf(&str, "%s%s=%s", mca_prefix, var->mbv_full_name, + var->mbv_storage->boolval ? "true" : "false"); + break; + case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: + asprintf(&str, "%s%s=%llu", mca_prefix, var->mbv_full_name, + var->mbv_storage->ullval); + break; + case MCA_BASE_VAR_TYPE_SIZE_T: + asprintf(&str, "%s%s=%" PRIsize_t, mca_prefix, var->mbv_full_name, + var->mbv_storage->sizetval); + break; + case MCA_BASE_VAR_TYPE_STRING: + if (NULL != var->mbv_storage->stringval) { + asprintf(&str, "%s%s=%s", mca_prefix, var->mbv_full_name, + var->mbv_storage->stringval); + } + break; + case MCA_BASE_VAR_TYPE_MAX: + goto cleanup; + } + + if (NULL != str) { + opal_argv_append(num_env, env, str); + free(str); + } + + switch (var->mbv_source) { + case MCA_BASE_VAR_SOURCE_FILE: + case MCA_BASE_VAR_SOURCE_OVERRIDE: + asprintf (&str, "%sSOURCE_%s=FILE:%s", mca_prefix, var->mbv_full_name, + var->mbv_source_file); + break; + case MCA_BASE_VAR_SOURCE_COMMAND_LINE: + asprintf (&str, "%sSOURCE_%s=COMMAND_LINE", mca_prefix, var->mbv_full_name); + break; + case MCA_BASE_VAR_SOURCE_ENV: + case MCA_BASE_VAR_SOURCE_SET: + case MCA_BASE_VAR_SOURCE_DEFAULT: + str = NULL; + break; + case MCA_BASE_VAR_SOURCE_MAX: + goto cleanup; + } + + if (NULL != str) { + opal_argv_append(num_env, env, str); + free(str); + } + } + + /* All done */ + + return OPAL_SUCCESS; + + /* Error condition */ + + cleanup: + if (*num_env > 0) { + opal_argv_free(*env); + *num_env = 0; + *env = NULL; + } + return OPAL_ERR_NOT_FOUND; +} + +/* + * Shut down the MCA parameter system (normally only invoked by the + * MCA framework itself). + */ +int mca_base_var_finalize(void) +{ + opal_object_t *object; + opal_list_item_t *item; + int size, i; + + if (initialized) { + size = opal_pointer_array_get_size(&mca_base_vars); + for (i = 0 ; i < size ; ++i) { + object = opal_pointer_array_get_item (&mca_base_vars, i); + if (NULL != object) { + OBJ_RELEASE(object); + } + } + OBJ_DESTRUCT(&mca_base_vars); + + while (NULL != + (item = opal_list_remove_first(&mca_base_var_file_values))) { + OBJ_RELEASE(item); + } + OBJ_DESTRUCT(&mca_base_var_file_values); + + while (NULL != + (item = opal_list_remove_first(&mca_base_var_override_values))) { + OBJ_RELEASE(item); + } + OBJ_DESTRUCT(&mca_base_var_override_values); + + if( NULL != cwd ) { + free(cwd); + cwd = NULL; + } + + size = opal_pointer_array_get_size(&mca_base_var_groups); + for (i = 0 ; i < size ; ++i) { + object = opal_pointer_array_get_item (&mca_base_var_groups, + i); + if (NULL != object) { + OBJ_RELEASE(object); + } + } + OBJ_DESTRUCT(&mca_base_var_groups); + + initialized = false; + mca_base_var_count = 0; + mca_base_var_group_count = 0; + + if (NULL != mca_base_var_file_list) { + opal_argv_free(mca_base_var_file_list); + } + } + + /* All done */ + + return OPAL_SUCCESS; +} + + +/*************************************************************************/ +static int fixup_files(char **file_list, char * path, bool rel_path_search) { + int exit_status = OPAL_SUCCESS; + char **files = NULL; + char **search_path = NULL; + char * tmp_file = NULL; + char **argv = NULL; + int mode = R_OK; /* The file exists, and we can read it */ + int count, i, argc = 0; + + search_path = opal_argv_split(path, OPAL_ENV_SEP); + files = opal_argv_split(*file_list, OPAL_ENV_SEP); + count = opal_argv_count(files); + + /* Read in reverse order, so we can preserve the original ordering */ + for (i = 0 ; i < count; ++i) { + /* Absolute paths preserved */ + if ( opal_path_is_absolute(files[i]) ) { + if( NULL == opal_path_access(files[i], NULL, mode) ) { + opal_show_help("help-mca-var.txt", "missing-param-file", + true, getpid(), files[i], path); + exit_status = OPAL_ERROR; + goto cleanup; + } + else { + opal_argv_append(&argc, &argv, files[i]); + } + } + /* Resolve all relative paths: + * - If filename contains a "/" (e.g., "./foo" or "foo/bar") + * - look for it relative to cwd + * - if exists, use it + * - ow warn/error + */ + else if (!rel_path_search && NULL != strchr(files[i], OPAL_PATH_SEP[0]) ) { + if( NULL != force_agg_path ) { + tmp_file = opal_path_access(files[i], force_agg_path, mode); + } + else { + tmp_file = opal_path_access(files[i], cwd, mode); + } + + if( NULL == tmp_file ) { + opal_show_help("help-mca-var.txt", "missing-param-file", + true, getpid(), files[i], cwd); + exit_status = OPAL_ERROR; + goto cleanup; + } + else { + opal_argv_append(&argc, &argv, tmp_file); + } + } + /* Resolve all relative paths: + * - Use path resolution + * - if found and readable, use it + * - otherwise, warn/error + */ + else { + if( NULL != (tmp_file = opal_path_find(files[i], search_path, mode, NULL)) ) { + opal_argv_append(&argc, &argv, tmp_file); + free(tmp_file); + tmp_file = NULL; + } + else { + opal_show_help("help-mca-var.txt", "missing-param-file", + true, getpid(), files[i], path); + exit_status = OPAL_ERROR; + goto cleanup; + } + } + } + + free(*file_list); + *file_list = opal_argv_join(argv, OPAL_ENV_SEP); + + cleanup: + if( NULL != files ) { + opal_argv_free(files); + files = NULL; + } + if( NULL != argv ) { + opal_argv_free(argv); + argv = NULL; + } + if( NULL != search_path ) { + opal_argv_free(search_path); + search_path = NULL; + } + if( NULL != tmp_file ) { + free(tmp_file); + tmp_file = NULL; + } + + return exit_status; +} + +static int read_files(char *file_list, opal_list_t *file_values) +{ + int i, count; + + /* Iterate through all the files passed in -- read them in reverse + order so that we preserve unix/shell path-like semantics (i.e., + the entries farthest to the left get precedence) */ + + mca_base_var_file_list = opal_argv_split(file_list, OPAL_ENV_SEP); + count = opal_argv_count(mca_base_var_file_list); + + for (i = count - 1; i >= 0; --i) { + mca_base_parse_paramfile(mca_base_var_file_list[i], file_values); + } + + return OPAL_SUCCESS; +} + +/******************************************************************************/ +static int register_variable (const char *project_name, const char *framework_name, + const char *component_name, const char *variable_name, + const char *description, mca_base_var_type_t type, + mca_base_var_enum_t *enumerator, int bind, + mca_base_var_flag_t flags, mca_base_var_info_lvl_t info_lvl, + mca_base_var_scope_t scope, int synonym_for, + void *storage) +{ + int ret, var_index, group; + mca_base_var_t *var; + + /* Developer error. Storage can not be NULL and type must exist */ + assert (((flags & MCA_BASE_VAR_FLAG_SYNONYM) || NULL != storage) && type >= 0 && type < MCA_BASE_VAR_TYPE_MAX); + + /* There are data holes in the var struct */ + OPAL_DEBUG_ZERO(var); + + /* Initialize the array if it has never been initialized */ + if (!initialized) { + mca_base_var_init(); + } + + /* XXX -- readd project name once it is available in the component structure */ + project_name = NULL; + + /* See if this entry is already in the array */ + var_index = var_find (project_name, framework_name, component_name, variable_name, + true); + + if (0 > var_index) { + /* Create a new parameter entry */ + group = group_register (project_name, framework_name, component_name, + NULL); + if (-1 > group) { + return group; + } + + /* Read-only and constant variables can't be settable */ + if (scope < MCA_BASE_VAR_SCOPE_LOCAL || (flags & MCA_BASE_VAR_FLAG_DEFAULT_ONLY)) { + if ((flags & MCA_BASE_VAR_FLAG_DEFAULT_ONLY) && (flags & MCA_BASE_VAR_FLAG_SETTABLE)) { + opal_show_help("help-mca-var.txt", "invalid-flag-combination", + true, "MCA_BASE_VAR_FLAG_DEFAULT_ONLY", "MCA_BASE_VAR_FLAG_SETTABLE"); + return OPAL_ERROR; + } + + /* Should we print a warning for other cases? */ + flags &= ~MCA_BASE_VAR_FLAG_SETTABLE; + } + + var = OBJ_NEW(mca_base_var_t); + + var->mbv_type = type; + var->mbv_flags = flags; + var->mbv_group_index = group; + var->mbv_info_lvl = info_lvl; + var->mbv_scope = scope; + var->mbv_synonym_for = synonym_for; + var->mbv_bind = bind; + + if (NULL != description) { + var->mbv_description = strdup(description); + } + + if (NULL != variable_name) { + var->mbv_variable_name = strdup(variable_name); + if (NULL == var->mbv_variable_name) { + OBJ_RELEASE(var); + return OPAL_ERR_OUT_OF_RESOURCE; + } + } + + ret = mca_base_var_generate_full_name4 (NULL, framework_name, component_name, + variable_name, &var->mbv_full_name); + if (OPAL_SUCCESS != ret) { + OBJ_RELEASE(var); + return OPAL_ERROR; + } + + ret = mca_base_var_generate_full_name4 (project_name, framework_name, component_name, + variable_name, &var->mbv_long_name); + if (OPAL_SUCCESS != ret) { + OBJ_RELEASE(var); + return OPAL_ERROR; + } + + /* Add it to the array. Note that we copy the mca_var_t by value, + so the entire contents of the struct is copied. The synonym list + will always be empty at this point, so there's no need for an + extra RETAIN or RELEASE. */ + var_index = opal_pointer_array_add (&mca_base_vars, var); + if (0 > var_index) { + OBJ_RELEASE(var); + return OPAL_ERROR; + } + + var->mbv_index = var_index; + + if (0 <= group) { + mca_base_var_group_add_var (group, var_index); + } + + mca_base_var_count++; + } else { + ret = var_get (var_index, &var, true); + if (OPAL_SUCCESS != ret) { + /* Shouldn't event happen */ + return OPAL_ERROR; + } + + if (var->mbv_type != type) { +#if OPAL_ENABLE_DEBUG + opal_show_help("help-mca-var.txt", + "re-register-with-different-type", + true, var->mbv_full_name); +#endif + return OPAL_ERR_VALUE_OUT_OF_BOUNDS; + } + } + + if (var->mbv_enumerator) { + OBJ_RELEASE (var->mbv_enumerator); + } + + if (NULL != enumerator) { + OBJ_RETAIN(enumerator); + } + + var->mbv_enumerator = enumerator; + + if (flags & MCA_BASE_VAR_FLAG_SYNONYM) { + mca_base_var_t *original = opal_pointer_array_get_item (&mca_base_vars, synonym_for); + + opal_value_array_append_item(&original->mbv_synonyms, &var_index); + } else { + var->mbv_storage = storage; + + /* make a copy of the default string value */ + if (MCA_BASE_VAR_TYPE_STRING == type && NULL != ((char **)storage)[0]) { + ((char **)storage)[0] = strdup (((char **)storage)[0]); + } + } + + ret = var_set_initial (var); + if (OPAL_SUCCESS != ret) { + return ret; + } + + var->mbv_flags |= MCA_BASE_VAR_FLAG_VALID; + + /* All done */ + return var_index; +} + +int mca_base_var_register (const char *project_name, const char *framework_name, + const char *component_name, const char *variable_name, + const char *description, mca_base_var_type_t type, + mca_base_var_enum_t *enumerator, int bind, + mca_base_var_flag_t flags, + mca_base_var_info_lvl_t info_lvl, + mca_base_var_scope_t scope, void *storage) +{ + /* Only integer variables can have enumerator */ + assert (NULL == enumerator || MCA_BASE_VAR_TYPE_INT == type); + + return register_variable (project_name, framework_name, component_name, + variable_name, description, type, enumerator, + bind, flags, info_lvl, scope, -1, storage); +} + +int mca_base_component_var_register (const mca_base_component_t *component, + const char *variable_name, const char *description, + mca_base_var_type_t type, mca_base_var_enum_t *enumerator, + int bind, mca_base_var_flag_t flags, + mca_base_var_info_lvl_t info_lvl, + mca_base_var_scope_t scope, void *storage) +{ + /* XXX -- component_update -- We will stash the project name in the component */ + return mca_base_var_register (NULL, component->mca_type_name, + component->mca_component_name, + variable_name, description, type, enumerator, + bind, flags, info_lvl, scope, storage); +} + +int mca_base_var_register_synonym (int synonym_for, const char *project_name, + const char *framework_name, + const char *component_name, + const char *synonym_name, + mca_base_var_syn_flag_t flags) +{ + mca_base_var_flag_t var_flags = MCA_BASE_VAR_FLAG_SYNONYM; + mca_base_var_t *var; + int ret; + + ret = var_get (synonym_for, &var, false); + if (OPAL_SUCCESS != ret || VAR_IS_SYNONYM(var[0])) { + return OPAL_ERR_BAD_PARAM; + } + + if (flags & MCA_BASE_VAR_SYN_FLAG_DEPRECATED) { + var_flags |= MCA_BASE_VAR_FLAG_DEPRECATED; + } + if (flags & MCA_BASE_VAR_SYN_FLAG_INTERNAL) { + var_flags |= MCA_BASE_VAR_FLAG_INTERNAL; + } + + return register_variable (project_name, framework_name, component_name, + synonym_name, NULL, var->mbv_type, var->mbv_enumerator, + var->mbv_bind, var_flags, var->mbv_info_lvl, var->mbv_scope, + synonym_for, NULL); +} + +/* + * Lookup a param in the environment + */ +static int var_set_from_env (mca_base_var_t *var) +{ + const char *var_full_name = var->mbv_full_name; + bool deprecated = VAR_IS_DEPRECATED(var[0]); + char *source, *source_env; + char *value, *value_env; + int ret; + + if (VAR_IS_SYNONYM(var[0])) { + ret = var_get (var->mbv_synonym_for, &var, true); + if (OPAL_SUCCESS != ret) { + return OPAL_ERROR; + } + + if (var->mbv_source >= MCA_BASE_VAR_SOURCE_ENV) { + return OPAL_SUCCESS; + } + } + + ret = asprintf (&source, "%sSOURCE_%s", mca_prefix, var_full_name); + if (0 > ret) { + return OPAL_ERROR; + } + + ret = asprintf (&value, "%s%s", mca_prefix, var_full_name); + if (0 > ret) { + free (source); + return OPAL_ERROR; + } + + source_env = getenv (source); + value_env = getenv (value); + + free (source); + free (value); + + if (NULL == value_env) { + return OPAL_ERR_NOT_FOUND; + } + + /* we found an environment variable but this variable is default-only. print + a warning. */ + if (VAR_IS_DEFAULT_ONLY(var[0])) { + opal_show_help("help-mca-var.txt", "default-only-param-set", + true, var_full_name); + + return OPAL_ERR_NOT_FOUND; + } + + if (MCA_BASE_VAR_SOURCE_OVERRIDE == var->mbv_source) { + if (!mca_base_var_suppress_override_warning) { + opal_show_help("help-mca-var.txt", "overridden-param-set", + true, var_full_name); + } + + return OPAL_ERR_NOT_FOUND; + } + + var->mbv_source = MCA_BASE_VAR_SOURCE_ENV; + + if (NULL != source_env) { + if (0 == strncasecmp (source_env, "file:", 5)) { + var->mbv_source_file = append_filename_to_list(source_env + 5); + if (0 == strcmp (var->mbv_source_file, mca_base_var_override_file)) { + var->mbv_source = MCA_BASE_VAR_SOURCE_OVERRIDE; + } else { + var->mbv_source = MCA_BASE_VAR_SOURCE_FILE; + } + } else if (0 == strcasecmp (source_env, "command")) { + var->mbv_source = MCA_BASE_VAR_SOURCE_COMMAND_LINE; + } + } + + if (deprecated) { + switch (var->mbv_source) { + case MCA_BASE_VAR_SOURCE_ENV: + opal_show_help("help-mca-var.txt", "deprecated-mca-env", + true, var->mbv_full_name); + break; + case MCA_BASE_VAR_SOURCE_COMMAND_LINE: + opal_show_help("help-mca-var.txt", "deprecated-mca-cli", + true, var->mbv_full_name); + break; + case MCA_BASE_VAR_SOURCE_FILE: + case MCA_BASE_VAR_SOURCE_OVERRIDE: + opal_show_help("help-mca-var.txt", "deprecated-mca-file", + true, var->mbv_full_name, var->mbv_source_file); + break; + + case MCA_BASE_VAR_SOURCE_DEFAULT: + case MCA_BASE_VAR_SOURCE_MAX: + case MCA_BASE_VAR_SOURCE_SET: + /* silence compiler warnings about unhandled enumerations */ + break; + } + } + + return var_set_from_string (var, value_env); +} + + +/* + * Lookup a param in the files + */ +static int var_set_from_file (mca_base_var_t *var, opal_list_t *file_values) +{ + const char *var_full_name = var->mbv_full_name; + const char *var_long_name = var->mbv_long_name; + bool deprecated = VAR_IS_DEPRECATED(var[0]); + mca_base_var_file_value_t *fv; + int ret; + + if (VAR_IS_SYNONYM(var[0])) { + ret = var_get (var->mbv_synonym_for, &var, true); + if (OPAL_SUCCESS != ret) { + return OPAL_ERROR; + } + + if (var->mbv_source >= MCA_BASE_VAR_SOURCE_FILE) { + return OPAL_SUCCESS; + } + } + + /* Scan through the list of values read in from files and try to + find a match. If we do, cache it on the param (for future + lookups) and save it in the storage. */ + + OPAL_LIST_FOREACH(fv, file_values, mca_base_var_file_value_t) { + if (0 != strcmp(fv->mbvfv_var, var_full_name) && + 0 != strcmp(fv->mbvfv_var, var_long_name)) { + continue; + } + + /* found it */ + if (VAR_IS_DEFAULT_ONLY(var[0])) { + opal_show_help("help-mca-var.txt", "default-only-param-set", + true, var_full_name); + + return OPAL_ERR_NOT_FOUND; + } + + if (MCA_BASE_VAR_FLAG_ENVIRONMENT_ONLY & var->mbv_flags) { + opal_show_help("help-mca-var.txt", "environment-only-param", + true, var_full_name, fv->mbvfv_value, + fv->mbvfv_file); + + return OPAL_ERR_NOT_FOUND; + } + + if (MCA_BASE_VAR_SOURCE_OVERRIDE == var->mbv_source) { + if (!mca_base_var_suppress_override_warning) { + opal_show_help("help-mca-var.txt", "overridden-param-set", + true, var_full_name); + } + + return OPAL_ERR_NOT_FOUND; + } + + if (deprecated) { + opal_show_help("help-mca-var.txt", "deprecated-mca-file", + true, var_full_name, fv->mbvfv_file); + } + + if (NULL != fv->mbvfv_file) { + var->mbv_source_file = fv->mbvfv_file; + if (NULL == var->mbv_source_file) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + } + + var->mbv_source = MCA_BASE_VAR_SOURCE_FILE; + + return var_set_from_string (var, fv->mbvfv_value); + } + + return OPAL_ERR_NOT_FOUND; +} + +/* + * Lookup the initial value for a parameter + */ +static int var_set_initial (mca_base_var_t *var) +{ + int ret; + + var->mbv_source = MCA_BASE_VAR_SOURCE_DEFAULT; + + /* Check all the places that the param may be hiding, in priority + order. If the default only flag is set the user will get a + warning if they try to set a value from the environment or a + file. */ + ret = var_set_from_file (var, &mca_base_var_override_values); + if (OPAL_SUCCESS == ret) { + var->mbv_flags = ~MCA_BASE_VAR_FLAG_SETTABLE & (var->mbv_flags | MCA_BASE_VAR_FLAG_OVERRIDE); + var->mbv_source = MCA_BASE_VAR_SOURCE_OVERRIDE; + } + + ret = var_set_from_env (var); + if (OPAL_ERR_NOT_FOUND != ret) { + return ret; + } + + ret = var_set_from_file (var, &mca_base_var_file_values); + if (OPAL_ERR_NOT_FOUND != ret) { + return ret; + } + + return OPAL_SUCCESS; +} + +/* + * Create an empty param container + */ +static void var_constructor(mca_base_var_t *var) +{ + memset ((char *) var + sizeof (var->super), 0, sizeof (*var) - sizeof (var->super)); + + var->mbv_type = MCA_BASE_VAR_TYPE_MAX; + OBJ_CONSTRUCT(&var->mbv_synonyms, opal_value_array_t); + opal_value_array_init (&var->mbv_synonyms, sizeof (int)); +} + + +/* + * Free all the contents of a param container + */ +static void var_destructor(mca_base_var_t *var) +{ + if (NULL != var->mbv_variable_name) { + free(var->mbv_variable_name); + } + if (NULL != var->mbv_full_name) { + free(var->mbv_full_name); + } + if (NULL != var->mbv_long_name) { + free(var->mbv_long_name); + } + if (NULL != var->mbv_description) { + free(var->mbv_description); + } + if (MCA_BASE_VAR_TYPE_STRING == var->mbv_type && + NULL != var->mbv_storage && + NULL != var->mbv_storage->stringval) { + free (var->mbv_storage->stringval); + } + + if (NULL != var->mbv_enumerator) { + OBJ_RELEASE(var->mbv_enumerator); + } + + /* Destroy the synonym array */ + OBJ_DESTRUCT(&var->mbv_synonyms); + + /* mark this parameter as invalid */ + var->mbv_type = MCA_BASE_VAR_TYPE_MAX; + +#if OPAL_ENABLE_DEBUG + /* Cheap trick to reset everything to NULL */ + memset ((char *) var + sizeof (var->super), 0, sizeof (*var) - sizeof (var->super)); +#endif +} + + +static void fv_constructor(mca_base_var_file_value_t *f) +{ + memset ((char *) f + sizeof (f->super), 0, sizeof (*f) - sizeof (f->super)); +} + + +static void fv_destructor(mca_base_var_file_value_t *f) +{ + if (NULL != f->mbvfv_var) { + free(f->mbvfv_var); + } + if (NULL != f->mbvfv_value) { + free(f->mbvfv_value); + } + /* the file name is stored in mca_*/ + fv_constructor(f); +} + +static void mca_base_var_group_constructor (mca_base_var_group_t *group) +{ + memset ((char *) group + sizeof (group->super), 0, sizeof (*group) - sizeof (group->super)); + + OBJ_CONSTRUCT(&group->group_subgroups, opal_value_array_t); + opal_value_array_init (&group->group_subgroups, sizeof (int)); + + OBJ_CONSTRUCT(&group->group_vars, opal_value_array_t); + opal_value_array_init (&group->group_vars, sizeof (int)); +} + +static void mca_base_var_group_destructor (mca_base_var_group_t *group) +{ + free (group->group_full_name); + group->group_full_name = NULL; + + free (group->group_description); + group->group_description = NULL; + + free (group->group_project); + group->group_project = NULL; + + free (group->group_framework); + group->group_framework = NULL; + + free (group->group_component); + group->group_component = NULL; + + OBJ_DESTRUCT(&group->group_subgroups); + OBJ_DESTRUCT(&group->group_vars); +} + +static char *source_name(mca_base_var_t *var) +{ + char *ret; + int rc; + + switch (var->mbv_source) { + case MCA_BASE_VAR_SOURCE_DEFAULT: + return strdup ("default value"); + case MCA_BASE_VAR_SOURCE_COMMAND_LINE: + return strdup ("command line"); + case MCA_BASE_VAR_SOURCE_ENV: + return strdup ("environment variable"); + case MCA_BASE_VAR_SOURCE_FILE: + rc = asprintf(&ret, "file (%s)", var->mbv_source_file); + /* some compilers will warn if the return code of asprintf is not checked (even if it is cast to void) */ + if (0 > rc) { + return NULL; + } + return ret; + case MCA_BASE_VAR_SOURCE_OVERRIDE: + return strdup ("override file"); + case MCA_BASE_VAR_SOURCE_SET: + return strdup ("code"); + case MCA_BASE_VAR_SOURCE_MAX: + break; + /* don't define a default so we get a warning if for unhandled enum variables */ + } + + return strdup ("unknown (!)"); +} + +int mca_base_var_check_exclusive (const char *project, + const char *type_a, + const char *component_a, + const char *param_a, + const char *type_b, + const char *component_b, + const char *param_b) +{ + mca_base_var_t *var_a, *var_b; + int var_ai, var_bi; + + /* XXX -- Remove me once the project name is in the componennt */ + project = NULL; + + var_ai = mca_base_var_find (project, type_a, component_a, param_a); + if (var_ai < 0) { + return OPAL_ERR_NOT_FOUND; + } + + var_bi = mca_base_var_find (project, type_b, component_b, param_b); + if (var_bi < 0) { + return OPAL_ERR_NOT_FOUND; + } + + (void) var_get (var_ai, &var_a, true); + (void) var_get (var_bi, &var_b, true); + + if (MCA_BASE_VAR_SOURCE_DEFAULT != var_a->mbv_source && + MCA_BASE_VAR_SOURCE_DEFAULT != var_b->mbv_source) { + char *str_a, *str_b; + + /* Form cosmetic string names for A */ + str_a = source_name(var_a); + + /* Form cosmetic string names for B */ + str_b = source_name(var_b); + + /* Print it all out */ + opal_show_help("help-mca-var.txt", + "mutually-exclusive-vars", + true, var_a->mbv_full_name, + str_a, var_b->mbv_full_name, + str_b); + + /* Free the temp strings */ + free(str_a); + free(str_b); + + return OPAL_ERR_BAD_PARAM; + } + + return OPAL_SUCCESS; +} + +int mca_base_var_get_count (void) +{ + return mca_base_var_count; +} + +int mca_base_var_group_get_count (void) +{ + return mca_base_var_group_count; +} + +int mca_base_var_group_get_stamp (void) +{ + return mca_base_var_groups_timestamp; +} + +int mca_base_var_dump(int index, char ***out, mca_base_var_dump_type_t output_type) +{ + const char *project, *framework, *component, *full_name; + int i, line_count, line = 0, enum_count = 0; + char *value_string, *source_string, *tmp; + const mca_base_var_storage_t *value; + int synonym_count, ret, *synonyms; + mca_base_var_t *var, *original; + mca_base_var_group_t *group; + const char *type_string; + + ret = var_get(index, &var, false); + if (OPAL_SUCCESS != ret) { + return ret; + } + + ret = group_get(var->mbv_group_index, &group, false); + if (OPAL_SUCCESS != ret) { + return ret; + } + + if (VAR_IS_SYNONYM(var[0])) { + ret = var_get(var->mbv_synonym_for, &original, false); + if (OPAL_SUCCESS != ret) { + return ret; + } + } + + ret = mca_base_var_get_value(index, &value, NULL, NULL); + if (OPAL_SUCCESS !=ret) { + return ret; + } + + project = group->group_project; + framework = group->group_framework; + component = group->group_component ? group->group_component : "base"; + full_name = var->mbv_full_name; + + synonym_count = opal_value_array_get_size(&var->mbv_synonyms); + if (synonym_count) { + synonyms = OPAL_VALUE_ARRAY_GET_BASE(&var->mbv_synonyms, int); + } + + if (NULL == var->mbv_enumerator) { + switch (var->mbv_type) { + case MCA_BASE_VAR_TYPE_INT: + ret = asprintf (&value_string, "%d", value->intval); + type_string = "integer"; + break; + case MCA_BASE_VAR_TYPE_UNSIGNED_INT: + ret = asprintf (&value_string, "%u", value->uintval); + type_string = "unsigned integer"; + break; + case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: + ret = asprintf (&value_string, "%llu", value->ullval); + type_string = "unsigned long long"; + break; + case MCA_BASE_VAR_TYPE_SIZE_T: + ret = asprintf (&value_string, "%" PRIsize_t, value->sizetval); + type_string = "size_t"; + break; + case MCA_BASE_VAR_TYPE_BOOL: + ret = asprintf (&value_string, value->boolval ? "true" : "false"); + type_string = "boolean"; + break; + case MCA_BASE_VAR_TYPE_STRING: + ret = asprintf (&value_string, "%s", value->stringval ? value->stringval : ""); + type_string = "string"; + break; + case MCA_BASE_VAR_TYPE_MAX: + return OPAL_ERROR; + } + } else { + const char *tmp; + type_string = "integer"; + ret = var->mbv_enumerator->string_from_value(var->mbv_enumerator, value->intval, &tmp); + + /* Sanity Check */ + assert (OPAL_SUCCESS == ret); + + value_string = strdup (tmp); + } + + if (0 > ret) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + source_string = source_name(var); + + if (MCA_BASE_VAR_DUMP_PARSABLE == output_type) { + if (NULL != var->mbv_enumerator) { + (void) var->mbv_enumerator->get_count(var->mbv_enumerator, &enum_count); + } + + line_count = 7 + (var->mbv_description ? 1 : 0) + (VAR_IS_SYNONYM(var[0]) ? 1 : synonym_count) + + enum_count; + + *out = (char **) calloc (line_count + 1, sizeof (char *)); + if (NULL == *out) { + free (value_string); + free (source_string); + return OPAL_ERR_OUT_OF_RESOURCE; + } + + /* build the message*/ + asprintf(&tmp, "mca:%s:%s:param:%s:", framework, component, + full_name); + + /* Output the value */ + asprintf(out[0] + line++, "%svalue:%s", tmp, value_string); + free(value_string); + + /* Output the source */ + asprintf(out[0] + line++, "%ssource:%s", tmp, source_string); + free(source_string); + + /* Output whether it's read only or writable */ + asprintf(out[0] + line++, "%sstatus:%s", tmp, VAR_IS_DEFAULT_ONLY(var[0]) ? "read-only" : "writeable"); + + /* If it has a help message, output the help message */ + if (var->mbv_description) { + asprintf(out[0] + line++, "%shelp:%s", tmp, var->mbv_description); + } + + if (NULL != var->mbv_enumerator) { + for (i = 0 ; i < enum_count ; ++i) { + const char *enum_string = NULL; + int enum_value; + + ret = var->mbv_enumerator->get_value(var->mbv_enumerator, i, &enum_value, + &enum_string); + if (OPAL_SUCCESS != ret) { + continue; + } + + asprintf(out[0] + line++, "%senumerator:value:%d:%s", tmp, enum_value, enum_string); + } + } + + /* Is this variable deprecated? */ + asprintf(out[0] + line++, "%sdeprecated:%s", tmp, VAR_IS_DEPRECATED(var[0]) ? "yes" : "no"); + + asprintf(out[0] + line++, "%stype:%s", tmp, type_string); + + /* Does this parameter have any synonyms or is it a synonym? */ + if (VAR_IS_SYNONYM(var[0])) { + asprintf(out[0] + line++, "%ssynonym_of:name:%s", tmp, original->mbv_full_name); + } else if (opal_value_array_get_size(&var->mbv_synonyms)) { + for (i = 0 ; i < synonym_count ; ++i) { + mca_base_var_t *synonym; + + ret = var_get(synonyms[i], &synonym, false); + if (OPAL_SUCCESS != ret) { + continue; + } + + asprintf(out[0] + line++, "%ssynonym:name:%s", tmp, synonym->mbv_full_name); + } + } + + free (tmp); + } else if (MCA_BASE_VAR_DUMP_READABLE == output_type) { + /* There will be at most three lines in the pretty print case */ + *out = (char **) calloc (4, sizeof (char *)); + if (NULL == *out) { + free (value_string); + free (source_string); + return OPAL_ERR_OUT_OF_RESOURCE; + } + + asprintf (out[0], "%s \"%s\" (current value: \"%s\", data source: %s", + VAR_IS_DEFAULT_ONLY(var[0]) ? "informational" : "parameter", + full_name, value_string, source_string); + free (value_string); + free (source_string); + + tmp = out[0][0]; + if (VAR_IS_DEPRECATED(var[0])) { + asprintf (out[0], "%s, deprecated", tmp); + tmp = out[0][0]; + } + + /* Does this parameter have any synonyms or is it a synonym? */ + if (VAR_IS_SYNONYM(var[0])) { + asprintf(out[0], "%s, synonym of: %s)", tmp, original->mbv_full_name); + free (tmp); + } else if (synonym_count) { + asprintf(out[0], "%s, synonyms: ", tmp); + free (tmp); + + for (i = 0 ; i < synonym_count ; ++i) { + mca_base_var_t *synonym; + + ret = var_get(synonyms[i], &synonym, false); + if (OPAL_SUCCESS != ret) { + continue; + } + + tmp = out[0][0]; + if (synonym_count == i+1) { + asprintf(out[0], "%s%s)", tmp, synonym->mbv_full_name); + } else { + asprintf(out[0], "%s%s, ", tmp, synonym->mbv_full_name); + } + free(tmp); + } + } else { + asprintf(out[0], "%s)", tmp); + free(tmp); + } + + line++; + + if (var->mbv_description) { + asprintf(out[0] + line++, "%s", var->mbv_description); + } + + if (NULL != var->mbv_enumerator) { + char *values; + + ret = var->mbv_enumerator->dump(var->mbv_enumerator, &values); + if (OPAL_SUCCESS == ret) { + asprintf (out[0] + line++, "Valid values: %s", values); + free (values); + } + } + } else if (MCA_BASE_VAR_DUMP_SIMPLE == output_type) { + *out = (char **) calloc (2, sizeof (char *)); + if (NULL == *out) { + free (value_string); + free (source_string); + return OPAL_ERR_OUT_OF_RESOURCE; + } + + asprintf(out[0], "%s=%s (%s)", var->mbv_full_name, value_string, source_string); + + free (value_string); + free (source_string); + } + + return OPAL_SUCCESS; +} diff --git a/opal/mca/base/mca_base_var.h b/opal/mca/base/mca_base_var.h new file mode 100644 index 0000000000..ab30df3ba7 --- /dev/null +++ b/opal/mca/base/mca_base_var.h @@ -0,0 +1,794 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2006 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +/** @file + * This file presents the MCA variable interface. + * + * Note that there are two scopes for MCA variables: "normal" and + * attributes. Specifically, all MCA variables are "normal" -- some + * are special and may also be found on attributes on communicators, + * datatypes, or windows. + * + * In general, these functions are intended to be used as follows: + * + * - Creating MCA variables + * -# Register a variable, get an index back + * - Using MCA variables + * -# Lookup a "normal" variable value on a specific index, or + * -# Lookup an attribute variable on a specific index and + * communicator / datatype / window. + * + * MCA variables can be defined in multiple different places. As + * such, variables are \em resolved to find their value. The order + * of resolution is as follows: + * + * - An "override" location that is only available to be set via the + * mca_base_param API. + * - Look for an environment variable corresponding to the MCA + * variable. + * - See if a file contains the MCA variable (MCA variable files are + * read only once -- when the first time any mca_param_t function is + * invoked). + * - If nothing else was found, use the variable's default value. + * + * Note that there is a second header file (mca_base_vari.h) + * that contains several internal type delcarations for the variable + * system. The internal file is only used within the variable system + * itself; it should not be required by any other Open MPI entities. + */ + +#ifndef OPAL_MCA_BASE_VAR_H +#define OPAL_MCA_BASE_VAR_H + +#include "opal_config.h" + +#include "opal/class/opal_list.h" +#include "opal/class/opal_value_array.h" +#include "opal/mca/base/mca_base_var_enum.h" +#include "opal/mca/mca.h" + +/** + * The types of MCA variables. + */ +typedef enum { + /** The variable is of type int. */ + MCA_BASE_VAR_TYPE_INT, + /** The variable is of type unsigned int */ + MCA_BASE_VAR_TYPE_UNSIGNED_INT, + /** The variable is of type unsigned long long */ + MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG, + /** The variable is of type size_t */ + MCA_BASE_VAR_TYPE_SIZE_T, + /** The variable is of type string. */ + MCA_BASE_VAR_TYPE_STRING, + /** The variable is of type bool */ + MCA_BASE_VAR_TYPE_BOOL, + /** Maximum variable type. */ + MCA_BASE_VAR_TYPE_MAX +} mca_base_var_type_t; + + +/** + * Source of an MCA variable's value + */ +typedef enum { + /** The default value */ + MCA_BASE_VAR_SOURCE_DEFAULT, + /** The value came from the command line */ + MCA_BASE_VAR_SOURCE_COMMAND_LINE, + /** The value came from the environment */ + MCA_BASE_VAR_SOURCE_ENV, + /** The value came from a file */ + MCA_BASE_VAR_SOURCE_FILE, + /** The value came a "set" API call */ + MCA_BASE_VAR_SOURCE_SET, + /** The value came from the override file */ + MCA_BASE_VAR_SOURCE_OVERRIDE, + + /** Maximum source type */ + MCA_BASE_VAR_SOURCE_MAX +} mca_base_var_source_t; + +/** + * MCA variable scopes + * + * Equivalent to MPIT scopes + */ +typedef enum { + /** The value of this variable will not change after it + is registered. Implies !MCA_BASE_VAR_FLAG_SETTABLE */ + MCA_BASE_VAR_SCOPE_CONSTANT, + /** The value of this variable may change but it should not be + changed using the mca_base_var_set function. Implies + !MCA_BASE_VAR_FLAG_SETTABLE */ + MCA_BASE_VAR_SCOPE_READONLY, + /** The value of this variable may be changed locally. */ + MCA_BASE_VAR_SCOPE_LOCAL, + /** The value of this variable must be set to a consistent value + within a group */ + MCA_BASE_VAR_SCOPE_GROUP, + /** The value of this variable must be set to the same value + within a group */ + MCA_BASE_VAR_SCOPE_GROUP_EQ, + /** The value of this variable must be set to a consistent value + for all processes */ + MCA_BASE_VAR_SCOPE_ALL, + /** The value of this variable must be set to the same value + for all processes */ + MCA_BASE_VAR_SCOPE_ALL_EQ, + MCA_BASE_VAR_SCOPE_MAX +} mca_base_var_scope_t; + +typedef enum { + OPAL_INFO_LVL_1, + OPAL_INFO_LVL_2, + OPAL_INFO_LVL_3, + OPAL_INFO_LVL_4, + OPAL_INFO_LVL_5, + OPAL_INFO_LVL_6, + OPAL_INFO_LVL_7, + OPAL_INFO_LVL_8, + OPAL_INFO_LVL_9, + OPAL_INFO_LVL_MAX +} mca_base_var_info_lvl_t; + +typedef enum { + MCA_BASE_VAR_SYN_FLAG_DEPRECATED = 0x0001, + MCA_BASE_VAR_SYN_FLAG_INTERNAL = 0x0002 +} mca_base_var_syn_flag_t; + +typedef enum { + /** Variable is internal (hidden from *_info/MPIT) */ + MCA_BASE_VAR_FLAG_INTERNAL = 0x0001, + /** Variable will always be the default value. Implies + !MCA_BASE_VAR_FLAG_SETTABLE */ + MCA_BASE_VAR_FLAG_DEFAULT_ONLY = 0x0002, + /** Variable can be set with mca_base_var_set() */ + MCA_BASE_VAR_FLAG_SETTABLE = 0x0004, + /** Variable is deprecated */ + MCA_BASE_VAR_FLAG_DEPRECATED = 0x0008, + /** Variable has been overridden */ + MCA_BASE_VAR_FLAG_OVERRIDE = 0x0010, + /** Variable may not be set from a file */ + MCA_BASE_VAR_FLAG_ENVIRONMENT_ONLY = 0x0020 +} mca_base_var_flag_t; + + +/** + * Types for MCA parameters. + */ +typedef union { + /** Integer value */ + int intval; + /** Unsigned int value */ + unsigned int uintval; + /** String value */ + char *stringval; + /** Boolean value */ + bool boolval; + /** unsigned long long value */ + unsigned long long ullval; + /** size_t value */ + size_t sizetval; +} mca_base_var_storage_t; + + +/** + * Entry for holding information about an MCA variable. + */ +struct mca_base_var_t { + /** Allow this to be an OPAL OBJ */ + opal_object_t super; + + /** Variable index. This will remain constant until mca_base_var_finalize() + is called. */ + int mbv_index; + /** Group index. This will remain constant until mca_base_var_finalize() + is called. This variable will be deregistered if the associated group + is deregistered with mca_base_var_group_deregister() */ + int mbv_group_index; + + /** Info level of this variable */ + mca_base_var_info_lvl_t mbv_info_lvl; + + /** Enum indicating the type of the variable (integer, string, boolean) */ + mca_base_var_type_t mbv_type; + + /** String of the variable name */ + char *mbv_variable_name; + /** Full variable name, in case it is not __ */ + char *mbv_full_name; + /** Long variable name ___ */ + char *mbv_long_name; + + /** List of synonym names for this variable. This *must* be a + pointer (vs. a plain opal_list_t) because we copy this whole + struct into a new var for permanent storage + (opal_vale_array_append_item()), and the internal pointers in + the opal_list_t will be invalid when that happens. Hence, we + simply keep a pointer to an external opal_list_t. Synonyms + are uncommon enough that this is not a big performance hit. */ + opal_value_array_t mbv_synonyms; + + /** Variable flags */ + mca_base_var_flag_t mbv_flags; + + /** Variable scope */ + mca_base_var_scope_t mbv_scope; + + /** Source of the current value */ + mca_base_var_source_t mbv_source; + + /** Synonym for */ + int mbv_synonym_for; + + /** Variable description */ + char *mbv_description; + + /** File the value came from */ + char *mbv_source_file; + + /** Value enumerator (only valid for integer variables) */ + mca_base_var_enum_t *mbv_enumerator; + + /** Bind value for this variable (0 - none) */ + int mbv_bind; + + /** Storage for this variable */ + mca_base_var_storage_t *mbv_storage; +}; +/** + * Convenience typedef. + */ +typedef struct mca_base_var_t mca_base_var_t; + +struct mca_base_var_group_t { + opal_list_item_t super; + + /** Index of group */ + int group_index; + + /** Group is valid (registered) */ + bool group_isvalid; + + /** Group name */ + char *group_full_name; + + char *group_project; + char *group_framework; + char *group_component; + + /** Group help message (description) */ + char *group_description; + + /** Integer value array of subgroup indices */ + opal_value_array_t group_subgroups; + + /** Integer array of group variables */ + opal_value_array_t group_vars; +}; + +typedef struct mca_base_var_group_t mca_base_var_group_t; + +/* + * Global functions for MCA + */ + +BEGIN_C_DECLS + +/** + * Object declarayion for mca_base_var_t + */ +OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_base_var_t); + + +/** + * Object declaration for mca_base_var_group_t + */ +OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_base_var_group_t); + +/** + * Initialize the MCA variable system. + * + * @retval OPAL_SUCCESS + * + * This function initalizes the MCA variable system. It is + * invoked internally (by mca_base_open()) and is only documented + * here for completeness. + */ +OPAL_DECLSPEC int mca_base_var_init(void); + +/** + * Register an MCA variable group + * + * @param[in] project_name Project name for this group. + * @param[in] framework_name Framework name for this group. + * @param[in] component_name Component name for this group. + * @param[in] descrition Description of this group. + * + * @retval index Unique group index + * @return opal error code on Error + * + * Create an MCA variable group. If the group already exists + * this call is equivalent to mca_base_ver_find_group(). + */ +OPAL_DECLSPEC int mca_base_var_group_register(const char *project_name, + const char *framework_name, + const char *component_name, + const char *description); + +/** + * Register an MCA variable group for a component + * + * @param[in] component [in] Pointer to the component for which the + * group is being registered. + * @param[in] description Description of this group. + * + * @retval index Unique group index + * @return opal error code on Error + */ +OPAL_DECLSPEC int mca_base_var_group_component_register (const mca_base_component_t *component, + const char *description); + +/** + * Deregister an MCA param group + * + * @param group_index [in] Group index from mca_base_var_group_register (), + * mca_base_var_group_find(). + * + * This call deregisters all associated variables and subgroups. + */ +OPAL_DECLSPEC int mca_base_var_group_deregister (int group_index); + +/** + * Find an MCA group + * + * @param project_name [in] Project name + * @param framework_name [in] Type name + * @param component_name [in] Component name + */ +OPAL_DECLSPEC int mca_base_var_group_find (const char *project_name, + const char *framework_name, + const char *component_name); + +/** + * Dump info from a group + * + * @param[in] group_index Group index + * @param[out] group Storage for the group object pointer. + * + * @retval OPAL_ERR_NOT_FOUND If the group specified by group_index does not exist. + * @retval OPAL_ERR_OUT_OF_RESOURCE If memory allocation fails. + * @retval OPAL_SUCCESS If the group is dumped successfully. + * + * The returned pointer belongs to the MCA variable system. Do not modify/release/retain + * the pointer. + */ +OPAL_DECLSPEC int mca_base_var_group_get (const int group_index, + const mca_base_var_group_t **group); + +/** + * Set/unset a flags for all variables in a group. + * + * @param[in] group_index Index of group + * @param[in] flag Flag(s) to set or unset. + * @param[in] set Boolean indicating whether to set flag(s). + * + * Set a flag for every variable in a group. See mca_base_var_set_flag() for more info. + */ +OPAL_DECLSPEC int mca_base_var_group_set_var_flag (const int group_index, + mca_base_var_flag_t flags, + bool set); + +/** + * Get the number of registered MCA groups + * + * @retval count Number of registered MCA groups + */ +OPAL_DECLSPEC int mca_base_var_group_get_count (void); + +/** + * Get a relative timestamp for the MCA group system + * + * @retval stamp + * + * This value will change if groups or variables are either added or removed. + */ +OPAL_DECLSPEC int mca_base_var_group_get_stamp (void); + +/** + * Register an MCA variable + * + * @param[in] project_name The name of the project associated with + * this variable + * @param[in] framework_name The name of the framework associated with + * this variable + * @param[in] component_name The name of the component associated with + * this variable + * @param[in] variable_name The name of this variable + * @param[in] description A string describing the use and valid + * values of the variable (string). + * @param[in] type The type of this variable (string, int, bool). + * @param[in] enumerator Enumerator describing valid values. + * @param[in] bind Hint for MPIT to specify type of binding (0 = none) + * @param[in] flags Flags for this variable. + * @param[in] info_lvl Info level of this variable + * @param[in] scope Indicates the scope of this variable + * @param[in,out] storage Pointer to the value's location. + * + * @retval index Index value representing this variable. + * @retval OPAL_ERR_OUT_OF_RESOURCE Upon failure to allocate memory. + * @retval OPAL_ERROR Upon failure to register the variable. + * + * This function registers an MCA variable and associates it + * with a specific group. + * + * The {description} is a string of arbitrary length (verbose is + * good!) for explaining what the variable is for and what its + * valid values are. This message is used in help messages, such + * as the output from the ompi_info executable. + * + * The {enumerator} describes the valid values of an integer + * variable. The variable may be set to either the enumerator value + * (0, 1, 2, etc) or a string representing that value. The + * value provided by the user will be compared against the + * values in the enumerator. The {enumerator} is not valid with + * any other type of variable. {enumerator} is retained until + * either the variable is deregistered using mca_base_var_deregister(), + * mca_base_var_group_deregister(), or mca_base_var_finalize(). + * + * The {flags} indicate attributes of this variable (internal, + * settable, default only, etc). + * + * If MCA_BASE_VAR_FLAG_SETTABLE is set in {flags}, this variable + * may be set using mca_base_var_set_value(). + * + * If MCA_BASE_VAR_FLAG_INTERNAL is set in {flags}, this variable + * is not shown by default in the output of ompi_info. That is, + * this variable is considered internal to the Open MPI implementation + * and is not supposed to be viewed / changed by the user. + * + * If MCA_BASE_VAR_FLAG_DEFAULT_ONLY is set in {flags}, then the + * value provided in storage will not be modified by the MCA + * variable system. It is up to the caller to specify (using the scope) + * if this value may change (MCA_BASE_VAR_SCOPE_READONLY) + * or remain constant (MCA_BASE_VAR_SCOPE_CONSTANT). + * MCA_BASE_VAR_FLAG_DEFAULT_ONLY must not be specified with + * MCA_BASE_VAR_FLAG_SETTABLE. + * + * Set MCA_BASE_VAR_FLAG_DEPRECATED in {flags} to indicate that + * this variable name is deprecated. The user will get a warning + * if they set this variable. + * + * The {scope} is for informational purposes to indicate how this + * variable should be set or if it is considered constant or readonly. + * A readonly scope means something different than setting {read_only} + * to true. A readonly scope will still allow the variable to be + * overridden by a file or environment variable. + * + * The {storage} pointer points to a char *, int, or bool where the + * value of this variable is stored. The {type} indicates the type + * of this pointer. The initial value passed to this function may + * be overwritten if the MCA_BASE_VAR_FLAG_DEFAULT_ONLY flag is not + * set and either an environment variable or a file value for this + * variable is set. If {storage} points to a char * the value will + * be duplicated and it is up to the caller to retain and free the + * original value if needed. Any string value set when this + * variable is deregistered (including finalize) will be freed + * automatically. + */ +OPAL_DECLSPEC int mca_base_var_register (const char *project_name, const char *framework_name, + const char *component_name, const char *variable_name, + const char *description, mca_base_var_type_t type, + mca_base_var_enum_t *enumerator, int bind, mca_base_var_flag_t flags, + mca_base_var_info_lvl_t info_lvl, + mca_base_var_scope_t scope, void *storage); + +/** + * Convinience function for registering a variable associated with a component. + * See mca_base_var_register(). + */ +OPAL_DECLSPEC int mca_base_component_var_register (const mca_base_component_t *component, + const char *variable_name, const char *description, + mca_base_var_type_t type, mca_base_var_enum_t *enumerator, + int bind, mca_base_var_flag_t flags, + mca_base_var_info_lvl_t info_lvl, + mca_base_var_scope_t scope, void *storage); + +/** + * Register a synonym name for an MCA variable. + * + * @param[in] synonym_for The index of the original variable. This index + * must not refer to a synonym. + * @param[in] project_name The project this synonym belongs to. Should + * not be NULL (except for legacy reasons). + * @param[in] framework_name The framework this synonym belongs to. + * @param[in] component_name The component this synonym belongs to. + * @param[in] synonym_name The synonym name. + * @param[in] flags Flags for this synonym. + * + * @returns index Variable index for new synonym on success. + * @returns OPAL_ERR_BAD_VAR If synonym_for does not reference a valid + * variable. + * @returns OPAL_ERR_OUT_OF_RESOURCE If memory could not be allocated. + * @returns OPAL_ERROR For all other errors. + * + * Upon success, this function creates a synonym MCA variable + * that will be treated almost exactly like the original. The + * type (int or string) is irrelevant; this function simply + * creates a new name that by which the same variable value is + * accessible. + * + * Note that the original variable name has precendence over all + * synonyms. For example, consider the case if variable is + * originally registered under the name "A" and is later + * registered with synonyms "B" and "C". If the user sets values + * for both MCA variable names "A" and "B", the value associated + * with the "A" name will be used and the value associated with + * the "B" will be ignored (and will not even be visible by the + * mca_base_var_*() API). If the user sets values for both MCA + * variable names "B" and "C" (and does *not* set a value for + * "A"), it is undefined as to which value will be used. + */ +OPAL_DECLSPEC int mca_base_var_register_synonym (int synonym_for, const char *project_name, + const char *framework_name, + const char *component_name, + const char *synonym_name, + mca_base_var_syn_flag_t flags); + +/** + * Deregister a MCA variable or synonym + * + * @param index Index returned from mca_base_var_register() or + * mca_base_var_register_synonym(). + * + * Deregistering a variable does not free the index or any memory assoicated + * with the variable. All memory will be freed and the index released when + * mca_base_var_finalize() is called. + * + * If an enumerator is associated with this variable it will be dereferenced. + */ +OPAL_DECLSPEC int mca_base_var_deregister(int index); + + +/** + * Get the current value of an MCA variable. + * + * @param[in] index Index of variable + * @param[in,out] value Pointer to copy the value to. Can be NULL. + * @param[in,out] value_size Size of memory pointed to by value. + * copied size will be returned in value_size. + * @param[out] source Source of current value. Can be NULL. + * @param[out] source_file Source file for the current value if + * it was set from a file. + * + * @return OPAL_ERROR Upon failure. The contents of value are + * undefined. + * @return OPAL_SUCCESS Upon success. value (if not NULL) will be filled + * with the variable's current value. value_size will contain the size + * copied. source (if not NULL) will contain the source of the variable. + * + * Note: The value can be changed by the registering code without using + * the mca_base_var_* interface so the source may be incorrect. + */ +OPAL_DECLSPEC int mca_base_var_get_value (int index, const void *value, + mca_base_var_source_t *source, + const char **source_file); + +/** + * Sets an "override" value for an integer MCA variable. + * + * @param[in] index Index of MCA variable to set + * @param[in] value Pointer to the value to set. Should point to + * a char * for string variables or a int * for integer variables. + * @param[in] size Size of value. + * @param[in] source Source of this value. + * @param[in] source_file Source file if source is MCA_BASE_VAR_SOURCE_FILE. + * + * @retval OPAL_SUCCESS Upon success. + * @retval OPAL_ERR_PERM If the variable is not settable. + * @retval OPAL_ERR_BAD_PARAM If the variable does not exist or has + * been deregistered. + * @retval OPAL_ERROR On other error. + * + * This function sets the value of an MCA variable. This value will + * overwrite the current value of the variable (or if index represents + * a synonym the variable the synonym represents) if the value is + * settable. + */ +OPAL_DECLSPEC int mca_base_var_set_value (int index, void *value, size_t size, + mca_base_var_source_t source, + const char *source_file); + +/** + * Get the string name corresponding to the MCA variable + * value in the environment. + * + * @param param_name Name of the type containing the variable. + * + * @retval string A string suitable for setenv() or appending to + * an environ-style string array. + * @retval NULL Upon failure. + * + * The string that is returned is owned by the caller; if + * appropriate, it must be eventually freed by the caller. + */ +OPAL_DECLSPEC int mca_base_var_env_name(const char *param_name, + char **env_name); + +/** + * Find the index for an MCA variable based on its names. + * + * @param type Name of the type containing the variable. + * @param component Name of the component containing the variable. + * @param param Name of the variable. + * + * @retval OPAL_ERROR If the variable was not found. + * @retval index If the variable was found. + * + * It is not always convenient to widely propagate a variable's index + * value, or it may be necessary to look up the variable from a + * different component -- where it is not possible to have the return + * value from mca_base_var_reg_int() or mca_base_var_reg_string(). + * This function can be used to look up the index of any registered + * variable. The returned index can be used with + * mca_base_var_lookup_int() and mca_base_var_lookup_string(). + */ +OPAL_DECLSPEC int mca_base_var_find (const char *project_name, + const char *type_name, + const char *component_name, + const char *param_name); + +/** + * Check that two MCA variables were not both set to non-default + * values. + * + * @param type_a [in] Framework name of variable A (string). + * @param component_a [in] Component name of variable A (string). + * @param param_a [in] Variable name of variable A (string. + * @param type_b [in] Framework name of variable A (string). + * @param component_b [in] Component name of variable A (string). + * @param param_b [in] Variable name of variable A (string. + * + * This function is useful for checking that the user did not set both + * of 2 mutually-exclusive MCA variables. + * + * This function will print an opal_show_help() message and return + * OPAL_ERR_BAD_VAR if it finds that the two variables both have + * value sources that are not MCA_BASE_VAR_SOURCE_DEFAULT. This + * means that both variables have been set by the user (i.e., they're + * not default values). + * + * Note that opal_show_help() allows itself to be hooked, so if this + * happens after the aggregated orte_show_help() system is + * initialized, the messages will be aggregated (w00t). + * + * @returns OPAL_ERR_BAD_VAR if the two variables have sources that + * are not MCA_BASE_VAR_SOURCE_DEFAULT. + * @returns OPAL_SUCCESS otherwise. + */ +OPAL_DECLSPEC int mca_base_var_check_exclusive (const char *project, + const char *type_a, + const char *component_a, + const char *param_a, + const char *type_b, + const char *component_b, + const char *param_b); + +/** + * Set or unset a flag on a variable. + * + * @param[in] index Index of variable + * @param[in] flag Flag(s) to set or unset. + * @param[in] set Boolean indicating whether to set flag(s). + * + * @returns OPAL_SUCCESS If the flags are set successfully. + * @returns OPAL_ERR_BAD_PARAM If the variable is not registered. + * @returns OPAL_ERROR Otherwise + */ +OPAL_DECLSPEC int mca_base_var_set_flag(int index, mca_base_var_flag_t flag, + bool set); + +/** + * Obtain basic info on a single variable (name, help message, etc) + * + * @param[in] index Valid variable index. + * @param[out] var Storage for the variable pointer. + * + * @retval OPAL_SUCCESS Upon success. + * @retval opal error code Upon failure. + * + * The returned pointer belongs to the MCA variable system. Do not + * modify/free/retain the pointer. + */ +OPAL_DECLSPEC int mca_base_var_get (int index, const mca_base_var_t **var); + +/** + * Obtain the number of variables that have been registered. + * + * @retval count on success + * @return opal error code on error + * + * Note: This function does not return the number of valid MCA variables as + * mca_base_var_deregister() has no impact on the variable count. The count + * returned is equal to the number of calls to mca_base_var_register with + * unique names. ie. two calls with the same name will not affect the count. + */ +OPAL_DECLSPEC int mca_base_var_get_count (void); + +/** + * Obtain a list of enironment variables describing the all + * valid (non-default) MCA variables and their sources. + * + * @param[out] env A pointer to an argv-style array of key=value + * strings, suitable for use in an environment + * @param[out] num_env A pointer to an int, containing the length + * of the env array (not including the final NULL entry). + * @param[in] internal Whether to include internal variables. + * + * @retval OPAL_SUCCESS Upon success. + * @retval OPAL_ERROR Upon failure. + * + * This function is similar to mca_base_var_dump() except that + * its output is in terms of an argv-style array of key=value + * strings, suitable for using in an environment. + */ +OPAL_DECLSPEC int mca_base_var_build_env(char ***env, int *num_env, + bool internal); + +/** + * Shut down the MCA variable system (normally only invoked by the + * MCA framework itself). + * + * @returns OPAL_SUCCESS This function never fails. + * + * This function shuts down the MCA variable repository and frees all + * associated memory. No other mca_base_var*() functions can be + * invoked after this function. + * + * This function is normally only invoked by the MCA framework itself + * when the process is shutting down (e.g., during MPI_FINALIZE). It + * is only documented here for completeness. + */ +OPAL_DECLSPEC int mca_base_var_finalize(void); + +typedef enum { + MCA_BASE_VAR_DUMP_READABLE = 0, + MCA_BASE_VAR_DUMP_PARSABLE = 1, + MCA_BASE_VAR_DUMP_SIMPLE = 2, +} mca_base_var_dump_type_t; + +/** + * Dump strings for variable at index. + * + * @param[in] index Variable index + * @param[out] out Array of strings representing this variable + * @param[in] flags Flags indication how to output variable + * + * This functions returns an array strings for the variable. All strings and the array + * need to be freed by the caller. + */ +OPAL_DECLSPEC int mca_base_var_dump(int index, char ***out, mca_base_var_dump_type_t output_type); + +END_C_DECLS + +#endif /* OPAL_MCA_BASE_VAR_H */ diff --git a/opal/mca/base/mca_base_var_enum.c b/opal/mca/base/mca_base_var_enum.c new file mode 100644 index 0000000000..005def4ca4 --- /dev/null +++ b/opal/mca/base/mca_base_var_enum.c @@ -0,0 +1,189 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2012 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" + +#include "opal/mca/base/mca_base_var_enum.h" + +#include +#include +#include + +static void mca_base_var_enum_constructor (mca_base_var_enum_t *enumerator); +static void mca_base_var_enum_destructor (mca_base_var_enum_t *enumerator); +OBJ_CLASS_INSTANCE(mca_base_var_enum_t, opal_object_t, + mca_base_var_enum_constructor, + mca_base_var_enum_destructor); + +int mca_base_var_enum_create (char *name, mca_base_var_enum_value_t *values, mca_base_var_enum_t **enumerator) +{ + mca_base_var_enum_t *new_enum; + int i; + + *enumerator = NULL; + + new_enum = OBJ_NEW(mca_base_var_enum_t); + if (NULL == new_enum) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + new_enum->enum_name = strdup (name); + if (NULL == new_enum->enum_name) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + new_enum->enum_values = values; + + for (i = 0 ; new_enum->enum_values[i].string ; ++i); + new_enum->enum_value_count = i; + + *enumerator = new_enum; + + return OPAL_SUCCESS; +} + +static int enum_dump (mca_base_var_enum_t *self, char **out) +{ + size_t len, i; + char *tmp; + int ret; + + *out = NULL; + + if (NULL == self) { + return OPAL_ERROR; + } + + tmp = NULL; + for (i = 0, len = 0 ; self->enum_values[i].string ; ++i) { + ret = asprintf (out, "%s%s%d:\"%s\"", tmp ? tmp : "", tmp ? ", " : "", self->enum_values[i].value, + self->enum_values[i].string); + if (tmp) free (tmp); + if (0 > ret) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + tmp = *out; + } + + return OPAL_SUCCESS; +} + +static int enum_get_count (mca_base_var_enum_t *self, int *count) +{ + *count = self->enum_value_count; + return OPAL_SUCCESS; +} + +static int enum_get_value (mca_base_var_enum_t *self, int index, int *value, const char **string_value) +{ + int count, ret; + + ret = self->get_count(self, &count); + if (OPAL_SUCCESS != ret) { + return ret; + } + + if (index >= count) { + return OPAL_ERR_VALUE_OUT_OF_BOUNDS; + } + + if (value) { + *value = self->enum_values[index].value; + } + + if (string_value) { + *string_value = self->enum_values[index].string; + } + + return OPAL_SUCCESS; +} + +static int enum_value_from_string(mca_base_var_enum_t *self, const char *string_value, int *value_out) { + int value, count, ret, i; + bool is_int; + char *tmp; + + ret = self->get_count(self, &count); + if (OPAL_SUCCESS != ret) { + return ret; + } + + value = strtol(string_value, &tmp, 0); + + /* Check if the string is an integer */ + is_int = tmp[0] == '\0'; + + for (i = 0 ; i < count ; ++i) { + if ((is_int && value == self->enum_values[i].value) || + 0 == strcasecmp (string_value, self->enum_values[i].string)) { + break; + } + } + + if (i == count) { + return OPAL_ERR_VALUE_OUT_OF_BOUNDS; + } + + *value_out = self->enum_values[i].value; + + return OPAL_SUCCESS; +} + +static int enum_string_from_value(mca_base_var_enum_t *self, const int value, const char **string_value) { + int count, ret, i; + + ret = self->get_count(self, &count); + if (OPAL_SUCCESS != ret) { + return ret; + } + + for (i = 0 ; i < count ; ++i) { + if (value == self->enum_values[i].value) { + break; + } + } + + if (i == count) { + return OPAL_ERR_VALUE_OUT_OF_BOUNDS; + } + + if (string_value) { + *string_value = self->enum_values[i].string; + } + + return OPAL_SUCCESS; +} + +static void mca_base_var_enum_constructor (mca_base_var_enum_t *enumerator) +{ + memset ((char *) enumerator + sizeof (enumerator->super), 0 , sizeof(*enumerator) - sizeof(enumerator->super)); + + enumerator->get_value = enum_get_value; + enumerator->get_count = enum_get_count; + enumerator->value_from_string = enum_value_from_string; + enumerator->string_from_value = enum_string_from_value; + enumerator->dump = enum_dump; +} + +static void mca_base_var_enum_destructor (mca_base_var_enum_t *enumerator) +{ +} diff --git a/opal/mca/base/mca_base_var_enum.h b/opal/mca/base/mca_base_var_enum.h new file mode 100644 index 0000000000..86009187cc --- /dev/null +++ b/opal/mca/base/mca_base_var_enum.h @@ -0,0 +1,151 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2006 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#if !defined(MCA_BASE_VAR_ENUM_H) +#define MCA_BASE_VAR_ENUM_H + +#include "opal/class/opal_object.h" +#include "opal/include/opal/constants.h" + +typedef struct mca_base_var_enum_t mca_base_var_enum_t; + +/** + * Get the number of values in the enumerator + * + * @param[in] self the enumerator + * @param[out] count the number of values in the enumerator + */ +typedef int (*mca_base_var_enum_get_count_fn_t)(mca_base_var_enum_t *self, int *count); + +/** + * Get the value and its string representation for an index 0..get_count() + * + * @param[in] self the enumerator + * @param[in] index the index to get the value of + * @param[out] value integer value + * @param[out] string_value string value + */ +typedef int (*mca_base_var_enum_get_value_fn_t)(mca_base_var_enum_t *self, int index, + int *value, const char **string_value); + +/** + * Look up the integer value of a string + * + * @param[in] self the enumerator + * @param[in] string_value string to lookup + * @param[out] value integer value for the string + * + * @retval OPAL_SUCCESS if found + * @retval OPAL_ERR_VALUE_OUT_OF_BOUNDS if not + */ +typedef int (*mca_base_var_enum_vfs_fn_t)(mca_base_var_enum_t *self, const char *string_value, + int *value); + +/** + * Dump a textual representation of all the values in an enumerator + * + * @param[in] self the enumerator + * @param[out] out the string representation + * + * @retval OPAL_SUCCESS on success + * @retval opal error on error + */ +typedef int (*mca_base_var_enum_dump_fn_t)(mca_base_var_enum_t *self, char **out); + +/** + * Get the string representation for an enumerator value + * + * @param[in] self the enumerator + * @param[in] value integer value + * @param[out] string_value string value for value + * + * @retval OPAL_SUCCESS on success + * @retval OPAL_ERR_VALUE_OUT_OF_BOUNDS if not found + */ +typedef int (*mca_base_var_enum_sfv_fn_t)(mca_base_var_enum_t *self, const int value, + const char **string_value); + +/** + * The default enumerator class takes in a list of integer-string pairs. If a + * string is read from an environment variable or a file value the matching + * integer value is used for the MCA variable. + */ +struct mca_base_var_enum_value_t { + const int value; + const char *string; +}; + +typedef struct mca_base_var_enum_value_t mca_base_var_enum_value_t; + +/* enumerator base class */ +struct mca_base_var_enum_t { + opal_object_t super; + + /** Name of this enumerator. This value is duplicated from the argument provided to + mca_base_var_enum_create() */ + char *enum_name; + + /** Get the number of values this enumerator represents. Subclasses should override + the default function. */ + mca_base_var_enum_get_count_fn_t get_count; + /** Get the value and string representation for a particular index. Subclasses should + override the default function */ + mca_base_var_enum_get_value_fn_t get_value; + /** Given a string return corresponding integer value. If the string does not match a + valid value return OPAL_ERR_VALUE_OUT_OF_BOUNDS */ + mca_base_var_enum_vfs_fn_t value_from_string; + /** Given an integer return the corresponding string value. If the integer does not + mathach a valid value return OPAL_ERR_VALUE_OUT_OF_BOUNDS */ + mca_base_var_enum_sfv_fn_t string_from_value; + /** Dump a textual representation of the enumerator. The caller is responsible for + freeing the string */ + mca_base_var_enum_dump_fn_t dump; + + int enum_value_count; + mca_base_var_enum_value_t *enum_values; +}; + +/** + * Object declaration for mca_base_var_enum_t + */ +OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_base_var_enum_t); + +/** + * Create a new default enumerator + * + * @param[in] name Name for this enumerator + * @param[in] values List of values terminated with a NULL .string + * member. + * @param[out] enumerator Newly created enumerator. + * + * @retval OPAL_SUCCESS On success + * @retval opal error code On error + * + * This function creates a value enumerator for integer variables. The + * value array is stored by reference in the enumerator so it should not + * be allocated on the stack. The returned enumerator should be released with + * OBJ_RELEASE. + */ +OPAL_DECLSPEC int mca_base_var_enum_create (char *name, mca_base_var_enum_value_t values[], + mca_base_var_enum_t **enumerator); + +#endif /* !defined(MCA_BASE_VAR_ENUM_H) */ diff --git a/opal/mca/base/mca_base_vari.h b/opal/mca/base/mca_base_vari.h new file mode 100644 index 0000000000..2e1feccc7f --- /dev/null +++ b/opal/mca/base/mca_base_vari.h @@ -0,0 +1,108 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2006 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2012 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +/** + * @file + * + * This is the private declarations for the MCA parameter system. + * This file is internal to the MCA parameter system and should not + * need to be used by any other elements in Open MPI except the + * special case of the ompi_info command. + * + * All the rest of the doxygen documentation in this file is marked as + * "internal" and won't show up unless you specifically tell doxygen + * to generate internal documentation (by default, it is skipped). + */ + +#ifndef OPAL_MCA_BASE_VAR_INTERNAL_H +#define OPAL_MCA_BASE_VAR_INTERNAL_H + +#include "opal_config.h" + +#include "opal/class/opal_object.h" +#include "opal/class/opal_list.h" +#include "opal/class/opal_value_array.h" +#include "opal/mca/base/mca_base_var.h" + +BEGIN_C_DECLS + +/* Internal flags start at bit 16 */ +#define MCA_BASE_VAR_FLAG_EXTERNAL_MASK 0x0000ffff + +typedef enum { + /** Variable is valid */ + MCA_BASE_VAR_FLAG_VALID = 0x00010000, + /** Variable is a synonym */ + MCA_BASE_VAR_FLAG_SYNONYM = 0x00020000, + /** mbv_source_file needs to be freed */ + MCA_BASE_VAR_FLAG_SOURCE_FILE_NEEDS_FREE = 0x00040000 +} mca_base_var_flag_internal_t; + +#define VAR_FLAG_ISSET(var, flag) (!!((var).mbp_flags & (flag))) + +#define VAR_IS_VALID(var) (!!((var).mbv_flags & MCA_BASE_VAR_FLAG_VALID)) +#define VAR_IS_SYNONYM(var) (!!((var).mbv_flags & MCA_BASE_VAR_FLAG_SYNONYM)) +#define VAR_IS_INTERNAL(var) (!!((var).mbv_flags & MCA_BASE_VAR_FLAG_INTERNAL)) +#define VAR_IS_DEFAULT_ONLY(var) (!!((var).mbv_flags & MCA_BASE_VAR_FLAG_DEFAULT_ONLY)) +#define VAR_IS_SETTABLE(var) (!!((var).mbv_flags & MCA_BASE_VAR_FLAG_SETTABLE)) +#define VAR_IS_DEPRECATED(var) (!!((var).mbv_flags & MCA_BASE_VAR_FLAG_DEPRECATED)) + + +/** + * \internal + * + * Structure for holding param names and values read in from files. + */ +struct mca_base_var_file_value_t { + /** Allow this to be an OPAL OBJ */ + opal_list_item_t super; + + /** Parameter name */ + char *mbvfv_var; + /** Parameter value */ + char *mbvfv_value; + /** File it came from */ + char *mbvfv_file; +}; +/** + * \internal + * + * Convenience typedef + */ +typedef struct mca_base_var_file_value_t mca_base_var_file_value_t; + +/** + * Object declaration for mca_base_var_file_value_t + */ +OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_base_var_file_value_t); + + +/** + * \internal + * + * Parse a parameter file. + */ +OPAL_DECLSPEC int mca_base_parse_paramfile(const char *paramfile, opal_list_t *list); + +END_C_DECLS + +#endif /* OPAL_MCA_BASE_VAR_INTERNAL_H */ diff --git a/opal/mca/compress/base/compress_base_open.c b/opal/mca/compress/base/compress_base_open.c index 53f0f69f6d..19ce062c3a 100644 --- a/opal/mca/compress/base/compress_base_open.c +++ b/opal/mca/compress/base/compress_base_open.c @@ -38,6 +38,22 @@ opal_compress_base_module_t opal_compress = { opal_list_t opal_compress_base_components_available; opal_compress_base_component_t opal_compress_base_selected_component; +static int opal_compress_base_verbose = 0; + +static int opal_compress_base_register(int flags) +{ + /* Debugging/Verbose output */ + opal_compress_base_verbose = 0; + (void) mca_base_var_register("opal", "compress", "base", "verbose", + "Verbosity level of the COMPRESS framework", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &opal_compress_base_verbose); + + return OPAL_SUCCESS; +} + /** * Function for finding and opening either all MCA components, * or the one that was specifically requested via a MCA parameter. @@ -45,32 +61,15 @@ opal_compress_base_component_t opal_compress_base_selected_component; int opal_compress_base_open(void) { int ret, exit_status = OPAL_SUCCESS; - int value; - char *str_value = NULL; - /* Debugging/Verbose output */ - mca_base_param_reg_int_name("compress", - "base_verbose", - "Verbosity level of the COMPRESS framework", - false, false, - 0, &value); - if(0 != value) { + (void) opal_compress_base_register(0); + + if(0 != opal_compress_base_verbose) { opal_compress_base_output = opal_output_open(NULL); } else { opal_compress_base_output = -1; } - opal_output_set_verbosity(opal_compress_base_output, value); - - /* - * Which COMPRESS component to open - * - NULL or "" = auto-select - * - "none" = Empty component - * - ow. select that specific component - */ - mca_base_param_reg_string_name("compress", NULL, - "Which COMPRESS component to use (empty = auto-select)", - false, false, - NULL, &str_value); + opal_output_set_verbosity(opal_compress_base_output, opal_compress_base_verbose); /* Compression currently only used with C/R */ if( !opal_cr_is_enabled ) { @@ -85,17 +84,18 @@ int opal_compress_base_open(void) mca_compress_base_static_components, &opal_compress_base_components_available, true)) ) { - if( OPAL_ERR_NOT_FOUND == ret && - NULL != str_value && - 0 == strncmp(str_value, "none", strlen("none")) ) { - exit_status = OPAL_SUCCESS; - } else { - exit_status = OPAL_ERROR; + exit_status = OPAL_ERROR; + if( OPAL_ERR_NOT_FOUND == ret) { + const char **str_value = NULL; + + ret = mca_base_var_find("opal", "compress", NULL, NULL); + mca_base_var_get_value(ret, &str_value, NULL, NULL); + if (NULL != str_value && NULL != str_value[0] && + 0 == strncmp(str_value[0], "none", strlen("none"))) { + exit_status = OPAL_SUCCESS; + } } } - if( NULL != str_value ) { - free(str_value); - } return exit_status; } diff --git a/opal/mca/compress/base/compress_base_select.c b/opal/mca/compress/base/compress_base_select.c index f9478ed898..62409d2492 100644 --- a/opal/mca/compress/base/compress_base_select.c +++ b/opal/mca/compress/base/compress_base_select.c @@ -19,7 +19,6 @@ #include "opal/util/output.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/mca/compress/compress.h" #include "opal/mca/compress/base/base.h" diff --git a/opal/mca/compress/bzip/compress_bzip_component.c b/opal/mca/compress/bzip/compress_bzip_component.c index d301cbbe40..3808642fc3 100644 --- a/opal/mca/compress/bzip/compress_bzip_component.c +++ b/opal/mca/compress/bzip/compress_bzip_component.c @@ -24,6 +24,7 @@ const char *opal_compress_bzip_component_version_string = /* * Local functionality */ +static int compress_bzip_register (void); static int compress_bzip_open(void); static int compress_bzip_close(void); @@ -49,7 +50,8 @@ opal_compress_bzip_component_t mca_compress_bzip_component = { /* Component open and close functions */ compress_bzip_open, compress_bzip_close, - opal_compress_bzip_component_query + opal_compress_bzip_component_query, + compress_bzip_register }, { /* The component is checkpoint ready */ @@ -59,9 +61,7 @@ opal_compress_bzip_component_t mca_compress_bzip_component = { /* Verbosity level */ 0, /* opal_output handler */ - -1, - /* Default priority */ - 10 + -1 } }; @@ -83,21 +83,32 @@ static opal_compress_base_module_t loc_module = { opal_compress_bzip_decompress_nb }; +static int compress_bzip_register (void) +{ + int ret; + + mca_compress_bzip_component.super.priority = 10; + ret = mca_base_component_var_register (&mca_compress_bzip_component.super.base_version, + "priority", "Priority of the COMPRESS bzip component " + "(default: 10)", MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_ALL_EQ, + &mca_compress_bzip_component.super.priority); + if (0 > ret) { + return ret; + } + + ret = mca_base_component_var_register (&mca_compress_bzip_component.super.base_version, + "verbose", + "Verbose level for the COMPRESS bzip component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_LOCAL, + &mca_compress_bzip_component.super.verbose); + return (0 > ret) ? ret : OPAL_SUCCESS; +} + static int compress_bzip_open(void) { - mca_base_param_reg_int(&mca_compress_bzip_component.super.base_version, - "priority", - "Priority of the COMPRESS bzip component", - false, false, - mca_compress_bzip_component.super.priority, - &mca_compress_bzip_component.super.priority); - - mca_base_param_reg_int(&mca_compress_bzip_component.super.base_version, - "verbose", - "Verbose level for the COMPRESS bzip component", - false, false, - mca_compress_bzip_component.super.verbose, - &mca_compress_bzip_component.super.verbose); /* If there is a custom verbose level for this component than use it * otherwise take our parents level and output channel */ diff --git a/opal/mca/compress/bzip/compress_bzip_module.c b/opal/mca/compress/bzip/compress_bzip_module.c index b32349f6c8..755b9f1152 100644 --- a/opal/mca/compress/bzip/compress_bzip_module.c +++ b/opal/mca/compress/bzip/compress_bzip_module.c @@ -27,7 +27,6 @@ #include "opal/util/opal_environ.h" #include "opal/constants.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/util/basename.h" #include "opal/mca/compress/compress.h" diff --git a/opal/mca/compress/gzip/compress_gzip_component.c b/opal/mca/compress/gzip/compress_gzip_component.c index 685f411ea3..414b51bc4e 100644 --- a/opal/mca/compress/gzip/compress_gzip_component.c +++ b/opal/mca/compress/gzip/compress_gzip_component.c @@ -24,6 +24,7 @@ const char *opal_compress_gzip_component_version_string = /* * Local functionality */ +static int compress_gzip_register (void); static int compress_gzip_open(void); static int compress_gzip_close(void); @@ -49,7 +50,8 @@ opal_compress_gzip_component_t mca_compress_gzip_component = { /* Component open and close functions */ compress_gzip_open, compress_gzip_close, - opal_compress_gzip_component_query + opal_compress_gzip_component_query, + compress_gzip_register }, { /* The component is checkpoint ready */ @@ -59,9 +61,7 @@ opal_compress_gzip_component_t mca_compress_gzip_component = { /* Verbosity level */ 0, /* opal_output handler */ - -1, - /* Default priority */ - 15 + -1 } }; @@ -83,21 +83,33 @@ static opal_compress_base_module_t loc_module = { opal_compress_gzip_decompress_nb }; +static int compress_gzip_register (void) +{ + int ret; + + mca_compress_gzip_component.super.priority = 15; + ret = mca_base_component_var_register (&mca_compress_gzip_component.super.base_version, + "priority", "Priority of the COMPRESS gzip component " + "(default: 15)", MCA_BASE_VAR_TYPE_INT, NULL, 0, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_ALL_EQ, + &mca_compress_gzip_component.super.priority); + if (0 > ret) { + return ret; + } + + mca_compress_gzip_component.super.verbose = 0; + ret = mca_base_component_var_register (&mca_compress_gzip_component.super.base_version, + "verbose", + "Verbose level for the COMPRESS gzip component", + MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_LOCAL, + &mca_compress_gzip_component.super.verbose); + return (0 > ret) ? ret : OPAL_SUCCESS; +} + static int compress_gzip_open(void) { - mca_base_param_reg_int(&mca_compress_gzip_component.super.base_version, - "priority", - "Priority of the COMPRESS gzip component", - false, false, - mca_compress_gzip_component.super.priority, - &mca_compress_gzip_component.super.priority); - - mca_base_param_reg_int(&mca_compress_gzip_component.super.base_version, - "verbose", - "Verbose level for the COMPRESS gzip component", - false, false, - mca_compress_gzip_component.super.verbose, - &mca_compress_gzip_component.super.verbose); /* If there is a custom verbose level for this component than use it * otherwise take our parents level and output channel */ diff --git a/opal/mca/compress/gzip/compress_gzip_module.c b/opal/mca/compress/gzip/compress_gzip_module.c index cb71e03191..36f56cdeed 100644 --- a/opal/mca/compress/gzip/compress_gzip_module.c +++ b/opal/mca/compress/gzip/compress_gzip_module.c @@ -27,7 +27,6 @@ #include "opal/util/opal_environ.h" #include "opal/constants.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/util/basename.h" #include "opal/mca/compress/compress.h" diff --git a/opal/mca/crs/base/crs_base_open.c b/opal/mca/crs/base/crs_base_open.c index 40bca363f3..95797230c7 100644 --- a/opal/mca/crs/base/crs_base_open.c +++ b/opal/mca/crs/base/crs_base_open.c @@ -50,6 +50,43 @@ opal_crs_base_module_t opal_crs = { opal_list_t opal_crs_base_components_available; opal_crs_base_component_t opal_crs_base_selected_component; +bool crs_base_do_not_select = false; + +static int crs_base_verbose = 0; + +static int opal_crs_base_register(int flags) +{ + /* + * Note: If we are a tool, then we will manually run the selection routine + * for the checkpointer. The tool will set the MCA parameter + * 'crs_base_do_not_select' before opal_init and then reset it after to + * disable the selection logic. + * This is useful for opal_restart because it reads the metadata file + * that indicates the checkpointer to be used after calling opal_init. + * Therefore it would need to select a specific module, but it doesn't + * know which one until later. It will set the MCA parameter 'crs' + * before calling this function. + */ + crs_base_do_not_select = false; + (void) mca_base_var_register("opal", "crs", "base", "do_not_select", + "Do not do the selection of the CRS component", + MCA_BASE_VAR_TYPE_BOOL, NULL, 0, MCA_BASE_VAR_FLAG_INTERNAL, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, &crs_base_do_not_select); + + + /* Debugging/Verbose output */ + crs_base_verbose = 0; + (void) mca_base_var_register("opal", "crs", "base", "verbose", + "Verbosity level of the CRS framework", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_READONLY, + &crs_base_verbose); + + return OPAL_SUCCESS; +} + /** * Function for finding and opening either all MCA components, * or the one that was specifically requested via a MCA parameter. @@ -57,32 +94,15 @@ opal_crs_base_component_t opal_crs_base_selected_component; int opal_crs_base_open(void) { int ret, exit_status = OPAL_SUCCESS; - int value; - char *str_value = NULL; - /* Debugging/Verbose output */ - mca_base_param_reg_int_name("crs", - "base_verbose", - "Verbosity level of the CRS framework", - false, false, - 0, &value); - if(0 != value) { + (void) opal_crs_base_register(0); + + if(0 != crs_base_verbose) { opal_crs_base_output = opal_output_open(NULL); } else { opal_crs_base_output = -1; } - opal_output_set_verbosity(opal_crs_base_output, value); - - /* - * Which CRS component to open - * - NULL or "" = auto-select - * - "none" = Empty component - * - ow. select that specific component - */ - mca_base_param_reg_string_name("crs", NULL, - "Which CRS component to use (empty = auto-select)", - false, false, - NULL, &str_value); + opal_output_set_verbosity(opal_crs_base_output, crs_base_verbose); if( !opal_cr_is_enabled ) { opal_output_verbose(10, opal_crs_base_output, @@ -96,17 +116,17 @@ int opal_crs_base_open(void) mca_crs_base_static_components, &opal_crs_base_components_available, true)) ) { - if( OPAL_ERR_NOT_FOUND == ret && - NULL != str_value && - 0 == strncmp(str_value, "none", strlen("none")) ) { - exit_status = OPAL_SUCCESS; - } else { - exit_status = OPAL_ERROR; - } - } + exit_status = OPAL_ERROR; + if( OPAL_ERR_NOT_FOUND == ret) { + const char **str_value = NULL; - if( NULL != str_value ) { - free(str_value); + ret = mca_base_var_find("opal", "crs", NULL, NULL); + mca_base_var_get_value(ret, &str_value, NULL, NULL); + if (NULL != str_value && NULL != str_value[0] && + 0 == strncmp(str_value[0], "none", strlen("none"))) { + exit_status = OPAL_SUCCESS; + } + } } return exit_status; diff --git a/opal/mca/crs/base/crs_base_select.c b/opal/mca/crs/base/crs_base_select.c index d1c6b85b7f..197e8688ed 100644 --- a/opal/mca/crs/base/crs_base_select.c +++ b/opal/mca/crs/base/crs_base_select.c @@ -26,16 +26,16 @@ #include "opal/util/output.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/mca/base/mca_base_param.h" #include "opal/mca/crs/crs.h" #include "opal/mca/crs/base/base.h" +extern bool crs_base_do_not_select; + int opal_crs_base_select(void) { int ret, exit_status = OPAL_SUCCESS; opal_crs_base_component_t *best_component = NULL; opal_crs_base_module_t *best_module = NULL; - int int_value = 0; if( !opal_cr_is_enabled ) { opal_output_verbose(10, opal_crs_base_output, @@ -43,24 +43,7 @@ int opal_crs_base_select(void) return OPAL_SUCCESS; } - /* - * Note: If we are a tool, then we will manually run the selection routine - * for the checkpointer. The tool will set the MCA parameter - * 'crs_base_do_not_select' before opal_init and then reset it after to - * disable the selection logic. - * This is useful for opal_restart because it reads the metadata file - * that indicates the checkpointer to be used after calling opal_init. - * Therefore it would need to select a specific module, but it doesn't - * know which one until later. It will set the MCA parameter 'crs' - * before calling this function. - */ - mca_base_param_reg_int_name("crs", - "base_do_not_select", - "Do not do the selection of the CRS component", - true, false, - false, - &int_value); - if( OPAL_INT_TO_BOOL(int_value) ) { + if( crs_base_do_not_select ) { opal_output_verbose(10, opal_crs_base_output, "crs:select: Not selecting at this time!"); return OPAL_SUCCESS; diff --git a/opal/mca/crs/blcr/crs_blcr_component.c b/opal/mca/crs/blcr/crs_blcr_component.c index 78044feeb0..7dc18f560b 100644 --- a/opal/mca/crs/blcr/crs_blcr_component.c +++ b/opal/mca/crs/blcr/crs_blcr_component.c @@ -26,6 +26,7 @@ /* * Local functionality */ +static int crs_blcr_register (void); static int crs_blcr_open(void); static int crs_blcr_close(void); @@ -53,7 +54,8 @@ opal_crs_blcr_component_t mca_crs_blcr_component = { /* Component open and close functions */ crs_blcr_open, crs_blcr_close, - opal_crs_blcr_component_query + opal_crs_blcr_component_query, + crs_blcr_register }, { /* The component is checkpoint ready */ @@ -63,29 +65,48 @@ opal_crs_blcr_component_t mca_crs_blcr_component = { /* Verbosity level */ 0, /* opal_output handler */ - -1, - /* Default priority */ - 10 + -1 } }; +static int crs_blcr_register (void) +{ + int ret; + + mca_crs_blcr_component.super.priority = 10; + ret = mca_base_component_var_register (&mca_crs_blcr_component.super.base_version, + "priority", "Priority of the CRS blcr component " + "(default: 10)". MCA_BASE_VAR_TYPE_INT, NULL, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_ALL_EQ, + &mca_crs_blcr_component.super.priority); + if (0 > ret) { + return ret; + } + + mca_crs_blcr_component.super.verbose = 0; + ret = mca_base_component_var_register (&mca_crs_blcr_component.super.base_version, + "verbose", + "Verbose level for the CRS blcr component", + MCA_BASE_VAR_TYPE_INT, NULL, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_LOCAL, + &mca_crs_blcr_component.super.verbose); + if (0 > ret) { + return ret; + } + + opal_crs_blcr_dev_null = false; + ret = mca_base_component_var_register (&mca_crs_blcr_component.super.base_version, + "dev_null", + "Not for general use! For debugging only! Save checkpoint to /dev/null. [Default = disabled]", + MCA_BASE_VAR_TYPE_BOOL, NULL, MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_ALL_EQ, + &opal_crs_blcr_dev_null); + return (0 > ret) ? ret : OPAL_SUCCESS +} + static int crs_blcr_open(void) { - int value; - - mca_base_param_reg_int(&mca_crs_blcr_component.super.base_version, - "priority", - "Priority of the CRS blcr component", - false, false, - mca_crs_blcr_component.super.priority, - &mca_crs_blcr_component.super.priority); - - mca_base_param_reg_int(&mca_crs_blcr_component.super.base_version, - "verbose", - "Verbose level for the CRS blcr component", - false, false, - mca_crs_blcr_component.super.verbose, - &mca_crs_blcr_component.super.verbose); /* If there is a custom verbose level for this component than use it * otherwise take our parents level and output channel */ @@ -97,14 +118,6 @@ static int crs_blcr_open(void) mca_crs_blcr_component.super.output_handle = opal_crs_base_output; } - mca_base_param_reg_int(&mca_crs_blcr_component.super.base_version, - "dev_null", - "Not for general use! For debugging only! Save checkpoint to /dev/null. [Default = disabled]", - false, false, - 0, - &value); - opal_crs_blcr_dev_null = OPAL_INT_TO_BOOL(value); - /* * Debug output */ diff --git a/opal/mca/crs/blcr/crs_blcr_module.c b/opal/mca/crs/blcr/crs_blcr_module.c index 81130f5272..f7e612a077 100644 --- a/opal/mca/crs/blcr/crs_blcr_module.c +++ b/opal/mca/crs/blcr/crs_blcr_module.c @@ -34,7 +34,7 @@ #include "opal/util/argv.h" #include "opal/constants.h" -#include "opal/mca/base/mca_base_param.h" +#include "opal/mca/base/mca_base_var.h" #include "opal/threads/threads.h" #include "opal/threads/mutex.h" @@ -245,7 +245,7 @@ int opal_crs_blcr_prelaunch(int32_t rank, { char * tmp_env_var = NULL; - tmp_env_var = mca_base_param_env_var("opal_cr_is_tool"); + (void) mca_base_var_env_name("opal_cr_is_tool", &tmp_env_var); opal_setenv(tmp_env_var, "0", true, env); free(tmp_env_var); diff --git a/opal/mca/crs/dmtcp/crs_dmtcp_component.c b/opal/mca/crs/dmtcp/crs_dmtcp_component.c index 34e7889db2..f2e8d875d0 100644 --- a/opal/mca/crs/dmtcp/crs_dmtcp_component.c +++ b/opal/mca/crs/dmtcp/crs_dmtcp_component.c @@ -23,6 +23,7 @@ /* * Local functionality */ +static int crs_dmtcp_register (void); static int crs_dmtcp_open(void); static int crs_dmtcp_close(void); @@ -48,7 +49,8 @@ opal_crs_dmtcp_component_t mca_crs_dmtcp_component = { /* Component open and close functions */ crs_dmtcp_open, crs_dmtcp_close, - opal_crs_dmtcp_component_query + opal_crs_dmtcp_component_query, + crs_dmtcp_register }, { /* The component is checkpoint ready */ @@ -58,34 +60,44 @@ opal_crs_dmtcp_component_t mca_crs_dmtcp_component = { /* Verbosity level */ 0, /* opal_output handler */ - -1, - /* Default priority */ - 20 + -1 } }; -static int crs_dmtcp_open(void) +static int crs_dmtcp_register (void) { + int ret; /* * User can adjust the relative priority of this component with respect * to other CRS components available for selection. */ - mca_base_param_reg_int(&mca_crs_dmtcp_component.super.base_version, - "priority", - "Priority of the CRS dmtcp component", - false, false, - mca_crs_dmtcp_component.super.priority, - &mca_crs_dmtcp_component.super.priority); + mca_crs_dmtcp_component.super.priority = 20 + ret = mca_base_component_var_register (&mca_crs_dmtcp_component.super.base_version, + "priority", "Priority of the CRS dmtcp component " + "(default: 20)", MCA_BASE_VAR_TYPE_INT, NULL, + MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, + MCA_BASE_VAR_SCOPE_ALL_EQ, + &mca_crs_dmtcp_component.super.priority); + if (0 > ret) { + return ret; + } /* * Adjust the verbosity level for this component. Default off or 0. */ - mca_base_param_reg_int(&mca_crs_dmtcp_component.super.base_version, - "verbose", - "Verbose level for the CRS dmtcp component", - false, false, - mca_crs_dmtcp_component.super.verbose, - &mca_crs_dmtcp_component.super.verbose); + mca_crs_dmtcp_component.super.verbose = 0; + ret = mca_base_component_var_register (&mca_crs_dmtcp_component.super.base_version, + "verbose", + "Verbose level for the CRS dmtcp component", + MCA_BASE_VAR_TYPE_INT, NULL,MCA_BASE_VAR_FLAG_SETTABLE, + OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_LOCAL, + &mca_crs_dmtcp_component.super.verbose); + return (0 > ret) ? ret : OPAL_SUCCESS; +} + +static int crs_dmtcp_open(void) +{ /* If there is a custom verbose level for this component than use it * otherwise take our parents level and output channel */ diff --git a/opal/mca/crs/dmtcp/crs_dmtcp_module.c b/opal/mca/crs/dmtcp/crs_dmtcp_module.c index 3c7e1cfa04..e18626ff57 100644 --- a/opal/mca/crs/dmtcp/crs_dmtcp_module.c +++ b/opal/mca/crs/dmtcp/crs_dmtcp_module.c @@ -28,7 +28,7 @@ #include "opal/util/argv.h" #include "opal/constants.h" -#include "opal/mca/base/mca_base_param.h" +#include "opal/mca/base/mca_base_var.h" #include "opal/threads/mutex.h" #include "opal/threads/condition.h" @@ -194,7 +194,7 @@ int opal_crs_dmtcp_prelaunch(int32_t rank, /* * The below should be left unt