|
| 1 | +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ |
| 2 | +/* |
| 3 | + * Copyright (c) 2017 Mellanox Technologies, Inc. |
| 4 | + * All rights reserved. |
| 5 | + * $COPYRIGHT$ |
| 6 | + * |
| 7 | + * Additional copyrights may follow |
| 8 | + * |
| 9 | + * $HEADER$ |
| 10 | + */ |
| 11 | + |
| 12 | +#include "oshmem_config.h" |
| 13 | + |
| 14 | +#include "opal/constants.h" |
| 15 | + |
| 16 | +#include "oshmem/mca/sshmem/sshmem.h" |
| 17 | +#include "oshmem/mca/sshmem/base/base.h" |
| 18 | +#include "oshmem/mca/spml/base/base.h" |
| 19 | + |
| 20 | +#include "sshmem_ucx.h" |
| 21 | + |
| 22 | +/** |
| 23 | + * public string showing the shmem ompi_ucx component version number |
| 24 | + */ |
| 25 | +const char *mca_sshmem_ucx_component_version_string = |
| 26 | + "OSHMEM ucx sshmem MCA component version " OSHMEM_VERSION; |
| 27 | + |
| 28 | + |
| 29 | +/** |
| 30 | + * local functions |
| 31 | + */ |
| 32 | +static int ucx_register(void); |
| 33 | +static int ucx_open(void); |
| 34 | +static int ucx_close(void); |
| 35 | +static int ucx_query(mca_base_module_t **module, int *priority); |
| 36 | +static int ucx_runtime_query(mca_base_module_t **module, |
| 37 | + int *priority, |
| 38 | + const char *hint); |
| 39 | + |
| 40 | +/** |
| 41 | + * instantiate the public struct with all of our public information |
| 42 | + * and pointers to our public functions in it |
| 43 | + */ |
| 44 | +mca_sshmem_ucx_component_t mca_sshmem_ucx_component = { |
| 45 | + /* ////////////////////////////////////////////////////////////////////// */ |
| 46 | + /* super */ |
| 47 | + /* ////////////////////////////////////////////////////////////////////// */ |
| 48 | + { |
| 49 | + /** |
| 50 | + * common MCA component data |
| 51 | + */ |
| 52 | + .base_version = { |
| 53 | + MCA_SSHMEM_BASE_VERSION_2_0_0, |
| 54 | + |
| 55 | + /* component name and version */ |
| 56 | + .mca_component_name = "ucx", |
| 57 | + MCA_BASE_MAKE_VERSION(component, OSHMEM_MAJOR_VERSION, OSHMEM_MINOR_VERSION, |
| 58 | + OSHMEM_RELEASE_VERSION), |
| 59 | + |
| 60 | + .mca_open_component = ucx_open, |
| 61 | + .mca_close_component = ucx_close, |
| 62 | + .mca_query_component = ucx_query, |
| 63 | + .mca_register_component_params = ucx_register, |
| 64 | + }, |
| 65 | + /* MCA v2.0.0 component meta data */ |
| 66 | + .base_data = { |
| 67 | + /* the component is checkpoint ready */ |
| 68 | + MCA_BASE_METADATA_PARAM_CHECKPOINT |
| 69 | + }, |
| 70 | + .runtime_query = ucx_runtime_query, |
| 71 | + }, |
| 72 | +}; |
| 73 | + |
| 74 | +static int |
| 75 | +ucx_runtime_query(mca_base_module_t **module, |
| 76 | + int *priority, |
| 77 | + const char *hint) |
| 78 | +{ |
| 79 | + /* check that spml ucx was selected. Otherwise disqualify */ |
| 80 | + if (strcmp(mca_spml_base_selected_component.spmlm_version.mca_component_name, "ucx")) { |
| 81 | + *module = NULL; |
| 82 | + return OSHMEM_ERR_NOT_AVAILABLE; |
| 83 | + } |
| 84 | + |
| 85 | + *priority = mca_sshmem_ucx_component.priority; |
| 86 | + /* use lowest priority because UCX does not support |
| 87 | + * fixed address mapping yet |
| 88 | + */ |
| 89 | + *priority = 0; |
| 90 | + *module = (mca_base_module_t *)&mca_sshmem_ucx_module.super; |
| 91 | + return OPAL_SUCCESS; |
| 92 | +} |
| 93 | + |
| 94 | +static int |
| 95 | +ucx_register(void) |
| 96 | +{ |
| 97 | + /* (default) priority - set high to make ucx the default */ |
| 98 | + mca_sshmem_ucx_component.priority = 100; |
| 99 | + mca_base_component_var_register (&mca_sshmem_ucx_component.super.base_version, |
| 100 | + "priority", "Priority for sshmem ucx " |
| 101 | + "component (default: 100)", MCA_BASE_VAR_TYPE_INT, |
| 102 | + NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, |
| 103 | + OPAL_INFO_LVL_3, |
| 104 | + MCA_BASE_VAR_SCOPE_ALL_EQ, |
| 105 | + &mca_sshmem_ucx_component.priority); |
| 106 | + |
| 107 | + return OSHMEM_SUCCESS; |
| 108 | +} |
| 109 | + |
| 110 | +static int |
| 111 | +ucx_open(void) |
| 112 | +{ |
| 113 | + return OSHMEM_SUCCESS; |
| 114 | +} |
| 115 | + |
| 116 | +static int |
| 117 | +ucx_query(mca_base_module_t **module, int *priority) |
| 118 | +{ |
| 119 | + *priority = mca_sshmem_ucx_component.priority; |
| 120 | + *module = (mca_base_module_t *)&mca_sshmem_ucx_module.super; |
| 121 | + return OSHMEM_SUCCESS; |
| 122 | +} |
| 123 | + |
| 124 | +static int |
| 125 | +ucx_close(void) |
| 126 | +{ |
| 127 | + return OSHMEM_SUCCESS; |
| 128 | +} |
| 129 | + |
0 commit comments