belated feedback Alex Shinn (16 Apr 2021 15:00 UTC)
Re: belated feedback Bradley Lucier (16 Apr 2021 17:08 UTC)
Re: belated feedback John Cowan (16 Apr 2021 18:25 UTC)
Re: belated feedback Bradley Lucier (17 Apr 2021 21:48 UTC)
Re: belated feedback Alex Shinn (18 Apr 2021 23:45 UTC)
Re: belated feedback Bradley Lucier (16 Apr 2021 23:46 UTC)
Re: belated feedback Alex Shinn (17 Apr 2021 00:03 UTC)
Re: belated feedback Bradley Lucier (17 Apr 2021 01:10 UTC)
Re: belated feedback Alex Shinn (17 Apr 2021 01:22 UTC)
Re: belated feedback Alex Shinn (30 Apr 2021 05:41 UTC)
Re: belated feedback Bradley Lucier (30 Apr 2021 14:17 UTC)
Re: belated feedback John Cowan (30 Apr 2021 15:04 UTC)
Re: belated feedback Bradley Lucier (30 Apr 2021 16:42 UTC)
Re: belated feedback Alex Shinn (01 May 2021 09:27 UTC)
array-elements-in-order? (Was: belated feedback) Bradley Lucier (16 Jan 2022 19:08 UTC)

Re: belated feedback Alex Shinn 30 Apr 2021 05:40 UTC

On Sat, Apr 17, 2021 at 10:22 AM Alex Shinn <xxxxxx@gmail.com> wrote:
>
> On Sat, Apr 17, 2021 at 10:10 AM Bradley Lucier <xxxxxx@math.purdue.edu> wrote:
> >
> > On 4/16/21 8:03 PM, Alex Shinn wrote:
> >
> > > What surprised me most is that after completing my work and looking at
> > > the reference implementation, the latter does not seem to perform this
> > > optimization.  In fact, the array record type only holds the indexer,
> > > not the affine coefficients, so it cannot perform this optimization
> > > (unless the compiler is smart enough to combine these closures at
> > > runtime).
> >
> > The strides, lower bounds, and base index are implicit in the closures
> > that implement the indexers in %%indexer-1/2/3/4/generic.  It's not the
> > compiler that computes these parameters, it's code in
> > %%compose-indexers.  Perhaps there's a better way.
>
> Ah, sorry, I missed that.  You can just call the indexer on the first few values
> to get the strides, very elegant.  For my own implementation since I want to
> tie in with the FFI I will want to make the strides more explicit though.

FYI I've implemented the indexer optimization/flattening in Chibi head.
I use the same approach for reshaping and just verify agreement on
offsets when taking one step in every dimension from the old and new
domains.  I'm pretty sure this works (it passes all the tests) but haven't
proved it.

Note the resulting indexers are more optimized than in the SRFI 179
reference implementation.  Your indexers are subtracting out the lower
bounds from the indexes on each call (optimizing out the first few 0 lower
bound cases), but you can just subtract that out from the base offset in
advance, whether or not the value is 0.

--
Alex