On Apr 26, 10:20 am, Toivo Henningsson <
toivo....@gmail.com> wrote:
> On Apr 26, 11:03 am, Stefan Karpinski <
ste...@karpinski.org> wrote:
>
> > If this kind of kernel requires immutable arrays, I would generally
> > recommend not mutating your arrays while performing such magic :-)
>
> Definitely. And you don't: there's no other operations intervening
> while X = @kernel A.*B + C is executed.
>
> What I'm talking about is a case like when you create some data in an
> array, and then pass it around to accumulate delayed evaluation steps
> in various parts of the code.
> You might call it dynamically delayed evaluation since the system
> creates kernels depending on the history of your data objects,
> as opposed statically delayed evaluation like X = @kernel A.*B + C
> where the programmer delimits the maximum delay explicitly.
One other potential reason for having immutability would be
parallelisation: if you know an array is immutable then, once it's
been created, you can duplicate it on participating NUMA node/machines
safely.
> I know there's a bit of a divide between those who want to do
> dynamically delayed evaluation, and those who prefer statically
> delayed evalutation since it's simpler and more explicit.
> I personally like the static case, and I feel that it's best to start
> with simple things first.
> But I still think that having an immutable array type integrated into
> Julia might make a big difference performance-wise at some point in
> the future, so I wanted to ask the question now.
FWIW, my interest falls into a third class. The kind of optimisation
I'd like to do is "statically compiling" a function into a version
which is faster, but with the expectation that the typical programmer
will use a wide array of constructs which won't have delayed-evalution
implementations (from the sheer volume of work).
The particular use case I care about is that lots of the time in an
IDE with a language like Matlab, it's common to end up repeatedly
selecting the same block of code and evaluating it (with the inputs
having been changed in-between). It always annoys me when after the
tenth time it's still taking 5 seconds when it could be being run in
1s if the system would just do some analysis. In this case you want
the minimum anotation of the source. Since Julia encourages small
functions, the function level seems like a basic-unit to imlement this
at.