From 87beef246defe16f7754caaef8045ee0cd5133c7 Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Wed, 31 Mar 2021 11:23:46 +0200 Subject: [PATCH 1/2] Change map for a for loop to work around https://github.com/JuliaLang/julia/issues/35800 which can cause very slow compile times in Julia 1.6. --- src/ensemble/basic_ensemble_solve.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ensemble/basic_ensemble_solve.jl b/src/ensemble/basic_ensemble_solve.jl index 20fffbd3d..fc5450faf 100644 --- a/src/ensemble/basic_ensemble_solve.jl +++ b/src/ensemble/basic_ensemble_solve.jl @@ -182,11 +182,15 @@ function solve_batch(prob,alg,ensemblealg::EnsembleDistributed,II,pmap_batch_siz tighten_container_eltype(batch_data) end -function solve_batch(prob,alg,::EnsembleSerial,II,pmap_batch_size;kwargs...) - batch_data = map(II) do i - batch_func(i,prob,alg;kwargs...) +function solve_batch(prob, alg, ::EnsembleSerial, II, pmap_batch_size; kwargs...) + if isempty(II) + throw(ArgumentError("number of trajectories must be positive")) end - tighten_container_eltype(batch_data) + batch_data = [batch_func(first(II), prob, alg; kwargs...)] + for i in 2:length(II) + @inbounds push!(batch_data, batch_func(II[i], prob, alg; kwargs...)) + end + return tighten_container_eltype(batch_data) end function solve_batch(prob,alg,ensemblealg::EnsembleThreads,II,pmap_batch_size;kwargs...) From b3ea4223e81ebf3ce3ae7a6ead69ca31d446b7c7 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 31 Mar 2021 08:12:51 -0400 Subject: [PATCH 2/2] Update basic_ensemble_solve.jl --- src/ensemble/basic_ensemble_solve.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ensemble/basic_ensemble_solve.jl b/src/ensemble/basic_ensemble_solve.jl index fc5450faf..0270995b5 100644 --- a/src/ensemble/basic_ensemble_solve.jl +++ b/src/ensemble/basic_ensemble_solve.jl @@ -187,6 +187,7 @@ function solve_batch(prob, alg, ::EnsembleSerial, II, pmap_batch_size; kwargs... throw(ArgumentError("number of trajectories must be positive")) end batch_data = [batch_func(first(II), prob, alg; kwargs...)] + sizehint!(batch_data,length(II)) for i in 2:length(II) @inbounds push!(batch_data, batch_func(II[i], prob, alg; kwargs...)) end