From 80c5c65b2e24c0c813e18e118f79bc120ffbfb20 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 6 Sep 2022 15:28:05 +0100 Subject: [PATCH] REMAP parallel-reduce: https://bugs.libre-soc.org/show_bug.cgi?id=864 * add 0b0111 csv entry for svshape * stop sv/trans/svp64.py raising exception for SVrm=0b0111 * add beginnings of svshape SVrm=0b0111 to simplev.mdwn * add first unit test --- openpower/isa/simplev.mdwn | 33 +++++ openpower/isatables/minor_22.csv | 4 +- .../isa/test_caller_svp64_parallel_reduce.py | 114 ++++++++++++++++++ src/openpower/sv/trans/svp64.py | 2 +- 4 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 src/openpower/decoder/isa/test_caller_svp64_parallel_reduce.py diff --git a/openpower/isa/simplev.mdwn b/openpower/isa/simplev.mdwn index 9ef43a2e..61dabd98 100644 --- a/openpower/isa/simplev.mdwn +++ b/openpower/isa/simplev.mdwn @@ -265,6 +265,39 @@ Pseudo-code: 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) + vlen[0:6] <- [0] * 7 + itercount[0:6] <- (0b00 || SVxd) + 0b0000001 + step[0:6] <- 0b0000001 + i[0:6] <- 0b0000000 + do while step >> lst = ["svshape 2, 2, 0, 7, 0", + "svremap 31, 1, 2, 3, 0, 0, 0", + #"sv.fadd *0, *8, *16" + ] + REMAP fmadds FRT, FRA, FRC, FRB + """ + lst = SVP64Asm(["svshape 2, 2, 0, 7, 0", + #"svremap 31, 1, 2, 3, 0, 0, 0", + #"sv.fmadds *0, *16, *32, *0" + ]) + lst = list(lst) + + fprs = [0] * 64 + # 3x2 matrix + X1 = [[1, 2, 3], + [3, 4, 5], + ] + # 2x3 matrix + Y1 = [[6, 7], + [8, 9], + [10, 11], + ] + + X = X1 + Y = Y1 + + xf = reduce(operator.add, X) + yf = reduce(operator.add, Y) + print ("flattened X,Y") + print ("\t", xf) + print ("\t", yf) + + # and create a linear result2, same scheme + #result1 = [0] * (ydim1*xdim2) + + + res = [] + # store FPs + for i, x in enumerate(xf): + fprs[i+16] = fp64toselectable(float(x)) # X matrix + for i, y in enumerate(yf): + fprs[i+32] = fp64toselectable(float(y)) # Y matrix + continue + #t = DOUBLE2SINGLE(fp64toselectable(t)) # convert to Power single + #u = DOUBLE2SINGLE(fp64toselectable(u)) # from double + #res.append((t, u)) + #print ("FFT", i, "in", a, b, "coeff", c, "mul", + # mul, "res", t, u) + + with Program(lst, bigendian=False) as program: + sim = self.run_tst_program(program, initial_fprs=fprs) + print ("spr svshape0", sim.spr['SVSHAPE0']) + print (" xdimsz", sim.spr['SVSHAPE0'].xdimsz) + print (" ydimsz", sim.spr['SVSHAPE0'].ydimsz) + print (" zdimsz", sim.spr['SVSHAPE0'].zdimsz) + print ("spr svshape1", sim.spr['SVSHAPE1']) + print ("spr svshape2", sim.spr['SVSHAPE2']) + print ("spr svshape3", sim.spr['SVSHAPE3']) + for i in range(4): + print ("i", i, float(sim.fpr(i))) + # confirm that the results are as expected + #for i, (t, u) in enumerate(res): + # self.assertEqual(sim.fpr(i+2), t) + # self.assertEqual(sim.fpr(i+6), u) + + + def run_tst_program(self, prog, initial_regs=None, + svstate=None, + initial_mem=None, + initial_fprs=None): + if initial_regs is None: + initial_regs = [0] * 32 + simulator = run_tst(prog, initial_regs, mem=initial_mem, + initial_fprs=initial_fprs, + svstate=svstate) + + print ("GPRs") + simulator.gpr.dump() + print ("FPRs") + simulator.fpr.dump() + + return simulator + + +if __name__ == "__main__": + unittest.main() diff --git a/src/openpower/sv/trans/svp64.py b/src/openpower/sv/trans/svp64.py index eed7b315..43c34721 100644 --- a/src/openpower/sv/trans/svp64.py +++ b/src/openpower/sv/trans/svp64.py @@ -173,7 +173,7 @@ def svshape(fields): SVzd -= 1 # check SVrm for reserved (and svshape2) values - assert SVrm not in [0b0111, 0b1000, 0b1001], \ + assert SVrm not in [0b1000, 0b1001], \ "svshape reserved SVrm value %s" % bin(SVrm) return instruction( -- 2.30.2