Thread -> Lane

"thread" is confusing, unify to lane when denoting a hardware SIMD lane
inside a single warp.
This commit is contained in:
Hansung Kim
2023-03-09 22:09:07 -08:00
parent a495149869
commit 9bfb813e1b
4 changed files with 78 additions and 65 deletions

View File

@@ -35,7 +35,7 @@ void MemTraceReader::parse() {
printf("MemTraceReader: started parsing\n");
while (infile >> line.cycle >> line.loadstore >> line.core_id >>
line.thread_id >> std::hex >> line.address >> line.data >> std::dec >>
line.lane_id >> std::hex >> line.address >> line.data >> std::dec >>
line.data_size) {
line.valid = true;
trace.push_back(line);
@@ -49,7 +49,7 @@ void MemTraceReader::parse() {
// given SIMD lane (= "thread"). In case no request happened at that point,
// return an empty line with .valid = false.
MemTraceLine MemTraceReader::read_trace_at(const long cycle,
const int thread_id) {
const int lane_id) {
MemTraceLine line;
line.valid = false;
@@ -67,17 +67,17 @@ MemTraceLine MemTraceReader::read_trace_at(const long cycle,
assert(false && "some trace lines are left unread in the past");
}
if (line.thread_id != thread_id) {
if (line.lane_id != lane_id) {
line.valid = false;
}
if (line.cycle > cycle) {
// We haven't reached the cycle mark specified in this line yet, so we don't
// read it right now.
return MemTraceLine{};
} else if (line.cycle == cycle && line.thread_id == thread_id) {
} else if (line.cycle == cycle && line.lane_id == lane_id) {
printf("fire! cycle=%ld, valid=%d, %s \n", cycle, line.valid, line.loadstore);
// FIXME! Currently thread_id is assumed to be in round-robin order, e.g.
// FIXME! Currently lane_id is assumed to be in round-robin order, e.g.
// 0->1->2->3->0->..., both in the trace file and the order the caller calls
// this function. If this is not true, we cannot simply monotonically
// increment read_pos.
@@ -101,7 +101,7 @@ extern "C" void memtrace_init(const char *filename) {
// TODO: accept core_id as well
extern "C" void memtrace_query(unsigned char trace_read_ready,
unsigned long trace_read_cycle,
int trace_read_thread_id,
int trace_read_lane_id,
unsigned char *trace_read_valid,
unsigned long *trace_read_address,
unsigned char *trace_read_is_store,
@@ -109,13 +109,13 @@ extern "C" void memtrace_query(unsigned char trace_read_ready,
unsigned long *trace_read_data,
unsigned char *trace_read_finished) {
// printf("memtrace_query(cycle=%ld, tid=%d)\n", trace_read_cycle,
// trace_read_thread_id);
// trace_read_lane_id);
if (!trace_read_ready) {
return;
}
auto line = reader->read_trace_at(trace_read_cycle, trace_read_thread_id);
auto line = reader->read_trace_at(trace_read_cycle, trace_read_lane_id);
*trace_read_valid = line.valid;
*trace_read_address = line.address;
*trace_read_is_store = strcmp(line.loadstore, "STORE") == 0 ;

View File

@@ -12,7 +12,7 @@ struct MemTraceLine {
long cycle = 0;
char loadstore[10];
int core_id = 0;
int thread_id = 0;
int lane_id = 0;
unsigned long address = 0;
unsigned long data = 0;
int data_size = 0;
@@ -23,7 +23,7 @@ public:
MemTraceReader(const std::string &filename);
~MemTraceReader();
void parse();
MemTraceLine read_trace_at(const long cycle, const int thread_id);
MemTraceLine read_trace_at(const long cycle, const int lane_id);
bool finished() const { return read_pos == trace.cend(); }
std::ifstream infile;
@@ -34,7 +34,7 @@ public:
extern "C" void memtrace_init(const char *filename);
extern "C" void memtrace_query(unsigned char trace_read_ready,
unsigned long trace_read_cycle,
int trace_read_thread_id,
int trace_read_lane_id,
unsigned char *trace_read_valid,
unsigned long *trace_read_address,
unsigned char *trace_read_is_store,

View File

@@ -1,5 +1,5 @@
`define DATA_WIDTH 64
`define MAX_NUM_THREADS 32
`define MAX_NUM_LANES 32
`define MASK_WIDTH 8
import "DPI-C" function void memtrace_init(
@@ -23,26 +23,26 @@ import "DPI-C" function void memtrace_query
output bit trace_read_finished
);
module SimMemTrace #(parameter FILENAME = "undefined", NUM_THREADS = 4) (
module SimMemTrace #(parameter FILENAME = "undefined", NUM_LANES = 4) (
input clock,
input reset,
// These have to match the IO port of the Chisel wrapper module.
input trace_read_ready,
output [NUM_THREADS-1:0] trace_read_valid,
output [`DATA_WIDTH*NUM_THREADS-1:0] trace_read_address,
output [NUM_LANES-1:0] trace_read_valid,
output [`DATA_WIDTH*NUM_LANES-1:0] trace_read_address,
output [NUM_THREADS-1:0] trace_read_is_store,
output [NUM_THREADS*`MASK_WIDTH-1:0] trace_read_store_mask,
output [`DATA_WIDTH*NUM_THREADS-1:0] trace_read_data,
output [NUM_LANES-1:0] trace_read_is_store,
output [NUM_LANES*`MASK_WIDTH-1:0] trace_read_store_mask,
output [`DATA_WIDTH*NUM_LANES-1:0] trace_read_data,
output trace_read_finished
);
bit __in_valid[NUM_THREADS-1:0];
longint __in_address[NUM_THREADS-1:0];
bit __in_valid[NUM_LANES-1:0];
longint __in_address[NUM_LANES-1:0];
bit __in_is_store[NUM_THREADS-1:0];
int __in_store_mask [NUM_THREADS-1:0];
longint __in_data[NUM_THREADS-1:0];
bit __in_is_store[NUM_LANES-1:0];
int __in_store_mask [NUM_LANES-1:0];
longint __in_data[NUM_LANES-1:0];
bit __in_finished;
string __uartlog;
@@ -54,18 +54,18 @@ module SimMemTrace #(parameter FILENAME = "undefined", NUM_THREADS = 4) (
assign next_cycle_counter = cycle_counter + 1'b1;
// registers that stage outputs of the C parser
reg [NUM_THREADS-1:0] __in_valid_reg;
reg [`DATA_WIDTH-1:0] __in_address_reg [NUM_THREADS-1:0];
reg [NUM_LANES-1:0] __in_valid_reg;
reg [`DATA_WIDTH-1:0] __in_address_reg [NUM_LANES-1:0];
reg [NUM_THREADS-1:0] __in_is_store_reg;
reg [`MASK_WIDTH-1:0] __in_store_mask_reg [NUM_THREADS-1:0];
reg [`DATA_WIDTH-1:0] __in_data_reg [NUM_THREADS-1:0];
reg [NUM_LANES-1:0] __in_is_store_reg;
reg [`MASK_WIDTH-1:0] __in_store_mask_reg [NUM_LANES-1:0];
reg [`DATA_WIDTH-1:0] __in_data_reg [NUM_LANES-1:0];
reg __in_finished_reg;
genvar g;
generate
for (g = 0; g < NUM_THREADS; g = g + 1) begin
for (g = 0; g < NUM_LANES; g = g + 1) begin
assign trace_read_valid[g] = __in_valid_reg[g];
assign trace_read_address[`DATA_WIDTH*(g+1)-1:`DATA_WIDTH*g] = __in_address_reg[g];
@@ -86,7 +86,7 @@ module SimMemTrace #(parameter FILENAME = "undefined", NUM_THREADS = 4) (
// Setting reset value
if (reset) begin
for (integer tid = 0; tid < NUM_THREADS; tid = tid + 1) begin
for (integer tid = 0; tid < NUM_LANES; tid = tid + 1) begin
__in_valid[tid] = 1'b0;
__in_address[tid] = `DATA_WIDTH'b0;
@@ -100,7 +100,7 @@ module SimMemTrace #(parameter FILENAME = "undefined", NUM_THREADS = 4) (
cycle_counter <= `DATA_WIDTH'b0;
// setting default value for register to avoid latches
for (integer tid = 0; tid < NUM_THREADS; tid = tid + 1) begin
for (integer tid = 0; tid < NUM_LANES; tid = tid + 1) begin
__in_valid_reg[tid] <= 1'b0;
__in_address_reg[tid] <= `DATA_WIDTH'b0;
@@ -114,7 +114,7 @@ module SimMemTrace #(parameter FILENAME = "undefined", NUM_THREADS = 4) (
cycle_counter <= next_cycle_counter;
// Getting values from C function into pseudeo register
for (integer tid = 0; tid < NUM_THREADS; tid = tid + 1) begin
for (integer tid = 0; tid < NUM_LANES; tid = tid + 1) begin
memtrace_query(
trace_read_ready,
// Since parsed results are latched to the output on the next
@@ -135,7 +135,7 @@ module SimMemTrace #(parameter FILENAME = "undefined", NUM_THREADS = 4) (
end
// Connect values from pseudo register into verilog register
for (integer tid = 0; tid < NUM_THREADS; tid = tid + 1) begin
for (integer tid = 0; tid < NUM_LANES; tid = tid + 1) begin
__in_valid_reg[tid] <= __in_valid[tid];
__in_address_reg[tid] <= __in_address[tid];