Skip to content

Commit

Permalink
added cleanup primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
bnicolae committed Oct 27, 2022
1 parent f7ef1ee commit c857688
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
7 changes: 7 additions & 0 deletions include/veloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ int VELOC_Mem_unprotect(int id);
// can be used to manually read/write checkpointing data without registering memory regions
int VELOC_Route_file(const char *original, char *routed);

/**************************
* Cleanup
*************************/

// remove all checkpoints in "scratch" corresponding to name
int VELOC_Cleanup(const char *name);

/**************************
* Checkpoint routines
*************************/
Expand Down
1 change: 1 addition & 0 deletions include/veloc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class client_t {
}

virtual std::string route_file(const std::string &original) = 0;
virtual bool cleanup(const std::string &name) = 0;

virtual bool checkpoint(const std::string &name, int version) = 0;
virtual bool checkpoint_begin(const std::string &name, int version) = 0;
Expand Down
7 changes: 7 additions & 0 deletions src/lib/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ client_impl_t::~client_impl_t() {
DBG("VELOC finalized");
}

bool client_impl_t::cleanup(const std::string &name) {
parse_dir(cfg.get("scratch"), name, [](const std::string &fname, int, int) {
remove(fname.c_str());
});
return true;
}

bool client_impl_t::checkpoint_wait() {
if (checkpoint_in_progress) {
ERROR("need to finalize local checkpoint first by calling checkpoint_end()");
Expand Down
1 change: 1 addition & 0 deletions src/lib/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class client_impl_t : public veloc::client_t {
client_impl_t(MPI_Comm comm, const std::string &cfg_file);

virtual std::string route_file(const std::string &original);
virtual bool cleanup(const std::string &name);

virtual bool checkpoint(const std::string &name, int version);
virtual bool checkpoint_begin(const std::string &name, int version);
Expand Down
6 changes: 5 additions & 1 deletion src/lib/veloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extern "C" int VELOC_Checkpoint_wait() {
}

extern "C" int VELOC_Checkpoint_finished() {
if (veloc_client == NULL)
if (veloc_client == NULL)
return -1;
return veloc_client->checkpoint_finished();
}
Expand All @@ -86,6 +86,10 @@ extern "C" int VELOC_Route_file(const char *original, char *routed) {
return routed[0] != 0 ? VELOC_SUCCESS : VELOC_FAILURE;
}

extern "C" int VELOC_Cleanup(const char *name) {
return CLIENT_CALL(veloc_client->cleanup(std::string(name)));
}

extern "C" int VELOC_Restart_begin(const char *name, int version) {
return CLIENT_CALL(veloc_client->restart_begin(std::string(name), version));
}
Expand Down
4 changes: 3 additions & 1 deletion test/heatdis_fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ int main(int argc, char *argv[]) {

free(h);
free(g);
VELOC_Finalize(1); // wait for checkpoints to finish
VELOC_Checkpoint_wait();
VELOC_Cleanup("heatdis");
VELOC_Finalize(1);
MPI_Finalize();
return 0;
}

0 comments on commit c857688

Please sign in to comment.