bug 1155: exploring / fixing svshape4, fields incorrect bug_1155_bigmul_remap
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 5 Mar 2024 14:40:22 +0000 (14:40 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 5 Mar 2024 14:40:22 +0000 (14:40 +0000)
openpower/isa/simplev.mdwn
openpower/isatables/fields.text
openpower/isatables/minor_22.csv
openpower/isatables/minor_5.csv
src/openpower/decoder/isa/ed25519/curve25519_mul.py
src/openpower/decoder/isa/remapyield.py
src/openpower/decoder/isa/svshape.py

index 14cb10a2093b4c29be9dca170173fd645429402d..01266d9a973a58080f2a3623abb599b21267dc87 100644 (file)
@@ -488,12 +488,12 @@ Pseudo-code:
     shape[30:31] <- 0b11          # triangle/bigmul mode
     shape[28:29] <- sm            # mode
     shape[24:27] <- SVo           # offset
-    shape[23]    <- SVyx          # swap x/y priority
-    shape[22]    <- sk            # skipping
+    shape[22:23] <- SVyx          # swap x/y priority
+    shape[21]    <- sk            # skipping
     shape[19:20] <- sm2           # submode2
     shape[18]    <- 0             # reserved
     shape[12:17] <- 1             # zdim
-    shape[6:11]  <- (0b0 || SVyd) # xdim
+    shape[6:11]  <- (0b0 || SVyd) # ydim
     shape[0:5]   <- (0b0 || SVxd) # xdim
     # activate requested shape
     if si = 0 then SVSHAPE0 <- shape
index 726c07778b0ba029697d251f7aae96f032266728..a8ed8a55b3e15f6aac6f49b7141ac1fda83f6f74 100644 (file)
 
 # 1.6.29.1 SVI2-FORM
 
-    |0     |6   |9   |11  |16  |21 |22  |24 |26  |27 31|
-    |PO    |SVo |si  |SVyd|SVxd|sk |sm2 |sm |SVyx|XO   |
+    |0     |6   |9   |11  |16  |21 |22  |24 |26  |28  |29  |31  |
+    |PO    |SVo |si  |SVyd|SVxd|sk |sm2 |sm |XO  |SVyx|XO  |SVyx|
 
 # 1.6.30 SVL-FORM
     |0     |6    |11    |16   |23 |24 |25 |26    |31 |
          Immediate field used to specify a 5-bit signed inte-
          ger.
          Formats: VX
+    sk (21)
+        Field used to specify dimensional skipping in svindex
+        Formats: SVI2
     sk (25)
         Field used to specify dimensional skipping in svindex
-        Formats: SVI, SVM2, SVI2
+        Formats: SVI, SVM2
     sm (24:25)
         submode for svindex4
         Formats: SVI2
     XO (26:27)
         Extended opcode field.
         Formats: XX4
+    XO (26:27,29:30)
+        Extended opcode field.
+        Formats: SVI2
     XO (26:30)
         Extended opcode field.
         Formats: A, DX, VA2, SVL, CRB, DCT
         Formats: MDS
     XO (27:31)
         Extended opcode field.
-        Formats: BM2, SVI2
+        Formats: BM2
     XO (29:31)
         Extended opcode field.
         Formats: DQ
         Formats: DQE, DS, SC
     SVyx (23)
         Field used to specify loop dimension order in svindex
-        Formats: SVI, SVI2
+        Formats: SVI
+    SVyx (28,31)
+        Field used to specify loop dimension order in svindex
+        Formats: SVI2
     SVyx (10)
         Field used to specify loop dimension order in svshape2
         Formats: SVM2
index 56c74f0954ae89020999a38c9785e6d8cf78a2a4..a6d39be40c9086077847844757ad4e72f8b60818 100644 (file)
@@ -27,7 +27,6 @@ opcode,unit,internal op,in1,in2,in3,out,CR in,CR out,inv A,inv out,cry in,cry ou
 100--011001,VL,OP_SVSHAPE,NONE,NONE,NONE,NONE,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,svshape2,SVM2,,1,unofficial until submitted and approved/renumbered by the opf isa wg
 # svshape3 and svshape4, none of the horribleness of shoe-horning svshape2 in it
 ------10000,VL,OP_SVSHAPE,NONE,NONE,NONE,NONE,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,svshape3,SVM,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-------11000,VL,OP_SVSHAPE,NONE,NONE,NONE,NONE,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,svshape4,SVI2,,1,unofficial until submitted and approved/renumbered by the opf isa wg
 # A/V bitmanip
 1101001110-,ALU,OP_AVGADD,RA,RB,NONE,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,avgadd,X,,1,unofficial until submitted and approved/renumbered by the opf isa wg
 --01101110-,ALU,OP_SHADD,RA,RB,NONE,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,sadd,Z23,,1,unofficial until submitted and approved/renumbered by the opf isa wg
index 742d7b69c0f72551afb4fcba16102ff3b52bc929..4c1dcd28f02a72b319d5a0c73d3d4a0139d800e4 100644 (file)
@@ -1,2 +1,3 @@
 opcode,unit,internal op,in1,in2,in3,out,CR in,CR out,inv A,inv out,cry in,cry out,ldst len,BR,sgn ext,upd,rsrv,32b,sgn,rc,lk,sgl pipe,comment,form,CONDITIONS,unofficial,comment2
 --------00-,SHIFT_ROT,OP_TERNLOG,RA,RB,RT,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,ternlogi,TLI,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+-----01-01-,VL,OP_SVSHAPE,NONE,NONE,NONE,NONE,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,svshape4,SVI2,,1,unofficial until submitted and approved/renumbered by the opf isa wg
index dbc87bbbeda4df19f05ee3f236362284093c783c..868ec313e89ad185fc4521c9a7d3e861a220bc9c 100644 (file)
@@ -140,7 +140,7 @@ if __name__ == '__main__':
     s[1] = 1<<51
     r[1] = 1<<51
     check(r, s)
-    for i in range(100000):
+    for i in range(1):
         r, s = [0]*5, [0]*5
         for j in range(5):
             r[j] = random.randint(0, 1<<50)
index c4df68387704d0d5db4a93f4309318ef7c204418..23639251d76e347e0d58b63a1cbe4d6b484eb861 100644 (file)
@@ -5,14 +5,19 @@
 # the indices are generated by using natural-looking nested loops
 def iterate_indices(SVSHAPE, VL=None):
     # establish if this is triangular mode
-    triangle = SVSHAPE.mode == 0b11 and SVSHAPE.submode & 0b10 == 0b10
-    bigmul = SVSHAPE.mode == 0b11 and SVSHAPE.submode & 0b01 == 0b01
+    triangle = SVSHAPE.mode == 0b11 and SVSHAPE._skip & 0b10 == 0b10
+    bigmul = SVSHAPE.mode == 0b11 and SVSHAPE._skip & 0b01 == 0b01
     in_offs = VL is not None and SVSHAPE.mode == 0b11
 
     # get indices to iterate over, in the required order
-    xd = SVSHAPE.lims[0]
-    yd = SVSHAPE.lims[1]
-    zd = SVSHAPE.lims[2]
+    if SVSHAPE.mode == 0b11: # bigmul/triangle has no Z-dim
+        xd = 1
+        yd = SVSHAPE.lims[0]
+        zd = SVSHAPE.lims[1]
+    else:
+        xd = SVSHAPE.lims[0]
+        yd = SVSHAPE.lims[1]
+        zd = SVSHAPE.lims[2]
     # create lists of indices to iterate over in each dimension
     _x_r = list(range(xd))
     _y_r = list(range(yd))
@@ -23,6 +28,9 @@ def iterate_indices(SVSHAPE, VL=None):
     if SVSHAPE.invxyz[2]: z_r.reverse()
     # start an infinite (wrapping) loop
     step = 0 # track src/dst step
+    print("iterate_indices", VL, triangle, bigmul, in_offs, "dims", xd, yd, zd,
+            "mode", bin(SVSHAPE.mode), "skip", SVSHAPE.skip,
+            "inv", SVSHAPE.invxyz)
     while True:
         for zi, z in enumerate(z_r):   # loop over 1st order dimension
             z_end = z == z_r[-1]
@@ -38,9 +46,9 @@ def iterate_indices(SVSHAPE, VL=None):
                     # ok work out which order to construct things in.
                     # start by creating a list of tuples of the dimension
                     # and its limit
-                    vals = [(SVSHAPE.lims[0], x, "x"),
-                            (SVSHAPE.lims[1], y, "y"),
-                            (SVSHAPE.lims[2], z, "z")
+                    vals = [(xd, x, "x"),
+                            (yd, y, "y"),
+                            (zd, z, "z")
                            ]
                     # now select those by order.  this allows us to
                     # create schedules for [z][x], [x][y], or [y][z]
@@ -102,9 +110,11 @@ def dump_shape(SVSHAPE, VL=None):
             break
         triangle = SVSHAPE.mode == 0b11 and SVSHAPE.submode & 0b10 == 0b10
         if triangle:
-            if SVSHAPE.lims[0] == 1: end &= ~0b001
+            if SVSHAPE.lims[0] == 1: end &= ~0b010
         if triangle:
-            if SVSHAPE.lims[1] == 1: end &= ~0b010
+            if SVSHAPE.lims[1] == 1: end &= ~0b100
+        if triangle:
+            if SVSHAPE.lims[2] == 1: end &= ~0b001
         if end != 0:
             print()
 
@@ -119,6 +129,7 @@ def demo():
     SVSHAPE0.order = [0,2,1]  # experiment with different permutations, here
     SVSHAPE0.mode = 0b00
     SVSHAPE0.skip = 0b00
+    SVSHAPE0._skip = 0b00
     SVSHAPE0.submode2 = 0b000    #
     SVSHAPE0.offset = 0       # experiment with different offset, here
     SVSHAPE0.invxyz = [0,0,0] # inversion if desired
@@ -134,6 +145,7 @@ def demo():
     SVSHAPE0.order = [0,1,2]  # experiment with different permutations, here
     SVSHAPE0.mode = 0b00
     SVSHAPE0.skip = 0b10
+    SVSHAPE0._skip = 0b10
     SVSHAPE0.submode2 = 0b000    #
     SVSHAPE0.offset = 0       # experiment with different offset, here
     SVSHAPE0.invxyz = [0,0,0] # inversion if desired
@@ -147,6 +159,7 @@ def demo():
     SVSHAPE0.order = [0,1,2]  # experiment with different permutations, here
     SVSHAPE0.mode = 0b00
     SVSHAPE0.skip = 0b01
+    SVSHAPE0._skip = 0b01
     SVSHAPE0.submode2 = 0b000    #
     SVSHAPE0.offset = 0       # experiment with different offset, here
     SVSHAPE0.invxyz = [0,0,0] # inversion if desired
@@ -163,6 +176,7 @@ def demo():
     SVSHAPE0.order = [1,0,2]  # experiment with different permutations, here
     SVSHAPE0.mode = 0b00
     SVSHAPE0.skip = 0b00
+    SVSHAPE0._skip = 0b00
     SVSHAPE0.submode2 = 0b000    #
     SVSHAPE0.offset = 0       # experiment with different offset, here
     SVSHAPE0.invxyz = [0,0,0] # inversion if desired
@@ -179,13 +193,14 @@ def demo():
     SVSHAPE0.submode = 0b01      # rhombus mode
     SVSHAPE0.submode2 = 0b000    #
     SVSHAPE0.skip = 0b00
+    SVSHAPE0._skip = 0b00
     SVSHAPE0.offset = 0       # experiment with different offset, here
     SVSHAPE0.invxyz = [0,0,0] # inversion if desired
 
     dump_shape(SVSHAPE0)
 
     # triangle
-    xdim, ydim, zdim = 1, 5, 5 # set the dimension sizes here
+    xdim, ydim, zdim = 5, 5, 1 # set the dimension sizes here
     print("\ntriangle", xdim, ydim, zdim)
     SVSHAPE0 = SVSHAPE()
     SVSHAPE0.lims = [xdim, ydim, zdim]
@@ -194,6 +209,7 @@ def demo():
     SVSHAPE0.submode = 0b10      # triangle mode
     SVSHAPE0.submode2 = 0b000    #
     SVSHAPE0.skip = 0b11
+    SVSHAPE0._skip = 0b11
     SVSHAPE0.offset = 0       # experiment with different offset, here
     SVSHAPE0.invxyz = [0,0,0] # inversion if desired
 
@@ -201,7 +217,7 @@ def demo():
 
     # triangle
     print("\ntriangle-bigmul", xdim, ydim, zdim)
-    xdim, ydim, zdim = 1, 3, 5 # set the dimension sizes here
+    xdim, ydim, zdim = 3, 5, 1 # set the dimension sizes here
     SVSHAPE0 = SVSHAPE()
     SVSHAPE0.lims = [xdim, ydim, zdim]
     SVSHAPE0.order = [0,1,2]  # experiment with different permutations, here
@@ -209,6 +225,7 @@ def demo():
     SVSHAPE0.submode = 0b11      # triangle mode, with sum
     SVSHAPE0.submode2 = 0b000    #
     SVSHAPE0.skip = 0b00
+    SVSHAPE0._skip = 0b00
     SVSHAPE0.offset = 0       # experiment with different offset, here
     SVSHAPE0.invxyz = [0,0,0] # inversion if desired
 
@@ -225,6 +242,7 @@ def demo():
     SVSHAPE0.mode = 0b11
     SVSHAPE0.submode = 0b00      #
     SVSHAPE0.skip = 0b00
+    SVSHAPE0._skip = 0b00
     SVSHAPE0.submode2 = 0b000    # cols or rows modulo
     SVSHAPE0.offset = 1 # experiment with different offset, here
     SVSHAPE0.invxyz = [0,0,0] # inversion if desired
index 81c08dbf4c341227f08eba4d912b133386fe995a..f391cb8181da840f4174b3827d59fc97657239cb 100644 (file)
@@ -39,7 +39,7 @@ class SVSHAPE(SelectableInt):
             fs = tuple(range(offs, end))
             v = FieldSelectableInt(self, fs)
             self.fsi[field] = v
-            log("SVSHAPE setup field", field, offs, end)
+            log("SVSHAPE setup field", field, offs, end, v.asint(msb0=True))
             offs = end
 
     def copy(self):
@@ -53,6 +53,10 @@ class SVSHAPE(SelectableInt):
         "REMAP Triangle Mode"
         return self.mode == 0b11 and self._skip in [0b10, 0b11]
 
+    def is_bigmul(self):
+        "REMAP Bigmul (Modulo) Mode"
+        return self.mode == 0b11 and self._skip in [0b01, 0b11]
+
     @property
     def submode2(self):
         return self.fsi['permute'].asint(msb0=True)
@@ -95,10 +99,11 @@ class SVSHAPE(SelectableInt):
 
     @property
     def zdimsz(self):
-        z = self.fsi['zdimsz'].asint(msb0=True)+1
+        if self.mode == 0b11: # no 3rd dimension in bigmul/triangle
+            return 1
         if self.is_indexed():
-            z = 1 # no z dimension when indexed
-        return z
+            return 1 # no z dimension when indexed
+        return self.fsi['zdimsz'].asint(msb0=True)+1
 
     @zdimsz.setter
     def zdimsz(self, value):
@@ -178,7 +183,9 @@ class SVSHAPE(SelectableInt):
         return remap
 
     def get_iterator(self):
-        log ("SVSHAPE get_iterator", self.mode, self.ydimsz, self.is_indexed())
+        log ("SVSHAPE get_iterator",
+            self.mode, self.ydimsz, "index", self.is_indexed(),
+                                    "triangle", self.is_triangle())
         if self.mode == 0b00:
             iterate_fn = iterate_indices
         elif self.mode == 0b10:
@@ -189,7 +196,9 @@ class SVSHAPE(SelectableInt):
                 iterate_fn = iterate_preduce_indices # parallel-reduce
         elif self.mode in [0b01, 0b11]:
             # further sub-selection
-            if self.ydimsz == 1:
+            if self.mode == 0b11:
+                iterate_fn = iterate_indices
+            elif self.ydimsz == 1:
                 iterate_fn = iterate_butterfly_indices
             elif self.ydimsz in [2, 4]:
                 iterate_fn = iterate_dct_inner_butterfly_indices
@@ -199,6 +208,7 @@ class SVSHAPE(SelectableInt):
                 iterate_fn = iterate_dct_inner_costable_indices
             elif self.ydimsz in [6, 14, 15]:
                 iterate_fn = iterate_dct_inner_halfswap_loadstore
+        log ("SVSHAPE get_iterator", iterate_fn)
         # create a **NEW** iterator each time this is called
         return iterate_fn(self.copy())