From: Luke Kenneth Casson Leighton Date: Sat, 23 Dec 2023 19:13:03 +0000 (+0000) Subject: first cut at a triangular mode X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8eef50287e5d991d6368d457e9fff5929b293254;p=openpower-isa.git first cut at a triangular mode --- diff --git a/src/openpower/decoder/isa/remapyield.py b/src/openpower/decoder/isa/remapyield.py index 82eb13b8..389cfb6b 100644 --- a/src/openpower/decoder/isa/remapyield.py +++ b/src/openpower/decoder/isa/remapyield.py @@ -4,13 +4,15 @@ # python "yield" can be iterated. use this to make it clear how # the indices are generated by using natural-looking nested loops def iterate_indices(SVSHAPE): + # establish if this is triangular mode + triangle = SVSHAPE.mode == 0b11 and SVSHAPE.submode == 0b00 # get indices to iterate over, in the required order 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)) + _x_r = list(range(xd)) + _y_r = list(range(yd)) z_r = list(range(zd)) # invert the indices if needed if SVSHAPE.invxyz[0]: x_r.reverse() @@ -19,11 +21,16 @@ def iterate_indices(SVSHAPE): # start an infinite (wrapping) loop step = 0 # track src/dst step while True: - for z in z_r: # loop over 1st order dimension + for zi, z in enumerate(z_r): # loop over 1st order dimension z_end = z == z_r[-1] - for y in y_r: # loop over 2nd order dimension + # triangle uses a truncated copy + y_r = list(_y_r[:zi+1] if triangle else _y_r) + y_end = True # if list is empty + for yi, y in enumerate(y_r): # loop over 2nd order dimension y_end = y == y_r[-1] - for x in x_r: # loop over 3rd order dimension + x_r = list(_x_r[:yi+1] if triangle else _x_r) + x_end = True # if list is empty + for xi, x in enumerate(x_r): # loop over 3rd order dimension x_end = x == x_r[-1] # ok work out which order to construct things in. # start by creating a list of tuples of the dimension @@ -49,12 +56,12 @@ def iterate_indices(SVSHAPE): # was actually selected above on all 3 dimensions, # e.g. [z][x][y] or [y][z][x]. "skip" allows one of # those to be knocked out - if SVSHAPE.skip == i+1: continue #print ("select %d %s" % (i, dbg)) - if SVSHAPE.mode == 0b00: + if SVSHAPE.mode == 0b00: # Matrix Mode + if SVSHAPE.skip == i+1: continue idx *= mult # shifts up by previous dimension(s) result += idx # adds on this dimension - if SVSHAPE.mode == 0b00: + if SVSHAPE.mode == 0b00: # Matrix Mode mult *= lim # for the next dimension loopends = (x_end | @@ -71,10 +78,16 @@ def dump_shape(SVSHAPE0): for idx, (new_idx, end) in enumerate(iterate_indices(SVSHAPE0)): estring = bin(end)[2:] if end else '' print ("%2d->%-2d" % (idx, new_idx), "%2s" % estring, end=' ') - if end != 0: - print() if end == 0b111: + print() break + triangle = SVSHAPE0.mode == 0b11 and SVSHAPE0.submode == 0b00 + if triangle: + if SVSHAPE0.lims[0] == 1: end &= ~0b001 + if triangle: + if SVSHAPE0.lims[1] == 1: end &= ~0b010 + if end != 0: + print() def demo(): @@ -96,12 +109,26 @@ def demo(): dump_shape(SVSHAPE0) # rhombus - see https://bugs.libre-soc.org/show_bug.cgi?id=1155#c17 - print("\ntriangular, skip-x", xdim, ydim, zdim) + xdim, ydim, zdim = 3, 4, 1 # set the dimension sizes here + print("\nrhombus", xdim, ydim, zdim) + SVSHAPE0 = SVSHAPE() + SVSHAPE0.lims = [xdim, ydim, zdim] + SVSHAPE0.order = [0,1,2] # experiment with different permutations, here + SVSHAPE0.mode = 0b11 + SVSHAPE0.submode = 0b01 # rhombus mode + SVSHAPE0.offset = 0 # experiment with different offset, here + SVSHAPE0.invxyz = [0,0,0] # inversion if desired + + dump_shape(SVSHAPE0) + + # triangle + print("\ntriangle", xdim, ydim, zdim) + xdim, ydim, zdim = 1, 5, 5 # set the dimension sizes here SVSHAPE0 = SVSHAPE() SVSHAPE0.lims = [xdim, ydim, zdim] SVSHAPE0.order = [0,1,2] # experiment with different permutations, here SVSHAPE0.mode = 0b11 - SVSHAPE0.skip = 0b01 # try skipping x-dimension (for fun) + SVSHAPE0.submode = 0b00 # triangle mode SVSHAPE0.offset = 0 # experiment with different offset, here SVSHAPE0.invxyz = [0,0,0] # inversion if desired diff --git a/src/openpower/decoder/isa/svshape.py b/src/openpower/decoder/isa/svshape.py index e34c0842..7876fda4 100644 --- a/src/openpower/decoder/isa/svshape.py +++ b/src/openpower/decoder/isa/svshape.py @@ -133,6 +133,11 @@ class SVSHAPE(SelectableInt): def elwid(self): return self.fsi['skip'].asint(msb0=True) + # submode is the same bits as skip (like elwidth) + @property + def submode(self): + return self.fsi['skip'].asint(msb0=True) + @property def skip(self): if self.is_indexed():