SciML / SciML/RecursiveArrayTools.jl
Multi-threading `VectorOfArray` of `SVector`s is broken on RecursiveArrayTools.jl version 4
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 233
- Forks
- 76
- Avg merge
- 2h 17m
- Merged PRs (30d)
- 9
Description
Describe the bug 🐞
julia> import Pkg; Pkg.activate(temp = true); Pkg.add(["FastBroadcast", "Polyester", "RecursiveArrayTools", "StaticArrays"])
Activating new project
Resolving package versions...
Updating
[7034ab61] + FastBroadcast v1.3.1
[f517fe37] + Polyester v0.7.19
[731186ca] + RecursiveArrayTools v4.0.1
[90137ffa] + StaticArrays v1.9.18
Updating
[7d9f7c33] + Accessors v0.1.44
[79e6a3ab] + Adapt v4.5.0
[4fba245c] + ArrayInterface v7.23.0
[62783981] + BitTwiddlingConvenienceFunctions v0.1.6
[2a0fbf3d] + CPUSummary v0.2.7
[fb6a15b2] + CloseOpenIntervals v0.1.13
[f70d9fcc] + CommonWorldInvalidations v1.0.0
[34da2185] + Compat v4.18.1
[a33af91c] + CompositionsBase v0.1.2
[187b0558] + ConstructionBase v1.6.0
[adafc99b] + CpuId v0.3.1
[ffbed154] + DocStringExtensions v0.9.5
[e2ba6199] + ExprTools v0.1.10
[7034ab61] + FastBroadcast v1.3.1
[46192b85] + GPUArraysCore v0.2.0
[615f187c] + IfElse v0.1.1
[3587e190] + InverseFunctions v0.1.17
[10f19ff3] + LayoutPointers v0.1.17
[1914dd2f] + MacroTools v0.5.16
[d125e4d3] + ManualMemory v0.1.8
[f517fe37] + Polyester v0.7.19
[1d0040c9] + PolyesterWeave v0.2.2
⌅ [aea7be01] + PrecompileTools v1.2.1
[21216c6a] + Preferences v1.5.2
[3cdcf5f2] + RecipesBase v1.3.4
[731186ca] + RecursiveArrayTools v4.0.1
[ae029012] + Requires v1.3.1
[7e49a35a] + RuntimeGeneratedFunctions v0.5.17
[94e857df] + SIMDTypes v0.1.0
[431bcebd] + SciMLPublic v1.0.1
[aedffcd0] + Static v1.3.1
[0d7ed370] + StaticArrayInterface v1.9.0
[90137ffa] + StaticArrays v1.9.18
[1e83bf80] + StaticArraysCore v1.4.4
[7792a7ef] + StrideArraysCore v0.5.8
[2efcf032] + SymbolicIndexingInterface v0.3.46
[8290d209] + ThreadingUtilities v0.5.5
[56f22d72] + Artifacts
[2a0f44e3] + Base64
[ade2ca70] + Dates
[8f399da3] + Libdl
[37e2e46d] + LinearAlgebra
[d6f4376e] + Markdown
[de0858da] + Printf
[9a3f8284] + Random
[ea8e919c] + SHA v0.7.0
[9e88b42a] + Serialization
[fa267f1f] + TOML v1.0.3
[cf7118a7] + UUIDs
[4ec0a83e] + Unicode
[e66e0078] + CompilerSupportLibraries_jll v1.1.1+0
[4536629a] + OpenBLAS_jll v0.3.23+5
[8e850b90] + libblastrampoline_jll v5.11.0+0
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`
julia> using FastBroadcast, Polyester, RecursiveArrayTools, StaticArrays
julia> u = VectorOfArray(fill(SVector(1.0, 1.0), 2, 2))
VectorOfArray{Float64,2}:
2×2 Matrix{SVector{2, Float64}}:
[1.0, 1.0] [1.0, 1.0]
[1.0, 1.0] [1.0, 1.0]
julia> v = copy(u)
VectorOfArray{Float64,2}:
2×2 Matrix{SVector{2, Float64}}:
[1.0, 1.0] [1.0, 1.0]
[1.0, 1.0] [1.0, 1.0]
julia> @.. thread=true v = v + u
ERROR: setindex!(::SVector{2, Float64}, value, ::Int) is not defined.
Hint: Use `MArray` or `SizedArray` to create a mutable static array
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] setindex!(a::SVector{2, Float64}, value::Float64, i::Int64)
@ StaticArrays ~/.julia/packages/StaticArrays/0cEwi/src/indexing.jl:3
[3] setindex!
@ ~/.julia/packages/RecursiveArrayTools/0peF1/src/vector_of_array.jl:904 [inlined]
[4] setindex!
@ ./subarray.jl:331 [inlined]
[5] _setindex!
@ ./abstractarray.jl:1425 [inlined]
[6] setindex!
@ ./abstractarray.jl:1395 [inlined]
[7] __fast_materialize!
@ ~/.julia/packages/FastBroadcast/WRPAc/src/FastBroadcast.jl:152 [inlined]
[8] _fast_materialize!
@ ~/.julia/packages/FastBroadcast/WRPAc/src/FastBroadcast.jl:164 [inlined]
[9] fast_materialize!
@ ~/.julia/packages/FastBroadcast/WRPAc/src/FastBroadcast.jl:191 [inlined]
[10] _batch_broadcast_fn
@ ~/.julia/packages/FastBroadcast/WRPAc/ext/FastBroadcastPolyesterExt.jl:10 [inlined]
[11] macro expansion
@ ~/.julia/packages/Polyester/GQ6c9/src/batch.jl:246 [inlined]
[12] _batch_no_reserve
@ ~/.julia/packages/Polyester/GQ6c9/src/batch.jl:168 [inlined]
[13] batch
@ ~/.julia/packages/Polyester/GQ6c9/src/batch.jl:335 [inlined]
[14] batch
@ ~/.julia/packages/Polyester/GQ6c9/src/batch.jl:286 [inlined]
[15] fast_materialize_threaded!(dst::VectorOfArray{…}, bc::Base.Broadcast.Broadcasted{…})
@ FastBroadcastPolyesterExt ~/.julia/packages/FastBroadcast/WRPAc/ext/FastBroadcastPolyesterExt.jl:32
[16] fast_materialize!(::Threaded, dst::VectorOfArray{…}, bc::Base.Broadcast.Broadcasted{…})
@ FastBroadcast ~/.julia/packages/FastBroadcast/WRPAc/src/FastBroadcast.jl:216
[17] top-level scope
@ REPL[5]:1
Some type information was truncated. Use `show(err)` to see complete types.
julia> Threads.nthreads()
2
Expected behavior
As in version v3.54.0 of RecursiveArrayTools.jl, the output is
julia> @.. thread=true v = v + u
VectorOfArray{Float64,2}:
2×2 Matrix{SVector{2, Float64}}:
[2.0, 2.0] [2.0, 2.0]
[2.0, 2.0] [2.0, 2.0]
Minimal Reproducible Example 👇
See above
Error & Stacktrace ⚠️
See above
Environment (please complete the following information):
See above
Additional context
Successor of #564. Does RecursiveArrayTools.jl use multiple threads in CI to test the new extensions properly?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example with RecursiveArrayTools v4.0.1 and inspect vector_of_array.jl around line 904, where the stack trace reaches setindex!. Compare the behavior with RecursiveArrayTools v3.54.0, and review the FastBroadcastPolyesterExt and Polyester batch frames. Done means the threaded broadcast over VectorOfArray of SVector values produces the expected doubled values without an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100