FPGA開発日記

カテゴリ別記事インデックス https://msyksphinz.github.io/github_pages , English Version https://fpgadevdiary.hatenadiary.com/

SonicBOOMのデザインを読み解く (2. LargeBoomConfigの場合)

LargeBOOMConfigの場合、Coremark値は以下のようになった。CMK/MHzは4.68となり、公称値よりも少し低いくらいになっている。

using random seed 1618715154
This emulator compiled with JTAG Remote Bitbang client. To enable, use +jtag_rbb_enable=1.
Listening on port 63674
2K performance run parameters for coremark.
CoreMark Size    : 666
Total ticks      : 213874
Total time (secs): %f
Iterations/Sec   : %f
ERROR! Must execute for at least 10 secs for a valid result!
Iterations       : 1
Compiler version : GCC9.2.0
link.ld
Memory location  : Please put data memory location here
                        (e.g. code in flash, data on heap etc)
seedcrc          : 0xe9f5
[0]crclist       : 0xe714
[0]crcmatrix     : 0x1fd7
[0]crcstate      : 0x8e3a
[0]crcfinal      : 0xe714
Errors detected
*** PASSED *** Completed after 399712 cycles
[UART] UART0 is here (stdin/stdout).

同じようにベンチマーク全体でのIPC値を測定した。通常のコンフィグレーションと同様に、最大発行命令数の限界である3.0に近い値が出ている部分が多い。

f:id:msyksphinz:20210418221928p:plain

IPC=3.0に近い値を出している部分のログを見てみる。どうも依存関係があったとしても1サイクルで演算ができているように見える。マジで?

               43217 3 0x00000000800018a8 c.add   t3, t6         x28 0x0000000080003c68
               43217 3 0x00000000800018aa c.mv    a2, t4        x12 0x0000000000000000
               43218 3 0x00000000800018ac c.mv    a3, t5        x13 0x0000000000000000  // ここの3命令は同時にコミット
               43218 3 0x00000000800018ae c.li    a1, 0         x11 0x0000000000000000  // ここの3命令は同時にコミット
               43218 3 0x00000000800018b0 slli    a4, a3, 32    x14 0x0000000000000000  // ここの3命令は同時にコミット
               43219 3 0x00000000800018b4 slli    a5, a2, 32    x15 0x0000000000000000
               43219 3 0x00000000800018b8 c.srli  a4, 32        x14 0x0000000000000000
               43219 3 0x00000000800018ba c.srli  a5, 32        x15 0x0000000000000000
               43220 3 0x00000000800018bc c.slli  a4, 1         x14 0x0000000000000000
               43220 3 0x00000000800018be c.slli  a5, 1         x15 0x0000000000000000
               43228 3 0x00000000800018c0 c.add   a4, t1        x14 0x0000000080003b24
               43229 3 0x00000000800018c2 c.add   a5, a7        x15 0x0000000080003bc6
               43230 3 0x00000000800018c4 lh      a4, 0(a4)     x14 0x0000000000000014
               43231 3 0x00000000800018c8 lh      a5, 0(a5)     x15 0x0000000000000002
               43232 3 0x00000000800018cc c.addiw a3, 1         x13 0x0000000000000001
               43232 3 0x00000000800018ce c.addw  a2, a0        x12 0x0000000000000009
               43236 3 0x00000000800018d0 mulw    a5, a4, a5    x15 0x0000000000000028
               43240 3 0x00000000800018d4 c.addw  a1, a5        x11 0x0000000000000028

調べてみると、3つのALUがすべてActivateされている時間帯はそんなに多くなかった。その代わりにLSUが動いており平均して3命令が常に同時に完了しているような形になっている。これである程度IPCを稼いでいる訳か。

f:id:msyksphinz:20210418222020p:plain
diff --git a/riscv64-baremetal/core_portme.h b/riscv64-baremetal/core_portme.h
index ef26e88..30b5b2a 100755
--- a/riscv64-baremetal/core_portme.h
+++ b/riscv64-baremetal/core_portme.h
@@ -104,7 +104,8 @@ typedef unsigned short ee_u16;
 typedef signed int ee_s32;
 typedef double ee_f32;
 typedef unsigned char ee_u8;
-typedef unsigned int ee_u32;
+// typedef unsigned int ee_u32;
+typedef signed int ee_u32;
 typedef unsigned long long ee_ptr_int;
 typedef size_t ee_size_t;
 /* align an offset to point to a 32b value */
using random seed 1618736478
This emulator compiled with JTAG Remote Bitbang client. To enable, use +jtag_rbb_enable=1.
Listening on port 60136
2K performance run parameters for coremark.
CoreMark Size    : 666
Total ticks      : 193819
Total time (secs): %f
Iterations/Sec   : %f
ERROR! Must execute for at least 10 secs for a valid result!
Iterations       : 1
Compiler version : GCC9.2.0
link.ld
Memory location  : Please put data memory location here
                        (e.g. code in flash, data on heap etc)
seedcrc          : 0xe9f5
[0]crclist       : 0xe714
[0]crcmatrix     : 0x1fd7
[0]crcstate      : 0x8e3a
[0]crcfinal      : 0xe714
Errors detected
*** PASSED *** Completed after 381305 cycles

193,819サイクルで、5.16CMK/MHzとなった。前の値が4.68なので、結構上がっている。命令数は312,733なので、367,593 にくらべてかなり減っている。結局これが効いているのか。