Skip to content

Commit 58aa699

Browse files
committed
Unroll the reduction loop once to get the container, and remove the Compiler call
1 parent 80bf453 commit 58aa699

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/ensemble/basic_ensemble_solve.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,20 @@ function __solve(prob::AbstractEnsembleProblem,
9898
return EnsembleSolution(_u,elapsed_time,true)
9999
end
100100

101-
if prob.u_init === nothing && prob.reduction === DEFAULT_REDUCTION
102-
batchrt = Core.Compiler.return_type(batch_function,Tuple{UnitRange{Int64}})
103-
else
104-
batchrt = Any
105-
end
106-
u = batchrt[]
107-
108-
converged = false
101+
converged::Bool = false
109102

110-
elapsed_time = @elapsed for i in 1:num_batches
103+
batch_data = batch_function(I)
104+
u = similar(batch_data, 0)
105+
u,converged = prob.reduction(u,batch_data,I)
106+
elapsed_time = @elapsed for i in 2:num_batches
107+
converged && break
111108
if i == num_batches
112109
I = (batch_size*(i-1)+1):trajectories
113110
else
114111
I = (batch_size*(i-1)+1):batch_size*i
115112
end
116113
batch_data = batch_function(I)
117114
u,converged = prob.reduction(u,batch_data,I)
118-
converged && break
119115
end
120116

121117
u = reduce(vcat, u)

0 commit comments

Comments
 (0)