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