Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support time unit definition for trace based workloads #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/host/ASCII_Trace_Definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ enum class Trace_Time_Unit { PICOSECOND, NANOSECOND, MICROSECOND};//The unit of
#define ASCIILineDelimiter ' '
#define ASCIIItemsPerLine 5

#define PicoSec2SimTimeCoeff 1000
#define NanoSec2SimTimeCoeff 1
#define MicroSec2SimTimeCoeff 1000

#endif // !ASCII_TRACE_DEFINITION_H

38 changes: 35 additions & 3 deletions src/host/IO_Flow_Trace_Based.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,28 @@ namespace Host_Components
else
total_requests_to_be_generated = total_requests_in_file * total_replay_no;

sim_time_type curFireTime = 0;
trace_file.open(trace_file_path);
current_trace_line.clear();
std::getline(trace_file, trace_line);
Utils::Helper_Functions::Remove_cr(trace_line);
Utils::Helper_Functions::Tokenize(trace_line, ASCIILineDelimiter, current_trace_line);
Simulator->Register_sim_event(std::strtoll(current_trace_line[ASCIITraceTimeColumn].c_str(), &pEnd, 10), this);
curFireTime = std::strtoll(current_trace_line[ASCIITraceTimeColumn].c_str(), &pEnd, 10);
//convert trace time to simulator time
switch(time_unit){
case Trace_Time_Unit::PICOSECOND:
curFireTime = curFireTime / PicoSec2SimTimeCoeff;
break;
case Trace_Time_Unit::NANOSECOND:
curFireTime = curFireTime * NanoSec2SimTimeCoeff;
break;
case Trace_Time_Unit::MICROSECOND:
curFireTime = curFireTime * MicroSec2SimTimeCoeff;
break;
default:
PRINT_ERROR("Unexpected Trace Time Unit!")
}
Simulator->Register_sim_event(curFireTime, this);
}

void IO_Flow_Trace_Based::Validate_simulation_config()
Expand Down Expand Up @@ -138,7 +154,23 @@ namespace Host_Components
PRINT_MESSAGE("* Replay round "<< replay_counter << "of "<< total_replay_no << " started for" << ID())
}
char* pEnd;
Simulator->Register_sim_event(time_offset + std::strtoll(current_trace_line[ASCIITraceTimeColumn].c_str(), &pEnd, 10), this);
sim_time_type curFireTime = 0;
curFireTime = std::strtoll(current_trace_line[ASCIITraceTimeColumn].c_str(), &pEnd, 10);
//convert trace time to simulator time
switch(time_unit){
case Trace_Time_Unit::PICOSECOND:
curFireTime = curFireTime / PicoSec2SimTimeCoeff;
break;
case Trace_Time_Unit::NANOSECOND:
curFireTime = curFireTime * NanoSec2SimTimeCoeff;
break;
case Trace_Time_Unit::MICROSECOND:
curFireTime = curFireTime * MicroSec2SimTimeCoeff;
break;
default:
PRINT_ERROR("Unexpected Trace Time Unit!")
}
Simulator->Register_sim_event(curFireTime, this);
}
}

Expand Down Expand Up @@ -276,4 +308,4 @@ namespace Host_Components
stats.Initial_occupancy_ratio = initial_occupancy_ratio;
stats.Replay_no = total_replay_no;
}
}
}