From 2e53465cdd5e92e9284e3328c5045eefe94833ff Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 5 Jul 2021 12:36:46 +0100 Subject: [PATCH] add in skip mode implementation into matrix demo --- openpower/sv/remapmatrixprint.py | 7 +++++-- openpower/sv/remapyield.py | 30 ++++++++++++++++++---------- openpower/sv/shape_table_format.mdwn | 8 ++++---- 3 files changed, 28 insertions(+), 17 deletions(-) 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<