-
Notifications
You must be signed in to change notification settings - Fork 27
Examples
kellekai edited this page Sep 28, 2017
·
12 revisions
Using FTI_Snapshot
Using FTI Checkpoint
#include <stdlib.h>
#include <fti.h>
int main(int argc, char** argv){
MPI_Init(&argc, &argv);
char* path = "config.fti"; //config file path
FTI_Init(path, MPI_COMM_WORLD);
int world_rank, world_size; //FTI_COMM rank & size
MPI_Comm_rank(FTI_COMM_WORLD, &world_rank);
MPI_Comm_size(FTI_COMM_WORLD, &world_size);
int *array = malloc(sizeof(int) * world_size);
int number = world_rank;
int i = 0;
//adding variables to protect
FTI_Protect(1, &i, 1, FTI_INTG);
FTI_Protect(2, &number, 1, FTI_INTG);
for (; i < 100; i++) {
FTI_Snapshot();
MPI_Allgather(&number, 1, MPI_INT, array,
1, MPI_INT, FTI_COMM_WORLD);
number += 1;
}
free(array);
FTI_Finalize();
MPI_Finalize();
return 0;
}DESCRIPTION
FTI_Snapshot()makes a checkpoint by given time and also recovers data after a failure, thus makes the code shorter. Checkpoints intervals can be set in configuration file (see: ckpt_L1 - ckpt_L4).
#include <stdlib.h>
#include <fti.h>
#define ITER_CHECK 10
int main(int argc, char** argv){
MPI_Init(&argc, &argv);
char* path = "config.fti"; //config file path
FTI_Init(path, MPI_COMM_WORLD);
int world_rank, world_size; //FTI_COMM rank & size
MPI_Comm_rank(FTI_COMM_WORLD, &world_rank);
MPI_Comm_size(FTI_COMM_WORLD, &world_size);
int *array = malloc(sizeof(int) * world_size);
int number = world_rank;
int i = 0;
//adding variables to protect
FTI_Protect(1, &i, 1, FTI_INTG);
FTI_Protect(2, &number, 1, FTI_INTG);
if (FTI_Status() != 0) {
FTI_Recover();
}
for (; i < 100; i++) {
if (i % ITER_CHECK == 0) {
FTI_Checkpoint(i / ITER_CHECK + 1, 2);
}
MPI_Allgather(&number, 1, MPI_INT, array,
1, MPI_INT, FTI_COMM_WORLD);
number += 1;
}
free(array);
FTI_Finalize();
MPI_Finalize();
return 0;
}DESCRIPTION
FTI_Checkpoint()allows to checkpoint at precise application intervals. Note that when usingFTI_Checkpoint(),ckpt_L1,ckpt_L2,ckpt_L3andckpt_L4are not taken into account.