1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3 * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
4 * University Research and Technology
5 * Corporation. All rights reserved.
6 * Copyright (c) 2004-2005 The University of Tennessee and The University
7 * of Tennessee Research Foundation. All rights
8 * reserved.
9 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10 * University of Stuttgart. All rights reserved.
11 * Copyright (c) 2004-2005 The Regents of the University of California.
12 * All rights reserved.
13 * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
14 * reserved.
15 * Copyright (c) 2015-2017 Intel, Inc. All rights reserved.
16 * $COPYRIGHT$
17 *
18 * Additional copyrights may follow
19 *
20 * $HEADER$
21 *
22 * These symbols are in a file by themselves to provide nice linker
23 * semantics. Since linkers generally pull in symbols by object
24 * files, keeping these symbols as the only symbols in this file
25 * prevents utility programs such as "ompi_info" from having to import
26 * entire components just to query their version and parameters.
27 */
28
29 #include "orte_config.h"
30 #include "orte/constants.h"
31
32 #include "orte/util/proc_info.h"
33
34 #include "orte/mca/ess/ess.h"
35 #include "orte/mca/ess/tool/ess_tool.h"
36
37 extern orte_ess_base_module_t orte_ess_tool_module;
38
39 static int tool_component_register(void);
40
41 /*
42 * Instantiate the public struct with all of our public information
43 * and pointers to our public functions in it
44 */
45 orte_ess_tool_component_t mca_ess_tool_component = {
46 {
47 .base_version = {
48 ORTE_ESS_BASE_VERSION_3_0_0,
49
50 /* Component name and version */
51 .mca_component_name = "tool",
52 MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION,
53 ORTE_RELEASE_VERSION),
54
55 /* Component open and close functions */
56 .mca_open_component = orte_ess_tool_component_open,
57 .mca_close_component = orte_ess_tool_component_close,
58 .mca_query_component = orte_ess_tool_component_query,
59 .mca_register_component_params = tool_component_register,
60 },
61 .base_data = {
62 /* The component is checkpoint ready */
63 MCA_BASE_METADATA_PARAM_CHECKPOINT
64 },
65 },
66 .async = false,
67 .system_server_first = false,
68 .system_server_only = false,
69 .wait_to_connect = 0,
70 .num_retries = 0,
71 .pid = 0
72 };
73
74 static int tool_component_register(void)
75 {
76 mca_base_component_t *c = &mca_ess_tool_component.super.base_version;
77
78 (void) mca_base_component_var_register (c, "async_progress", "Setup an async progress thread",
79 MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
80 OPAL_INFO_LVL_2,
81 MCA_BASE_VAR_SCOPE_READONLY,
82 &mca_ess_tool_component.async);
83
84 (void) mca_base_component_var_register (c, "do_not_connect",
85 "Do not connect to a PMIx server",
86 MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
87 OPAL_INFO_LVL_2,
88 MCA_BASE_VAR_SCOPE_READONLY,
89 &mca_ess_tool_component.do_not_connect);
90
91 (void) mca_base_component_var_register (c, "system_server_first",
92 "Look for a system PMIx server first",
93 MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
94 OPAL_INFO_LVL_2,
95 MCA_BASE_VAR_SCOPE_READONLY,
96 &mca_ess_tool_component.system_server_first);
97
98 (void) mca_base_component_var_register (c, "system_server_only",
99 "Only connect to a system server (and not an mpirun)",
100 MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
101 OPAL_INFO_LVL_2,
102 MCA_BASE_VAR_SCOPE_READONLY,
103 &mca_ess_tool_component.system_server_only);
104
105 (void) mca_base_component_var_register (c, "wait_to_connect",
106 "Time in seconds to wait before retrying connection to server",
107 MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
108 OPAL_INFO_LVL_2,
109 MCA_BASE_VAR_SCOPE_READONLY,
110 &mca_ess_tool_component.wait_to_connect);
111
112 (void) mca_base_component_var_register (c, "num_retries",
113 "Number of times to retry connecting to server",
114 MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
115 OPAL_INFO_LVL_2,
116 MCA_BASE_VAR_SCOPE_READONLY,
117 &mca_ess_tool_component.num_retries);
118
119 (void) mca_base_component_var_register (c, "server_pid",
120 "PID of the server to which we are to connect",
121 MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
122 OPAL_INFO_LVL_2,
123 MCA_BASE_VAR_SCOPE_READONLY,
124 &mca_ess_tool_component.pid);
125 return ORTE_SUCCESS;
126 }
127
128 int
129 orte_ess_tool_component_open(void)
130 {
131 return ORTE_SUCCESS;
132 }
133
134
135 int orte_ess_tool_component_query(mca_base_module_t **module, int *priority)
136 {
137 /* if we are a tool, we want to be selected
138 * UNLESS some enviro-specific component takes
139 * precedence. This would happen, for example,
140 * if the tool is a distributed set of processes
141 */
142 if (ORTE_PROC_IS_TOOL) {
143 *priority = 10;
144 *module = (mca_base_module_t *)&orte_ess_tool_module;
145 return ORTE_SUCCESS;
146 }
147
148 /* else, don't */
149 *priority = -1;
150 *module = NULL;
151 return ORTE_ERROR;
152 }
153
154
155 int
156 orte_ess_tool_component_close(void)
157 {
158 return ORTE_SUCCESS;
159 }