root/orte/mca/sstore/base/sstore_base_frame.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. orte_sstore_base_register
  2. orte_sstore_base_close
  3. orte_sstore_base_open
  4. orte_sstore_base_determine_context

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c)      2010 The Trustees of Indiana University.
   4  *                         All rights reserved.
   5  * Copyright (c) 2012      The University of Wisconsin-La Crosse. All rights
   6  *                         reserved.
   7  * Copyright (c) 2013      Los Alamos National Security, LLC.  All rights reserved.
   8  * Copyright (c) 2015      Research Organization for Information Science
   9  *                         and Technology (RIST). All rights reserved.
  10  * Copyright (c) 2018      Intel, Inc.  All rights reserved.
  11  * $COPYRIGHT$
  12  *
  13  * Additional copyrights may follow
  14  *
  15  * $HEADER$
  16  */
  17 
  18 #include "orte_config.h"
  19 
  20 #include "orte/constants.h"
  21 #include "orte/mca/mca.h"
  22 #include "opal/util/output.h"
  23 #include "opal/util/opal_environ.h"
  24 #include "opal/mca/base/base.h"
  25 
  26 #include "orte/util/proc_info.h"
  27 
  28 #include "orte/mca/sstore/sstore.h"
  29 #include "orte/mca/sstore/base/base.h"
  30 
  31 #include "orte/mca/sstore/base/static-components.h"
  32 
  33 /*
  34  * Globals
  35  */
  36 orte_sstore_base_module_t orte_sstore = {
  37     NULL, /* sstore_init     */
  38     NULL, /* ssotore_finalize */
  39 
  40     NULL, /* request_checkpoint_handle    */
  41     NULL, /* request_restart_handle       */
  42     NULL, /* request_global_snapshot_data */
  43     NULL, /* register_handle              */
  44     NULL, /* get_attr */
  45     NULL, /* set_attr */
  46     NULL, /* sync     */
  47     NULL, /* remove   */
  48     NULL, /* pack     */
  49     NULL, /* unpack   */
  50     NULL, /* fetch_app_deps */
  51     NULL  /* wait_all_deps  */
  52 };
  53 int orte_sstore_context = -1;
  54 
  55 bool   orte_sstore_base_is_checkpoint_available = false;
  56 char * orte_sstore_base_local_metadata_filename = NULL;
  57 char * orte_sstore_base_global_metadata_filename = NULL;
  58 char * orte_sstore_base_local_snapshot_fmt = NULL;
  59 char * orte_sstore_base_global_snapshot_dir = NULL;
  60 char * orte_sstore_base_global_snapshot_ref = NULL;
  61 char * orte_sstore_base_prelaunch_location  = NULL;
  62 
  63 orte_sstore_base_handle_t orte_sstore_handle_current = {0};
  64 orte_sstore_base_handle_t orte_sstore_handle_last_stable = {0};
  65 
  66 /* Determine the context of this module */
  67 int orte_sstore_base_determine_context(void);
  68 
  69 static int orte_sstore_base_register(mca_base_register_flag_t flags)
  70 {
  71     int mca_index;
  72     /*
  73      * Base Global Snapshot directory
  74      */
  75     orte_sstore_base_global_snapshot_dir = (char *) opal_home_directory();
  76     mca_index = mca_base_var_register("orte", "sstore", "base", "global_snapshot_dir",
  77                                       "The base directory to use when storing global snapshots",
  78                                       MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
  79                                       OPAL_INFO_LVL_9,
  80                                       MCA_BASE_VAR_SCOPE_READONLY,
  81                                       &orte_sstore_base_global_snapshot_dir);
  82     mca_base_var_register_synonym(mca_index, "orte", "snapc", "base", "global_snapshot_dir",
  83                                   MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
  84 
  85     /*
  86      * User defined snapshot reference to use for this job
  87      */
  88     orte_sstore_base_global_snapshot_ref = NULL;
  89     mca_index = mca_base_var_register("orte", "sstore", "base", "global_snapshot_ref",
  90                                       "The global snapshot reference to be used for this job. "
  91                                       " [Default = ompi_global_snapshot_MPIRUNPID.ckpt]",
  92                                       MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
  93                                       OPAL_INFO_LVL_9,
  94                                       MCA_BASE_VAR_SCOPE_READONLY,
  95                                       &orte_sstore_base_global_snapshot_ref);
  96     mca_base_var_register_synonym(mca_index, "orte", "snapc", "base", "global_snapshot_ref",
  97                                   MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
  98 
  99     return ORTE_SUCCESS;
 100 }
 101 
 102 static int orte_sstore_base_close(void)
 103 {
 104     /* Close the selected component */
 105     if( NULL != orte_sstore.sstore_finalize ) {
 106         orte_sstore.sstore_finalize();
 107     }
 108 
 109     return mca_base_framework_components_close(&orte_sstore_base_framework, NULL);
 110 }
 111 
 112 /**
 113  * Function for finding and opening either all MCA components,
 114  * or the one that was specifically requested via a MCA parameter.
 115  */
 116 static int orte_sstore_base_open(mca_base_open_flag_t flags)
 117 {
 118     int rc;
 119 
 120     orte_sstore_handle_current     = ORTE_SSTORE_HANDLE_INVALID;
 121     orte_sstore_handle_last_stable = ORTE_SSTORE_HANDLE_INVALID;
 122 
 123     orte_sstore_base_local_metadata_filename  = strdup("snapshot_meta.data");
 124     orte_sstore_base_global_metadata_filename = strdup("global_snapshot_meta.data");
 125     orte_sstore_base_local_snapshot_fmt       = strdup("opal_snapshot_%d.ckpt");
 126 
 127     /*
 128      * Setup the prelaunch variable to point to the first possible snapshot
 129      * location
 130      */
 131     if( NULL != orte_sstore_base_global_snapshot_ref ) {
 132         opal_asprintf(&orte_sstore_base_prelaunch_location,
 133                  "%s/%s/%d",
 134                  orte_sstore_base_global_snapshot_dir,
 135                  orte_sstore_base_global_snapshot_ref,
 136                  0);
 137     }
 138 
 139     /* Open up all available components */
 140     if (ORTE_SUCCESS != (rc = mca_base_framework_components_open(&orte_sstore_base_framework, flags))) {
 141         return rc;
 142     }
 143 
 144     opal_output_verbose(10, orte_sstore_base_framework.framework_output,
 145                         "sstore:base: open()");
 146     opal_output_verbose(10, orte_sstore_base_framework.framework_output,
 147                         "sstore:base: open: Global snapshot directory = %s",
 148                         orte_sstore_base_global_snapshot_dir);
 149     opal_output_verbose(10, orte_sstore_base_framework.framework_output,
 150                         "sstore:base: open: Global snapshot reference = %s",
 151                         (NULL == orte_sstore_base_global_snapshot_ref ? "Default" : orte_sstore_base_global_snapshot_ref));
 152     opal_output_verbose(10, orte_sstore_base_framework.framework_output,
 153                         "sstore:base: open: Prelaunch location        = %s",
 154                         (NULL == orte_sstore_base_prelaunch_location ? "Undefined" : orte_sstore_base_prelaunch_location));
 155 
 156     orte_sstore_context = ORTE_SSTORE_UNASSIGN_TYPE;
 157     orte_sstore_base_determine_context();
 158 
 159     return ORTE_SUCCESS;
 160 }
 161 
 162 MCA_BASE_FRAMEWORK_DECLARE(orte, sstore, "ORTE Sstore", orte_sstore_base_register,
 163                            orte_sstore_base_open, orte_sstore_base_close,
 164                            mca_sstore_base_static_components, 0);
 165 
 166 
 167 int orte_sstore_base_determine_context(void)
 168 {
 169     if( ORTE_PROC_IS_HNP) {
 170         orte_sstore_context |= ORTE_SSTORE_GLOBAL_TYPE;
 171         if( ORTE_PROC_IS_DAEMON ) {
 172             orte_sstore_context |= ORTE_SSTORE_LOCAL_TYPE;
 173         }
 174     }
 175     else if( ORTE_PROC_IS_DAEMON ) {
 176         orte_sstore_context |= ORTE_SSTORE_LOCAL_TYPE;
 177     }
 178     else if( ORTE_PROC_IS_TOOL ) {
 179         orte_sstore_context |= ORTE_SSTORE_TOOL_TYPE;
 180     }
 181     else if( !ORTE_PROC_IS_DAEMON ) {
 182         orte_sstore_context |= ORTE_SSTORE_APP_TYPE;
 183     }
 184 
 185     return ORTE_SUCCESS;
 186 }

/* [<][>][^][v][top][bottom][index][help] */