OpenMPI  0.1.1
base.h
1 /*
2  * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
3  * University Research and Technology
4  * Corporation. All rights reserved.
5  * Copyright (c) 2004-2005 The University of Tennessee and The University
6  * of Tennessee Research Foundation. All rights
7  * reserved.
8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9  * University of Stuttgart. All rights reserved.
10  * Copyright (c) 2004-2005 The Regents of the University of California.
11  * All rights reserved.
12  * Copyright (c) 2007 Evergrid, Inc. All rights reserved.
13  *
14  * $COPYRIGHT$
15  *
16  * Additional copyrights may follow
17  *
18  * $HEADER$
19  */
20 #ifndef OPAL_CRS_BASE_H
21 #define OPAL_CRS_BASE_H
22 
23 #include "opal_config.h"
24 #include "opal/mca/crs/crs.h"
25 #include "opal/util/opal_environ.h"
26 #include "opal/runtime/opal_cr.h"
27 
28 /*
29  * Global functions for MCA overall CRS
30  */
31 
32 BEGIN_C_DECLS
33 
34 /* Some local strings to use genericly with the local metadata file */
35 #define CRS_METADATA_BASE ("# ")
36 #define CRS_METADATA_COMP ("# OPAL CRS Component: ")
37 #define CRS_METADATA_PID ("# PID: ")
38 #define CRS_METADATA_CONTEXT ("# CONTEXT: ")
39 #define CRS_METADATA_MKDIR ("# MKDIR: ")
40 #define CRS_METADATA_TOUCH ("# TOUCH: ")
41 
42  /**
43  * Initialize the CRS MCA framework
44  *
45  * @retval OPAL_SUCCESS Upon success
46  * @retval OPAL_ERROR Upon failures
47  *
48  * This function is invoked during opal_init();
49  */
50  OPAL_DECLSPEC int opal_crs_base_open(void);
51 
52  /**
53  * Select an available component.
54  *
55  * @retval OPAL_SUCCESS Upon Success
56  * @retval OPAL_NOT_FOUND If no component can be selected
57  * @retval OPAL_ERROR Upon other failure
58  *
59  */
60  OPAL_DECLSPEC int opal_crs_base_select(void);
61 
62  /**
63  * Finalize the CRS MCA framework
64  *
65  * @retval OPAL_SUCCESS Upon success
66  * @retval OPAL_ERROR Upon failures
67  *
68  * This function is invoked during opal_finalize();
69  */
70  OPAL_DECLSPEC int opal_crs_base_close(void);
71 
72  /**
73  * Globals
74  */
75  OPAL_DECLSPEC extern int opal_crs_base_output;
76  OPAL_DECLSPEC extern opal_list_t opal_crs_base_components_available;
77  OPAL_DECLSPEC extern opal_crs_base_component_t opal_crs_base_selected_component;
78  OPAL_DECLSPEC extern opal_crs_base_module_t opal_crs;
79 
80  /**
81  * Some utility functions
82  */
83  OPAL_DECLSPEC char * opal_crs_base_state_str(opal_crs_state_type_t state);
84 
85  /*
86  * Extract the expected component and pid from the metadata
87  */
88  OPAL_DECLSPEC int opal_crs_base_extract_expected_component(FILE *metadata, char ** component_name, int *prev_pid);
89 
90  /*
91  * Read a token to the metadata file
92  */
93  OPAL_DECLSPEC int opal_crs_base_metadata_read_token(FILE *metadata, char * token, char ***value);
94 
95  /*
96  * Register a file for cleanup.
97  * Useful in C/R when files only need to temporarily exist for restart
98  */
99  OPAL_DECLSPEC int opal_crs_base_cleanup_append(char* filename, bool is_dir);
100 
101  /*
102  * Flush the cleanup of all registered files.
103  */
104  OPAL_DECLSPEC int opal_crs_base_cleanup_flush(void);
105 
106  /*
107  * Copy the options structure
108  */
109  OPAL_DECLSPEC int opal_crs_base_copy_options(opal_crs_base_ckpt_options_t *from,
111  /*
112  * Clear the options structure
113  */
114  OPAL_DECLSPEC int opal_crs_base_clear_options(opal_crs_base_ckpt_options_t *target);
115 
116  /*
117  * CRS self application interface functions
118  */
119  typedef int (*opal_crs_base_self_checkpoint_fn_t)(char **restart_cmd);
120  typedef int (*opal_crs_base_self_restart_fn_t)(void);
121  typedef int (*opal_crs_base_self_continue_fn_t)(void);
122 
123  extern opal_crs_base_self_checkpoint_fn_t crs_base_self_checkpoint_fn;
124  extern opal_crs_base_self_restart_fn_t crs_base_self_restart_fn;
125  extern opal_crs_base_self_continue_fn_t crs_base_self_continue_fn;
126 
127  OPAL_DECLSPEC int opal_crs_base_self_register_checkpoint_callback
128  (opal_crs_base_self_checkpoint_fn_t function);
129  OPAL_DECLSPEC int opal_crs_base_self_register_restart_callback
130  (opal_crs_base_self_restart_fn_t function);
131  OPAL_DECLSPEC int opal_crs_base_self_register_continue_callback
132  (opal_crs_base_self_continue_fn_t function);
133 
134 END_C_DECLS
135 
136 #endif /* OPAL_CRS_BASE_H */
Structure for CRS modules.
Definition: crs.h:267
Structure for CRS components.
Definition: crs.h:248
Generic helper routines for environment manipulation.
Definition: opal_list.h:147
Checkpoint and Restart Service (CRS) Interface.
Checkpoint functionality for Open MPI.
opal_crs_state_type_t
States of the module.
Definition: crs.h:60