From: Luke Kenneth Casson Leighton Date: Mon, 5 Jul 2021 11:36:46 +0000 (+0100) Subject: add in skip mode implementation into matrix demo X-Git-Tag: DRAFT_SVP64_0_1~657 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2e53465cdd5e92e9284e3328c5045eefe94833ff;p=libreriscv.git add in skip mode implementation into matrix demo --- diff --git a/openpower/sv/remapmatrixprint.py b/openpower/sv/remapmatrixprint.py index 94a4c4b52..577f2a727 100644 --- a/openpower/sv/remapmatrixprint.py +++ b/openpower/sv/remapmatrixprint.py @@ -56,20 +56,23 @@ def matrixscheduledemo(): SVSHAPE0.lims = [xdim2, ydim2, 1] SVSHAPE0.order = [0,1,2] # result iterates through i and j (modulo) SVSHAPE0.mode = 0b00 + SVSHAPE0.skip = 0b00 SVSHAPE0.offset = 0 # no offset SVSHAPE0.invxyz = [0,0,0] # no inversion # X uses SVSHAPE1 SVSHAPE1 = SVSHAPE() SVSHAPE1.lims = [xdim2, ydim2, ydim1] SVSHAPE1.order = [0,2,1] # X iterates through i and k - SVSHAPE1.mode = 0b10 + SVSHAPE1.mode = 0b00 + SVSHAPE1.skip = 0b01 SVSHAPE1.offset = 0 # no offset SVSHAPE1.invxyz = [0,0,0] # no inversion # y-selector uses SHAPE2 SVSHAPE2 = SVSHAPE() SVSHAPE2.lims = [xdim2, ydim2, ydim1] SVSHAPE2.order = [0,2,1] # X iterates through i and k - SVSHAPE2.mode = 0b01 + SVSHAPE2.mode = 0b00 + SVSHAPE2.skip = 0b11 SVSHAPE2.offset = 0 # no offset SVSHAPE2.invxyz = [0,0,0] # no inversion diff --git a/openpower/sv/remapyield.py b/openpower/sv/remapyield.py index 6c53f65b6..7ff21c0b1 100644 --- a/openpower/sv/remapyield.py +++ b/openpower/sv/remapyield.py @@ -28,23 +28,31 @@ def iterate_indices(SVSHAPE): (SVSHAPE.lims[1], y, "y"), (SVSHAPE.lims[2], z, "z") ] - # now select those by order: + # now select those by order. this allows us to + # create schedules for [z][x], [x][y], or [y][z] + # for matrix multiply. vals = [vals[SVSHAPE.order[0]], vals[SVSHAPE.order[1]], vals[SVSHAPE.order[2]] ] - # ok now we can construct the result, using bits of - # "order" to say which ones get stacked on + # some of the dimensions can be "skipped". the order + # 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 == 0b00: + select = 0b111 + elif SVSHAPE.skip == 0b11: + select = 0b011 + elif SVSHAPE.skip == 0b01: + select = 0b110 + elif SVSHAPE.skip == 0b10: + select = 0b101 + else: + select = 0b111 result = 0 mult = 1 - if SVSHAPE.mode == 0b00: - permute = 0b111 - elif SVSHAPE.mode == 0b01: - permute = 0b011 - elif SVSHAPE.mode == 0b10: - permute = 0b110 - else: - permute = 0b111 + # ok now we can construct the result, using bits of + # "order" to say which ones get stacked on for i in range(3): lim, idx, dbg = vals[i] if permute & (1<