1 /*
2  * Copyright (c) 2015      Mellanox Technologies, Inc.
3  *                         All rights reserved.
4  * $COPYRIGHT$
5  *
6  * Additional copyrights may follow
7  *
8  * $HEADER$
9  */
10 
11 #include "oshmem_config.h"
12 
13 #include "oshmem/constants.h"
14 #include "oshmem/mca/atomic/atomic.h"
15 #include "oshmem/mca/atomic/base/base.h"
16 #include "oshmem/mca/spml/base/base.h"
17 
18 #include "atomic_ucx.h"
19 
20 
21 /*
22  * Public string showing the scoll ucx component version number
23  */
24 const char *mca_atomic_ucx_component_version_string =
25 "Open SHMEM ucx atomic MCA component version " OSHMEM_VERSION;
26 
27 /*
28  * Global variable
29  */
30 mca_spml_ucx_t *mca_spml_self = NULL;
31 
32 /*
33  * Local function
34  */
35 static int ucx_register(void);
36 static int ucx_open(void);
37 
38 /*
39  * Instantiate the public struct with all of our public information
40  * and pointers to our public functions in it
41  */
42 
43 mca_atomic_base_component_t mca_atomic_ucx_component = {
44 
45     /* First, the mca_component_t struct containing meta information
46        about the component itself */
47 
48     {
49         MCA_ATOMIC_BASE_VERSION_2_0_0,
50 
51         /* Component name and version */
52         "ucx",
53         OSHMEM_MAJOR_VERSION,
54         OSHMEM_MINOR_VERSION,
55         OSHMEM_RELEASE_VERSION,
56 
57         /* component open */
58         ucx_open,
59         /* component close */
60         NULL,
61         /* component query */
62         NULL,
63         /* component register */
64         ucx_register
65     },
66     {
67         /* The component is checkpoint ready */
68         MCA_BASE_METADATA_PARAM_CHECKPOINT
69     },
70 
71     /* Initialization / querying functions */
72 
73     mca_atomic_ucx_startup,
74     mca_atomic_ucx_finalize,
75     mca_atomic_ucx_query
76 };
77 
ucx_register(void)78 static int ucx_register(void)
79 {
80     mca_atomic_ucx_component.priority = 100;
81     mca_base_component_var_register (&mca_atomic_ucx_component.atomic_version,
82                                      "priority", "Priority of the atomic:ucx "
83                                      "component (default: 100)", MCA_BASE_VAR_TYPE_INT,
84                                      NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
85                                      OPAL_INFO_LVL_3,
86                                      MCA_BASE_VAR_SCOPE_ALL_EQ,
87                                      &mca_atomic_ucx_component.priority);
88 
89     opal_common_ucx_mca_var_register(&mca_atomic_ucx_component.atomic_version);
90 
91     return OSHMEM_SUCCESS;
92 }
93 
ucx_open(void)94 static int ucx_open(void)
95 {
96     /*
97      * This component is able to work using spml:ikrit component only
98      * (this check is added instead of !mca_spml_ikrit.enabled)
99      */
100     if (strcmp(mca_spml_base_selected_component.spmlm_version.mca_component_name, "ucx")) {
101         ATOMIC_VERBOSE(5,
102                        "Can not use atomic/ucx because spml ucx component disabled");
103         return OSHMEM_ERR_NOT_AVAILABLE;
104     }
105     mca_spml_self = (mca_spml_ucx_t *)mca_spml.self;
106 
107     return OSHMEM_SUCCESS;
108 }
109 
110 OBJ_CLASS_INSTANCE(mca_atomic_ucx_module_t,
111                    mca_atomic_base_module_t,
112                    NULL,
113                    NULL);
114 
115