[Libre-soc-dev] maxloc working
Luke Kenneth Casson Leighton
lkcl at lkcl.net
Mon Jan 15 23:03:38 GMT 2024
finally, after several weeks spread out over many months,
i have a "correct" version of maxloc in svp64 assembler.
it is known for being insanely complex to implement,
typically 150 to 400 instructions and involving recursive descent
tree walking.
this has been by far and above the most complex example
to date, although it looks trivial:
71 m, nm, i, n = 0, 0, 0, len(a)
72 while (i<n):
73 while (i<n and a[i]<=m) : i += 1
74 while (i<n and a[i] > m): m, nm, i = a[i], i, i+1
75 return nm
line 73 is superficially trivial - sv.cmp/ff=gt/m=ge *0,0,*10,4
but the rest is convoluted and intimately tied to a combination
of data-dependent fail-first *and masking*, but producing
a *single* CR field (not a vector) that then has to have its
bits combined for further testing.
there are some planned instructions (to be implemented,
they are in the spec) - crternluti and the crweirds - that will
bring the instruction count down, but for now it is,.. 16 instructions
which is a lot more than i was expecting, almost double.
it *might* be possible to cut down to 12 but we have to see
how it goes. the main thing is, i have a working algorithm to
start from for further optimisation.
l.
---
geometry: without it life is pointless
the fibonacci series: easy as 1 1 2 3
More information about the Libre-soc-dev
mailing list