From: Luke Kenneth Casson Leighton Date: Tue, 29 Jun 2021 10:46:32 +0000 (+0100) Subject: add remap.py X-Git-Tag: DRAFT_SVP64_0_1~697 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d8442e6e2f32bac7391b44d7f29c9771bf69625a;p=libreriscv.git add remap.py --- diff --git a/openpower/sv/remap.mdwn b/openpower/sv/remap.mdwn index a63e3c6f2..815c342b3 100644 --- a/openpower/sv/remap.mdwn +++ b/openpower/sv/remap.mdwn @@ -27,49 +27,9 @@ which have the same format. The algorithm below shows how REMAP works more clearly, and may be executed as a python program: -[[!inline quick="yes" raw="yes" pages="/openpower/sv/remap.py" ]] - - xdim = 3 # changeme - ydim = 4 - zdim = 1 - - lims = [xdim, ydim, zdim] - idxs = [0,0,0] # starting indices - order = [0,1,2] # experiment with different permutations, here - offset = 2 # experiment with different offset, here - VL = xdim * ydim * zdim # multiply (or add) to this to get "cycling" - applydim = 0 - invxyz = [0,0,0] - - # run for offset iterations before actually starting - for idx in range(offset): - for i in range(3): - idxs[order[i]] = idxs[order[i]] + 1 - if (idxs[order[i]] != lims[order[i]]): - break - idxs[order[i]] = 0 - - break_count = 0 - - for idx in range(VL): - ix = [0] * 3 - for i in range(3): - if i >= applydim: - ix[i] = idxs[i] - if invxyz[i]: - ix[i] = lims[i] - 1 - ix[i] - new_idx = ix[0] + ix[1] * xdim + ix[2] * xdim * ydim - print new_idx, - break_count += 1 - if break_count == lims[order[0]]: - print - break_count = 0 - for i in range(3): - idxs[order[i]] = idxs[order[i]] + 1 - if (idxs[order[i]] != lims[order[i]]): - break - idxs[order[i]] = 0 - +``` +[[!inline quick="yes" raw="yes" pages="openpower/sv/remap.py" ]] +``` Each element index from the for-loop `0..VL-1` is run through the above algorithm to work out the **actual** element diff --git a/openpower/sv/remap.py b/openpower/sv/remap.py new file mode 100644 index 000000000..c14b1102a --- /dev/null +++ b/openpower/sv/remap.py @@ -0,0 +1,39 @@ +xdim = 3 +ydim = 2 +zdim = 1 + +lims = [xdim, ydim, zdim] +idxs = [0,0,0] # starting indices +order = [0,1,2] # experiment with different permutations, here +offs = 2 # experiment with different offset, here +applydim = 0 +invxyz = [1,0,0] + +for idx in range(offs): + for i in range(3): + idxs[order[i]] = idxs[order[i]] + 1 + if (idxs[order[i]] != lims[order[i]]): + break + print + idxs[order[i]] = 0 + +break_count = 0 + +for idx in range(xdim * ydim * zdim): + ix = [0] * 3 + for i in range(3): + if i >= applydim: + ix[i] = idxs[i] + if invxyz[i]: + ix[i] = lims[i] - 1 - ix[i] + new_idx = ix[0] + ix[1] * xdim + ix[2] * xdim * ydim + print new_idx, + break_count += 1 + if break_count == lims[order[0]]: + print + break_count = 0 + for i in range(3): + idxs[order[i]] = idxs[order[i]] + 1 + if (idxs[order[i]] != lims[order[i]]): + break + idxs[order[i]] = 0