2007-03-17 02:11:45 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2007-03-20 15:38:06 +03:00
|
|
|
* Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
|
2007-03-17 02:11:45 +03:00
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2008-08-08 16:37:26 +04:00
|
|
|
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
|
2007-03-17 02:11:45 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
*
|
|
|
|
* Checkpoint functionality for Open MPI
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "opal/mca/crs/crs.h"
|
2007-10-09 00:53:02 +04:00
|
|
|
#include "opal/event/event.h"
|
|
|
|
#include "opal/runtime/opal_progress.h"
|
2007-03-17 02:11:45 +03:00
|
|
|
#include "opal/util/output.h"
|
2007-03-20 15:38:06 +03:00
|
|
|
#include "opal/prefetch.h"
|
2007-03-17 02:11:45 +03:00
|
|
|
|
|
|
|
#ifndef OPAL_CR_H
|
|
|
|
#define OPAL_CR_H
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some defines shared with opal-[checkpoint|restart] commands
|
|
|
|
*/
|
|
|
|
#define OPAL_CR_DONE ((char) 0)
|
|
|
|
#define OPAL_CR_ACK ((char) 1)
|
|
|
|
#define OPAL_CR_CHECKPOINT ((char) 2)
|
2007-04-03 01:12:16 +04:00
|
|
|
#define OPAL_CR_NAMED_PROG_R ("opal_cr_prog_read")
|
|
|
|
#define OPAL_CR_NAMED_PROG_W ("opal_cr_prog_write")
|
|
|
|
#define OPAL_CR_BASE_ENV_NAME ("opal_cr_restart-env")
|
2007-03-17 02:11:45 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Possible responses to a checkpoint request from opal-checkpoint
|
|
|
|
*/
|
|
|
|
enum opal_cr_ckpt_cmd_state_t {
|
|
|
|
OPAL_CHECKPOINT_CMD_START, /* Checkpoint is starting on this request */
|
|
|
|
OPAL_CHECKPOINT_CMD_IN_PROGRESS, /* Checkpoint is currently running */
|
|
|
|
OPAL_CHECKPOINT_CMD_NULL, /* Checkpoint cannot be started because it is not supported */
|
2007-10-09 00:53:02 +04:00
|
|
|
OPAL_CHECKPOINT_CMD_ERROR, /* An error occurred such that the checkpoint cannot be completed */
|
|
|
|
/* State of the checkpoint operation */
|
|
|
|
OPAL_CR_STATUS_NONE, /* No checkpoint in progress */
|
|
|
|
OPAL_CR_STATUS_REQUESTED, /* Checkpoint has been requested */
|
|
|
|
OPAL_CR_STATUS_RUNNING, /* Checkpoint is currently running */
|
2008-05-08 22:47:47 +04:00
|
|
|
OPAL_CR_STATUS_TERM, /* Checkpoint is running and will terminate process upon completion */
|
|
|
|
/* State of the continue operation */
|
|
|
|
OPAL_CR_STATUS_CONTINUE,
|
|
|
|
/* State of the restart operation */
|
|
|
|
OPAL_CR_STATUS_RESTART_PRE,
|
|
|
|
OPAL_CR_STATUS_RESTART_POST
|
2007-03-17 02:11:45 +03:00
|
|
|
};
|
|
|
|
typedef enum opal_cr_ckpt_cmd_state_t opal_cr_ckpt_cmd_state_t;
|
|
|
|
|
2008-05-08 22:47:47 +04:00
|
|
|
/* An output handle to be used by the cr runtime
|
|
|
|
* functionality as an argument to opal_output() */
|
|
|
|
OPAL_DECLSPEC extern int opal_cr_output;
|
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
/* Directory containing the named pipes for communication
|
|
|
|
* with the opal-checkpoint tool */
|
|
|
|
OPAL_DECLSPEC extern char * opal_cr_pipe_dir;
|
2008-05-08 22:47:47 +04:00
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
/* Signal that opal-checkpoint uses to contact the
|
|
|
|
* application process */
|
2007-10-09 00:53:02 +04:00
|
|
|
OPAL_DECLSPEC extern int opal_cr_entry_point_signal;
|
2008-05-08 22:47:47 +04:00
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
/* If Checkpointing is enabled in this application */
|
|
|
|
OPAL_DECLSPEC extern bool opal_cr_is_enabled;
|
2008-05-08 22:47:47 +04:00
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
/* If the application running is a tool
|
|
|
|
* (e.g., opal-checkpoint, orted, ...) */
|
|
|
|
OPAL_DECLSPEC extern bool opal_cr_is_tool;
|
2008-05-08 22:47:47 +04:00
|
|
|
|
2007-10-09 00:53:02 +04:00
|
|
|
/* If a checkpoint has been requested */
|
|
|
|
OPAL_DECLSPEC extern int opal_cr_checkpoint_request;
|
2008-05-08 22:47:47 +04:00
|
|
|
|
2007-10-09 00:53:02 +04:00
|
|
|
/* The current state of a checkpoint operation */
|
2008-05-08 22:47:47 +04:00
|
|
|
OPAL_DECLSPEC extern int opal_cr_checkpointing_state;
|
2007-03-17 02:11:45 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is an application that doesn't want to have
|
|
|
|
* a notification callback installed, set this to false.
|
|
|
|
* To see the effect, this must be called before opal_cr_init().
|
|
|
|
* Default: Enabled
|
|
|
|
*/
|
|
|
|
OPAL_DECLSPEC int opal_cr_set_enabled(bool);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the notification and coordination
|
|
|
|
* elements.
|
|
|
|
*/
|
|
|
|
OPAL_DECLSPEC int opal_cr_init(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finalize the notification and coordination
|
|
|
|
* elements.
|
|
|
|
*/
|
|
|
|
OPAL_DECLSPEC int opal_cr_finalize(void);
|
|
|
|
|
|
|
|
/*************************************************
|
|
|
|
* Check to see if a checkpoint has been requested
|
|
|
|
*
|
|
|
|
* When the checkpoint thread is disabled:
|
|
|
|
* This will be checked whenever the MPI Library
|
|
|
|
* is entered by the application. It will stop
|
|
|
|
* the application for the duration of the entire
|
|
|
|
* checkpoint.
|
|
|
|
* When the checkpoint thread is enabled:
|
|
|
|
* The request is handled in the thread parallel
|
|
|
|
* with the execution of the program regardless
|
|
|
|
* of where the program is in exection.
|
|
|
|
* The problem with this method is that it
|
|
|
|
* requires the support of progress threads
|
|
|
|
* which is currently not working properly :/
|
|
|
|
*
|
|
|
|
*************************************************/
|
|
|
|
OPAL_DECLSPEC void opal_cr_test_if_checkpoint_ready(void);
|
|
|
|
|
|
|
|
/* If the checkpoint operation should be stalled to
|
|
|
|
* wait for another sevice to complete before
|
|
|
|
* continuing with the checkpoint */
|
|
|
|
OPAL_DECLSPEC extern bool opal_cr_stall_check;
|
2007-10-09 00:53:02 +04:00
|
|
|
OPAL_DECLSPEC extern bool opal_cr_currently_stalled;
|
2007-03-17 02:11:45 +03:00
|
|
|
|
2008-02-20 01:15:52 +03:00
|
|
|
#if OPAL_ENABLE_FT_THREAD == 1
|
|
|
|
/* Some thread functions */
|
|
|
|
OPAL_DECLSPEC void opal_cr_thread_init_library(void);
|
|
|
|
OPAL_DECLSPEC void opal_cr_thread_finalize_library(void);
|
|
|
|
OPAL_DECLSPEC void opal_cr_thread_abort_library(void);
|
|
|
|
OPAL_DECLSPEC void opal_cr_thread_enter_library(void);
|
|
|
|
OPAL_DECLSPEC void opal_cr_thread_exit_library(void);
|
|
|
|
OPAL_DECLSPEC void opal_cr_thread_noop_progress(void);
|
|
|
|
#endif /* OPAL_ENABLE_FT_THREAD == 1 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If not using FT then make the #defines noops
|
|
|
|
*/
|
|
|
|
#if OPAL_ENABLE_FT == 0
|
|
|
|
#define OPAL_CR_TEST_CHECKPOINT_READY() ;
|
|
|
|
#define OPAL_CR_TEST_CHECKPOINT_READY_STALL() ;
|
|
|
|
#define OPAL_CR_INIT_LIBRARY() ;
|
|
|
|
#define OPAL_CR_FINALIZE_LIBRARY() ;
|
|
|
|
#define OPAL_CR_ABORT_LIBRARY() ;
|
|
|
|
#define OPAL_CR_ENTER_LIBRARY() ;
|
|
|
|
#define OPAL_CR_EXIT_LIBRARY() ;
|
|
|
|
#define OPAL_CR_NOOP_PROGRESS() ;
|
|
|
|
#endif /* #if OPAL_ENABLE_FT == 0 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If using FT
|
|
|
|
*/
|
|
|
|
#if OPAL_ENABLE_FT == 1
|
2007-03-17 02:11:45 +03:00
|
|
|
#define OPAL_CR_TEST_CHECKPOINT_READY() \
|
|
|
|
{ \
|
|
|
|
if(OPAL_UNLIKELY(opal_cr_is_enabled) ) { \
|
|
|
|
opal_cr_test_if_checkpoint_ready(); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OPAL_CR_TEST_CHECKPOINT_READY_STALL() \
|
|
|
|
{ \
|
|
|
|
if(OPAL_UNLIKELY(opal_cr_is_enabled && !opal_cr_stall_check)) { \
|
|
|
|
opal_cr_test_if_checkpoint_ready(); \
|
|
|
|
} \
|
|
|
|
}
|
2008-02-20 01:15:52 +03:00
|
|
|
|
|
|
|
/* If *not* using FT thread */
|
|
|
|
#if OPAL_ENABLE_FT_THREAD == 0
|
|
|
|
#define OPAL_CR_INIT_LIBRARY() OPAL_CR_TEST_CHECKPOINT_READY();
|
|
|
|
#define OPAL_CR_FINALIZE_LIBRARY() OPAL_CR_TEST_CHECKPOINT_READY();
|
|
|
|
#define OPAL_CR_ABORT_LIBRARY() OPAL_CR_TEST_CHECKPOINT_READY();
|
|
|
|
#define OPAL_CR_ENTER_LIBRARY() OPAL_CR_TEST_CHECKPOINT_READY();
|
|
|
|
#define OPAL_CR_EXIT_LIBRARY() OPAL_CR_TEST_CHECKPOINT_READY();
|
|
|
|
#define OPAL_CR_NOOP_PROGRESS() OPAL_CR_TEST_CHECKPOINT_READY();
|
|
|
|
#endif /* OPAL_ENABLE_FT_THREAD == 0 */
|
|
|
|
|
|
|
|
/* If using FT thread */
|
|
|
|
#if OPAL_ENABLE_FT_THREAD == 1
|
|
|
|
#define OPAL_CR_INIT_LIBRARY() \
|
|
|
|
{ \
|
|
|
|
opal_cr_thread_init_library(); \
|
|
|
|
}
|
|
|
|
#define OPAL_CR_FINALIZE_LIBRARY() \
|
|
|
|
{ \
|
|
|
|
opal_cr_thread_finalize_library(); \
|
|
|
|
}
|
|
|
|
#define OPAL_CR_ABORT_LIBRARY() \
|
|
|
|
{ \
|
|
|
|
opal_cr_thread_abort_library(); \
|
|
|
|
}
|
|
|
|
#define OPAL_CR_ENTER_LIBRARY() \
|
|
|
|
{ \
|
|
|
|
opal_cr_thread_enter_library(); \
|
|
|
|
}
|
|
|
|
#define OPAL_CR_EXIT_LIBRARY() \
|
|
|
|
{ \
|
|
|
|
opal_cr_thread_exit_library(); \
|
|
|
|
}
|
|
|
|
#define OPAL_CR_NOOP_PROGRESS() \
|
|
|
|
{ \
|
|
|
|
opal_cr_thread_noop_progress(); \
|
|
|
|
}
|
|
|
|
#endif /* OPAL_ENABLE_FT_THREAD == 1 */
|
|
|
|
|
|
|
|
#endif /* OPAL_ENABLE_FT == 1 */
|
2007-03-17 02:11:45 +03:00
|
|
|
|
|
|
|
/*******************************
|
|
|
|
* Notification Routines
|
|
|
|
*******************************/
|
2007-10-09 00:53:02 +04:00
|
|
|
/*******************************
|
|
|
|
* Notification Routines
|
|
|
|
*******************************/
|
2007-03-17 02:11:45 +03:00
|
|
|
/**
|
2007-10-09 00:53:02 +04:00
|
|
|
* A function to respond to the async checkpoint request
|
|
|
|
* this is useful when figuring out who should respond
|
|
|
|
* when stalling.
|
2007-03-17 02:11:45 +03:00
|
|
|
*/
|
2007-10-09 00:53:02 +04:00
|
|
|
typedef int (*opal_cr_notify_callback_fn_t) (opal_cr_ckpt_cmd_state_t);
|
|
|
|
|
|
|
|
OPAL_DECLSPEC int opal_cr_reg_notify_callback
|
|
|
|
(opal_cr_notify_callback_fn_t new_func,
|
|
|
|
opal_cr_notify_callback_fn_t *prev_func);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to go through the INC
|
|
|
|
* - Call Registered INC_Coord(CHECKPOINT)
|
|
|
|
* - Call the CRS.checkpoint()
|
|
|
|
* - Call Registered INC_Coord(state)
|
|
|
|
*/
|
|
|
|
OPAL_DECLSPEC int opal_cr_inc_core(pid_t pid,
|
|
|
|
opal_crs_base_snapshot_t *snapshot,
|
|
|
|
bool term, int *state);
|
2007-03-17 02:11:45 +03:00
|
|
|
|
|
|
|
/*******************************
|
|
|
|
* Coordination Routines
|
|
|
|
*******************************/
|
|
|
|
/**
|
|
|
|
* Coordination callback routine signature
|
|
|
|
*/
|
|
|
|
typedef int (*opal_cr_coord_callback_fn_t) (int);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a checkpoint coodination routine
|
|
|
|
* for a higher level.
|
|
|
|
*/
|
|
|
|
OPAL_DECLSPEC int opal_cr_reg_coord_callback
|
|
|
|
(opal_cr_coord_callback_fn_t new_func,
|
|
|
|
opal_cr_coord_callback_fn_t *prev_func);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* OPAL Checkpoint Coordination Routine
|
|
|
|
*/
|
|
|
|
OPAL_DECLSPEC int opal_cr_coord(int state);
|
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* OPAL_CR_H */
|
|
|
|
|