Skip to content

Commit ffa84ba

Browse files
committed
Promote param vectors in params_partitioned
This helps avoid some very frustrating performance bugs when e.g. you have something like ```julia [SubsystemParams{T}(a=1, b=2) SubsystemParams{T}(a=3.0, b=4)] ``` this gets promoted to ``` [SubsystemParams{T}(a=1.0, b=2) SubsystemParams{T}(a=3.0, b=4)] ```
1 parent ae944bf commit ffa84ba

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/problems.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ function _problem(g::PartitionedGraphSystem, tspan; scheduler, allow_nonconcrete
102102
param_namemap,
103103
compu_namemap) = g
104104

105+
params_partitioned = map(params_partitioned) do v
106+
if !isconcretetype(eltype(v))
107+
unique_types = unique(typeof.(v))
108+
@debug "Non-concrete param types. Promoting" unique_types
109+
T = mapreduce(typeof, promote_type, v)
110+
convert.(T, v)
111+
else
112+
v
113+
end
114+
end
115+
105116
total_eltype = let
106117
states_eltype = mapreduce(promote_type, states_partitioned) do v
107118
eltype(eltype(v))

0 commit comments

Comments
 (0)