/* StarPU --- Runtime system for heterogeneous multicore architectures.
 *
 * Copyright (C) 2013-2020  Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
 *
 * StarPU is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.
 *
 * StarPU is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU Lesser General Public License in COPYING.LGPL for more details.
 */

#ifndef FT_STARPU_STARPU_MPI_FT_H
#define FT_STARPU_STARPU_MPI_FT_H

#ifdef __cplusplus
extern "C"
{
#endif

struct _starpu_mpi_checkpoint_template;
typedef struct _starpu_mpi_checkpoint_template* starpu_mpi_checkpoint_template_t;

/**
 * Registers a checkpoint template \p cp_template with the given arguments.
 * It is then ready to use with ::starpu_mpi_submit_checkpoint_template during the program execution.
 * A unique checkpoint id \p cp_id is requested from the user in order to
 * match with a corresponding ::starpu_mpi_init_from_checkpoint.
 *
 * The arguments following the cp_template and the checkpoint_id can be of the following types:
 * <ul>
 * <li> ::STARPU_R followed by a data handle and the backup rank;
 * <li> ::STARPU_DATA_ARRAY followed by an array of data handles,
 * its number of elements and a backup rank;
 * <li> ::STARPU_VALUE followed by a pointer to the unregistered value,
 * its size in bytes, a unique tag (as the ones given for data handle registering)
 * and the function giving the back up rank of the rank argument : int(backup_of)(int) .
 * <li> The argument list must be ended by the value 0.
 * </ul>
 */

#ifdef STARPU_USE_MPI_FT
int starpu_mpi_checkpoint_template_register(starpu_mpi_checkpoint_template_t* cp_template, int cp_id, int cp_domain, ...);
int starpu_mpi_checkpoint_template_create(starpu_mpi_checkpoint_template_t* cp_template, int cp_id, int cp_domain);
int starpu_mpi_checkpoint_template_add_entry(starpu_mpi_checkpoint_template_t* cp_template, ...);
int starpu_mpi_checkpoint_template_freeze(starpu_mpi_checkpoint_template_t* cp_template);
int starpu_mpi_submit_checkpoint_template(starpu_mpi_checkpoint_template_t cp_template);
int starpu_mpi_ft_turn_on(void);
int starpu_mpi_ft_turn_off(void);
int _starpu_mpi_checkpoint_template_print(starpu_mpi_checkpoint_template_t cp_template);
#else //STARPU_USE_MPI_FT
static int starpu_mpi_checkpoint_template_register(starpu_mpi_checkpoint_template_t* cp_template, int cp_id, int cp_domain, ...) {return 0;}
static int starpu_mpi_checkpoint_template_create(starpu_mpi_checkpoint_template_t* cp_template, int cp_id, int cp_domain) {return 0;}
static int starpu_mpi_checkpoint_template_add_entry(starpu_mpi_checkpoint_template_t* cp_template, ...) {return 0;}
static int starpu_mpi_checkpoint_template_freeze(starpu_mpi_checkpoint_template_t* cp_template) {return 0;}
static int starpu_mpi_submit_checkpoint_template(starpu_mpi_checkpoint_template_t cp_template) {return 0;}
static int starpu_mpi_ft_turn_on(void) {return 0;}
static int starpu_mpi_ft_turn_off(void) {return 0;}
static int _starpu_mpi_checkpoint_template_print(starpu_mpi_checkpoint_template_t cp_template) {return 0;}
#endif //STARPU_USE_MPI_FT

#ifdef __cplusplus
}
#endif

#endif //FT_STARPU_STARPU_MPI_FT_H
