Replies: 11 comments 13 replies
-
Heavy use of Static.jl was cited as one of the reasons for LoopVectorization.jl's bad compile times. Given that latency is perhaps the number one problem with Julia, I do think people should be wary of investing too much in this approach, as they're likely to suffer consequences when they take it far. |
Beta Was this translation helpful? Give feedback.
-
@chriselrod it's important to avoid problems like this, but this approach sounds a little like reinventing the wheel. Since it comes up so often, wouldn't it be better to have a reusable solution, so we don't have to solve each instance independently? I might well be misunderstanding, since I haven't seen details of the replacement you're working on. |
Beta Was this translation helpful? Give feedback.
-
If the replacement completely removes the need to encode the size at the type level for something like |
Beta Was this translation helpful? Give feedback.
-
Sorry, to be clear, it's a replacement for LoopVectorization. |
Beta Was this translation helpful? Give feedback.
-
The replacement is to rewrite in c++ IIUC, right? Presumably we'd like to have whatever it is that makes C++ more amenable to this, In Julia |
Beta Was this translation helpful? Give feedback.
-
If it's decided this shouldn't be in base I'm hoping to get an idea of where the rest of the community should be going with things like traits and corresponding optimizations. Compiler work is super important but I'm worried about requiring any similar additions in the future to be through the compiler. Perhaps this will change, but that sort of coding seems like it requires a lot of extra knowledge to do right. |
Beta Was this translation helpful? Give feedback.
-
This is also important for things like #43642 and related compiler optimizations. @Tokazama What about named dimensions or ragged arrays? xref discussion here https://discourse.julialang.org/t/is-my-understanding-of-julia-correct/76924/33 |
Beta Was this translation helpful? Give feedback.
-
I'm sure there are other collections than dense arrays that could be optimized for some operations and it would be a shame if that could only ever happen in the compiler. If we don't need to worry about static values then it would be great to have named dimensions just be a I'm not saying that using |
Beta Was this translation helpful? Give feedback.
-
Agreed. I highly recommend you check out https://youtu.be/npDCCVIaSVQ to see how a from scratch re-design of array typing solves these issues. I wonder how much we can adapt from that into julia. There are also the issues of making these arrays play nicely with GPU and AD (and as a bonus, shape checking) , which Dex's type system takes into account |
Beta Was this translation helpful? Give feedback.
-
It's a tough call. But I guess I fall into the camp of thinking that since it's not yet been made unnecessary by compiler optimizations, it seems to be asking for trouble to trust that it will (soon) be. For that reason, I'd suggest we submit this to Base, and give people until a month or so before the 1.9 feature freeze to implement compiler optimizations that make it unnecessary. If that doesn't happen, then I say we merge it (along with other traits that have been found generically useful). |
Beta Was this translation helpful? Give feedback.
-
I don't think that specifically could happen, since the compiler cannot switch a
So I would like to understand better what is needed from the compiler. |
Beta Was this translation helpful? Give feedback.
-
Would
struct StaticInt{N::Int} <: Integer end
be a welcome addition here? Most of what it would involve is found here.It's helpful to have it specifically be a subtype of
Integer
so that it can provide optionally static ranges without the user having to worry about explicitly propagating static information from something likeSArray
or making thedim
argument of something likef(A, dim)
type stable. There are also times it can reduce the number of unique types generated for trait systems. For examplecontiguous_axis
returns aStaticInt
instead ofContiguousAxis{N}
. The benefit of having it in base would be better native support, integration, and propagation of types/traits that useStaticInt
I understand there may be some concern that this overextends the intended use of the type system, and instead the focus should be better constant propagation on the compiler side of things so that something like
SArray
doesn't need this. I'm not sure if the other use cases are also better handled by some future compiler wizardry but I thought I'd at least put it forward.EDIT:
If we ultimately don't go forward with this because the utility of
StaticInt
will be replaced with more appropriate compiler optimizations, it would be nice to have some clarity on how that will effect code development moving forward. For example,Base.OneTo
indexing another array is explicitly written to only check the upper bound is in bounds.StaticArrays.SOneTo
does everything in the type domain so nothing is done at run time.ArrayInterface.OptionallyStaticUnitRange
usesInt
orStaticInt
to potentially allow either of those optimizations. Will optimizations to the compiler allow the same benefits without using type information. In other words, will the compiler turn this line into this line? If that's not an anticipated benefit of compiler work then how do we appropriately approach problems like these without abusing the type system?@chriselrod is familiar with the
StaticInt
implementation inStatic.jl
and may have more to add to the discussion.I think @timholy at one point expressed some support for this being in base.
@Keno probably has an opinion on whether this will eventually not be useful to maintain in base given more internal development.
Beta Was this translation helpful? Give feedback.
All reactions