Sniperの解析の続き。RISC-Vのベクトル命令のサイクル解析を行えるようになりたい。 前回の結果では、まだまだ想定したサイクル数になっていない。16個のメモリリクエストを発生させるとして、16サイクルくらいかかってほしいのだがそうもいっていない。引き続き解析する。
まず、dynamic_instruction.h
におけるメモリアクセスの最大保持容量を増やす。ただしこれだけでは何も変化がない。
diff --git a/common/performance_model/dynamic_instruction.h b/common/performance_model/dynamic_instruction.h index feaf4f4..ee5cf7f 100644 --- a/common/performance_model/dynamic_instruction.h +++ b/common/performance_model/dynamic_instruction.h @@ -37,7 +37,7 @@ class DynamicInstruction SubsecondTime latency; HitWhere::where_t hit_where; }; - static const UInt8 MAX_MEMORY = 2; + static const UInt8 MAX_MEMORY = 32;
また、Sniper側のデコーダにも、メモリアクセスのオペランド回数を記述する必要がある。こういうのはSIFT側の情報をそのまま受け入れてほしいのだけれども、なぜか知らないがSniper側でも指定する必要がある。
diff --git a/decoder_lib/riscv_decoder.cc b/decoder_lib/riscv_decoder.cc index 5ea04ad..fe1bb52 100644 --- a/decoder_lib/riscv_decoder.cc +++ b/decoder_lib/riscv_decoder.cc @@ -188,6 +188,7 @@ unsigned int RISCVDecoder::num_memory_operands(const DecodedInst * inst) unsigned int num_memory_operands = 0; riscv::decode *dec = ((RISCVDecodedInst *)inst)->get_rv8_dec(); const char *format = rv_inst_format[dec->op]; + if (format == rv_fmt_rd_offset_rs1 /* lb, lh, lw, lbu, lhu, lwu, ld, ldu, lq, c.lwsp, c.ld, c.ldsp, c.lq, c.lqsp */ || format == rv_fmt_frd_offset_rs1 /* flw, fld, flq, c.fld, c.flw, c.fldsp, c.flwsp */ || format == rv_fmt_rs2_offset_rs1 /* sb, sh, sw, sd, sq, c.sw, c.swsp, c.sd, c.sdsp, c.sq, c.sqsp */ @@ -196,6 +197,9 @@ unsigned int RISCVDecoder::num_memory_operands(const DecodedInst * inst) || format == rv_fmt_aqrl_rd_rs2_rs1 /* amoswap.d */ || format == rv_fmt_aqrl_rd_rs2_rs1 /* amoswap.q */) { num_memory_operands++; + } else if (dec->op == rv_op_vle8_v || + dec->op == rv_op_vse8_v) { + num_memory_operands = 16; } return num_memory_operands; } @@ -204,7 +208,7 @@ unsigned int RISCVDecoder::num_memory_operands(const DecodedInst * inst) /// Get the base register of the memory operand pointed by mem_idx Decoder::decoder_reg RISCVDecoder::mem_base_reg (const DecodedInst * inst, unsigned int mem_idx) { - assert(mem_idx == 0); + // assert(mem_idx == 0); Decoder::decoder_reg reg; riscv::decode *dec = ((RISCVDecodedInst *)inst)->get_rv8_dec(); @@ -246,7 +250,10 @@ bool RISCVDecoder::op_read_mem(const DecodedInst * inst, unsigned int mem_idx) if (format == rv_fmt_rd_offset_rs1 /* lb, lh, lw, lbu, lhu, lwu, ld, ldu, lq, c.lwsp, c.ld, c.ldsp, c.lq, c.lqsp */ || format == rv_fmt_frd_offset_rs1 /* flw, fld, flq, c.fld, c.flw, c.fldsp, c.flwsp */ ) { res = true; + } else if (dec->op == rv_op_vle8_v) { + res = true; } + return res; } @@ -260,6 +267,8 @@ bool RISCVDecoder::op_write_mem(const DecodedInst * inst, unsigned int mem_idx) if (format == rv_fmt_rs2_offset_rs1 /* sb, sh, sw, sd, sq, c.sw, c.swsp, c.sd, c.sdsp, c.sq, c.sqsp */ || format == rv_fmt_frs2_offset_rs1 /* fsw, fsd, fsq, c.fsd, c.fsw, c.fsdsp, c.fswsp */ ) { res = true; + } else if (dec->op == rv_op_vse8_v) { + res = true; } return res; }
デバッグ時の情報を出力するように変更して再度実行した。
diff --git a/common/performance_model/performance_models/rob_performance_model/rob_timer.cc b/common/performance_model/performance_models/rob_performance_model/rob_timer.cc index 7330c00..5576a7e 100644 --- a/common/performance_model/performance_models/rob_performance_model/rob_timer.cc +++ b/common/performance_model/performance_models/rob_performance_model/rob_timer.cc @@ -19,7 +19,7 @@ #include <iomanip> // Define to get per-cycle printout of dispatch, issue, writeback stages -//#define DEBUG_PERCYCLE +#define DEBUG_PERCYCLE //#define STOP_PERCYCLE
なんとなくこのあたりなのかなあ?
Running cycle 4853 InstAddr = 80002854, num_addresses = 16, num_memory_operands = 16 ** simulate: LOAD (:0x 112) -- vle8.v s0, a1 =============================== FIRST LOAD: (:0x112) ------------------------------- ** simulate: EXEC (:0x 112) -- vle8.v s0, a1 =============================== LAST EXEC (:0x112) -------------------------------
これだけだとあまり変化がない。引き続き解析する。