root/ompi/mpiext/cr/c/checkpoint.c

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

DEFINITIONS

This source file includes following definitions.
  1. OMPI_CR_Checkpoint

   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) 2012 Cisco Systems, Inc.  All rights reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  */
  12 #include "ompi_config.h"
  13 #include <stdio.h>
  14 
  15 #include "ompi/mpi/c/bindings.h"
  16 #include "ompi/info/info.h"
  17 #include "ompi/runtime/params.h"
  18 #include "ompi/communicator/communicator.h"
  19 #include "orte/mca/snapc/snapc.h"
  20 
  21 #include "ompi/mpiext/cr/c/mpiext_cr_c.h"
  22 
  23 static const char FUNC_NAME[] = "OMPI_CR_Checkpoint";
  24 #define HANDLE_SIZE_MAX 256
  25 
  26 int OMPI_CR_Checkpoint(char **handle, int *seq, MPI_Info *info)
  27 {
  28     int ret = MPI_SUCCESS;
  29     MPI_Comm comm = MPI_COMM_WORLD;
  30     orte_snapc_base_request_op_t *datum = NULL;
  31     int state = 0;
  32     int my_rank;
  33 
  34     /* argument checking */
  35     if (MPI_PARAM_CHECK) {
  36         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  37     }
  38 
  39     /*
  40      * Setup the data structure for the operation
  41      */
  42     datum = OBJ_NEW(orte_snapc_base_request_op_t);
  43     datum->event = ORTE_SNAPC_OP_CHECKPOINT;
  44     datum->is_active = true;
  45 
  46     MPI_Comm_rank(comm, &my_rank);
  47     if( 0 == my_rank ) {
  48         datum->leader = OMPI_PROC_MY_NAME->vpid;
  49     } else {
  50         datum->leader = -1; /* Unknown from non-root ranks */
  51     }
  52 
  53     /*
  54      * All processes must make this call before it can start
  55      */
  56     MPI_Barrier(comm);
  57 
  58     /*
  59      * Leader sends the request
  60      */
  61     OPAL_CR_ENTER_LIBRARY();
  62     ret = orte_snapc.request_op(datum);
  63     if( OMPI_SUCCESS != ret ) {
  64         OBJ_RELEASE(datum);
  65         OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OTHER,
  66                                FUNC_NAME);
  67     }
  68     OPAL_CR_EXIT_LIBRARY();
  69 
  70     /*
  71      * Leader then sends out the commit message
  72      */
  73     if( datum->leader == (int)OMPI_PROC_MY_NAME->vpid ) {
  74         *handle = strdup(datum->global_handle);
  75         *seq = datum->seq_num;
  76         state = 0;
  77     } else {
  78         *handle = (char*)malloc(sizeof(char)*HANDLE_SIZE_MAX);
  79     }
  80 
  81     MPI_Bcast(&state, 1, MPI_INT, 0, comm);
  82     MPI_Bcast(seq,    1, MPI_INT, 0, comm);
  83     MPI_Bcast(*handle, HANDLE_SIZE_MAX, MPI_CHAR, 0, comm);
  84 
  85     datum->is_active = false;
  86     OBJ_RELEASE(datum);
  87 
  88     return ret;
  89 }

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