From c1a1e920062a5e154507f75af37fcbffee556629 Mon Sep 17 00:00:00 2001 From: lkcl Date: Sun, 26 Mar 2023 22:17:19 +0100 Subject: [PATCH] --- openpower/sv/rfc/ls009.mdwn | 176 +++++++++++++++++++++++++++++++++--- 1 file changed, 165 insertions(+), 11 deletions(-) diff --git a/openpower/sv/rfc/ls009.mdwn b/openpower/sv/rfc/ls009.mdwn index 490df0642..fa5cc6d57 100644 --- a/openpower/sv/rfc/ls009.mdwn +++ b/openpower/sv/rfc/ls009.mdwn @@ -575,7 +575,9 @@ determine which shape is applied to an activated register. the `pst` bit if cleared indicated that the REMAP operation shall only apply to the immediately-following instruction. If set then REMAP remains permanently enabled until such time as it is explicitly disabled, either by `setvl` setting a new MAXVL, or with another -`svremap` instruction. +`svremap` instruction. `svindex` and `svshape2` are also capable of setting or +clearing persistence, as well as partially covering a subset of the capability of +`svremap` to set register-to-SVSHAPE relationships. # SHAPE Remapping SPRs @@ -793,6 +795,90 @@ Form: SVM-Form SV "Matrix" Form (see [[isatables/fields.text]]) | -- | -- | --- | ----- | ------ | -- | ------| -------- | |OPCD| SVxd | SVyd | SVzd | SVRM | vf | XO | svshape | +``` + # for convenience, VL to be calculated and stored in SVSTATE + vlen <- [0] * 7 + mscale[0:5] <- 0b000001 # for scaling MAXVL + itercount[0:6] <- [0] * 7 + SVSTATE[0:31] <- [0] * 32 + # only overwrite REMAP if "persistence" is zero + if (SVSTATE[62] = 0b0) then + SVSTATE[32:33] <- 0b00 + SVSTATE[34:35] <- 0b00 + SVSTATE[36:37] <- 0b00 + SVSTATE[38:39] <- 0b00 + SVSTATE[40:41] <- 0b00 + SVSTATE[42:46] <- 0b00000 + SVSTATE[62] <- 0b0 + SVSTATE[63] <- 0b0 + # clear out all SVSHAPEs + SVSHAPE0[0:31] <- [0] * 32 + SVSHAPE1[0:31] <- [0] * 32 + SVSHAPE2[0:31] <- [0] * 32 + SVSHAPE3[0:31] <- [0] * 32 + + # set schedule up for multiply + if (SVrm = 0b0000) then + # VL in Matrix Multiply is xd*yd*zd + xd <- (0b00 || SVxd) + 1 + yd <- (0b00 || SVyd) + 1 + zd <- (0b00 || SVzd) + 1 + n <- xd * yd * zd + vlen[0:6] <- n[14:20] + # set up template in SVSHAPE0, then copy to 1-3 + SVSHAPE0[0:5] <- (0b0 || SVxd) # xdim + SVSHAPE0[6:11] <- (0b0 || SVyd) # ydim + SVSHAPE0[12:17] <- (0b0 || SVzd) # zdim + SVSHAPE0[28:29] <- 0b11 # skip z + # copy + SVSHAPE1[0:31] <- SVSHAPE0[0:31] + SVSHAPE2[0:31] <- SVSHAPE0[0:31] + SVSHAPE3[0:31] <- SVSHAPE0[0:31] + # set up FRA + SVSHAPE1[18:20] <- 0b001 # permute x,z,y + SVSHAPE1[28:29] <- 0b01 # skip z + # FRC + SVSHAPE2[18:20] <- 0b001 # permute x,z,y + SVSHAPE2[28:29] <- 0b11 # skip y + + # set schedule up for FFT butterfly + if (SVrm = 0b0001) then + # calculate O(N log2 N) + n <- [0] * 3 + do while n < 5 + if SVxd[4-n] = 0 then + leave + n <- n + 1 + n <- ((0b0 || SVxd) + 1) * n + vlen[0:6] <- n[1:7] + # set up template in SVSHAPE0, then copy to 1-3 + # for FRA and FRT + SVSHAPE0[0:5] <- (0b0 || SVxd) # xdim + SVSHAPE0[12:17] <- (0b0 || SVzd) # zdim - "striding" (2D FFT) + mscale <- (0b0 || SVzd) + 1 + SVSHAPE0[30:31] <- 0b01 # Butterfly mode + # copy + SVSHAPE1[0:31] <- SVSHAPE0[0:31] + SVSHAPE2[0:31] <- SVSHAPE0[0:31] + # set up FRB and FRS + SVSHAPE1[28:29] <- 0b01 # j+halfstep schedule + # FRC (coefficients) + SVSHAPE2[28:29] <- 0b10 # k schedule + + # set schedule up for (i)DCT Inner butterfly + # SVrm Mode 2 (Mode 6 for iDCT) is for pre-calculated coefficients, + # SVrm Mode 4 (Mode 12 for iDCT) is for on-the-fly (Vertical-First Mode) + if ((SVrm = 0b0010) | (SVrm = 0b0100) | + (SVrm = 0b1010) | (SVrm = 0b1100)) then + # calculate O(N log2 N) + n <- [0] * 3 + do while n < 5 + if SVxd[4-n] = 0 then + leave + n <- n + 1 + n <- ((0b0 || SVxd) + 1) * n + vlen[0:6] <- n[1:7] + # set up template in SVSHAPE0, then copy to 1-3 # set up FRB and FRS SVSHAPE0[0:5] <- (0b0 || SVxd) # xdim SVSHAPE0[12:17] <- (0b0 || SVzd) # zdim - "striding" (2D DCT) @@ -812,6 +898,7 @@ Form: SVM-Form SV "Matrix" Form (see [[isatables/fields.text]]) SVSHAPE1[28:29] <- 0b01 # j+halfstep schedule # reset costable "striding" to 1 SVSHAPE2[12:17] <- 0b000000 + # set schedule up for DCT COS table generation if (SVrm = 0b0101) | (SVrm = 0b1101) then # calculate O(N log2 N) @@ -840,6 +927,7 @@ Form: SVM-Form SV "Matrix" Form (see [[isatables/fields.text]]) # for cos coefficient SVSHAPE1[28:29] <- 0b10 # ci schedule SVSHAPE2[28:29] <- 0b11 # size schedule + # set schedule up for iDCT / DCT inverse of half-swapped ordering if (SVrm = 0b0110) | (SVrm = 0b1110) | (SVrm = 0b1111) then vlen[0:6] <- (0b00 || SVxd) + 0b0000001 @@ -854,6 +942,7 @@ Form: SVM-Form SV "Matrix" Form (see [[isatables/fields.text]]) else SVSHAPE0[30:31] <- 0b11 # DCT mode SVSHAPE0[6:11] <- 0b000101 # DCT "half-swap" mode + # set schedule up for parallel reduction if (SVrm = 0b0111) then # calculate the total number of operations (brute-force) @@ -879,12 +968,14 @@ Form: SVM-Form SV "Matrix" Form (see [[isatables/fields.text]]) SVSHAPE1[0:31] <- SVSHAPE0[0:31] # set up right operand (left operand 28:29 is zero) SVSHAPE1[28:29] <- 0b01 # right operand + # set VL, MVL and Vertical-First m[0:12] <- vlen * mscale maxvl[0:6] <- m[6:12] SVSTATE[0:6] <- maxvl # MAVXL SVSTATE[7:13] <- vlen # VL SVSTATE[63] <- vf +``` Special Registers Altered: @@ -945,21 +1036,85 @@ instruction, `psvshape`, may extend the capability here. # svindex instruction + +| 0.5|6.10 |11.15 |16.20 | 21..25 | 26..31| name | Form | +| -- | -- | --- | ---- | ----------- | ------| -------- | ---- | +|OPCD| SVG | rmm | SVd | ew/yx/mm/sk | XO | svindex | SVI-Form | + +SVI-Form + +* svindex SVG,rmm,SVd,ew,SVyx,mm,sk + +Pseudo-code: + + # based on nearest MAXVL compute other dimension + MVL <- SVSTATE[0:6] + d <- [0] * 6 + dim <- SVd+1 + do while d*dim