SciML / DiffEqGPU.jl

GPU-acceleration routines for DifferentialEquations.jl and the broader SciML scientific machine learning ecosystem
https://docs.sciml.ai/DiffEqGPU/stable/
MIT License
283 stars 29 forks source link

Segfault when using ModelingToolkit #56

Closed ArnoStrouwen closed 4 years ago

ArnoStrouwen commented 4 years ago

Is MTK compatible with DiffEqGPU?

using ModelingToolkit
using OrdinaryDiffEq
using DiffEqGPU

@parameters t σ ρ β
@variables x(t) y(t) z(t)
@derivatives D'~t

eqs = [D(x) ~ σ*(y-x),
       D(y) ~ x*(ρ-z)-y,
       D(z) ~ x*y - β*z]

sys = ODESystem(eqs)

u0 = [x => 1.0f0
      y => 0.0f0
      z => 0.0f0]

p  = [σ => 10.0f0
      ρ => 28.0f0
      β => 8f0/3f0]
tspan = (0.0f0,100.0f0)
prob = ODEProblem(sys,u0,tspan,p)
prob_func = (prob,i,repeat) -> remake(prob,p=rand(Float32,3).*prob.p)
monteprob = EnsembleProblem(prob, prob_func = prob_func)
sol = solve(monteprob,Tsit5(),EnsembleGPUArray(),trajectories=10,saveat=1.0f0)
ChrisRackauckas commented 4 years ago

Interesting. That worked for me. What version of the packages?

ArnoStrouwen commented 4 years ago

From a fresh install

(base) arno@Workstation:~$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.2 (2020-05-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.4) pkg> add ModelingToolkit
    Cloning default registries into `~/.julia`
    Cloning registry from "https://github.com/JuliaRegistries/General.git"
      Added registry `General` to `~/.julia/registries/General`
  Resolving package versions...
  Installed SafeTestsets ───────────────── v0.0.1
  Installed OpenSpecFun_jll ────────────── v0.5.3+3
  Installed UnPack ─────────────────────── v1.0.1
  Installed TableTraits ────────────────── v1.0.0
  Installed CpuId ──────────────────────── v0.2.2
  Installed ArnoldiMethod ──────────────── v0.0.4
  Installed DiffEqJump ─────────────────── v6.7.6
  Installed ModelingToolkit ────────────── v3.7.0
  Installed RecursiveFactorization ─────── v0.1.2
  Installed CanonicalTraits ────────────── v0.2.1
  Installed JuliaVariables ─────────────── v0.2.0
  Installed VectorizationBase ──────────── v0.12.6
  Installed Combinatorics ──────────────── v1.0.2
  Installed TreeViews ──────────────────── v0.3.0
  Installed IterativeSolvers ───────────── v0.8.4
  Installed RandomNumbers ──────────────── v1.4.0
  Installed PrettyPrint ────────────────── v0.1.0
  Installed LeftChildRightSiblingTrees ─── v0.1.2
  Installed FunctionWrappers ───────────── v1.1.1
  Installed DataStructures ─────────────── v0.17.17
  Installed ArrayInterface ─────────────── v2.8.7
  Installed ProgressLogging ────────────── v0.1.2
  Installed ProgressMeter ──────────────── v1.3.0
  Installed MLStyle ────────────────────── v0.3.1
  Installed LoggingExtras ──────────────── v0.4.1
  Installed SIMDPirates ────────────────── v0.8.5
  Installed IteratorInterfaceExtensions ── v1.0.0
  Installed LabelledArrays ─────────────── v1.2.1
  Installed TimerOutputs ───────────────── v0.5.5
  Installed AbstractTrees ──────────────── v0.3.3
  Installed Unitful ────────────────────── v1.2.1
  Installed MacroTools ─────────────────── v0.5.5
  Installed OrderedCollections ─────────── v1.2.0
  Installed ChainRulesCore ─────────────── v0.8.0
  Installed Latexify ───────────────────── v0.13.2
  Installed GeneralizedGenerated ───────── v0.2.4
  Installed TerminalLoggers ────────────── v0.1.1
  Installed NameResolution ─────────────── v0.1.3
  Installed LightGraphs ────────────────── v1.3.3
  Installed StaticArrays ───────────────── v0.12.3
  Installed Inflate ────────────────────── v0.1.2
  Installed DiffEqBase ─────────────────── v6.36.3
  Installed OffsetArrays ───────────────── v1.0.4
  Installed SimpleTraits ───────────────── v0.9.2
  Installed CompilerSupportLibraries_jll ─ v0.3.3+0
  Installed NaNMath ────────────────────── v0.3.3
  Installed DiffRules ──────────────────── v1.0.1
  Installed LaTeXStrings ───────────────── v1.1.0
  Installed ConstructionBase ───────────── v1.0.0
  Installed Parameters ─────────────────── v0.12.1
  Installed ConsoleProgressMonitor ─────── v0.1.2
  Installed ZygoteRules ────────────────── v0.2.0
  Installed LoopVectorization ──────────── v0.8.2
  Installed PoissonRandom ──────────────── v0.4.0
  Installed Compat ─────────────────────── v3.10.0
  Installed Roots ──────────────────────── v1.0.1
  Installed DocStringExtensions ────────── v0.8.1
  Installed SymbolicUtils ──────────────── v0.3.2
  Installed SpecialFunctions ───────────── v0.10.3
  Installed RecursiveArrayTools ────────── v2.3.5
  Installed SLEEFPirates ───────────────── v0.5.0
  Installed Formatting ─────────────────── v0.4.1
  Installed Requires ───────────────────── v1.0.1
  Installed MuladdMacro ────────────────── v0.2.2
  Installed RecipesBase ────────────────── v1.0.1
Downloading artifact: OpenSpecFun
######################################################################## 100,0%##O=#  #                              Downloading artifact: CompilerSupportLibraries
######################################################################## 100,0%##O=#  #                                 Updating `~/.julia/environments/v1.4/Project.toml`
  [961ee093] + ModelingToolkit v3.7.0
   Updating `~/.julia/environments/v1.4/Manifest.toml`
  [1520ce14] + AbstractTrees v0.3.3
  [ec485272] + ArnoldiMethod v0.0.4
  [4fba245c] + ArrayInterface v2.8.7
  [a603d957] + CanonicalTraits v0.2.1
  [d360d2e6] + ChainRulesCore v0.8.0
  [861a8166] + Combinatorics v1.0.2
  [34da2185] + Compat v3.10.0
  [e66e0078] + CompilerSupportLibraries_jll v0.3.3+0
  [88cd18e8] + ConsoleProgressMonitor v0.1.2
  [187b0558] + ConstructionBase v1.0.0
  [adafc99b] + CpuId v0.2.2
  [864edb3b] + DataStructures v0.17.17
  [2b5f629d] + DiffEqBase v6.36.3
  [c894b116] + DiffEqJump v6.7.6
  [b552c78f] + DiffRules v1.0.1
  [ffbed154] + DocStringExtensions v0.8.1
  [59287772] + Formatting v0.4.1
  [069b7b12] + FunctionWrappers v1.1.1
  [6b9d7cbe] + GeneralizedGenerated v0.2.4
  [d25df0c9] + Inflate v0.1.2
  [42fd0dbc] + IterativeSolvers v0.8.4
  [82899510] + IteratorInterfaceExtensions v1.0.0
  [b14d175d] + JuliaVariables v0.2.0
  [b964fa9f] + LaTeXStrings v1.1.0
  [2ee39098] + LabelledArrays v1.2.1
  [23fbe1c1] + Latexify v0.13.2
  [1d6d02ad] + LeftChildRightSiblingTrees v0.1.2
  [093fc24a] + LightGraphs v1.3.3
  [e6f89c97] + LoggingExtras v0.4.1
  [bdcacae8] + LoopVectorization v0.8.2
  [d8e11817] + MLStyle v0.3.1
  [1914dd2f] + MacroTools v0.5.5
  [961ee093] + ModelingToolkit v3.7.0
  [46d2c3a1] + MuladdMacro v0.2.2
  [77ba4419] + NaNMath v0.3.3
  [71a1bf82] + NameResolution v0.1.3
  [6fe1bfb0] + OffsetArrays v1.0.4
  [efe28fd5] + OpenSpecFun_jll v0.5.3+3
  [bac558e1] + OrderedCollections v1.2.0
  [d96e819e] + Parameters v0.12.1
  [e409e4f3] + PoissonRandom v0.4.0
  [8162dcfd] + PrettyPrint v0.1.0
  [33c8b6b6] + ProgressLogging v0.1.2
  [92933f4c] + ProgressMeter v1.3.0
  [e6cf234a] + RandomNumbers v1.4.0
  [3cdcf5f2] + RecipesBase v1.0.1
  [731186ca] + RecursiveArrayTools v2.3.5
  [f2c3362d] + RecursiveFactorization v0.1.2
  [ae029012] + Requires v1.0.1
  [f2b01f46] + Roots v1.0.1
  [21efa798] + SIMDPirates v0.8.5
  [476501e8] + SLEEFPirates v0.5.0
  [1bc83da4] + SafeTestsets v0.0.1
  [699a6c99] + SimpleTraits v0.9.2
  [276daf66] + SpecialFunctions v0.10.3
  [90137ffa] + StaticArrays v0.12.3
  [d1185830] + SymbolicUtils v0.3.2
  [3783bdb8] + TableTraits v1.0.0
  [5d786b92] + TerminalLoggers v0.1.1
  [a759f4b9] + TimerOutputs v0.5.5
  [a2a6695c] + TreeViews v0.3.0
  [3a884ed6] + UnPack v1.0.1
  [1986cc42] + Unitful v1.2.1
  [3d5dd08c] + VectorizationBase v0.12.6
  [700de1a5] + ZygoteRules v0.2.0
  [2a0f44e3] + Base64 
  [ade2ca70] + Dates 
  [8bb1440f] + DelimitedFiles 
  [8ba89e20] + Distributed 
  [b77e0a4c] + InteractiveUtils 
  [76f85450] + LibGit2 
  [8f399da3] + Libdl 
  [37e2e46d] + LinearAlgebra 
  [56ddb016] + Logging 
  [d6f4376e] + Markdown 
  [a63ad114] + Mmap 
  [44cfe95a] + Pkg 
  [de0858da] + Printf 
  [3fa0cd96] + REPL 
  [9a3f8284] + Random 
  [ea8e919c] + SHA 
  [9e88b42a] + Serialization 
  [1a1011a3] + SharedArrays 
  [6462fe0b] + Sockets 
  [2f01184e] + SparseArrays 
  [10745b16] + Statistics 
  [4607b0f0] + SuiteSparse 
  [8dfed614] + Test 
  [cf7118a7] + UUIDs 
  [4ec0a83e] + Unicode 
   Building VectorizationBase → `~/.julia/packages/VectorizationBase/SyqTC/deps/build.log`
   Building SLEEFPirates ─────→ `~/.julia/packages/SLEEFPirates/mkNmA/deps/build.log`

(@v1.4) pkg> add OrdinaryDiffEq
  Resolving package versions...
  Installed Adapt ──────────────── v1.1.0
  Installed DiffResults ────────── v1.0.2
  Installed ExponentialUtilities ─ v1.6.0
  Installed NLSolversBase ──────── v7.6.1
  Installed NLsolve ────────────── v4.3.0
  Installed ForwardDiff ────────── v0.10.10
  Installed SparseDiffTools ────── v1.8.0
  Installed OrdinaryDiffEq ─────── v5.39.1
  Installed LineSearches ───────── v7.0.1
  Installed VertexSafeGraphs ───── v0.1.2
  Installed GenericSVD ─────────── v0.3.0
  Installed Reexport ───────────── v0.2.0
  Installed FiniteDiff ─────────── v2.3.2
  Installed Distances ──────────── v0.8.2
  Installed CommonSubexpressions ─ v0.2.0
   Updating `~/.julia/environments/v1.4/Project.toml`
  [1dea7af3] + OrdinaryDiffEq v5.39.1
   Updating `~/.julia/environments/v1.4/Manifest.toml`
  [79e6a3ab] + Adapt v1.1.0
  [bbf7d656] + CommonSubexpressions v0.2.0
  [163ba53b] + DiffResults v1.0.2
  [b4f34e82] + Distances v0.8.2
  [d4d017d3] + ExponentialUtilities v1.6.0
  [6a86dc24] + FiniteDiff v2.3.2
  [f6369f11] + ForwardDiff v0.10.10
  [01680d73] + GenericSVD v0.3.0
  [d3d80556] + LineSearches v7.0.1
  [d41bc354] + NLSolversBase v7.6.1
  [2774e3e8] + NLsolve v4.3.0
  [1dea7af3] + OrdinaryDiffEq v5.39.1
  [189a3867] + Reexport v0.2.0
  [47a9eef4] + SparseDiffTools v1.8.0
  [19fa3120] + VertexSafeGraphs v0.1.2

(@v1.4) pkg> add DiffEqGPU
  Resolving package versions...
  Installed CUDAapi ──────── v4.0.0
  Installed DiffEqGPU ────── v1.3.0
  Installed ExprTools ────── v0.1.1
  Installed GPUifyLoops ──── v0.2.9
  Installed BinaryProvider ─ v0.5.10
  Installed GPUCompiler ──── v0.2.0
  Installed CUDAdrv ──────── v6.3.0
  Installed Cassette ─────── v0.3.3
  Installed CEnum ────────── v0.3.0
  Installed CodeTracking ─── v0.5.11
  Installed Cthulhu ──────── v1.1.1
  Installed NNlib ────────── v0.6.6
  Installed LLVM ─────────── v1.5.1
  Installed AbstractFFTs ─── v0.5.0
  Installed CuArrays ─────── v2.2.0
  Installed CUDAnative ───── v3.1.0
  Installed GPUArrays ────── v3.4.1
   Updating `~/.julia/environments/v1.4/Project.toml`
  [071ae1c0] + DiffEqGPU v1.3.0
   Updating `~/.julia/environments/v1.4/Manifest.toml`
  [621f4979] + AbstractFFTs v0.5.0
  [b99e7846] + BinaryProvider v0.5.10
  [fa961155] + CEnum v0.3.0
  [3895d2a7] + CUDAapi v4.0.0
  [c5f51814] + CUDAdrv v6.3.0
  [be33ccc6] + CUDAnative v3.1.0
  [7057c7e9] + Cassette v0.3.3
  [da1fd8a2] + CodeTracking v0.5.11
  [f68482b8] + Cthulhu v1.1.1
  [3a865a2d] + CuArrays v2.2.0
  [071ae1c0] + DiffEqGPU v1.3.0
  [e2ba6199] + ExprTools v0.1.1
  [0c68f7d7] + GPUArrays v3.4.1
  [61eb1bfa] + GPUCompiler v0.2.0
  [ba82f77b] + GPUifyLoops v0.2.9
  [929cbde3] + LLVM v1.5.1
  [872c559c] + NNlib v0.6.6
   Building NNlib → `~/.julia/packages/NNlib/FAI3o/deps/build.log`

(@v1.4) pkg> status
Status `~/.julia/environments/v1.4/Project.toml`
  [071ae1c0] DiffEqGPU v1.3.0
  [961ee093] ModelingToolkit v3.7.0
  [1dea7af3] OrdinaryDiffEq v5.39.1

julia> using ModelingToolkit
[ Info: Precompiling ModelingToolkit [961ee093-0014-501f-94e3-6117800e7a78]

julia> using OrdinaryDiffEq
[ Info: Precompiling OrdinaryDiffEq [1dea7af3-3e70-54e6-95c3-0bf5283fa5ed]

julia> using DiffEqGPU
[ Info: Precompiling DiffEqGPU [071ae1c0-96b5-11e9-1965-c90190d839ea]

julia> @parameters t σ ρ β
(t, σ, ρ, β)

julia> @variables x(t) y(t) z(t)
(x(t), y(t), z(t))

julia> @derivatives D'~t
((D'~t),)

julia> eqs = [D(x) ~ σ*(y-x),
              D(y) ~ x*(ρ-z)-y,
              D(z) ~ x*y - β*z]
3-element Array{Equation,1}:
 Equation(derivative(x(t), t), σ * (y(t) - x(t)))
 Equation(derivative(y(t), t), x(t) * (ρ - z(t)) - y(t))
 Equation(derivative(z(t), t), x(t) * y(t) - β * z(t))

julia> sys = ODESystem(eqs)
ODESystem(Equation[Equation(derivative(x(t), t), σ * (y(t) - x(t))), Equation(derivative(y(t), t), x(t) * (ρ - z(t)) - y(t)), Equation(derivative(z(t), t), x(t) * y(t) - β * z(t))], t, Variable[x, y, z], Variable[ρ, σ, β], Base.RefValue{Array{Expression,1}}(Expression[]), Base.RefValue{Array{Expression,2}}(Array{Expression}(undef,0,0)), Base.RefValue{Array{Expression,2}}(Array{Expression}(undef,0,0)), Base.RefValue{Array{Expression,2}}(Array{Expression}(undef,0,0)), Symbol("##ODESystem#347"), ODESystem[])

julia> u0 = [x => 1.0f0
             y => 0.0f0
             z => 0.0f0]
3-element Array{Pair{Operation,Float32},1}:
 x(t) => 1.0
 y(t) => 0.0
 z(t) => 0.0

julia> p  = [σ => 10.0f0
             ρ => 28.0f0
             β => 8f0/3f0]
3-element Array{Pair{Operation,Float32},1}:
 σ => 10.0
 ρ => 28.0
 β => 2.6666667

julia> tspan = (0.0f0,100.0f0)
(0.0f0, 100.0f0)

julia> prob = ODEProblem(sys,u0,tspan,p)
ODEProblem with uType Array{Float32,1} and tType Float32. In-place: true
timespan: (0.0f0, 100.0f0)
u0: Float32[1.0, 0.0, 0.0]

julia> prob_func = (prob,i,repeat) -> remake(prob,p=rand(Float32,3).*prob.p)
#3 (generic function with 1 method)

julia> monteprob = EnsembleProblem(prob, prob_func = prob_func)
EnsembleProblem with problem ODEProblem

julia> sol = solve(monteprob,Tsit5(),EnsembleGPUArray(),trajectories=10,saveat=1.0f0)
Downloading artifact: CUDA10.2
######################################################################## 100,0%##O=#  #                              
signal (11): Segmentation fault
in expression starting at REPL[20]:1
unknown function (ip: 0x7f0a44ccb1d7)
unknown function (ip: 0x415434796e413348)
Allocations: 195774690 (Pool: 195714028; Big: 60662); GC: 165
Segmentation fault (core dumped)
(base) arno@Workstation:~$ julia
(base) arno@Workstation:~$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.2 (2020-05-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using OrdinaryDiffEq

julia> using DiffEqGPU

julia> function lorenz(du,u,p,t)
        @inbounds begin
            du[1] = p[1]*(u[2]-u[1])
            du[2] = u[1]*(p[2]-u[3]) - u[2]
            du[3] = u[1]*u[2] - p[3]*u[3]
        end
        nothing
       end
lorenz (generic function with 1 method)

julia> u0 = Float32[1.0;0.0;0.0]
3-element Array{Float32,1}:
 1.0
 0.0
 0.0

julia> tspan = (0.0f0,100.0f0)
(0.0f0, 100.0f0)

julia> p = (10.0f0,28.0f0,8/3f0)
(10.0f0, 28.0f0, 2.6666667f0)

julia> prob = ODEProblem(lorenz,u0,tspan,p)
ODEProblem with uType Array{Float32,1} and tType Float32. In-place: true
timespan: (0.0f0, 100.0f0)
u0: Float32[1.0, 0.0, 0.0]

julia> prob_func = (prob,i,repeat) -> remake(prob,p=rand(Float32,3).*prob.p)
#3 (generic function with 1 method)

julia> monteprob = EnsembleProblem(prob, prob_func = prob_func)
EnsembleProblem with problem ODEProblem

julia> sol = solve(monteprob,Tsit5(),EnsembleGPUArray(),trajectories=10_000,saveat=1.0f0)
EnsembleSolution Solution of length 10000 with uType:
ODESolution{Float32,2,Array{SubArray{Float32,1,Array{Float32,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true},1},Nothing,Nothing,Array{Float32,1},Nothing,ODEProblem{Array{Float32,1},Tuple{Float32,Float32},true,Array{Float32,1},ODEFunction{true,typeof(lorenz),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,DiffEqBase.LinearInterpolation{Array{Float32,1},Array{SubArray{Float32,1,Array{Float32,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true},1}},DiffEqBase.DEStats}

julia> 
ArnoStrouwen commented 4 years ago

Here is also a larger example that caused me to make the above MWE. The error is different though: ERROR: LLVM error: Symbol name with unsupported characters https://gist.github.com/ArnoStrouwen/fab46e3ec6dc7972761aa36dcbda6354 (running this script is very dependent on the version of MTK, as remake and callback parameter indexes are hardcoded due to MTK limitations)

ChrisRackauckas commented 4 years ago

(@v1.4) pkg> activate Tester
 Activating environment at `D:\OneDrive\Computer\Desktop\Tester\Project.toml`

(Tester) pkg> add ModelingToolkit OrdinaryDiffEq DiffEqGPU
   Updating registry at `C:\Users\accou\.julia\registries\General`
   Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Resolving package versions...
  Installed GeneralizedGenerated ─ v0.2.4
  Installed DiffEqJump ─────────── v6.7.6
  Installed ModelingToolkit ────── v3.7.0
   Updating `D:\OneDrive\Computer\Desktop\Tester\Project.toml`
  [071ae1c0] + DiffEqGPU v1.3.0
  [961ee093] + ModelingToolkit v3.7.0
  [1dea7af3] + OrdinaryDiffEq v5.35.1
   Updating `D:\OneDrive\Computer\Desktop\Tester\Manifest.toml`
  [a603d957] + CanonicalTraits v0.2.1
  [7057c7e9] + Cassette v0.3.3
  [861a8166] + Combinatorics v1.0.2
  [187b0558] + ConstructionBase v1.0.0
  [071ae1c0] + DiffEqGPU v1.3.0
  [c894b116] + DiffEqJump v6.7.6
  [ba82f77b] + GPUifyLoops v0.2.9
  [6b9d7cbe] + GeneralizedGenerated v0.2.4
  [b14d175d] + JuliaVariables v0.2.0
  [d8e11817] + MLStyle v0.3.1
  [961ee093] + ModelingToolkit v3.7.0
  [71a1bf82] + NameResolution v0.1.3
  [e409e4f3] + PoissonRandom v0.4.0
  [8162dcfd] + PrettyPrint v0.1.0
  [e6cf234a] + RandomNumbers v1.4.0
  [1bc83da4] + SafeTestsets v0.0.1
  [d1185830] + SymbolicUtils v0.3.2
  [1986cc42] + Unitful v1.2.1

julia> using ModelingToolkit

julia> 

julia> using OrdinaryDiffEq

julia> 

julia> using DiffEqGPU

julia> 

julia> 

julia> 

julia> @parameters t σ ρ β
(t, σ, ρ, β)

julia> 

julia> @variables x(t) y(t) z(t)
(x(t), y(t), z(t))

julia> 

julia> @derivatives D'~t
((D'~t),)

julia> 

julia> 

julia> 

julia> eqs = [D(x) ~ σ*(y-x),

              D(y) ~ x*(ρ-z)-y,

              D(z) ~ x*y - β*z]
3-element Array{Equation,1}:
 Equation(derivative(x(t), t), σ * (y(t) - x(t)))
 Equation(derivative(y(t), t), x(t) * (ρ - z(t)) - y(t))
 Equation(derivative(z(t), t), x(t) * y(t) - β * z(t))

julia> 

julia> 

julia> 

julia> sys = ODESystem(eqs)
ODESystem(Equation[Equation(derivative(x(t), t), σ * (y(t) - x(t))), Equation(derivative(y(t), t), x(t) * (ρ - z(t)) - y(t)), Equation(derivative(z(t), t), x(t) * y(t) - β * z(t))], t, Variable[x, y, z], Variable[ρ, β, σ], Variable[], Equation[], Base.RefValue{Array{Expression,1}}(Expression[]), Base.RefValue{Array{Expression,2}}(Array{Expression}(undef,0,0)), Base.RefValue{Array{Expression,2}}(Array{Expression}(undef,0,0)), Base.RefValue{Array{Expression,2}}(Array{Expression}(undef,0,0)), Symbol("##ODESystem#539"), ODESystem[])

julia> 

julia> 

julia> 

julia> u0 = [x => 1.0f0

             y => 0.0f0

             z => 0.0f0]
3-element Array{Pair{Operation,Float32},1}:
 x(t) => 1.0
 y(t) => 0.0
 z(t) => 0.0

julia> 

julia> 

julia> 

julia> p  = [σ => 10.0f0

             ρ => 28.0f0

             β => 8f0/3f0]
3-element Array{Pair{Operation,Float32},1}:
 σ => 10.0
 ρ => 28.0
 β => 2.6666667

julia> 

julia> tspan = (0.0f0,100.0f0)
(0.0f0, 100.0f0)

julia> 

julia> prob = ODEProblem(sys,u0,tspan,p)
ODEProblem with uType Array{Float32,1} and tType Float32. In-place: true
timespan: (0.0f0, 100.0f0)
u0: Float32[1.0, 0.0, 0.0]

julia> 

julia> prob_func = (prob,i,repeat) -> remake(prob,p=rand(Float32,3).*prob.p)
#17 (generic function with 1 method)

julia> 

julia> monteprob = EnsembleProblem(prob, prob_func = prob_func)
EnsembleProblem with problem ODEProblem

julia> 

julia> sol = solve(monteprob,Tsit5(),EnsembleGPUArray(),trajectories=10,saveat=1.0f0)
EnsembleSolution Solution of length 10 with uType:
ODESolution{Float32,2,Array{SubArray{Float32,1,Array{Float32,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true},1},Nothing,Nothing,Array{Float32,1},Nothing,ODEProblem{Array{Float32,1},Tuple{Float32,Float32},true,Array{Float32,1},ODEFunction{true,ModelingToolkit.var"#f#88"{GeneralizedGenerated.NGG.RuntimeFn{TypeEncoding(list(##MTKArg#540, ##MTKArg#541, ##MTKArg#542)),TypeEncoding(nil(GeneralizedGenerated.NGG.Argument)),TypeEncoding(begin
    begin
        #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:74 =#
        #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:75 =#
        if (ModelingToolkit).isa(var"##MTKArg#540", (ModelingToolkit).Array) || (ModelingToolkit).:!((ModelingToolkit).typeof(var"##MTKArg#540") <: (ModelingToolkit).StaticArray) && false 
            #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:257 =#
            return begin
                    $(Expr(:inbounds, true))
                    local var"#733#val" = begin
                                #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:251 =#
                                let (x, y, z, ρ, β, σ, t) = (var"##MTKArg#540"[1], var"##MTKArg#540"[2], var"##MTKArg#540"[3], var"##MTKArg#541"[1], var"##MTKArg#541"[2], var"##MTKArg#541"[3], var"##MTKArg#542")
                                    [(ModelingToolkit).:*(σ, (ModelingToolkit).:-(y, x)), (ModelingToolkit).:-((ModelingToolkit).:*(x, (ModelingToolkit).:-(ρ, z)), y), (ModelingToolkit).:-((ModelingToolkit).:*(x, y), (ModelingToolkit).:*(β, z))]
                                end
                            end
                    $(Expr(:inbounds, :((ModelingToolkit).pop)))
                    var"#733#val"
                end
        else
            #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:259 =#
            X = begin
                    $(Expr(:inbounds, true))
                    local var"#734#val" = begin
                                #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:250 =#
                                let (x, y, z, ρ, β, σ, t) = (var"##MTKArg#540"[1], var"##MTKArg#540"[2], var"##MTKArg#540"[3], var"##MTKArg#541"[1], var"##MTKArg#541"[2], var"##MTKArg#541"[3], var"##MTKArg#542")
                                    ((ModelingToolkit).:*(σ, (ModelingToolkit).:-(y, x)), (ModelingToolkit).:-((ModelingToolkit).:*(x, (ModelingToolkit).:-(ρ, z)), y), (ModelingToolkit).:-((ModelingToolkit).:*(x, y), (ModelingToolkit).:*(β, z)))
                                end
                            end
                    $(Expr(:inbounds, :((ModelingToolkit).pop)))
                    var"#734#val"
                end
            #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:260 =#
            construct = if (ModelingToolkit).isa(var"##MTKArg#540", (ModelingToolkit).ModelingToolkit.StaticArrays.StaticArray)
                    (ModelingToolkit).ModelingToolkit.StaticArrays.similar_type((ModelingToolkit).typeof(var"##MTKArg#540"), (ModelingToolkit).eltype(X))
                else
                    #= C:\Users\accou\.julia\packages\GeneralizedGenerated\YYD7s\src\closure_conv.jl:53 =#
                    let freevars = (var"##MTKArg#540",)
                        #= C:\Users\accou\.julia\packages\GeneralizedGenerated\YYD7s\src\closure_conv.jl:54 =#
                        (GeneralizedGenerated.Closure){function = (##MTKArg#540, x;) -> begin 
    begin
        (ModelingToolkit).convert((ModelingToolkit).typeof(var"##MTKArg#540"), x)
    end
end, Base.typeof(freevars)}(freevars)
                    end
                end
            #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:261 =#
            return construct(X)
        end
    end
end),:function},GeneralizedGenerated.NGG.RuntimeFn{TypeEncoding(list(##MTIIPVar#544, ##MTKArg#540, ##MTKArg#541, ##MTKArg#542)),TypeEncoding(nil(GeneralizedGenerated.NGG.Argument)),TypeEncoding(begin
    begin
        #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:67 =#
        #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:68 =#
        begin
            $(Expr(:inbounds, true))
            local var"#735#val" = begin
                        #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:252 =#
                        let (x, y, z, ρ, β, σ, t) = (var"##MTKArg#540"[1], var"##MTKArg#540"[2], var"##MTKArg#540"[3], var"##MTKArg#541"[1], var"##MTKArg#541"[2], var"##MTKArg#541"[3], var"##MTKArg#542")
                            begin
                                var"##MTIIPVar#544"[1] = (ModelingToolkit).:*(σ, (ModelingToolkit).:-(y, x))
                                var"##MTIIPVar#544"[2] = (ModelingToolkit).:-((ModelingToolkit).:*(x, (ModelingToolkit).:-(ρ, z)), y)
                                var"##MTIIPVar#544"[3] = (ModelingToolkit).:-((ModelingToolkit).:*(x, y), (ModelingToolkit).:*(β, z))
                            end
                        end
                    end
            $(Expr(:inbounds, :((ModelingToolkit).pop)))
            var"#735#val"
        end
        #= C:\Users\accou\.julia\dev\ModelingToolkit\src\build_function.jl:69 =#
        (ModelingToolkit).nothing
    end
end),:function}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Array{Symbol,1},Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,DiffEqBase.LinearInterpolation{Array{Float32,1},Array{SubArray{Float32,1,Array{Float32,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true},1}},DiffEqBase.DEStats}
ChrisRackauckas commented 4 years ago

We might want to get this repo updated to KernelAbstractions.jl before digging deeper, as it's hard to know what that will fix and break.

ChrisRackauckas commented 4 years ago

ERROR: LLVM error: Symbol name with unsupported characters

@vchuravy do you know what could even cause this?

ArnoStrouwen commented 4 years ago

The upgrade to KernelAbstractions.jl fixed this for me, both the segfault and the LLVM symbol name error.

ChrisRackauckas commented 4 years ago

Great!