[Libre-soc-bugs] [Bug 676] FORTRAN MAXLOC SVP64 example

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Fri Nov 17 14:27:59 GMT 2023


https://bugs.libre-soc.org/show_bug.cgi?id=676

--- Comment #25 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Luke Kenneth Casson Leighton from comment #2)

in-register version

first prepare offsets

    setvl vl=8
    sv.svstep *offs, srcstep # 0 1 2 ... vl-1

and nm-potential

    li nm, -1
    li nmbase, 0
    li idx, 0    # start at first

> while (i<n) { 
>     // skip up to first max
>     while (i<n && a[i]<=m)  i++;

get max comparison, overlap-loop into m where reg a=m+1,
and terminate at the first

    sv.max./ff=gt/vli *m, *a, idx

now the search will terminate at the first failure,
truncating VL to point at it.

next we must discard the numbers already analysed:

    sv.addi/sm=lt *m, *m, 0

next, these two both use mapreduce mode with predication.

>     // continue as long as picking new m
>     while (i<n && a[i]>m) { 

use the same max-trick, terminating this time at the greatest first number

    sv.max./ff=lt/vli *m, *a, idx

>        m = a[i]; 



>        nm = i;

add-overwriting base with vector-offset into nm, yes *scalar* nm,
the "last winner" is the largest index. reverse-gear would make
this easier (pick the first success)

    sv.add/mr/m=gt nm, nmbase, *offs

>        i++;
>     }
> }

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list