2 Commits

Author SHA1 Message Date
Zhongdi LUO
370a630230 Configure Blackwell simulation for 4x4 execution 2026-07-16 07:27:21 +00:00
Zhongdi LUO
3cbe2e90be fix: update Blackwell 4-lane writeback integration 2026-07-13 10:27:39 +00:00
4 changed files with 17 additions and 32 deletions

View File

@@ -17,14 +17,14 @@ RADIANCE_VSRC_DIR = $(base_dir)/generators/radiance/src/main/resources/vsrc
ifeq ($(shell echo $(CONFIG) | grep -E "SynConfig$$"),$(CONFIG)) ifeq ($(shell echo $(CONFIG) | grep -E "SynConfig$$"),$(CONFIG))
EXTRA_SIM_PREPROC_DEFINES += +define+SYNTHESIS +define+NDEBUG +define+DPI_DISABLE EXTRA_SIM_PREPROC_DEFINES += +define+SYNTHESIS +define+NDEBUG +define+DPI_DISABLE
endif endif
ifeq ($(shell echo $(CONFIG) | grep -E "(FP16|Volta|Ampere)Config$$"),$(CONFIG)) ifeq ($(shell echo $(CONFIG) | grep -E "FP16Config$$"),$(CONFIG))
EXTRA_SIM_PREPROC_DEFINES += +define+NUM_CORES=1 +define+TENSOR_DPU_FP16 EXTRA_SIM_PREPROC_DEFINES += +define+NUM_CORES=8
endif endif
ifeq ($(shell echo $(CONFIG) | grep -E "HopperConfig$$"),$(CONFIG)) ifeq ($(shell echo $(CONFIG) | grep -E "HopperConfig$$"),$(CONFIG))
EXTRA_SIM_PREPROC_DEFINES += +define+NUM_CORES=1 +define+EXT_T_HOPPER +define+TENSOR_DPU_FP16 EXTRA_SIM_PREPROC_DEFINES += +define+NUM_CORES=4 +define+EXT_T_HOPPER
endif endif
ifeq ($(shell echo $(CONFIG) | grep -E "BlackwellConfig$$"),$(CONFIG)) ifeq ($(shell echo $(CONFIG) | grep -E "BlackwellConfig$$"),$(CONFIG))
EXTRA_SIM_PREPROC_DEFINES += +define+NUM_CORES=1 +define+EXT_T_BLACKWELL +define+TENSOR_DPU_FP16 EXTRA_SIM_PREPROC_DEFINES += +define+NUM_CORES=1 +define+NUM_WARPS=4 +define+NUM_THREADS=4 +define+NUM_BARRIERS=4 +define+LSUQ_SIZE=32 +define+EXT_T_BLACKWELL
endif endif
ifeq ($(shell echo $(CONFIG) | grep -E "FlashConfig$$"),$(CONFIG)) ifeq ($(shell echo $(CONFIG) | grep -E "FlashConfig$$"),$(CONFIG))
EXTRA_SIM_PREPROC_DEFINES += +define+NUM_CORES=4 EXTRA_SIM_PREPROC_DEFINES += +define+NUM_CORES=4

View File

@@ -47,16 +47,8 @@ class TensorCoreDecoupled(
val numSourceIds: Int = 16, val numSourceIds: Int = 16,
val numFPRegs: Int = 32 val numFPRegs: Int = 32
) extends Module { ) extends Module {
require(numLanes == 4 || numLanes == 8,
s"Hopper tensor core supports 4 or 8 lanes, got ${numLanes}")
val tilingParams = val tilingParams =
if (half && numLanes == 4) { if (half) TensorTilingParams.fp16 else TensorTilingParams.fp32
TensorTilingParams(m = 16, n = 16, k = 32, mc = 4, nc = 2, kc = 8)
} else if (half) {
TensorTilingParams.fp16
} else {
TensorTilingParams.fp32
}
val numWarpBits = log2Ceil(numWarps) val numWarpBits = log2Ceil(numWarps)
val wordSize = if (half) 2 else 4 val wordSize = if (half) 2 else 4
val wordSizeInBits = wordSize * 8/*bits*/ val wordSizeInBits = wordSize * 8/*bits*/
@@ -135,8 +127,7 @@ class TensorCoreDecoupled(
// or [0,n/2), where 2 is the stride can be read in a single request size. // or [0,n/2), where 2 is the stride can be read in a single request size.
require(tilingParams.m == tilingParams.n, require(tilingParams.m == tilingParams.n,
"currently only supports square SMEM tile") "currently only supports square SMEM tile")
val fragmentBytes = memWidth / 8 val numIndices = tilingParams.m / 2/*FIXME:hardcoded?*/
val numIndices = (tilingParams.m * tilingParams.kc * wordSize) / fragmentBytes
val indexBits = log2Ceil(numIndices) val indexBits = log2Ceil(numIndices)
val lastIndex = (1 << indexBits) - 1 val lastIndex = (1 << indexBits) - 1
@@ -354,10 +345,8 @@ class TensorCoreDecoupled(
// serialize every two B responses into one full 4x4 B tile // serialize every two B responses into one full 4x4 B tile
// FIXME: do the same for A // FIXME: do the same for A
val numBFragmentsPerTile =
(tilingParams.nc * tilingParams.kc * wordSize) / fragmentBytes
val fullB = Module(new FillBuffer( val fullB = Module(new FillBuffer(
chiselTypeOf(respQueueB.bits.data), numBFragmentsPerTile chiselTypeOf(respQueueB.bits.data), 2/*substeps*/
)) ))
fullB.io.enq.valid := respQueueB.valid fullB.io.enq.valid := respQueueB.valid
fullB.io.enq.bits := respQueueB.bits.data fullB.io.enq.bits := respQueueB.bits.data
@@ -535,13 +524,10 @@ class TensorCoreDecoupled(
// select the correct 4x4 tile from A operand buffer // select the correct 4x4 tile from A operand buffer
val numTilesM = tilingParams.m / tilingParams.mc val numTilesM = tilingParams.m / tilingParams.mc
val numTilesMBits = log2Ceil(numTilesM) val numTilesMBits = log2Ceil(numTilesM)
val numAFragmentsPerTile =
(tilingParams.mc * tilingParams.kc * wordSize) / fragmentBytes
def selectOperandA(buf: Vec[UInt]): UInt = { def selectOperandA(buf: Vec[UInt]): UInt = {
require(buf.length == numIndices) require(buf.length == numIndices)
val stepM = stepCompute & ((1 << numTilesMBits) - 1).U val stepM = stepCompute & ((1 << numTilesMBits) - 1).U
val base = stepM * numAFragmentsPerTile.U Cat(buf((stepM << 1) + 1.U), buf(stepM << 1))
Cat((0 until numAFragmentsPerTile).reverse.map(i => buf(base + i.U)))
} }
val operandA = selectOperandA(fullABuf.io.deq.bits.data) val operandA = selectOperandA(fullABuf.io.deq.bits.data)
val operandATag = fullABuf.io.deq.bits.tag val operandATag = fullABuf.io.deq.bits.tag

View File

@@ -764,14 +764,13 @@ class RadianceTileModuleImp(outer: RadianceTile)
} }
def connectTensor = { def connectTensor = {
core.io.tc_tmem_C_rdata := DontCare
if (outer.radianceParams.core.tensorCoreDecoupled) { if (outer.radianceParams.core.tensorCoreDecoupled) {
val tcb0 = new { val tcb0 = new {
val addr = core.io.tc_a_bits_address(31, 0) val addr = core.io.tc_a_bits_address(31, 0)
val tag = core.io.tc_a_bits_tag(outer.tensorTagWidth - 1, 0) val tag = core.io.tc_a_bits_tag(outer.tensorTagWidth - 1, 0)
val write = core.io.tc_a_bits_write(0) val write = core.io.tc_a_bits_write(0)
val mask = core.io.tc_a_bits_mask(outer.tcSmemSize - 1, 0) val mask = core.io.tc_a_bits_mask(31, 0)
val data = core.io.tc_a_bits_data(outer.tcSmemSize * 8 - 1, 0) val data = core.io.tc_a_bits_data(255, 0)
val aValid = core.io.tc_a_valid(0) val aValid = core.io.tc_a_valid(0)
val dReady = core.io.tc_d_ready(0) val dReady = core.io.tc_d_ready(0)
} }
@@ -779,8 +778,8 @@ class RadianceTileModuleImp(outer: RadianceTile)
val addr = core.io.tc_a_bits_address(63, 32) val addr = core.io.tc_a_bits_address(63, 32)
val tag = core.io.tc_a_bits_tag(4 + outer.tensorTagWidth - 1, 4) val tag = core.io.tc_a_bits_tag(4 + outer.tensorTagWidth - 1, 4)
val write = core.io.tc_a_bits_write(1) val write = core.io.tc_a_bits_write(1)
val mask = core.io.tc_a_bits_mask(2 * outer.tcSmemSize - 1, outer.tcSmemSize) val mask = core.io.tc_a_bits_mask(63, 32)
val data = core.io.tc_a_bits_data(2 * outer.tcSmemSize * 8 - 1, outer.tcSmemSize * 8) val data = core.io.tc_a_bits_data(511, 256)
val aValid = core.io.tc_a_valid(1) val aValid = core.io.tc_a_valid(1)
val dReady = core.io.tc_d_ready(1) val dReady = core.io.tc_d_ready(1)
} }
@@ -790,8 +789,8 @@ class RadianceTileModuleImp(outer: RadianceTile)
val adapter = Module( val adapter = Module(
new VortexTLAdapter( new VortexTLAdapter(
outer.smemSourceWidth, outer.smemSourceWidth,
new VortexBundleA(tagWidth = outer.tensorTagWidth, dataWidth = outer.tcSmemSize * 8), new VortexBundleA(tagWidth = outer.tensorTagWidth, dataWidth = 32 * 8),
new VortexBundleD(tagWidth = outer.tensorTagWidth, dataWidth = outer.tcSmemSize * 8), new VortexBundleD(tagWidth = outer.tensorTagWidth, dataWidth = 32 * 8),
client client
) )
) )
@@ -801,7 +800,7 @@ class RadianceTileModuleImp(outer: RadianceTile)
adapter.io.inReq.valid := bundle.aValid adapter.io.inReq.valid := bundle.aValid
adapter.io.inReq.bits.address := bundle.addr adapter.io.inReq.bits.address := bundle.addr
adapter.io.inReq.bits.source := bundle.tag adapter.io.inReq.bits.source := bundle.tag
adapter.io.inReq.bits.size := log2Ceil(outer.tcSmemSize).U adapter.io.inReq.bits.size := 5.U // 256 bits
adapter.io.inReq.bits.opcode := Mux(bundle.write.asBool, TLMessages.PutFullData, TLMessages.Get) adapter.io.inReq.bits.opcode := Mux(bundle.write.asBool, TLMessages.PutFullData, TLMessages.Get)
adapter.io.inReq.bits.mask := bundle.mask adapter.io.inReq.bits.mask := bundle.mask
adapter.io.inReq.bits.data := bundle.data adapter.io.inReq.bits.data := bundle.data
@@ -813,7 +812,7 @@ class RadianceTileModuleImp(outer: RadianceTile)
} }
core.io.tc_a_ready := Cat(0.U(1.W), adapters.last.io.inReq.ready, adapters.head.io.inReq.ready) core.io.tc_a_ready := Cat(0.U(1.W), adapters.last.io.inReq.ready, adapters.head.io.inReq.ready)
core.io.tc_d_valid := Cat(0.U(1.W), adapters.last.io.inResp.valid, adapters.head.io.inResp.valid) core.io.tc_d_valid := Cat(0.U(1.W), adapters.last.io.inResp.valid, adapters.head.io.inResp.valid)
core.io.tc_d_bits_data := Cat(0.U((outer.tcSmemSize * 8).W), adapters.last.io.inResp.bits.data, adapters.head.io.inResp.bits.data) core.io.tc_d_bits_data := Cat(0.U((32 * 8).W), adapters.last.io.inResp.bits.data, adapters.head.io.inResp.bits.data)
core.io.tc_d_bits_tag := Cat(0.U(outer.tensorTagWidth.W), adapters.last.io.inResp.bits.source, adapters.head.io.inResp.bits.source) core.io.tc_d_bits_tag := Cat(0.U(outer.tensorTagWidth.W), adapters.last.io.inResp.bits.source, adapters.head.io.inResp.bits.source)
require(core.io.tc_d_bits_data.widthOption.get == adapters.head.io.inResp.bits.data.widthOption.get * 3) require(core.io.tc_d_bits_data.widthOption.get == adapters.head.io.inResp.bits.data.widthOption.get * 3)
require(core.io.tc_d_bits_tag.widthOption.get == adapters.head.io.inResp.bits.source.widthOption.get * 3) require(core.io.tc_d_bits_tag.widthOption.get == adapters.head.io.inResp.bits.source.widthOption.get * 3)