MasonProtter / Bumper.jl

Bring Your Own Stack
MIT License
152 stars 6 forks source link

Zero-dimensional arrays: #41

Closed Jutho closed 3 weeks ago

Jutho commented 3 weeks ago

It seems Bumper.jl cannot allocate zero-dimensional arrays. There might not be much use for that in itself (as they only contain a single element, they are small), but in a general framework where some arrays may happen to be zero-dimensional, this is somewhat annoying:

julia> @no_escape begin
           a = @alloc(Float64, ())
       end
ERROR: MethodError: no method matching alloc!(::SlabBuffer{1048576}, ::Type{Float64}, ::Tuple{})

Closest candidates are:
  alloc!(::Any, ::Type{T}, ::Integer...) where {T, N}
   @ Bumper ~/.julia/packages/Bumper/eoK0g/src/internals.jl:89

Stacktrace:
 [1] macro expansion
   @ REPL[3]:2 [inlined]
 [2] macro expansion
   @ ~/.julia/packages/Bumper/eoK0g/src/internals.jl:74 [inlined]
 [3] top-level scope
   @ REPL[3]:1

julia> @no_escape begin
           a = @alloc(Float64)
       end
ERROR: MethodError: no method matching eachop(::typeof(Static._get_known), ::Tuple{}, ::Type{Tuple{}})

Closest candidates are:
  eachop(::F, ::Tuple{I}, ::Any...) where {F, I, K}
   @ Static ~/.julia/packages/Static/pkxBE/src/tuples.jl:31
  eachop(::F, ::Tuple{I1, I2, Vararg}, ::Any...) where {F, I1, I2, K}
   @ Static ~/.julia/packages/Static/pkxBE/src/tuples.jl:28

Stacktrace:
 [1] known(::Type{Tuple{}})
   @ Static ~/.julia/packages/Static/pkxBE/src/Static.jl:44
 [2] #s25#5
   @ ~/.julia/packages/StrideArraysCore/fDiB0/src/ptr_array.jl:179 [inlined]
 [3] var"#s25#5"(T::Any, N::Any, ::Any, ptr::Any, s::Any)
   @ StrideArraysCore ./none:0
 [4] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
   @ Core ./boot.jl:602
 [5] alloc!(::SlabBuffer{1048576}, ::Type{Float64})
   @ Bumper.Internals ~/.julia/packages/Bumper/eoK0g/src/internals.jl:91
 [6] macro expansion
   @ REPL[4]:2 [inlined]
 [7] macro expansion
   @ ~/.julia/packages/Bumper/eoK0g/src/internals.jl:74 [inlined]
 [8] top-level scope
   @ REPL[4]:1
Jutho commented 3 weeks ago

Inspecting the error messages, this should probably have been a StrideArraysCore.jl issue.

Jutho commented 3 weeks ago

Ok, it seems I had an older version of StrideArraysCore, but now there is another issue with strides of a zero-dimensional PtrArray not being defined. I will take this over to StrideArraysCore and close this.