From: lkcl Date: Sat, 25 Jun 2022 18:51:32 +0000 (+0100) Subject: (no commit message) X-Git-Tag: opf_rfc_ls005_v1~1522 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1963e5aceb4b44fef899cab0fe111323253cb57a;p=libreriscv.git --- diff --git a/openpower/sv/svp64/appendix.mdwn b/openpower/sv/svp64/appendix.mdwn index 1ed354fda..3ff57f151 100644 --- a/openpower/sv/svp64/appendix.mdwn +++ b/openpower/sv/svp64/appendix.mdwn @@ -999,29 +999,10 @@ Additional state cannot be saved on context-switching beyond that of SVSTATE, making things slightly tricky. Executable demo pseudocode, full version -[here](https://git.libre-soc.org/?p=libreriscv.git;a=blob;f=openpower/sv/preduce.py;hb=HEAD) +[here](https://git.libre-soc.org/?p=libreriscv.git;a=blob;f=openpower/sv/test_preduce.py;hb=HEAD) ``` -def preducei(vl, vec, pred): - vec = copy(vec) - pred = copy(pred) # must not damage predicate - step = 1 - ix = list(range(vl)) # indices move rather than copy data - print(" start", step, pred, vec) - while step < vl: - step *= 2 - for i in range(0, vl, step): - other = i + step // 2 - ci = ix[i] - oi = ix[other] if other < vl else None - other_pred = other < vl and pred[oi] - if pred[ci] and other_pred: - vec[ci] += vec[oi] - elif other_pred: - ix[i] = oi # leave data in-place, copy index instead - pred[ci] |= other_pred - print(" row", step, pred, vec, ix) - return vec +[[!inline raw="yes" pages="openpower/sv/preduce.py" ]] ``` This algorithm works by noting when data remains in-place rather than