Skip to content

Commit

Permalink
serializer: reserve an interval size of instuctions for warm up (#361)
Browse files Browse the repository at this point in the history
* serializer: reserve an interval size of instuctions for warm up before ROI
* Add warmup interval option, support manually specify the interval of warmup, the default value is equal to the checkpoint interval


---------

Signed-off-by: jiaxiaoyu <[email protected]>
  • Loading branch information
xyyy1420 authored Jun 20, 2024
1 parent c090b71 commit 9a46d46
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/checkpoint/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Serializer
private:

uint64_t intervalSize{10 * 1000 * 1000};
uint64_t warmupIntervalSize{10 * 1000 * 1000};

int cptID;
std::string weightIndicator;
Expand Down
1 change: 1 addition & 0 deletions include/profiling/profiling_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern int profiling_state;
extern int checkpoint_state;
extern bool checkpoint_restoring;
extern uint64_t checkpoint_interval;
extern uint64_t warmup_interval;

extern bool recvd_manual_oneshot_cpt;
extern bool recvd_manual_uniform_cpt;
Expand Down
5 changes: 3 additions & 2 deletions src/checkpoint/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ void Serializer::init() {
if (checkpoint_state == SimpointCheckpointing) {
assert(checkpoint_interval);
intervalSize = checkpoint_interval;
warmupIntervalSize = warmup_interval;
Log("Taking simpoint checkpionts with profiling interval %lu", checkpoint_interval);

auto simpoints_file = fstream(pathManager.getSimpointPath() + "simpoints0");
Expand Down Expand Up @@ -275,9 +276,9 @@ bool Serializer::instrsCouldTakeCpt(uint64_t num_insts) {
if (simpoint2Weights.empty()) {
break;
} else {
uint64_t next_point = simpoint2Weights.begin()->first * intervalSize + 100000;
uint64_t next_point = (simpoint2Weights.begin()->first * intervalSize) <= warmupIntervalSize ? 0 : (simpoint2Weights.begin()->first * intervalSize) - warmupIntervalSize;
if (num_insts >= next_point) {
Log("Should take cpt now: %lu", num_insts);
Log("Should take cpt now: %lu next point %lu", num_insts, next_point);
return true;
} else if (num_insts % intervalSize == 0) {
Log("First cpt @ %lu, now: %lu", next_point, num_insts);
Expand Down
7 changes: 7 additions & 0 deletions src/monitor/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static inline int parse_args(int argc, char *argv[]) {
{"manual-oneshot-cpt" , no_argument , NULL, 11},
{"manual-uniform-cpt" , no_argument , NULL, 9},
{"cpt-interval" , required_argument, NULL, 5},
{"warmup-interval" , required_argument, NULL, 14},
{"cpt-mmode" , no_argument , NULL, 7},
{"map-cpt" , required_argument, NULL, 10},
{"checkpoint-format" , required_argument, NULL, 12},
Expand Down Expand Up @@ -240,6 +241,7 @@ static inline int parse_args(int argc, char *argv[]) {
log_file = optarg;
small_log = true;
break;
case 14: sscanf(optarg, "%lu", &warmup_interval); break;

default:
printf("Usage: %s [OPTION...] IMAGE [args]\n\n", argv[0]);
Expand All @@ -261,6 +263,7 @@ static inline int parse_args(int argc, char *argv[]) {
printf("\t-S,--simpoint-dir=SIMPOINT_DIR simpoints dir\n");
printf("\t-u,--uniform-cpt uniformly take cpt with fixed interval\n");
printf("\t--cpt-interval=INTERVAL cpt interval: the profiling period for simpoint; the checkpoint interval for uniform cpt\n");
printf("\t--warmup-interval=INTERVAL warmup interval: the warmup interval for SimPoint cpt\n");
printf("\t--cpt-mmode force to take cpt in mmode, which might not work.\n");
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");
Expand Down Expand Up @@ -290,6 +293,10 @@ void init_monitor(int argc, char *argv[]) {
parse_args(argc, argv);
#endif

if (warmup_interval == 0) {
warmup_interval = checkpoint_interval;
}

if (map_image_as_output_cpt) {
assert(!mapped_cpt_file);
mapped_cpt_file = img_file;
Expand Down
1 change: 1 addition & 0 deletions src/profiling/profiling_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ int checkpoint_state = NoCheckpoint;
bool checkpoint_taking = false;
bool checkpoint_restoring = false;
uint64_t checkpoint_interval = 0;
uint64_t warmup_interval = 0;

bool recvd_manual_oneshot_cpt = false;
bool recvd_manual_uniform_cpt = false;
Expand Down

0 comments on commit 9a46d46

Please sign in to comment.