Skip to content

Commit

Permalink
feat: add --store-cpt-in-flash option (#778)
Browse files Browse the repository at this point in the history
This commit introduces the `--using-flash-store-checkpoint` option, which is intended to enable saving checkpoints directly to flash storage.

Currently, this option is not yet implemented in the workflow. Future updates will integrate this feature into the relevant checkpoint handling logic.

Signed-off-by: jiaxiaoyu <[email protected]>
  • Loading branch information
xyyy1420 authored Jan 14, 2025
1 parent fa634b4 commit 0bb9160
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion include/checkpoint/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Serializer

explicit Serializer();

void init();
void init(bool store_cpt_in_flash);

bool shouldTakeCpt(uint64_t num_insts);
bool instrsCouldTakeCpt(uint64_t num_insts);
Expand Down Expand Up @@ -68,6 +68,7 @@ class Serializer
const uint32_t MISCDoneFlag;

bool regDumped{false};
bool store_cpt_in_flash{false};

std::map<uint64_t, double> simpoint2Weights;

Expand Down
8 changes: 5 additions & 3 deletions src/checkpoint/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ void Serializer::serialize(uint64_t inst_count) {
#endif
}

void Serializer::init() {
void Serializer::init(bool store_cpt_in_flash) {
this->store_cpt_in_flash = store_cpt_in_flash;

if (checkpoint_state == SimpointCheckpointing) {
assert(checkpoint_interval);
intervalSize = checkpoint_interval;
Expand Down Expand Up @@ -382,8 +384,8 @@ uint64_t Serializer::next_index(){

extern "C" {

void init_serializer() {
serializer.init();
void init_serializer(bool store_cpt_in_flash) {
serializer.init(store_cpt_in_flash);
}

bool try_take_cpt(uint64_t icount) {
Expand Down
15 changes: 13 additions & 2 deletions src/monitor/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static char *flash_image = NULL;
static int batch_mode = false;
static int difftest_port = 1234;
char *max_instr = NULL;
static bool store_cpt_in_flash = false;
char compress_file_format = 0; // default is gz

extern char *mapped_cpt_file; // defined in paddr.c
Expand Down Expand Up @@ -115,6 +116,7 @@ static inline int parse_args(int argc, char *argv[]) {
{"cpt-mmode" , no_argument , NULL, 7},
{"map-cpt" , required_argument, NULL, 10},
{"checkpoint-format" , required_argument, NULL, 12},
{"store-cpt-in-flash", no_argument, NULL, 17},

// profiling
{"simpoint-profile" , no_argument , NULL, 3},
Expand Down Expand Up @@ -154,6 +156,14 @@ static inline int parse_args(int argc, char *argv[]) {
flash_image = optarg;
break;

case 17:
#ifdef CONFIG_HAS_FLASH
store_cpt_in_flash = true;
#else
assert(0);
#endif
break;

case 'r':
restorer = optarg;
break;
Expand Down Expand Up @@ -271,6 +281,7 @@ static inline int parse_args(int argc, char *argv[]) {
printf("\t--manual-oneshot-cpt Manually take one-shot cpt by send signal.\n");
printf("\t--manual-uniform-cpt Manually take uniform cpt by send signal.\n");
printf("\t--checkpoint-format=FORMAT Specify the checkpoint format('gz' or 'zstd'), default: 'gz'.\n");
printf("\t--store-cpt-in-flash Use this option to save the checkpoint to flash storage.\n");
// printf("\t--map-cpt map to this file as pmem, which can be treated as a checkpoint.\n"); //comming back soon

printf("\t--flash-image=FLASH_IMAGE image path of flash\n");
Expand Down Expand Up @@ -315,14 +326,14 @@ void init_monitor(int argc, char *argv[]) {

extern void init_path_manager();
extern void simpoint_init();
extern void init_serializer();
extern void init_serializer(bool store_cpt_in_flash);

//checkpoint and profiling set output
bool output_features_enabled = checkpoint_state != NoCheckpoint || profiling_state == SimpointProfiling;
if (output_features_enabled) {
init_path_manager();
simpoint_init();
init_serializer();
init_serializer(store_cpt_in_flash);
}

/* Initialize memory. */
Expand Down

0 comments on commit 0bb9160

Please sign in to comment.