diff --git a/VX_config.toml b/VX_config.toml index db2a13d3ce..81ae01bba4 100644 --- a/VX_config.toml +++ b/VX_config.toml @@ -266,12 +266,19 @@ VX_CFG_ICACHE_MRSQ_SIZE = 0 VX_CFG_ICACHE_MREQ_SIZE = 0 VX_CFG_ICACHE_CRSQ_SIZE = 0 VX_CFG_ICACHE_MEM_PORTS = 1 -# banks behind the fetch-slice request ports -VX_CFG_ICACHE_NUM_BANKS = "expr: pow(2, clog2($VX_CFG_FETCH_WIDTH))" +# banks behind the fetch-slice request ports; with the fetch L0 the slices share +# one port, which a bank serves +VX_CFG_ICACHE_NUM_BANKS = "expr: 1 if $VX_CFG_ICACHE_L0_ENABLE else pow(2, clog2($VX_CFG_FETCH_WIDTH))" # Merge same-line fetches from the core's slices in the same cycle into one # bank access; the response goes to every merged slice, each with its word. VX_CFG_ICACHE_READ_MERGE = 1 VX_CFG_ICACHE_LATENCY = "expr: 2 + max(0, clog2($VX_CFG_ICACHE_SIZE) - clog2(16384))" +# Fetch L0: each fetch slice keeps a few whole icache lines, and a fetch that +# hits there reaches decode the next cycle instead of after the icache's round +# trip. A warp fetches again only after its instruction is decoded, so with few +# warps per slice that round trip bounds issue. Fixed-length fetch only (no C). +VX_CFG_ICACHE_L0_ENABLE = false +VX_CFG_ICACHE_L0_LINES = 4 VX_CFG_DCACHE_SIZE = 16384 VX_CFG_DCACHE_NUM_WAYS = 4 diff --git a/ci/baselines/perf/core.json b/ci/baselines/perf/core.json index a4fed9d6c6..5a717f7b02 100644 --- a/ci/baselines/perf/core.json +++ b/ci/baselines/perf/core.json @@ -6,7 +6,7 @@ }, "app": "raycast", "args": "", - "config_hash": "6a8db2da81885bd3", + "config_hash": "ee62a428d0faeabb", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "raycast", "args": "", - "config_hash": "a7365739bd29ae7f", + "config_hash": "582945597853fc7a", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "a94d5512bae0d0c4", + "config_hash": "c4ed8061884b8581", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=16 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "ed82856d2fbdb4fa", + "config_hash": "6d28c41cb33bab0a", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "207c97cf1edf224d", + "config_hash": "f2953a53cc1970ff", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -61,7 +61,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "ddaf766d29f0c9e2", + "config_hash": "cd10e4f446959b85", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -72,7 +72,7 @@ }, "app": "sgemm2", "args": "-n64 -t4", - "config_hash": "e3a289024245088f", + "config_hash": "5ad3bee978bc681d", "configs": "-DVX_CFG_EXT_LDST_WIDE_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -83,7 +83,7 @@ }, "app": "sgemmx", "args": "-n128", - "config_hash": "b33624dacfde5ab3", + "config_hash": "696055b197a0176e", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -94,7 +94,7 @@ }, "app": "sgemmx", "args": "-n128", - "config_hash": "c2faf5453d1010f0", + "config_hash": "83033a42a7ef3c6f", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -105,7 +105,7 @@ }, "app": "sgemv", "args": "-m512 -n512", - "config_hash": "ba5846fb3e38ff61", + "config_hash": "26982abdfbeb85ee", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -116,7 +116,7 @@ }, "app": "sgemv", "args": "-m512 -n512", - "config_hash": "ff7c79ffef364ae9", + "config_hash": "71520c03ef99f807", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -127,7 +127,7 @@ }, "app": "softmax", "args": "-n64", - "config_hash": "5c38536ce941bce9", + "config_hash": "dac769be8957ba2d", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -138,7 +138,7 @@ }, "app": "softmax", "args": "-n64", - "config_hash": "647c47cbc33e0b1e", + "config_hash": "d050a332df68acaa", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -149,7 +149,7 @@ }, "app": "stencil3d", "args": "-n32", - "config_hash": "e962be6c4a705bd0", + "config_hash": "c5893a783df02fa6", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -160,7 +160,7 @@ }, "app": "stencil3d", "args": "-n32", - "config_hash": "44671bcb89d71094", + "config_hash": "98aba4d66a20a6c5", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -171,7 +171,7 @@ }, "app": "vecadd", "args": "-n16384", - "config_hash": "3c46a73d97d7dde8", + "config_hash": "eec2891c0f4dc7d1", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -182,7 +182,7 @@ }, "app": "vecadd", "args": "-n16384", - "config_hash": "67f76328e947f037", + "config_hash": "43c063b7b2bc8353", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" } diff --git a/ci/baselines/perf/dxa.json b/ci/baselines/perf/dxa.json index 9c42109c5f..1c9b8a19e3 100644 --- a/ci/baselines/perf/dxa.json +++ b/ci/baselines/perf/dxa.json @@ -6,7 +6,7 @@ }, "app": "dxa_copy_mcast", "args": "", - "config_hash": "a98f143d348178b8", + "config_hash": "6508d11862252bfc", "configs": "-DVX_CFG_EXT_DXA_ENABLE", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "dxa_copy", "args": "-d1", - "config_hash": "55c5155d6ab46f83", + "config_hash": "94b5f6ff7e05a12d", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "dxa_copy", "args": "-d1", - "config_hash": "ee5d9d68a6bee766", + "config_hash": "276aa7f1b3fef5b2", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "sgemm2_dxa_mcast", "args": "-n128", - "config_hash": "82c50e47ea6ea51c", + "config_hash": "baf0ca5f70fbffd8", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "sgemm2_dxa_mcast", "args": "-n128", - "config_hash": "8f2e3ded05181df5", + "config_hash": "1e4e377e4c0998e5", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -61,7 +61,7 @@ }, "app": "sgemm2_dxa", "args": "-n128 -t4 -m1", - "config_hash": "a94548f6a341be69", + "config_hash": "c9fa6f2e8840411c", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -72,7 +72,7 @@ }, "app": "sgemm2_dxa", "args": "-n128 -t4 -m1", - "config_hash": "b647693500d03cdb", + "config_hash": "7022cd727b55cdbc", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -83,7 +83,7 @@ }, "app": "sgemm_tcu_wg_dxa_mcast", "args": "-m 128 -n 128 -k 64", - "config_hash": "7506c2b313ddfb40", + "config_hash": "5eadebf206b6b001", "configs": "-DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -94,7 +94,7 @@ }, "app": "sgemm_tcu_wg_dxa_mcast", "args": "-m 128 -n 128 -k 64", - "config_hash": "a7d7a7c19cc97d7f", + "config_hash": "cb0f3a92496dfd01", "configs": "-DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -105,7 +105,7 @@ }, "app": "sgemm_tcu_wg_dxa", "args": "-m 128 -n 128 -k 64", - "config_hash": "0dfd4e6b3f65442b", + "config_hash": "8e59bba128dd8ae0", "configs": "-DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DWGMMA_NRC=16 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_THREADS=32", "driver": "rtlsim" }, @@ -116,7 +116,7 @@ }, "app": "sgemm_tcu_wg_sp_dxa", "args": "-m 128 -n 128 -k 128", - "config_hash": "30f77e58ea21b51b", + "config_hash": "68878a6e505b9748", "configs": "-DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_TCU_SPARSE_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DWGMMA_NRC=32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_THREADS=32", "driver": "rtlsim" } diff --git a/ci/baselines/perf/graphics.json b/ci/baselines/perf/graphics.json index d52d41eda8..ebde81d14d 100644 --- a/ci/baselines/perf/graphics.json +++ b/ci/baselines/perf/graphics.json @@ -6,7 +6,7 @@ }, "app": "gfx_draw3d", "args": "-w 128 -h 128 -t box.cgltrace -r box_ref_128.png", - "config_hash": "c548118c41bcef23", + "config_hash": "61ac2bea9e718ae6", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "gfx_draw3d", "args": "-w 128 -h 128 -t box.cgltrace -r box_ref_128.png", - "config_hash": "48890b8c1ad7fe04", + "config_hash": "d72e5cb799606e6d", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "gfx_draw3d", "args": "-w 128 -h 128 -t box.cgltrace -r box_ref_128.png", - "config_hash": "b08776e5f96f6b97", + "config_hash": "4a13f956a2d5d572", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "gfx_om", "args": "-w 128 -h 128 -r whitebox_128.png", - "config_hash": "32307cceb33dc7a6", + "config_hash": "d3d0d33d18bf8b9a", "configs": "-DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "gfx_om", "args": "-w 128 -h 128 -r whitebox_128.png", - "config_hash": "ce07b69d9a182c02", + "config_hash": "8751642a0d79a809", "configs": "-DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -61,7 +61,7 @@ }, "app": "gfx_raster", "args": "-w 128 -h 128 -t triangle.cgltrace -r triangle_ref_128.png", - "config_hash": "366fbc3590ee481f", + "config_hash": "9130e9fde569a633", "configs": "-DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -72,7 +72,7 @@ }, "app": "gfx_raster", "args": "-w 128 -h 128 -t triangle.cgltrace -r triangle_ref_128.png", - "config_hash": "8c3f6ea5a04a0d52", + "config_hash": "8f9c1de064541e41", "configs": "-DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -83,7 +83,7 @@ }, "app": "gfx_tex", "args": "-i toad.png -r toad_ref_f0.png -f 0 -g 0", - "config_hash": "370db7ba23efdbb2", + "config_hash": "57cd57fec49c1bc6", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -94,7 +94,7 @@ }, "app": "gfx_tex", "args": "-i toad.png -r toad_ref_f0.png -f 0 -g 0", - "config_hash": "a680ecaa56a2c2fd", + "config_hash": "4aaa695dfefd46c8", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" } diff --git a/ci/baselines/perf/raytracing.json b/ci/baselines/perf/raytracing.json index db66430680..7f118f020f 100644 --- a/ci/baselines/perf/raytracing.json +++ b/ci/baselines/perf/raytracing.json @@ -6,7 +6,7 @@ }, "app": "rt_raycast", "args": "", - "config_hash": "9fa9d930efb7a892", + "config_hash": "1234a743dca60ff9", "configs": "-DVX_CFG_EXT_RTU_ENABLE -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "rt_raycast", "args": "", - "config_hash": "bf5c79f92d7a2d0b", + "config_hash": "4a56ac28c29397af", "configs": "-DVX_CFG_EXT_RTU_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "rt_raycast", "args": "", - "config_hash": "6eca2ad296cbc4c8", + "config_hash": "9210f172fe133bca", "configs": "-DVX_CFG_EXT_RTU_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor.json b/ci/baselines/perf/tensor.json index 660bb540f9..2a45091c2c 100644 --- a/ci/baselines/perf/tensor.json +++ b/ci/baselines/perf/tensor.json @@ -6,7 +6,7 @@ }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "395b9f89b1613b5f", + "config_hash": "84fc444647522e6e", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "14c25c4ef390468d", + "config_hash": "7cbd2b6ccbef99c6", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=16 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "3a5afbca2316def1", + "config_hash": "97e84a1efb066f9f", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "fd128828360dcf27", + "config_hash": "1455192155e67038", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "sgemm2_tcu", "args": "-m 128 -n 128 -k 64", - "config_hash": "9934ecd51fa79038", + "config_hash": "6ab260b380e298d0", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" }, @@ -61,7 +61,7 @@ }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "328c614d0141deb8", + "config_hash": "56e9ae3efc6e5a11", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_EXT_LDST_MATRIX_ENABLE", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor_mx.json b/ci/baselines/perf/tensor_mx.json index e8acc30a31..71b80d92c3 100644 --- a/ci/baselines/perf/tensor_mx.json +++ b/ci/baselines/perf/tensor_mx.json @@ -6,7 +6,7 @@ }, "app": "sgemm_tcu_mx", "args": "-m 128 -n 128 -k32", - "config_hash": "af77d4a5f0a8576f", + "config_hash": "ab68a67e8ee61342", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_MX_ENABLE -DVX_CFG_TCU_FP8_ENABLE -DITYPE=mxfp8 -DOTYPE=fp32 -DVX_CFG_TCU_TYPE_DPI", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor_sp.json b/ci/baselines/perf/tensor_sp.json index 7e3e05593e..f6b28ae402 100644 --- a/ci/baselines/perf/tensor_sp.json +++ b/ci/baselines/perf/tensor_sp.json @@ -6,7 +6,7 @@ }, "app": "sgemm_tcu_sp", "args": "-m 128 -n 128 -k 128", - "config_hash": "e7354a7a2bc00238", + "config_hash": "8afe9207eab1c46b", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_SPARSE_ENABLE", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor_wg.json b/ci/baselines/perf/tensor_wg.json index 1c5354893e..0b0174d6e2 100644 --- a/ci/baselines/perf/tensor_wg.json +++ b/ci/baselines/perf/tensor_wg.json @@ -6,7 +6,7 @@ }, "app": "sgemm_tcu_wg", "args": "-m64 -n64 -k64", - "config_hash": "4d4bf375520e05f4", + "config_hash": "d0dc0df7cb32f087", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_TCU_FEDP2K -DITYPE=fp16 -DOTYPE=fp32 -DWGMMA_NRC=8 -DWGMMA_RS", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "sgemm_tcu_wg", "args": "-m 128 -n 128 -k 128", - "config_hash": "9eda8c6f5a4af670", + "config_hash": "87f301da2e139400", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DWGMMA_NRC=32 -DWGMMA_SS -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "sgemm_tcu_wg_sp", "args": "-m 128 -n 128 -k 128", - "config_hash": "279fd043db54e2d1", + "config_hash": "f82c4f5099494fcd", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_TCU_SPARSE_ENABLE -DWGMMA_NRC=32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" } diff --git a/ci/testcases/core.yaml b/ci/testcases/core.yaml index c60982dc5d..0b379bdfcb 100644 --- a/ci/testcases/core.yaml +++ b/ci/testcases/core.yaml @@ -191,6 +191,39 @@ tests: parity_counters: prefix: "core0: dcache" tolerance: [bank_st] +# Fetch L0: hits, line fills and next-line prefetches, and runs within and +# across lines, at the default 4 warps and at 2, where fetch latency bounds issue. +- id: parity-l0-sgemm + check: model_parity + via: blackbox + app: sgemm + args: -n64 + configs: -DVX_CFG_ICACHE_L0_ENABLE +- id: parity-l0-sgemm-2w + check: model_parity + via: blackbox + app: sgemm + args: -n64 + configs: -DVX_CFG_ICACHE_L0_ENABLE -DVX_CFG_NUM_WARPS=2 +# Two fetch slices share the icache port through the L0s' round-robin arbiter. +- id: parity-l0-vecadd-fw2 + check: model_parity + via: blackbox + app: vecadd + args: -n16384 + configs: -DVX_CFG_ICACHE_L0_ENABLE -DVX_CFG_ISSUE_WIDTH=2 -DVX_CFG_FETCH_WIDTH=2 -DVX_CFG_NUM_SFU_BLOCKS=2 +- id: parity-l0-sgemm-fw4 + check: model_parity + via: blackbox + app: sgemm + args: -n32 + configs: -DVX_CFG_ICACHE_L0_ENABLE -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_FETCH_WIDTH=4 -DVX_CFG_NUM_SFU_BLOCKS=4 -DVX_CFG_NUM_WARPS=8 +- id: parity-l0-vecadd-vm + check: model_parity + via: blackbox + app: vecadd + args: -n4096 + configs: -DVX_CFG_ICACHE_L0_ENABLE -DVX_CFG_VM_ENABLE # Softmax: elementwise exp + reduction (FPU + reduction traffic). - id: parity-softmax check: model_parity diff --git a/docs/designs/mlp_optimizations.md b/docs/designs/mlp_optimizations.md index e2439950ec..5b57b3487c 100644 --- a/docs/designs/mlp_optimizations.md +++ b/docs/designs/mlp_optimizations.md @@ -76,6 +76,7 @@ Some of these features can be set with a `VX_CFG_*` knob (see [Build Configurati | Icache same-line merge | `VX_CFG_ICACHE_READ_MERGE` | 1 (on). No effect with one fetch slice. | | CP DMA through the LLC | `VX_CFG_CP_LLC_CLIENT` | 1 (on). Takes effect only when one LLC serves every core. | | Per-slice fetch | `VX_CFG_FETCH_WIDTH` | Equal to the issue width (a power of two) | +| Fetch L0 | `VX_CFG_ICACHE_L0_ENABLE`, `VX_CFG_ICACHE_L0_LINES` | **Off**; 4 lines. Fixed-length fetch only (no C extension). | | Miss tracking | `VX_CFG_{DCACHE,L2,L3}_MSHR_SIZE`, `VX_CFG_LSU_PENDING_LIMIT` | Derived from the platform's bandwidth × latency (`VX_CFG_PLATFORM_MEMORY_PEAK_BW`, `VX_CFG_PLATFORM_CLOCK_RATE`, `VX_CFG_PLATFORM_MEMORY_LATENCY`, `VX_CFG_{L1,L2}_LINK_LATENCY`). The stock shapes set no memory latency and resolve to the floors: 16 MSHR entries, an LSU limit of 32 | | Non-power-of-two way count | `VX_CFG_{ICACHE,DCACHE,L2,L3}_NUM_WAYS` | 4, 4, 8, 8. Any count; the sets per bank stay a power of two | | Stack interleave | `VX_CFG_LSU_STACK_INTERLEAVE_ENABLE` | On | @@ -118,6 +119,29 @@ Some of these features can be set with a `VX_CFG_*` knob (see [Build Configurati - SimX, 4 cores, FW 4 against FW 1: sgemm −29.7% on the rtx5080 profile (-n192) and −40.7% on the a100 profile (-n128). - At issue width 1 the split structure moves rtlsim by at most +132 cycles (printf). +### Fetch L0 + +**Problem.** A warp fetches again only after its instruction is decoded, so each warp waits out the icache round trip (request buffer, icache, response) between two instructions. With few warps per fetch slice nothing hides it, and the round trip, not the operands, bounds issue. Kernels that use many registers per thread leave few warps resident, so they are hit hardest. + +**How it works:** +- Each fetch slice keeps `VX_CFG_ICACHE_L0_LINES` whole icache lines, fully associative and replaced round-robin. A fetch that hits reaches decode the next cycle; a miss asks the icache for the whole line and keeps it. +- Decode reads only a two-entry registered output buffer, so every handshake into it is registered. +- Once an instruction is delivered, the L0 delivers the warp's next instruction behind it (a run), into the next line too when the L0 holds it, up to 16. The warp stays locked until the run's last instruction is decoded. Decode drops the instruction behind a stalling one, and the run gives its ibuffer slot back. +- One prefetch of the next line per slice is in flight at a time, sent in a cycle no fetch misses. +- The slices share one icache port, round-robin, and the icache has one bank. +- The icache flush invalidates the L0. +- SimX models the same structure in `fetch_l0()`. + +**Gain** (rtlsim, 1 core, 4 threads): + +| app | 4 warps off → on | 2 warps off → on | +|---|---|---| +| sgemm -n64 | 787,625 → 540,413 (−31.4%) | 1,569,734 → 923,326 (−41.2%) | +| sgemv -m512 -n512 | 746,326 → 642,652 (−13.9%) | 1,480,487 → 1,127,469 (−23.8%) | +| softmax -n64 | 4,850,762 → 3,640,724 (−24.9%) | 9,621,362 → 5,706,496 (−40.7%) | +| vecadd -n16384 | 348,467 → 267,246 (−23.3%) | 663,834 → 486,621 (−26.7%) | +| geomean | −23.6% | −33.6% | + --- ## Cache organization diff --git a/docs/proposals/fetch_l0_design_note.md b/docs/proposals/fetch_l0_design_note.md new file mode 100644 index 0000000000..f42ce2eaf4 --- /dev/null +++ b/docs/proposals/fetch_l0_design_note.md @@ -0,0 +1,22 @@ +# Design note: fetch L0 + +| Field | Content | +|---|---| +| **Goal** | Keep a warp issuing back to back when few warps share a fetch slice. A warp fetches again only after its instruction is decoded, so with few warps per slice the icache round trip (request buffer, icache, response) bounds each warp's issue rate. This matters most for kernels that use many registers per thread, which leave few warps resident. The L0 is the first step toward 256 registers per thread. | +| **Extension point** | None reaches it. The latency to remove sits between the warp scheduler and decode, which is the fetch stage itself; every extension point is behind decode. The change is gated by `VX_CFG_ICACHE_L0_ENABLE` (default off), and with the knob off the stages are the same hardware (V-ISO-3). | +| **Mainstream analogue** | NVIDIA has had an L0 instruction cache per SM processing block since Volta, in front of an L1 instruction cache shared by the SM. AMD keeps a per-wave instruction buffer that fetches ahead of the wave, in front of an instruction cache shared by the WGP. The L0 here is the NVIDIA-style per-slice cache. Its runs, which deliver a warp's next instructions without going back through the scheduler, are closer to AMD's per-wave fetch-ahead. | +| **Alternatives considered** | (1) A line buffer at the icache output (the isolated alternative). It saves the tag lookup and data read but not the request and response registers, which make most of the round trip. It was not built: the change is preliminary work for 256 registers, and the maintainer is asked to waive V-ISO-6 items 2 and 3 for it. (2) More warps per slice. This hides the round trip today but is exactly what 256 registers per thread removes. (3) Sequential fetch-ahead from the scheduler without an L0. This touches the same shared stages (it needs a next-PC guess in the scheduler) and still pays the icache round trip on every line. | +| **Budget** | Knob off: the same RTL. Beacon on `core` and `top_vortex` gives the same depth and LUTs as master (127,132 and 126,581 LUTs, 15 levels), and `perf_gate` the same cycles. Knob on, `top_vortex` (two cores): deepest path 15 → 15 levels, LUTs +6.7%, FFs +7.8%, LUTRAM +19.7%. Per core the L0 is 1,268 LUTs, 376 FFs and 410 LUTRAM; most of the rest carries whole lines on the icache response path (response queue and crossbar, flush arbiter, iMMU pipes). The only path 4 or more levels deeper is the ibuffer counter of each warp (5 → 9 levels, through `run_take`); the L0's own deepest path is 10 levels. | +| **SimX plan** | `fetch_l0()` in `core.cpp` models the line store, the two-entry output buffer, runs and their decode-side drop, the next-line prefetch and the shared icache port with each slice's two-entry request buffer. Covered by the three parity cases above. | +| **Verification plan** | The regression suite on SimX and rtlsim with the knob on. Parity at 4 and 2 warps and with two fetch slices sharing the port. The icache flush also invalidates the L0. | +| **Forward progress** | See below. | +| **Migration** | One commit with the RTL, SimX, knob and parity cases; a second with the perf baselines re-recorded for the new knob's config hash. | +| **Open questions** | Whether the maintainer waives the measured isolated alternative and the measured gain (V-ISO-6 items 2 and 3) for this preliminary step. | + +## Forward progress (V-FP-1, V-FP-2) + +- **Run lock.** Decode keeps the warp locked while the L0 delivers the next instruction of its run. The run's last instruction releases the warp at decode. If a stalling instruction inside the run is decoded, the instruction behind it is dropped, and the stalling instruction's existing releaser (its commit) frees the warp. A run is at most 16 instructions, and it yields to a scheduled fetch that hit the L0 but could not enter the output buffer the cycle before. +- **Run slot.** A run takes its warp's ibuffer slot as it is made (`run_take`), and only when the ibuffer had a free slot the cycle before. The slot is released when the instruction issues or when decode drops it (`run_refund`). Decode therefore never waits on the ibuffer for a run's instruction. +- **Output buffer and the shared response path.** The icache response port is shared by every slice, so a full output buffer holds the responses of the other slices. Each entry already owns an ibuffer slot, taken at schedule or by `run_take`, and so it leaves as soon as decode takes it. The scheduler's fallback that lets a warp fetch when every ibuffer is full is disabled with the L0. That fetch would own no slot: its entry could wait behind a warp that is itself waiting, at a barrier, for a warp of another slice whose response it blocks. +- **Prefetch.** One L0 prefetch per slice is in flight at a time. Its response is always accepted. +- **Stress cases.** `parity-l0-sgemm-2w` (two warps, long runs) and `parity-l0-vecadd-fw2` (two slices on one port). diff --git a/hw/rtl/VX_gpu_pkg.sv b/hw/rtl/VX_gpu_pkg.sv index 1b3d5d594c..f8641ab80b 100644 --- a/hw/rtl/VX_gpu_pkg.sv +++ b/hw/rtl/VX_gpu_pkg.sv @@ -1659,6 +1659,10 @@ package VX_gpu_pkg; `ifdef VX_CFG_EXT_C_ENABLE logic is_rvc; `endif + `ifdef VX_CFG_ICACHE_L0_ENABLE + logic run_more; // the L0 delivers the next instruction of the run behind it + logic run_cont; // this instruction continues an L0 run + `endif } fetch_t; typedef struct packed { @@ -2107,29 +2111,45 @@ package VX_gpu_pkg; ////////////////////////// Icache Parameters ////////////////////////////// - // Word size in bytes - localparam ICACHE_WORD_SIZE = 4; - localparam ICACHE_ADDR_WIDTH = (`VX_CFG_MEM_ADDR_WIDTH - `CLOG2(ICACHE_WORD_SIZE)); - // Block size in bytes localparam ICACHE_LINE_SIZE = `VX_CFG_L1_LINE_SIZE; - // Request ports per core: one per frontend slice, each fetching its own warps - localparam ICACHE_NUM_REQS = `VX_CFG_FETCH_WIDTH; + // Lines in each fetch slice's L0, which takes whole lines from the icache +`ifdef VX_CFG_ICACHE_L0_ENABLE + localparam ICACHE_L0_LINES = `VX_CFG_ICACHE_L0_LINES; +`else + localparam ICACHE_L0_LINES = 0; +`endif + + // Word size in bytes + localparam ICACHE_WORD_SIZE = (ICACHE_L0_LINES != 0) ? ICACHE_LINE_SIZE : 4; + localparam ICACHE_ADDR_WIDTH = (`VX_CFG_MEM_ADDR_WIDTH - `CLOG2(ICACHE_WORD_SIZE)); + + // Request ports per core: one per frontend slice, each fetching its own + // warps; with the L0, one that the slices share for its fills + localparam ICACHE_NUM_REQS = (ICACHE_L0_LINES != 0) ? 1 : `VX_CFG_FETCH_WIDTH; localparam ICACHE_NUM_BANKS = `VX_CFG_ICACHE_NUM_BANKS; // Core request tag Id bits: the warp id local to the requesting frontend slice localparam ICACHE_TAG_ID_BITS = FETCH_WFS_W; - // Core request tag bits as VX_fetch writes them (UUID + warp id). - localparam ICACHE_FETCH_TAG_WIDTH = (UUID_WIDTH + ICACHE_TAG_ID_BITS); + // An L0 prefetch is marked in its request tag. + localparam ICACHE_FETCH_PF_BITS = (ICACHE_L0_LINES != 0) ? 1 : 0; + + // Core request tag bits as VX_fetch writes them (UUID + [L0 prefetch] + warp id). + localparam ICACHE_FETCH_TAG_WIDTH = (UUID_WIDTH + ICACHE_FETCH_PF_BITS + ICACHE_TAG_ID_BITS); + + // A slice's tag with the flush arbiter's select bit; the arbiter that shares + // the icache port among the slices adds their index above it. + localparam ICACHE_SLICE_TAG_WIDTH = (ICACHE_FETCH_TAG_WIDTH + 1); + localparam ICACHE_ARB_SEL_BITS = (ICACHE_NUM_REQS < `VX_CFG_FETCH_WIDTH) ? `CLOG2(`VX_CFG_FETCH_WIDTH) : 0; // Core request tag bits on mmu_icache_if (post-flush, pre-MMU). When // VM_ENABLE is on, the iMMU widens this by ICACHE_TLB_SOURCE_BITS for // its internal bypass/TLB/PTW arbiter; the externally-visible // icache_bus_if (ICACHE_TAG_WIDTH below) carries that wider tag. // The +1 is the VX_dcr_flush arb-sel bit injected on the icache side. - localparam ICACHE_TAG_WIDTH_BASE = (ICACHE_FETCH_TAG_WIDTH + 1); + localparam ICACHE_TAG_WIDTH_BASE = (ICACHE_SLICE_TAG_WIDTH + ICACHE_ARB_SEL_BITS); // The iMMU forwards the translated tag unchanged: ITLB misses are walked // by the shared per-core walker, whose PTE fetches ride the dcache port, // so the icache stream carries no extra MMU arbitration bit. diff --git a/hw/rtl/core/VX_compute_slice.sv b/hw/rtl/core/VX_compute_slice.sv index adb27c3252..53bc6175c7 100644 --- a/hw/rtl/core/VX_compute_slice.sv +++ b/hw/rtl/core/VX_compute_slice.sv @@ -43,6 +43,7 @@ import VX_tcu_pkg::*; // core scheduler and icache VX_slice_sched_if.slave slice_sched_if, VX_mem_bus_if.master icache_bus_if, + input wire icache_flush, output wire [PER_ISSUE_WARPS-1:0] committed_wis, // core scheduler state @@ -201,6 +202,7 @@ import VX_tcu_pkg::*; `endif .slice_sched_if (fs_sched_if), .icache_bus_if (icache_bus_if), + .icache_flush (icache_flush), .decode_if (decode_if), .branch (branch), .wctl (wctl), diff --git a/hw/rtl/core/VX_core.sv b/hw/rtl/core/VX_core.sv index 9ecb6aecf9..1bbbdcadfb 100644 --- a/hw/rtl/core/VX_core.sv +++ b/hw/rtl/core/VX_core.sv @@ -106,13 +106,47 @@ import VX_tcu_pkg::*; wire [`VX_CFG_NUM_LSU_BLOCKS-1:0][PERF_CTR_BITS-1:0] lsu_coalescer_misses; `endif - // frontend-slice icache ports, tagged with the flush arbiter's select bit (the - // LSB); port 0 also carries the injected flush + // frontend-slice icache buses, tagged with the flush arbiter's select bit (the LSB) + VX_mem_bus_if #( + .DATA_SIZE (ICACHE_WORD_SIZE), + .TAG_WIDTH (ICACHE_SLICE_TAG_WIDTH) + ) slice_icache_if[`VX_CFG_FETCH_WIDTH](); + + // icache ports; port 0 also carries the injected flush VX_mem_bus_if #( .DATA_SIZE (ICACHE_WORD_SIZE), .TAG_WIDTH (ICACHE_TAG_WIDTH) ) fetch_icache_if[ICACHE_NUM_REQS](); + if (ICACHE_NUM_REQS == `VX_CFG_FETCH_WIDTH) begin : g_icache_slices + for (genvar i = 0; i < ICACHE_NUM_REQS; ++i) begin : g_ports + assign fetch_icache_if[i].req_valid = slice_icache_if[i].req_valid; + assign fetch_icache_if[i].req_data = slice_icache_if[i].req_data; + assign slice_icache_if[i].req_ready = fetch_icache_if[i].req_ready; + assign slice_icache_if[i].rsp_valid = fetch_icache_if[i].rsp_valid; + assign slice_icache_if[i].rsp_data = fetch_icache_if[i].rsp_data; + assign fetch_icache_if[i].rsp_ready = slice_icache_if[i].rsp_ready; + end + end else begin : g_icache_arb + // The slices' L0 fills share one port, round-robin; the slice's index + // goes in the tag above the flush select bit. + VX_mem_bus_arb #( + .NUM_INPUTS (`VX_CFG_FETCH_WIDTH), + .NUM_OUTPUTS (ICACHE_NUM_REQS), + .DATA_SIZE (ICACHE_WORD_SIZE), + .TAG_WIDTH (ICACHE_SLICE_TAG_WIDTH), + .TAG_SEL_IDX (1), + .ARBITER ("R"), + .REQ_OUT_BUF (0), + .RSP_OUT_BUF (0) + ) icache_arb ( + .clk (clk), + .reset (reset), + .bus_in_if (slice_icache_if), + .bus_out_if (fetch_icache_if) + ); + end + `ifdef VX_CFG_TCU_WGMMA_ENABLE localparam TCU_LMEM_BANK_ADDR_W = `VX_CFG_LMEM_LOG_SIZE - `CLOG2(LSU_MEM_WORD_SIZE) - `CLOG2(`VX_CFG_LMEM_NUM_BANKS); VX_mem_bus_if #( @@ -236,7 +270,7 @@ import VX_tcu_pkg::*; // register and the slice. The injector observes the response for its done. VX_mem_bus_if #( .DATA_SIZE (ICACHE_WORD_SIZE), - .TAG_WIDTH (ICACHE_FETCH_TAG_WIDTH) + .TAG_WIDTH (ICACHE_TAG_WIDTH-1) ) flush_core_if(); assign flush_core_if.req_valid = fetch_icache_if[0].req_valid; @@ -257,7 +291,7 @@ import VX_tcu_pkg::*; VX_dcr_flush #( .WORD_SIZE (ICACHE_WORD_SIZE), - .TAG_WIDTH (ICACHE_FETCH_TAG_WIDTH), + .TAG_WIDTH (ICACHE_TAG_WIDTH-1), .REQ_OUT_BUF (3) ) icache_dcr_flush ( .clk (clk), @@ -456,7 +490,8 @@ import VX_tcu_pkg::*; .issue_perf (per_slice_issue_perf[i]), `endif .slice_sched_if (slice_sched_if[i]), - .icache_bus_if (fetch_icache_if[i]), + .icache_bus_if (slice_icache_if[i]), + .icache_flush (dcr_flush_icache_if.req), .committed_wis (committed_wis), .cycles (sched_cycles), .instret (sched_instret), @@ -617,7 +652,8 @@ import VX_tcu_pkg::*; .fetch_perf (per_slice_fetch_perf[f]), `endif .slice_sched_if (slice_sched_if[f]), - .icache_bus_if (fetch_icache_if[f]), + .icache_bus_if (slice_icache_if[f]), + .icache_flush (dcr_flush_icache_if.req), .decode_if (fs_decode_if[f]), .branch (fs_branch[f]), .wctl (fs_wctl[f]), diff --git a/hw/rtl/core/VX_decode.sv b/hw/rtl/core/VX_decode.sv index 7f684ff055..6ca0292566 100644 --- a/hw/rtl/core/VX_decode.sv +++ b/hw/rtl/core/VX_decode.sv @@ -28,7 +28,9 @@ module VX_decode import // outputs VX_decode_if.master decode_if, - VX_decode_sched_if.master decode_sched_if + VX_decode_sched_if.master decode_sched_if, + // a stalling instruction an L0 run continued past: fetch drops the next one + output wire run_kill ); `UNUSED_SPARAM (INSTANCE_ID) @@ -1232,13 +1234,33 @@ module VX_decode import `ifdef VX_CFG_EXT_C_ENABLE reg decode_sched_is_rvc_r; `endif +`ifdef VX_CFG_ICACHE_L0_ENABLE + // the warp stays locked while its L0 run continues; a stalling instruction + // the run continued past drops the run's next instruction + wire run_more = fetch_if.data.run_more; + reg decode_sched_cont_r; + reg run_kill_r; + always @(posedge clk) begin + if (reset) begin + run_kill_r <= 1'b0; + end else begin + run_kill_r <= fetch_fire && run_more && is_wstall; + end + decode_sched_cont_r <= fetch_if.data.run_cont; + end + assign decode_sched_if.cont = decode_sched_cont_r; + assign run_kill = run_kill_r; +`else + wire run_more = 1'b0; + assign run_kill = 1'b0; +`endif always @(posedge clk) begin if (reset) begin decode_sched_valid_r <= 1'b0; end else begin decode_sched_valid_r <= fetch_fire; - decode_sched_unlock_r <= ~is_wstall; + decode_sched_unlock_r <= ~is_wstall && ~run_more; decode_sched_use_rd_r <= use_rd; decode_sched_rd_freg_r <= (get_reg_type(reg_ids[RV_RD]) == REG_TYPE_F); decode_sched_fs_write_r <= fs_write_fcsr; diff --git a/hw/rtl/core/VX_fetch.sv b/hw/rtl/core/VX_fetch.sv index 43442d9bb0..3981e37449 100644 --- a/hw/rtl/core/VX_fetch.sv +++ b/hw/rtl/core/VX_fetch.sv @@ -30,6 +30,15 @@ module VX_fetch import VX_gpu_pkg::*; #( // Icache interface VX_mem_bus_if.master icache_bus_if, + // the icache is being invalidated: so is the L0 + input wire icache_flush, + // decode found a stalling instruction that an L0 run continued past + input wire run_kill, + // per warp: its ibuffer has a free slot (registered); a run takes one as + // it continues, or gives it back when decode drops its instruction + input wire [NUM_WARPS-1:0] ibuf_free, + output wire [NUM_WARPS-1:0] run_take, + output wire [NUM_WARPS-1:0] run_refund, // inputs VX_schedule_if.slave schedule_if, @@ -57,6 +66,8 @@ module VX_fetch import VX_gpu_pkg::*; #( wire [ICACHE_FETCH_TAG_WIDTH-1:0] icache_req_tag; wire [WID_W-1:0] icache_req_wid; wire [UUID_WIDTH-1:0] icache_req_uuid; + // an L0 prefetch: no warp waits for it + wire icache_req_pf; wire [UUID_WIDTH-1:0] rsp_uuid; wire [PC_BITS-1:0] rsp_PC; @@ -69,7 +80,13 @@ module VX_fetch import VX_gpu_pkg::*; #( assign req_tag = sched_wid; - assign {rsp_uuid, rsp_tag} = icache_bus_if.rsp_data.tag; + wire rsp_pf; + if (ICACHE_FETCH_PF_BITS != 0) begin : g_rsp_pf + assign {rsp_uuid, rsp_pf, rsp_tag} = icache_bus_if.rsp_data.tag; + end else begin : g_rsp_no_pf + assign {rsp_uuid, rsp_tag} = icache_bus_if.rsp_data.tag; + assign rsp_pf = 1'b0; + end VX_dp_ram #( .DATAW (PC_BITS + `VX_CFG_NUM_THREADS + NCTA_WIDTH), @@ -80,7 +97,7 @@ module VX_fetch import VX_gpu_pkg::*; #( .clk (clk), .reset (reset), .read (1'b1), - .write (icache_req_fire), + .write (icache_req_fire && ~icache_req_pf), .wren (1'b1), .waddr (req_tag), .wdata ({schedule_if.data.PC, schedule_if.data.tmask, schedule_if.data.cta_id}), @@ -92,6 +109,14 @@ module VX_fetch import VX_gpu_pkg::*; #( ("invalid PC=0x%0h, wid=%0d, tmask=%b (#%0d)", to_fullPC(schedule_if.data.PC), schedule_if.data.wid, schedule_if.data.tmask, schedule_if.data.uuid)) `ifdef VX_CFG_EXT_C_ENABLE + `STATIC_ASSERT (ICACHE_L0_LINES == 0, ("the fetch L0 serves the fixed-length fetch path")) + `UNUSED_VAR (icache_flush) + `UNUSED_VAR (run_kill) + `UNUSED_VAR (ibuf_free) + `UNUSED_VAR (rsp_pf) + assign run_take = '0; + assign run_refund = '0; + assign icache_req_pf = 1'b0; // ------------------------------------------------------------------------ // RVC path: VX_decompressor + follow-up request mux // ------------------------------------------------------------------------ @@ -198,25 +223,331 @@ module VX_fetch import VX_gpu_pkg::*; #( `else // !VX_CFG_EXT_C_ENABLE // ------------------------------------------------------------------------ - // Direct path (no RVC): scheduler PC → icache request → fetch_if. + // Direct path (no RVC): scheduler PC → L0 or icache request → fetch_if. // ------------------------------------------------------------------------ - assign icache_req_valid = schedule_if.valid; - assign icache_req_addr = schedule_if.data.PC[2-(`VX_CFG_XLEN-PC_BITS) +: ICACHE_ADDR_WIDTH]; + localparam PC_LSB = `VX_CFG_XLEN - PC_BITS; + + wire [ICACHE_ADDR_WIDTH-1:0] sched_line = schedule_if.data.PC[`CLOG2(ICACHE_WORD_SIZE)-PC_LSB +: ICACHE_ADDR_WIDTH]; assign icache_req_wid = sched_wid; assign icache_req_uuid = schedule_if.data.uuid; - assign icache_req_tag = {icache_req_uuid, icache_req_wid}; assign schedule_if.ibuf_pop = fetch_if.ibuf_pop; - assign schedule_if.ready = icache_req_ready; - - assign fetch_if.valid = icache_bus_if.rsp_valid; - assign fetch_if.data.tmask = rsp_tmask; - assign fetch_if.data.wid = NW_WIDTH'(rsp_tag); - assign fetch_if.data.cta_id = rsp_cta_id; - assign fetch_if.data.PC = rsp_PC; - assign fetch_if.data.instr = icache_bus_if.rsp_data.data; - assign fetch_if.data.uuid = rsp_uuid; - assign icache_bus_if.rsp_ready = fetch_if.ready; + + if (ICACHE_L0_LINES != 0) begin : g_l0 + // L0: whole icache lines, fully associative, replaced round-robin. + // Decode reads only a two-entry output buffer, and every handshake into + // it is registered: a hit enters when the buffer holds at most one entry, + // no fetch response waits and the front is not running; a response + // enters while the buffer is not full. Once delivered, the front entry + // becomes the warp's next instruction (a run), into the next line too + // when the L0 holds it, up to RUN_MAX of them, its warp kept locked; + // decode drops the one behind a stalling instruction. One prefetch of the + // next line is in flight at a time, sent in a cycle no fetch misses. + localparam N = ICACHE_L0_LINES; + localparam NWW = `LOG2UP(N); + localparam RUN_MAX = 16; + localparam RW = `CLOG2(RUN_MAX); + localparam AW = ICACHE_ADDR_WIDTH; + localparam FW_WORDS = ICACHE_WORD_SIZE / 4; + localparam FW_WORDSW = `CLOG2(FW_WORDS); + `STATIC_ASSERT (ICACHE_WORD_SIZE == ICACHE_LINE_SIZE, ("the L0 fetches whole lines")) + `STATIC_ASSERT (N >= 1, ("the L0 needs at least one line")) + + typedef struct packed { + logic [31:0] instr; + logic [PC_BITS-1:0] PC; + logic [`VX_CFG_NUM_THREADS-1:0] tmask; + logic [NCTA_WIDTH-1:0] cta_id; + logic [WID_W-1:0] wid; + logic [UUID_WIDTH-1:0] uuid; + logic [NWW-1:0] way; + logic nx; + logic [NWW-1:0] nxway; + logic [RW-1:0] run; + logic cont; + } l0_entry_t; + + reg [N-1:0] l0_valid; + reg [N-1:0][AW-1:0] l0_tag; + // each line's tag minus one and minus two, so the next-line lookups of + // a scheduled fetch and of a run compare their own line and add nothing + reg [N-1:0][AW-1:0] l0_ptag, l0_p2tag; + reg [NWW-1:0] l0_victim; + + reg [1:0] ob_valid_r; + l0_entry_t [1:0] ob_r; + + reg pf_want_r, pf_inflight_r; + // the icache was flushed while the prefetch was in flight: its line is + // not installed + reg pf_stale_r; + reg [AW-1:0] pf_want_line_r, pf_line_r, pf_pline_r, pf_p2line_r; + // a scheduled fetch hit but could not enter the buffer last cycle: a + // run yields to it + reg hit_waited_r; + + // the front entry: its line, its next instruction, and whether it runs on + wire [AW-1:0] front_line = ob_r[0].PC[`CLOG2(ICACHE_WORD_SIZE)-PC_LSB +: AW]; + wire [FW_WORDSW-1:0] front_idx = ob_r[0].PC[2-PC_LSB +: FW_WORDSW]; + wire [FW_WORDSW:0] front_next = {1'b0, front_idx} + (FW_WORDSW+1)'(1); + wire front_way_ok = l0_valid[ob_r[0].way] && (l0_tag[ob_r[0].way] == front_line); + // a run past the line's end continues in the next line when the L0 + // holds it, and asks for the one after it as a fetch would. Whether it + // does, and in which way, is looked up when the entry is written (nx, + // nxway), so the run decision compares only the front entry's own tag. + wire front_cross = front_next[FW_WORDSW]; + wire [AW-1:0] front_line_nx2 = front_line + AW'(2); + wire [N-1:0] cross2_match; + for (genvar i = 0; i < N; ++i) begin : g_cross_match + assign cross2_match[i] = l0_valid[i] && (l0_p2tag[i] == front_line); + end + wire [NWW-1:0] cross2_way; + VX_onehot_encoder #( + .N (N) + ) cross2_enc ( + .data_in (cross2_match), + .data_out (cross2_way), + `UNUSED_PIN (valid_out) + ); + wire front_run = ob_valid_r[0] && front_way_ok && (~front_cross || ob_r[0].nx) + && (ob_r[0].run != RW'(RUN_MAX-1)) && ibuf_free[ob_r[0].wid] + && ~hit_waited_r; + wire front_drop = ob_valid_r[0] && ob_r[0].cont && run_kill; + + wire fetch_fire = fetch_if.valid && fetch_if.ready; + wire front_rewrite = fetch_fire && front_run; + wire front_pop = front_drop || (fetch_fire && ~front_run); + + // lookups of the scheduled fetch and of the returned line + wire [N-1:0] sched_match, rsp_match, next_match, want_match; + wire [AW-1:0] sched_next_line = sched_line + AW'(1); + wire [AW-1:0] rsp_line = rsp_pf ? pf_line_r : rsp_PC[`CLOG2(ICACHE_WORD_SIZE)-PC_LSB +: AW]; + for (genvar i = 0; i < N; ++i) begin : g_match + assign sched_match[i] = l0_valid[i] && (l0_tag[i] == sched_line); + assign rsp_match[i] = l0_valid[i] && (l0_tag[i] == rsp_line); + assign next_match[i] = l0_valid[i] && (l0_ptag[i] == sched_line); + assign want_match[i] = l0_valid[i] && (l0_tag[i] == pf_want_line_r); + end + wire sched_hit = (| sched_match); + wire [NWW-1:0] hit_way, rsp_hit_way, next_way; + VX_onehot_encoder #( + .N (N) + ) hit_enc ( + .data_in (sched_match), + .data_out (hit_way), + `UNUSED_PIN (valid_out) + ); + VX_onehot_encoder #( + .N (N) + ) rsp_enc ( + .data_in (rsp_match), + .data_out (rsp_hit_way), + `UNUSED_PIN (valid_out) + ); + VX_onehot_encoder #( + .N (N) + ) next_enc ( + .data_in (next_match), + .data_out (next_way), + `UNUSED_PIN (valid_out) + ); + + wire [1:0] ob_count = 2'(ob_valid_r[0]) + 2'(ob_valid_r[1]); + wire rsp_demand = icache_bus_if.rsp_valid && ~rsp_pf; + wire hit_take = schedule_if.valid && sched_hit && (ob_count <= 2'd1) && ~rsp_demand && ~front_run; + wire rsp_take = rsp_demand && (ob_count != 2'd2); + assign icache_bus_if.rsp_ready = rsp_pf || (ob_count != 2'd2); + wire rsp_fire = icache_bus_if.rsp_valid && icache_bus_if.rsp_ready; + wire install = rsp_fire && ~(rsp_pf && pf_stale_r) && ~(| rsp_match); + wire [NWW-1:0] rsp_way = (| rsp_match) ? rsp_hit_way : l0_victim; + + // one L0 read: the front's next instruction while it runs, else the hit + wire [NWW-1:0] rd_way = front_run ? (front_cross ? ob_r[0].nxway : ob_r[0].way) : hit_way; + wire [FW_WORDSW-1:0] rd_idx = front_run ? front_next[FW_WORDSW-1:0] : schedule_if.data.PC[2-PC_LSB +: FW_WORDSW]; + // the data as one small RAM per word of the line, indexed by the way: + // an install writes them all, a read takes one way from all of them + wire [FW_WORDS-1:0][31:0] rd_words; + for (genvar b = 0; b < FW_WORDS; ++b) begin : g_l0_banks + VX_dp_ram #( + .DATAW (32), + .SIZE (N), + .RDW_MODE ("R"), + .LUTRAM (1) + ) l0_bank ( + .clk (clk), + .reset (reset), + .read (1'b1), + .write (install), + .wren (1'b1), + .waddr (l0_victim), + .wdata (icache_bus_if.rsp_data.data[b * 32 +: 32]), + .raddr (rd_way), + .rdata (rd_words[b]) + ); + end + wire [31:0] rd_instr = rd_words[rd_idx]; + wire [31:0] rsp_instr = icache_bus_if.rsp_data.data[rsp_PC[2-PC_LSB +: FW_WORDSW] * 32 +: 32]; + + // a fetch miss asks the icache; else a prefetch of the line it wants next + wire demand_req = schedule_if.valid && ~sched_hit; + wire pf_req = pf_want_r && ~pf_inflight_r && ~(| want_match) && ~demand_req; + assign icache_req_valid = demand_req || pf_req; + assign icache_req_pf = ~demand_req; + assign icache_req_addr = demand_req ? sched_line : pf_want_line_r; + assign icache_req_tag = {icache_req_uuid, icache_req_pf, icache_req_wid}; + assign schedule_if.ready = sched_hit ? hit_take : icache_req_ready; + wire pf_fire = icache_req_fire && pf_req; + + // the next prefetch wanted: a scheduled fetch's, else a crossing run's + wire sched_want = schedule_if.valid && ~(| next_match) && ~(pf_inflight_r && (pf_pline_r == sched_line)); + wire cross_want = front_rewrite && front_cross && ~(| cross2_match) && ~(pf_inflight_r && (pf_p2line_r == front_line)); + + l0_entry_t enq; + always @(*) begin + enq.instr = rsp_take ? rsp_instr : rd_instr; + enq.PC = rsp_take ? rsp_PC : schedule_if.data.PC; + enq.tmask = rsp_take ? rsp_tmask : schedule_if.data.tmask; + enq.cta_id = rsp_take ? rsp_cta_id : schedule_if.data.cta_id; + enq.wid = rsp_take ? rsp_tag : sched_wid; + enq.uuid = rsp_take ? rsp_uuid : schedule_if.data.uuid; + enq.way = rsp_take ? rsp_way : hit_way; + // a returned line's run stops at its end: looking up the line after + // it would follow the icache response tag through a tag compare + enq.nx = ~rsp_take && (| next_match); + enq.nxway = next_way; + enq.run = '0; + enq.cont = 1'b0; + end + wire enq_valid = rsp_take || hit_take; + + reg [1:0] ob_valid_n; + l0_entry_t [1:0] ob_n; + always @(*) begin + ob_valid_n = ob_valid_r; + ob_n = ob_r; + if (front_rewrite) begin + ob_n[0].instr = rd_instr; + ob_n[0].PC = ob_r[0].PC + PC_BITS'(4 >> PC_LSB); + ob_n[0].way = rd_way; + if (front_cross) begin + ob_n[0].nx = (| cross2_match); + ob_n[0].nxway = cross2_way; + end + ob_n[0].uuid = ob_r[0].uuid + UUID_WIDTH'(1); + ob_n[0].run = ob_r[0].run + RW'(1); + ob_n[0].cont = 1'b1; + end else if (front_pop) begin + ob_valid_n = {1'b0, ob_valid_r[1]}; + ob_n[0] = ob_r[1]; + end + if (enq_valid) begin + if (~ob_valid_n[0]) begin + ob_valid_n[0] = 1'b1; + ob_n[0] = enq; + end else begin + ob_valid_n[1] = 1'b1; + ob_n[1] = enq; + end + end + // a line an entry continues into is gone once its way is replaced + for (integer i = 0; i < 2; ++i) begin + if (icache_flush || (install && (ob_n[i].nxway == l0_victim))) begin + ob_n[i].nx = 1'b0; + end + end + end + + always @(posedge clk) begin + if (reset) begin + ob_valid_r <= '0; + pf_want_r <= 1'b0; + pf_inflight_r <= 1'b0; + pf_stale_r <= 1'b0; + hit_waited_r <= 1'b0; + end else begin + ob_valid_r <= ob_valid_n; + hit_waited_r <= schedule_if.valid && sched_hit && ~hit_take; + if (sched_want || cross_want) begin + pf_want_r <= 1'b1; + end else if (pf_fire || (| want_match) || icache_flush) begin + pf_want_r <= 1'b0; + end + if (pf_fire) begin + pf_inflight_r <= 1'b1; + end else if (rsp_fire && rsp_pf) begin + pf_inflight_r <= 1'b0; + end + if (icache_flush && pf_inflight_r) begin + pf_stale_r <= 1'b1; + end else if (rsp_fire && rsp_pf) begin + pf_stale_r <= 1'b0; + end + end + ob_r <= ob_n; + if (sched_want) begin + pf_want_line_r <= sched_next_line; + end else if (cross_want) begin + pf_want_line_r <= front_line_nx2; + end + if (pf_fire) begin + pf_line_r <= pf_want_line_r; + pf_pline_r <= pf_want_line_r - AW'(1); + pf_p2line_r <= pf_want_line_r - AW'(2); + end + end + + always @(posedge clk) begin + if (reset || icache_flush) begin + l0_valid <= '0; + l0_victim <= '0; + end else if (install) begin + l0_valid[l0_victim] <= 1'b1; + l0_victim <= (l0_victim == NWW'(N-1)) ? '0 : (l0_victim + NWW'(1)); + end + if (install) begin + l0_tag[l0_victim] <= rsp_line; + l0_ptag[l0_victim] <= rsp_line - AW'(1); + l0_p2tag[l0_victim] <= rsp_line - AW'(2); + end + end + + assign run_take = NUM_WARPS'(front_rewrite) << ob_r[0].wid; + assign run_refund = NUM_WARPS'(front_drop) << ob_r[0].wid; + + assign fetch_if.valid = ob_valid_r[0] && ~front_drop; + assign fetch_if.data.instr = ob_r[0].instr; + assign fetch_if.data.PC = ob_r[0].PC; + assign fetch_if.data.tmask = ob_r[0].tmask; + assign fetch_if.data.cta_id = ob_r[0].cta_id; + assign fetch_if.data.wid = NW_WIDTH'(ob_r[0].wid); + assign fetch_if.data.uuid = ob_r[0].uuid; + `ifdef VX_CFG_ICACHE_L0_ENABLE + assign fetch_if.data.run_more = front_run; + assign fetch_if.data.run_cont = ob_r[0].cont; + `endif + end else begin : g_no_l0 + `UNUSED_VAR (icache_flush) + `UNUSED_VAR (run_kill) + `UNUSED_VAR (ibuf_free) + `UNUSED_VAR (rsp_pf) + assign run_take = '0; + assign run_refund = '0; + assign icache_req_pf = 1'b0; + + assign icache_req_valid = schedule_if.valid; + assign icache_req_addr = sched_line; + assign icache_req_tag = {icache_req_uuid, icache_req_wid}; + assign schedule_if.ready = icache_req_ready; + + assign fetch_if.valid = icache_bus_if.rsp_valid; + assign fetch_if.data.tmask = rsp_tmask; + assign fetch_if.data.wid = NW_WIDTH'(rsp_tag); + assign fetch_if.data.cta_id = rsp_cta_id; + assign fetch_if.data.PC = rsp_PC; + assign fetch_if.data.instr = icache_bus_if.rsp_data.data; + assign fetch_if.data.uuid = rsp_uuid; + assign icache_bus_if.rsp_ready = fetch_if.ready; + end `endif // ------------------------------------------------------------------------ diff --git a/hw/rtl/core/VX_frontend_slice.sv b/hw/rtl/core/VX_frontend_slice.sv index f82ed4a3f9..a118c95f1d 100644 --- a/hw/rtl/core/VX_frontend_slice.sv +++ b/hw/rtl/core/VX_frontend_slice.sv @@ -38,6 +38,8 @@ module VX_frontend_slice import VX_gpu_pkg::*; #( // instruction fetch, tagged with the core's flush select bit (the LSB) VX_mem_bus_if.master icache_bus_if, + // the icache is being invalidated: so is the fetch L0 + input wire icache_flush, // decoded instructions VX_decode_if.master decode_if, @@ -72,6 +74,8 @@ module VX_frontend_slice import VX_gpu_pkg::*; #( VX_fetch_if fetch_if(); VX_decode_if fe_decode_if(); VX_decode_sched_if decode_sched_if(); + wire run_kill; + wire [SW-1:0] ibuf_free, run_take, run_refund; // A response with the select bit set answers the core's cache flush on this // port, and the core takes it: it is dropped here, on the cache's registered @@ -92,7 +96,7 @@ module VX_frontend_slice import VX_gpu_pkg::*; #( assign fetch_bus_if.rsp_valid = icache_bus_if.rsp_valid && ~icache_bus_if.rsp_data.tag[0]; assign fetch_bus_if.rsp_data.data = icache_bus_if.rsp_data.data; - assign fetch_bus_if.rsp_data.tag = icache_bus_if.rsp_data.tag[ICACHE_TAG_WIDTH-1:1]; + assign fetch_bus_if.rsp_data.tag = icache_bus_if.rsp_data.tag[ICACHE_SLICE_TAG_WIDTH-1:1]; assign icache_bus_if.rsp_ready = fetch_bus_if.rsp_ready; VX_warp_sched #( @@ -120,6 +124,9 @@ module VX_frontend_slice import VX_gpu_pkg::*; #( .committed (committed), .ibuf_pop (decode_if.ibuf_pop[SW-1:0]), .pending_alm_empty(pending_alm_empty), + .run_take (run_take), + .run_refund (run_refund), + .ibuf_free (ibuf_free), .schedule_if (schedule_if) ); @@ -134,6 +141,11 @@ module VX_frontend_slice import VX_gpu_pkg::*; #( .fetch_perf (fetch_perf), `endif .icache_bus_if (fetch_bus_if), + .icache_flush (icache_flush), + .run_kill (run_kill), + .ibuf_free (ibuf_free), + .run_take (run_take), + .run_refund (run_refund), .schedule_if (schedule_if), .fetch_if (fetch_if) ); @@ -145,7 +157,8 @@ module VX_frontend_slice import VX_gpu_pkg::*; #( .reset (reset), .fetch_if (fetch_if), .decode_if (fe_decode_if), - .decode_sched_if(decode_sched_if) + .decode_sched_if(decode_sched_if), + .run_kill (run_kill) ); // decoded instructions take their core-wide wid diff --git a/hw/rtl/core/VX_warp_sched.sv b/hw/rtl/core/VX_warp_sched.sv index 38fd738242..216b8928d5 100644 --- a/hw/rtl/core/VX_warp_sched.sv +++ b/hw/rtl/core/VX_warp_sched.sv @@ -51,6 +51,12 @@ module VX_warp_sched import VX_gpu_pkg::*; #( input wire [PER_FETCH_WARPS-1:0] committed, input wire [PER_FETCH_WARPS-1:0] ibuf_pop, output wire [PER_FETCH_WARPS-1:0] pending_alm_empty, + // per warp: an L0 run took an ibuffer slot, or gave it back when decode + // dropped its instruction + input wire [PER_FETCH_WARPS-1:0] run_take, + input wire [PER_FETCH_WARPS-1:0] run_refund, + // per warp: the ibuffer has a free slot (registered) + output wire [PER_FETCH_WARPS-1:0] ibuf_free, // fetch request VX_schedule_if.master schedule_if @@ -175,6 +181,9 @@ module VX_warp_sched import VX_gpu_pkg::*; #( .dec_fs_dirty (decode_sched_if.fs_dirty), `ifdef VX_CFG_EXT_C_ENABLE .dec_is_rvc (decode_sched_if.is_rvc), + `endif + `ifdef VX_CFG_ICACHE_L0_ENABLE + .dec_cont (decode_sched_if.cont), `endif .branch (branch[QA]), .br_hit (branch[QA].valid && (br_lid[QA] == LID)), @@ -193,6 +202,8 @@ module VX_warp_sched import VX_gpu_pkg::*; #( .sched_fire (sched_fire), .sched_sel (cand_onehot[l]), .ibuf_pop (ibuf_pop[l]), + .run_take (run_take[l]), + .run_refund (run_refund[l]), .issued (issued[l]), .committed (committed[l]), .active (active_warps[l]), @@ -200,6 +211,7 @@ module VX_warp_sched import VX_gpu_pkg::*; #( .tmask (thread_masks[l]), .pc (warp_pcs[l]), .ibuf_full (ibuf_full[l]), + .ibuf_free (ibuf_free[l]), .pending_empty (pending_empty[l]), .pending_alm_empty (pending_alm_empty[l]), .mscratch (mscratch[l]), @@ -219,9 +231,11 @@ module VX_warp_sched import VX_gpu_pkg::*; #( wire [SW-1:0] schedule_warps = preferred_warps; `UNUSED_VAR (sched_if.slice_ibuf_full) `else - // once every ibuffer of the core is full, any ready warp may fetch + // once every ibuffer of the core is full, any ready warp may fetch, its + // instruction waiting at decode; not with the L0, whose output buffer it + // would hold, and with it the icache responses of every slice wire [SW-1:0] full_warps = ready_warps; - wire [SW-1:0] schedule_warps = (& sched_if.slice_ibuf_full) ? full_warps : preferred_warps; + wire [SW-1:0] schedule_warps = ((& sched_if.slice_ibuf_full) && (ICACHE_L0_LINES == 0)) ? full_warps : preferred_warps; `endif wire [`UP(FETCH_WFS_BITS)-1:0] cand_index; diff --git a/hw/rtl/core/VX_warp_sched_ctx.sv b/hw/rtl/core/VX_warp_sched_ctx.sv index 55c7fed52b..c687abfcfd 100644 --- a/hw/rtl/core/VX_warp_sched_ctx.sv +++ b/hw/rtl/core/VX_warp_sched_ctx.sv @@ -56,6 +56,10 @@ module VX_warp_sched_ctx import VX_gpu_pkg::*; #( `ifdef VX_CFG_EXT_C_ENABLE input wire dec_is_rvc, `endif +`ifdef VX_CFG_ICACHE_L0_ENABLE + // the decoded instruction continued an L0 run + input wire dec_cont, +`endif // the warp's ALU port input sched_branch_t branch, @@ -81,6 +85,8 @@ module VX_warp_sched_ctx import VX_gpu_pkg::*; #( input wire sched_fire, input wire sched_sel, input wire ibuf_pop, + input wire run_take, + input wire run_refund, input wire issued, input wire committed, @@ -90,6 +96,7 @@ module VX_warp_sched_ctx import VX_gpu_pkg::*; #( output wire [`VX_CFG_NUM_THREADS-1:0] tmask, output wire [PC_BITS-1:0] pc, output wire ibuf_full, + output wire ibuf_free, output wire pending_empty, output wire pending_alm_empty, @@ -258,6 +265,13 @@ module VX_warp_sched_ctx import VX_gpu_pkg::*; #( pc_n = pc_r + from_fullPC(dec_is_rvc ? `VX_CFG_XLEN'(2) : `VX_CFG_XLEN'(4)); end `endif + `ifdef VX_CFG_ICACHE_L0_ENABLE + // an instruction continuing an L0 run was never scheduled: its PC + // advance happens at decode + if (dec_hit && dec_cont) begin + pc_n = pc_r + from_fullPC(`VX_CFG_XLEN'(4)); + end + `endif `ifdef VX_SCHED_UNLOCK_ENABLE // An execution unit releases a warp it wstall'd at decode. @@ -339,8 +353,18 @@ module VX_warp_sched_ctx import VX_gpu_pkg::*; #( // ibuffer occupancy: registered full keeps arbitration off the critical path logic [IBUF_CW-1:0] ibuf_size_r, ibuf_size_n; logic ibuf_full_r; - wire ibuf_incr = sched_fire && sched_sel; - assign ibuf_size_n = ibuf_size_r + IBUF_CW'(ibuf_incr) - IBUF_CW'(ibuf_pop); + // a scheduled fetch or an L0 run takes its slot as it is made, so the + // instruction never waits at decode for one + wire l0_run_take = (ICACHE_L0_LINES != 0) && run_take; + wire l0_run_refund = (ICACHE_L0_LINES != 0) && run_refund; + if (ICACHE_L0_LINES == 0) begin : g_no_l0_run + `UNUSED_VAR (run_take) + `UNUSED_VAR (run_refund) + end + `RUNTIME_ASSERT(~(l0_run_take && ibuf_full_r), ("%t: an L0 run took a slot of a full ibuffer", $time)) + `RUNTIME_ASSERT(~l0_run_refund || (ibuf_size_r != '0), ("%t: an L0 run refunded a slot of an empty ibuffer", $time)) + wire ibuf_incr = (sched_fire && sched_sel) || l0_run_take; + assign ibuf_size_n = ibuf_size_r + IBUF_CW'(ibuf_incr) - IBUF_CW'(ibuf_pop) - IBUF_CW'(l0_run_refund); wire ibuf_full_n = (ibuf_size_n == IBUF_CW'(`VX_CFG_IBUF_SIZE)); always @(posedge clk) begin if (reset) begin @@ -352,6 +376,7 @@ module VX_warp_sched_ctx import VX_gpu_pkg::*; #( end end assign ibuf_full = ibuf_full_r; + assign ibuf_free = (ICACHE_L0_LINES != 0) && ~ibuf_full_r; VX_pending_size #( .SIZE (256), diff --git a/hw/rtl/interfaces/VX_decode_sched_if.sv b/hw/rtl/interfaces/VX_decode_sched_if.sv index 6dfaeb9248..f34ced6e96 100644 --- a/hw/rtl/interfaces/VX_decode_sched_if.sv +++ b/hw/rtl/interfaces/VX_decode_sched_if.sv @@ -19,6 +19,11 @@ interface VX_decode_sched_if import VX_gpu_pkg::*; (); wire unlock; `ifdef VX_CFG_EXT_C_ENABLE wire is_rvc; +`endif +`ifdef VX_CFG_ICACHE_L0_ENABLE + // the instruction continued an L0 run: the schedule did not count it or + // advance the PC past it + wire cont; `endif wire [NW_WIDTH-1:0] wid; // the decoded instruction may write FP state: mstatus.FS becomes Dirty @@ -31,6 +36,9 @@ interface VX_decode_sched_if import VX_gpu_pkg::*; (); output unlock, `ifdef VX_CFG_EXT_C_ENABLE output is_rvc, + `endif + `ifdef VX_CFG_ICACHE_L0_ENABLE + output cont, `endif output wid, output fs_dirty, @@ -42,6 +50,9 @@ interface VX_decode_sched_if import VX_gpu_pkg::*; (); input unlock, `ifdef VX_CFG_EXT_C_ENABLE input is_rvc, + `endif + `ifdef VX_CFG_ICACHE_L0_ENABLE + input cont, `endif input wid, input fs_dirty, diff --git a/sim/simx/constants.h b/sim/simx/constants.h index 401202436c..41768a9c0a 100644 --- a/sim/simx/constants.h +++ b/sim/simx/constants.h @@ -150,7 +150,13 @@ inline constexpr uint32_t ISSUE_WIS_BITS = log2ceil(PER_ISSUE_WARPS); // Frontend slice f owns the warps with wid % VX_CFG_FETCH_WIDTH == f; each has its // own warp scheduler, fetch unit, decoder and icache request port. inline constexpr uint32_t PER_FETCH_WARPS = VX_CFG_NUM_WARPS / VX_CFG_FETCH_WIDTH; -inline constexpr uint32_t ICACHE_NUM_REQS = VX_CFG_FETCH_WIDTH; +// With the fetch L0, the slices share one icache port for their line fills. +#ifdef VX_CFG_ICACHE_L0_ENABLE +inline constexpr uint32_t ICACHE_L0_LINES = VX_CFG_ICACHE_L0_LINES; +#else +inline constexpr uint32_t ICACHE_L0_LINES = 0; +#endif +inline constexpr uint32_t ICACHE_NUM_REQS = (ICACHE_L0_LINES != 0) ? 1 : VX_CFG_FETCH_WIDTH; static_assert(VX_CFG_ISSUE_WIDTH != 0 && (VX_CFG_ISSUE_WIDTH & (VX_CFG_ISSUE_WIDTH - 1)) == 0, "ISSUE_WIDTH must be a power of two: the RTL takes a warp's issue slice from the low bits of its id"); static_assert(VX_CFG_FETCH_WIDTH != 0 && (VX_CFG_FETCH_WIDTH & (VX_CFG_FETCH_WIDTH - 1)) == 0 diff --git a/sim/simx/core.cpp b/sim/simx/core.cpp index 095de0ee40..2f51bdb0b1 100644 --- a/sim/simx/core.cpp +++ b/sim/simx/core.cpp @@ -535,6 +535,13 @@ class Core::Impl { queue_flags_idle_ = false; std::fill(ibuf_queued_.begin(), ibuf_queued_.end(), 0); std::fill(ibuf_queue_full_r_.begin(), ibuf_queue_full_r_.end(), false); +#ifdef VX_CFG_ICACHE_L0_ENABLE + for (auto &l0 : l0_) { + l0 = L0(); + } + l0_rr_ = 0; + std::fill(run_kill_.begin(), run_kill_.end(), false); +#endif // perf_stats_ deliberately survives: these are the MPM counters, which // accumulate from device reset. A kernel launch re-enters reset() here but @@ -606,6 +613,14 @@ class Core::Impl { return false; } } +#ifdef VX_CFG_ICACHE_L0_ENABLE + // an L0 prefetch may still be wanted, queued or in flight + for (auto &l0 : l0_) { + if (l0.pf_want || l0.pf_inflight || !l0.reqq.empty() || !l0.out.empty()) { + return false; + } + } +#endif return true; } @@ -667,8 +682,10 @@ class Core::Impl { // Each frontend slice picks among its own warps whose ibuffer is not full; a // buffer is full at exactly IBUF_SIZE entries, a flag registered at the end // of the previous cycle. With an L1, once every warp's buffer is full any - // ready warp may fetch, its instruction waiting at decode. - bool all_full = (VX_CFG_ICACHE_ENABLED || VX_CFG_DCACHE_ENABLED); + // ready warp may fetch, its instruction waiting at decode; not with the L0, + // whose output buffer it would hold, and with it every slice's icache + // responses. + bool all_full = (VX_CFG_ICACHE_ENABLED || VX_CFG_DCACHE_ENABLED) && (ICACHE_L0_LINES == 0); for (uint32_t w = 0; w < VX_CFG_NUM_WARPS && all_full; ++w) { all_full = ibuf_full_r_.at(w); } @@ -716,11 +733,323 @@ class Core::Impl { void fetch() { perf_stats_.ifetch_latency += pending_ifetches_; +#ifdef VX_CFG_ICACHE_L0_ENABLE + this->fetch_l0(); +#else for (uint32_t f = 0; f < VX_CFG_FETCH_WIDTH; ++f) { this->fetch_slice(f); } +#endif + } + +#ifdef VX_CFG_ICACHE_L0_ENABLE + // --------------------------------------------------------------------------- + // Fetch with an L0 per slice: whole icache lines, filled through one icache + // port the slices share. Each slice's two-entry output buffer is decode's + // only source, so every handshake into it is a registered one. The front + // entry, once delivered, becomes the warp's next instruction (a run), into + // the next line too when the L0 holds it; decode keeps the warp locked until + // the run's last one, and drops the one behind a stalling instruction. + // --------------------------------------------------------------------------- + + // an output-buffer entry: its instruction, the L0 way holding its line, the + // way holding the line after it as looked up when the entry was written (-1: + // none), how far into a run it is, the cycle it reaches decode, and whether + // it continues a run + struct L0Entry { + instr_trace_t *trace; + uint32_t way; + int nx; + uint32_t run; + uint64_t ready; + bool cont; + }; + static constexpr uint32_t L0_PF_TAG = 0x80000000u; + static constexpr uint32_t L0_SLICE_SHIFT = 16; + + void l0_fill_code(instr_trace_t *trace, const uint8_t *line) { + uint32_t offset = trace->PC & (VX_CFG_MEM_BLOCK_SIZE - 1); + std::memcpy(&trace->code, line + offset, sizeof(uint32_t)); + } + + int l0_lookup(uint32_t f, Word pc) const { + Word tag = pc / VX_CFG_MEM_BLOCK_SIZE; + auto &lines = l0_.at(f).lines; + for (uint32_t w = 0; w < lines.size(); ++w) { + if (lines[w].valid && lines[w].tag == tag) + return w; + } + return -1; } + // the way holding the line an icache response brings + uint32_t l0_install(uint32_t f, Word pc, const uint8_t *line) { + int found = this->l0_lookup(f, pc); + if (found >= 0) + return found; + auto &l0 = l0_.at(f); + uint32_t w = l0.victim; + // a line an entry continues into is gone once its way is replaced + for (auto &e : l0.out) { + if (e.nx == int(w)) + e.nx = -1; + } + auto &l = l0.lines.at(w); + l.valid = true; + l.tag = pc / VX_CFG_MEM_BLOCK_SIZE; + std::memcpy(l.data.data(), line, VX_CFG_MEM_BLOCK_SIZE); + l0.victim = (w + 1) % ICACHE_L0_LINES; + return w; + } + + // the entry, once delivered, continues with the next instruction + bool l0_runs_on(uint32_t f, const L0Entry &e) const { + if (e.run + 1 >= L0_RUN_MAX) + return false; + // the warp's ibuffer has a free slot (registered); the run takes it as it + // is made, so its instruction never waits at decode holding the output + // buffer, and with it every slice's icache responses + if (ibuf_full_r_.at(e.trace->wid)) + return false; + auto &l = l0_.at(f).lines.at(e.way); + Word line = e.trace->PC / VX_CFG_MEM_BLOCK_SIZE; + if (!(l.valid && l.tag == line)) + return false; + return (e.trace->PC + 4) / VX_CFG_MEM_BLOCK_SIZE == line || e.nx >= 0; + } + + void fetch_l0() { + uint64_t now = SimPlatform::instance().cycles(); + constexpr uint32_t FW = VX_CFG_FETCH_WIDTH; + static_assert(ICACHE_NUM_REQS == 1, "the slices share one icache port"); + + auto &icache_rsp = fetch_rsp_in_.at(0); + auto &icache_req = fetch_req_out_.at(0); + + // what the registered handshakes see this cycle: each slice's output + // buffer, whether its front runs on, whether a fetch response for it + // waits, and its prefetch state + std::array occ; + std::array running, rsp_waiting, pf_want, pf_present; + std::array xwant{}; + std::array pf_want_line; + std::array reqq_size; + for (uint32_t f = 0; f < FW; ++f) { + auto &l0 = l0_.at(f); + occ[f] = l0.out.size(); + reqq_size[f] = l0.reqq.size(); + // a run yields to a fetch that hit and waited last cycle + running[f] = !l0.out.empty() && this->l0_runs_on(f, l0.out.front()) && !l0.hit_waited; + rsp_waiting[f] = false; + pf_want[f] = l0.pf_want; + pf_want_line[f] = l0.pf_want_line; + pf_present[f] = l0.pf_want && this->l0_lookup(f, l0.pf_want_line * VX_CFG_MEM_BLOCK_SIZE) >= 0; + } + if (!icache_rsp.empty() && !(icache_rsp.peek().tag & L0_PF_TAG)) { + rsp_waiting[icache_rsp.peek().tag >> L0_SLICE_SHIFT] = true; + } + + // 1. each slice delivers its front entry; once delivered it becomes the + // warp's next instruction while it runs on + for (uint32_t f = 0; f < FW; ++f) { + auto &l0 = l0_.at(f); + if (l0.out.empty() || l0.out.front().ready > now) + continue; + auto &e = l0.out.front(); + auto trace = e.trace; + uint32_t wid = trace->wid; + if (e.cont && run_kill_.at(wid)) { + // the instruction ahead of it holds the warp until it resolves + run_kill_.at(wid) = false; + assert(ibuf_inflight_.at(wid) > 0); + --ibuf_inflight_.at(wid); + DT(3, simobject_->name() << " l0-run-drop: addr=0x" << std::hex << trace->PC << std::dec << ", " << *trace); + this->pending_remove(wid); + trace->~instr_trace_t(); + trace_pool_.deallocate(trace, 1); + l0.out.pop_front(); + continue; + } + if (ibuf_queue_full_r_.at(wid) || !try_stage(*decode_latch_.at(f), trace, 1)) { + ++perf_stats_.ibuf_stalls; + continue; + } + ++ibuf_queued_.at(wid); + DT(3, simobject_->name() << " l0-out: addr=0x" << std::hex << trace->PC << std::dec << ", " << *trace); + if (running[f]) { + auto nt = trace_pool_.allocate(1); + new (nt) instr_trace_t(trace->uuid + 1); + nt->cid = trace->cid; + nt->wid = wid; + nt->cta_id = trace->cta_id; + nt->tmask = trace->tmask; + nt->PC = trace->PC + 4; + uint32_t nway = e.way; + int nnx = e.nx; + Word nline = nt->PC / VX_CFG_MEM_BLOCK_SIZE; + if (nline != trace->PC / VX_CFG_MEM_BLOCK_SIZE) { + // the run enters the next line: it asks for the one after, as a fetch would + nway = uint32_t(e.nx); + nnx = this->l0_lookup(f, (nline + 1) * VX_CFG_MEM_BLOCK_SIZE); + if (nnx < 0 && !(l0.pf_inflight && l0.pf_line == nline + 1)) { + xwant[f] = true; + l0.pf_want_line = nline + 1; + } + } + this->l0_fill_code(nt, l0.lines.at(nway).data.data()); + trace->run_more = true; + this->pending_add(wid); + ++ibuf_inflight_.at(wid); + e = {nt, nway, nnx, e.run + 1, now + 1, true}; + } else { + l0.out.pop_front(); + } + } + + // 2. each slice looks up its scheduled fetch: a hit enters the output + // buffer when the registered state lets it; a miss asks the icache. The + // lookup also names the line to prefetch next. + std::array miss{}; + std::array want_set{}; + std::array hit_waits{}; + for (uint32_t f = 0; f < FW; ++f) { + auto &fetch_latch = *fetch_latch_.at(f); + if (fetch_latch.empty()) + continue; + auto trace = fetch_latch.peek(); + auto &l0 = l0_.at(f); + Word next_line = trace->PC / VX_CFG_MEM_BLOCK_SIZE + 1; + int next_way = this->l0_lookup(f, next_line * VX_CFG_MEM_BLOCK_SIZE); + if (next_way < 0 && !(l0.pf_inflight && l0.pf_line == next_line)) { + want_set[f] = true; + l0.pf_want_line = next_line; + } + int way = this->l0_lookup(f, trace->PC); + if (way < 0) { + miss[f] = trace; + continue; + } + if (occ[f] > 1 || rsp_waiting[f] || running[f]) { + hit_waits[f] = true; + continue; + } + this->l0_fill_code(trace, l0.lines.at(way).data.data()); + l0.out.push_back({trace, uint32_t(way), next_way, 0, now + 1, false}); + fetch_latch.pop(); + } + + // 3. the icache response: a prefetch installs its line; a fetch enters its + // slice's output buffer while the buffer is not full + if (!icache_rsp.empty()) { + auto &mem_rsp = icache_rsp.peek(); + assert(mem_rsp.data && "icache response must carry line payload"); + uint32_t f = (mem_rsp.tag & ~L0_PF_TAG) >> L0_SLICE_SHIFT; + auto &l0 = l0_.at(f); + if (mem_rsp.tag & L0_PF_TAG) { + assert(l0.pf_inflight); + if (!l0.pf_stale) { + this->l0_install(f, l0.pf_line * VX_CFG_MEM_BLOCK_SIZE, mem_rsp.data->data()); + } + DT(3, simobject_->name() << " l0-prefetch-rsp: addr=0x" << std::hex << l0.pf_line * VX_CFG_MEM_BLOCK_SIZE << std::dec); + l0.pf_inflight = false; + l0.pf_stale = false; + icache_rsp.pop(); + --pending_ifetches_; + } else if (occ[f] < 2) { + uint32_t tag = mem_rsp.tag & ((1u << L0_SLICE_SHIFT) - 1); + auto trace = pending_icache_.at(f).at(tag); + this->l0_fill_code(trace, mem_rsp.data->data()); + uint32_t way = this->l0_install(f, trace->PC, mem_rsp.data->data()); + // a returned line's run stops at its end, as in the RTL + l0.out.push_back({trace, way, -1, 0, now + 1, false}); + DT(3, simobject_->name() << " icache-rsp: addr=0x" << std::hex << trace->PC << ", tag=0x" << mem_rsp.tag << std::dec << ", " << *trace); + pending_icache_.at(f).release(tag); + icache_rsp.pop(); + --pending_ifetches_; + } + } + + // 4. the shared port takes one request a cycle, round-robin over the + // slices' request buffers (two entries each, registered output); each + // slice then puts in one request, its fetch miss or else its prefetch + for (uint32_t i = 0; i < FW; ++i) { + uint32_t f = (l0_rr_ + i) % FW; + auto &reqq = l0_.at(f).reqq; + if (reqq.empty() || reqq.front().second > now) + continue; + if (icache_req.try_send(reqq.front().first, 0)) { + DT(3, simobject_->name() << " icache-req: addr=0x" << std::hex << reqq.front().first.addr << ", tag=0x" << reqq.front().first.tag << std::dec); + reqq.pop_front(); + l0_rr_ = (f + 1) % FW; + ++perf_stats_.ifetches; + ++pending_ifetches_; + } + break; + } + for (uint32_t f = 0; f < FW; ++f) { + auto &l0 = l0_.at(f); + if (reqq_size[f] >= 2) { + // a request waits for room in the slice's request buffer + if (miss[f] != nullptr || (pf_want[f] && !l0.pf_inflight && !pf_present[f])) { + ++perf_stats_.fetch_stalls; + } + continue; + } + MemReq mem_req; + if (miss[f] != nullptr) { + auto &pending_icache = pending_icache_.at(f); + if (pending_icache.full()) { + ++perf_stats_.fetch_stalls; + continue; + } + uint32_t tag = pending_icache.allocate(miss[f]); + mem_req.addr = miss[f]->PC; + mem_req.tag = (f << L0_SLICE_SHIFT) | tag; + mem_req.hart_id = miss[f]->cid; + mem_req.uuid = miss[f]->uuid; + fetch_latch_.at(f)->pop(); + } else if (pf_want[f] && !l0.pf_inflight && !pf_present[f]) { + mem_req.addr = pf_want_line[f] * VX_CFG_MEM_BLOCK_SIZE; + mem_req.tag = L0_PF_TAG | (f << L0_SLICE_SHIFT); + mem_req.hart_id = simobject_->id(); + DT(3, simobject_->name() << " l0-prefetch: addr=0x" << std::hex << mem_req.addr << std::dec); + l0.pf_inflight = true; + l0.pf_line = pf_want_line[f]; + pf_want[f] = false; + } else { + continue; + } + l0.reqq.push_back({mem_req, now + 1}); + } + + // the prefetch wanted next: a new lookup's, else the old one until it is sent or present + for (uint32_t f = 0; f < FW; ++f) { + auto &l0 = l0_.at(f); + l0.hit_waited = hit_waits[f]; + if (want_set[f] || xwant[f]) { + l0.pf_want = true; + } else { + l0.pf_want = pf_want[f] && !pf_present[f]; + l0.pf_want_line = pf_want_line[f]; + } + } + } + + void icache_l0_flush() { + for (auto &l0 : l0_) { + for (auto &l : l0.lines) { + l.valid = false; + } + l0.victim = 0; + l0.pf_want = false; + l0.pf_stale = l0.pf_inflight; + for (auto &e : l0.out) { + e.nx = -1; + } + } + } +#endif + // Frontend slice f: its icache response into its decode latch, then its next // fetch request out of its fetch latch, on icache port f. void fetch_slice(uint32_t f) { @@ -897,8 +1226,15 @@ class Core::Impl { } // Resume warp for non-stalling instructions (ALU, FPU); - // stalling instructions (LSU, SFU, TCU, branches) stay suspended until commit - if (!trace->fetch_stall) { + // stalling instructions (LSU, SFU, TCU, branches) stay suspended until commit. + // An L0 run holds the warp until its last instruction; a stalling one + // inside the run drops the instruction behind it. +#ifdef VX_CFG_ICACHE_L0_ENABLE + if (trace->run_more) { + run_kill_.at(trace->wid) = trace->fetch_stall; + } else +#endif + if (!trace->fetch_stall) { scheduler_->resume(trace->wid); } @@ -1652,6 +1988,40 @@ class Core::Impl { PoolAllocator trace_pool_; +#ifdef VX_CFG_ICACHE_L0_ENABLE + static_assert(!VX_CFG_EXT_C_ENABLED, "the L0 serves the fixed-length fetch path"); + static_assert(ICACHE_L0_LINES >= 1, "the L0 needs at least one line"); + // instructions one run can deliver before its slot serves another fetch + static constexpr uint32_t L0_RUN_MAX = 16; + // per fetch slice: whole icache lines, replaced round-robin, and its output buffer + struct L0 { + struct Line { + bool valid = false; + Word tag = 0; + std::array data; + }; + std::array lines; + uint32_t victim = 0; + std::deque out; + // the next line to prefetch, and the one in flight + bool pf_want = false; + Word pf_want_line = 0; + bool pf_inflight = false; + Word pf_line = 0; + // the icache was flushed while the prefetch was in flight: its line is not installed + bool pf_stale = false; + // a fetch hit but could not enter the output buffer last cycle + bool hit_waited = false; + // the requests on their way to the shared icache port, and the cycle each + // can leave + std::deque> reqq; + }; + std::vector l0_ = std::vector(VX_CFG_FETCH_WIDTH); + uint32_t l0_rr_ = 0; + // per warp: decode found a stalling instruction that a run continued past + std::vector run_kill_ = std::vector(VX_CFG_NUM_WARPS, false); +#endif + #ifdef VX_CFG_EXT_C_ENABLE // RVC fetch SimObject per frontend slice (per-warp halfword buffer + refetch // queue + pick/commit_request helpers). See decompressor.h. @@ -1712,6 +2082,12 @@ bool Core::running() const { return impl_->running(); } +void Core::icache_l0_flush() { +#ifdef VX_CFG_ICACHE_L0_ENABLE + impl_->icache_l0_flush(); +#endif +} + bool Core::mem_req_drained() const { return impl_->mem_req_drained(); } diff --git a/sim/simx/core.h b/sim/simx/core.h index fa59cf5eab..53d8ac283d 100644 --- a/sim/simx/core.h +++ b/sim/simx/core.h @@ -112,6 +112,9 @@ class Core : public SimObject { void resume(uint32_t wid); + // The icache is being invalidated: so is the fetch L0. + void icache_l0_flush(); + // Every request has left the LSU blocks' paths to the data cache and the // local memory's block inputs (a barrier's memory drain). bool mem_req_drained() const; diff --git a/sim/simx/instr_trace.h b/sim/simx/instr_trace.h index 36b841ba18..3a0cd39425 100644 --- a/sim/simx/instr_trace.h +++ b/sim/simx/instr_trace.h @@ -77,6 +77,10 @@ struct instr_trace_t { bool fetch_stall; + // The fetch L0 delivers the warp's next instruction behind this one (a run): + // decode keeps the warp locked. + bool run_more = false; + // Set by a func-unit when a fetch_stall instruction has resolved; the warp // is released when the trace drains from the FU output (commit fan-in). // Branches and warp-control ops release their warp as they resolve instead diff --git a/sim/simx/socket.cpp b/sim/simx/socket.cpp index 00c58a2f02..62b8aff34f 100644 --- a/sim/simx/socket.cpp +++ b/sim/simx/socket.cpp @@ -493,7 +493,12 @@ class Socket::Impl { void dcache_flush_begin(uint32_t fence_op) { dcaches_->flush_begin(fence_op); } bool dcache_flush_done() const { return dcaches_->flush_done(); } - void icache_flush_begin() { icaches_->flush_begin(); } + void icache_flush_begin() { + icaches_->flush_begin(); + for (auto &core : cores_) { + core->icache_l0_flush(); + } + } bool icache_flush_done() const { return icaches_->flush_done(); } #ifdef VX_CFG_EXT_TEX_ENABLE void tcache_flush_begin() { tcache_->flush_begin(); }