[Libre-soc-isa] [Bug 1071] add parallel prefix sum remap mode

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Fri Apr 28 09:17:07 BST 2023


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

--- Comment #14 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #13)
> (In reply to Jacob Lifshay from comment #12)
> > other thing I noticed, we need a svshape instruction that can take a dynamic
> > length and produce the prefix-sum or reduce schedules, currently svshape
> > only supports constant lengths.
> 
> they're all very deliberately immediate-based because it otherwise
> means that the establishment of REMAP Schedules is dependent on
> GPR registers.  the sole exception is Indexed REMAP and even that
> is an "indicator to trigger the process of cacheing GPRs" rather than
> "actual Hazard"

I was expecting the input to be VL rather than a GPR...

> 
> what's the story there? why is dynamic length needed?

because, for code that is trying to reduce or prefix-sum a large array, it
needs to be able to have a dynamic length for the vector tail (or similar
scenarios):
(not the most efficient algorithm, but needs to be possible for non-associative
ops):
chunk_size = 64
sum = 0
for i in range(0, length, chunk_size):
    sum += reduce_chunk(VL=chunk_size)
sum += reduce_tail(VL=length % chunk_size)  # dynamic VL here

or, for prefix-sum:

chunk_size = 64
sum = 0
for i in range(0, len(array), chunk_size):
    vec = load(array[i:][:chunk_size],VL=chunk_size)
    vec = vec.prefix_sum(length=chunk_size)
    vec += splat(sum)
    sum = vec[-1]
    store(vec,array[i:][:chunk_size],VL=chunk_size)
remainder = len(array) % chunk_size
vec = load(array[i:][:remainder],VL=remainder)
vec = vec.prefix_sum(length=remainder)  # dynamic VL here
vec += splat(sum)
store(vec,array[i:][:remainder],VL=remainder)

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


More information about the Libre-SOC-ISA mailing list