This source file includes following definitions.
- opal_crs_none_module_init
- opal_crs_none_module_finalize
- opal_crs_none_checkpoint
- opal_crs_none_restart
- opal_crs_none_disable_checkpoint
- opal_crs_none_enable_checkpoint
- opal_crs_none_prelaunch
- opal_crs_none_reg_thread
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #include "opal_config.h"
17
18 #include <string.h>
19 #include <sys/types.h>
20 #ifdef HAVE_UNISTD_H
21 #include <unistd.h>
22 #endif
23
24 #include "opal/util/opal_environ.h"
25 #include "opal/util/output.h"
26 #include "opal/util/argv.h"
27 #include "opal/util/show_help.h"
28 #include "opal/util/opal_environ.h"
29
30 #include "opal/constants.h"
31 #include "opal/mca/base/mca_base_var.h"
32
33 #include "opal/mca/crs/crs.h"
34 #include "opal/mca/crs/base/base.h"
35 #include "opal/runtime/opal_cr.h"
36
37 #include "crs_none.h"
38
39 int opal_crs_none_module_init(void)
40 {
41
42
43
44 if( opal_crs_none_select_warning &&
45 !opal_cr_is_tool && opal_cr_is_enabled ) {
46 opal_show_help("help-opal-crs-none.txt", "none:select-warning",
47 true);
48 }
49
50 return OPAL_SUCCESS;
51 }
52
53 int opal_crs_none_module_finalize(void)
54 {
55 return OPAL_SUCCESS;
56 }
57
58 int opal_crs_none_checkpoint(pid_t pid,
59 opal_crs_base_snapshot_t *snapshot,
60 opal_crs_base_ckpt_options_t *options,
61 opal_crs_state_type_t *state)
62 {
63 *state = OPAL_CRS_CONTINUE;
64
65 snapshot->component_name = strdup("none");
66 snapshot->cold_start = false;
67
68
69
70
71 if( NULL == snapshot->metadata ) {
72 if (NULL == (snapshot->metadata = fopen(snapshot->metadata_filename, "a")) ) {
73 opal_output(0,
74 "crs:none: checkpoint(): Error: Unable to open the file (%s)",
75 snapshot->metadata_filename);
76 return OPAL_ERROR;
77 }
78 }
79 fprintf(snapshot->metadata, "%s%s\n", CRS_METADATA_COMP, snapshot->component_name);
80 fclose(snapshot->metadata);
81 snapshot->metadata = NULL;
82
83 if( options->stop ) {
84 opal_output(0,
85 "crs:none: checkpoint(): Error: SIGSTOP Not currently supported!");
86 }
87
88 return OPAL_SUCCESS;
89 }
90
91 int opal_crs_none_restart(opal_crs_base_snapshot_t *base_snapshot, bool spawn_child, pid_t *child_pid)
92 {
93 int exit_status = OPAL_SUCCESS;
94 char **tmp_argv = NULL;
95 char **cr_argv = NULL;
96 int status;
97
98 *child_pid = getpid();
99
100 if( NULL == base_snapshot->metadata ) {
101 if (NULL == (base_snapshot->metadata = fopen(base_snapshot->metadata_filename, "a")) ) {
102 opal_output(0,
103 "crs:none: checkpoint(): Error: Unable to open the file (%s)",
104 base_snapshot->metadata_filename);
105 return OPAL_ERROR;
106 }
107 }
108
109 opal_crs_base_metadata_read_token(base_snapshot->metadata, CRS_METADATA_CONTEXT, &tmp_argv);
110
111 if( NULL == tmp_argv ) {
112 opal_output(opal_crs_base_framework.framework_output,
113 "crs:none: none_restart: Error: Failed to read the %s token from the local checkpoint in %s",
114 CRS_METADATA_CONTEXT, base_snapshot->metadata_filename);
115 exit_status = OPAL_ERROR;
116 goto cleanup;
117 }
118
119 if( opal_argv_count(tmp_argv) <= 0 ) {
120 opal_output_verbose(10, opal_crs_base_framework.framework_output,
121 "crs:none: none_restart: No command line to exec, so just returning");
122 exit_status = OPAL_SUCCESS;
123 goto cleanup;
124 }
125
126 if ( NULL == (cr_argv = opal_argv_split(tmp_argv[0], ' ')) ) {
127 exit_status = OPAL_ERROR;
128 goto cleanup;
129 }
130
131 if( !spawn_child ) {
132 opal_output_verbose(10, opal_crs_base_framework.framework_output,
133 "crs:none: none_restart: exec :(%s, %s):",
134 cr_argv[0], tmp_argv[0]);
135
136 status = execvp(cr_argv[0], cr_argv);
137
138 if(status < 0) {
139 opal_output(opal_crs_base_framework.framework_output,
140 "crs:none: none_restart: Child failed to execute :(%d):", status);
141 }
142 opal_output(opal_crs_base_framework.framework_output,
143 "crs:none: none_restart: execvp returned %d", status);
144 exit_status = status;
145 goto cleanup;
146 } else {
147 opal_output(opal_crs_base_framework.framework_output,
148 "crs:none: none_restart: Spawn not implemented");
149 exit_status = OPAL_ERR_NOT_IMPLEMENTED;
150 goto cleanup;
151 }
152
153 cleanup:
154 if (cr_argv) {
155 opal_argv_free (cr_argv);
156 }
157
158 fclose(base_snapshot->metadata);
159
160 return exit_status;
161 }
162
163 int opal_crs_none_disable_checkpoint(void)
164 {
165 return OPAL_SUCCESS;
166 }
167
168 int opal_crs_none_enable_checkpoint(void)
169 {
170 return OPAL_SUCCESS;
171 }
172
173 int opal_crs_none_prelaunch(int32_t rank,
174 char *base_snapshot_dir,
175 char **app,
176 char **cwd,
177 char ***argv,
178 char ***env)
179 {
180 char * tmp_env_var = NULL;
181
182 (void) mca_base_var_env_name("opal_cr_is_tool", &tmp_env_var);
183 opal_setenv(tmp_env_var,
184 "0", true, env);
185 free(tmp_env_var);
186 tmp_env_var = NULL;
187
188 return OPAL_SUCCESS;
189 }
190
191 int opal_crs_none_reg_thread(void)
192 {
193 return OPAL_SUCCESS;
194 }