int main(int argc, char **argv) { char *ckptname = "ckpt_test"; char *sec = "default"; char *val; void *h; char buf[64]; int ret; int op = 0; while((ret = getopt(argc, argv, "c:w:r:d:j?")) != EOF) { switch(ret) { case 'c': ckptname = optarg; break; case 'w': op = 'w'; sec = optarg; break; case 'r': op = 'r'; sec = optarg; break; case 'd': val = optarg; break; case '?': case 'h': usage(0); default: usage(1); } } if (!op) { usage(1); } if (!sec) { usage(1); } h = ckpt_init(ckptname, 262144, 4096, 64, 10); if (!h) { perror("ckpt_init"); return -1; } if (op == 'w') { if (ckpt_write(h, sec, val, strlen(val)+1) < 0) { perror("ckpt_write"); return 1; } } else if (op == 'r') { ret = ckpt_read(h, sec, buf, sizeof(buf)); if (ret < 0) { perror("ckpt_read"); return 1; } printf("%d bytes\nDATA for '%s':\n%s\n", ret, sec, buf); } ckpt_finish(h); return 0; }
int main(int argc, char *argv[]) { int ret, exit_status = ORTE_SUCCESS; /*************** * Initialize ***************/ if (ORTE_SUCCESS != (ret = ckpt_init(argc, argv))) { exit_status = ret; goto cleanup; } /*************************** * Find the HNP that we want to connect to, if it exists ***************************/ if (ORTE_SUCCESS != (ret = find_hnp())) { /* Error printed by called function */ exit_status = ret; goto cleanup; } /******************************* * Checkpoint the requested PID *******************************/ if( orte_checkpoint_globals.verbose ) { opal_output_verbose(10, orte_checkpoint_globals.output, "orte_checkpoint: Checkpointing..."); if (0 < orte_checkpoint_globals.pid) { opal_output_verbose(10, orte_checkpoint_globals.output, "\t PID %d", orte_checkpoint_globals.pid); } else if (ORTE_JOBID_INVALID != orte_checkpoint_globals.req_hnp){ opal_output_verbose(10, orte_checkpoint_globals.output, "\t Mpirun (%s)", ORTE_JOBID_PRINT(orte_checkpoint_globals.req_hnp)); } opal_output_verbose(10, orte_checkpoint_globals.output, "\t Connected to Mpirun %s", ORTE_NAME_PRINT(&orterun_hnp->name)); if(orte_checkpoint_globals.term) { opal_output_verbose(10, orte_checkpoint_globals.output, "\t Terminating after checkpoint\n"); } } if(ORTE_SUCCESS != (ret = notify_process_for_checkpoint( orte_checkpoint_globals.term)) ) { orte_show_help("help-orte-checkpoint.txt", "ckpt_failure", true, orte_checkpoint_globals.pid, ret); exit_status = ret; goto cleanup; } /* * Wait for the checkpoint to complete */ if(!orte_checkpoint_globals.nowait) { while( ORTE_SNAPC_CKPT_STATE_FINISHED != orte_checkpoint_globals.ckpt_status && ORTE_SNAPC_CKPT_STATE_NO_CKPT != orte_checkpoint_globals.ckpt_status && ORTE_SNAPC_CKPT_STATE_ERROR != orte_checkpoint_globals.ckpt_status ) { opal_progress(); } } if( ORTE_SNAPC_CKPT_STATE_NO_CKPT == orte_checkpoint_globals.ckpt_status ) { exit_status = ORTE_ERROR; goto cleanup; } if( ORTE_SNAPC_CKPT_STATE_ERROR == orte_checkpoint_globals.ckpt_status ) { orte_show_help("help-orte-checkpoint.txt", "ckpt_failure", true, orte_checkpoint_globals.pid, ORTE_ERROR); exit_status = ORTE_ERROR; goto cleanup; } if( orte_checkpoint_globals.status ) { orte_checkpoint_globals.ckpt_status = ORTE_SNAPC_CKPT_STATE_FINISHED; pretty_print_status(); } if(!orte_checkpoint_globals.nowait) { pretty_print_reference(); } cleanup: /*************** * Cleanup ***************/ if (ORTE_SUCCESS != (ret = ckpt_finalize())) { return ret; } return exit_status; }
void _init() { ckpt_init(); }