Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AD on WaterLily using Enzyme #1647

Closed
b-fg opened this issue Jul 15, 2024 · 4 comments
Closed

AD on WaterLily using Enzyme #1647

b-fg opened this issue Jul 15, 2024 · 4 comments

Comments

@b-fg
Copy link

b-fg commented Jul 15, 2024

Hey! I have been trying to use Enzyme to perform AD on WaterLily but haven't succeeded so far. Currently, AD works fine with ForwardDiff but we would like to switch to Enzyme to be able to have AD running on GPU (WaterLily-jl/WaterLily.jl#130). Below is the ForwardDiff MWE that works when using our SIMD backend or KernelAbstractions.jl CPU backend (note that WaterLily uses SIMD when launching julia -t 1 ..., and KA otherwise)

using Pkg
Pkg.activate(temp=true)
Pkg.add(["WaterLily", "StaticArrays", "ForwardDiff", "Enzyme"])

using WaterLily
using StaticArrays
using ForwardDiff
using Enzyme

function make_sim(θ; L=32, U=1, Re=100, mem=Array)
    function map(x, _)
        s, c = sincos(θ)
        SA[c -s; s c] * (x - SA[L, L])
    end
    function sdf(ξ, _)
        p = ξ - SA[0, clamp(ξ[1], -L / 2, L / 2)]
        (p' * p) - 2
    end
    Simulation((2L, 2L), (U, 0), L, ν=U * L / Re, body=AutoBody(sdf, map), T=typeof(θ), mem=mem)
end

function dsim(θ)
    sim = make_sim(θ)
    sim_step!(sim)
    sum(sim.flow.p)
end

function main()
    θ = Float64/ 36)
    ForwardDiff.derivative(dsim, θ) # 4.685738778914697
end

main()

When trying to switch to Enzyme, the following code would hopefully reproduce the results of ForwardDiff, but so far I only get a very long stacktrace that makes it difficult to debug. From my limited understanding, I think it is complaining about type inference on the creation of the Simulation struct (and something related to a memcpy).

function main()
    θ = Float64/ 36)
    Enzyme.autodiff(Forward, dsim, Duplicated, Duplicated(θ, 1.0)) # Error
end
ERROR: LoadError: Enzyme execution failed.
Enzyme cannot deduce type
Current scope: 
; Function Attrs: mustprogress willreturn
define "enzyme_type"="{[0]:Pointer, [8]:Pointer, [16]:Pointer, [32]:Pointer}" "enzymejl_parmtype"="133701604737760" "enzymejl_parmtype_ref"="1" [6 x {} addrspace(10)*] @preprocess_julia__make_sim_1_6187_inner.1(i64 signext "enzyme_inactive" "enzyme_type"="{[-1]:Integer}" "enzymejl_parmtype"="133702186036736" "enzymejl_parmtype_ref"="0" %0, i64 signext "enzyme_inactive" "enzyme_type"="{[-1]:Integer}" "enzymejl_parmtype"="133702186036736" "enzymejl_parmtype_ref"="0" %1, i64 signext "enzyme_inactive" "enzyme_type"="{[-1]:Integer}" "enzymejl_parmtype"="133702186036736" "enzymejl_parmtype_ref"="0" %2, {} addrspace(10)* nofree noundef nonnull readonly "enzyme_type"="{[-1]:Pointer}" "enzymejl_parmtype"="133702120486048" "enzymejl_parmtype_ref"="2" %3, double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="133702186035936" "enzymejl_parmtype_ref"="0" %4) local_unnamed_addr #11 !dbg !57 {
entry:
  %newstruct7.i.sroa.5 = alloca [7 x i8], align 1
  %newstruct7.i.sroa.5.0.sroa_idx27 = getelementptr inbounds [7 x i8], [7 x i8]* %newstruct7.i.sroa.5, i64 0, i64 0
  %newstruct7.i.sroa.5.0.sroa_idx2 = getelementptr inbounds [7 x i8], [7 x i8]* %newstruct7.i.sroa.5, i64 0, i64 0
  call void @llvm.lifetime.start.p0i8(i64 7, i8* %newstruct7.i.sroa.5.0.sroa_idx2)
  %5 = call {}*** @julia.get_pgcstack() #12, !noalias !58
  %current_task1.i49 = getelementptr inbounds {}**, {}*** %5, i64 -14
  %current_task1.i = bitcast {}*** %current_task1.i49 to {}**
  %ptls_field.i50 = getelementptr inbounds {}**, {}*** %5, i64 2
  %6 = bitcast {}*** %ptls_field.i50 to i64***
  %ptls_load.i5152 = load i64**, i64*** %6, align 8, !tbaa !11, !noalias !58
  %7 = getelementptr inbounds i64*, i64** %ptls_load.i5152, i64 2
  %safepoint.i = load i64*, i64** %7, align 8, !tbaa !15, !noalias !58
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint.i) #12, !dbg !61, !noalias !58
  fence syncscope("singlethread") seq_cst
  %8 = shl i64 %0, 1, !dbg !63
  %9 = mul i64 %1, %0, !dbg !63
  %10 = sitofp i64 %9 to double, !dbg !65
  %11 = sitofp i64 %2 to double, !dbg !65
  %12 = fdiv double %10, %11, !dbg !69
  %box.i = call noalias nonnull dereferenceable(8) "enzyme_type"="{[-1]:Pointer, [-1,-1]:Float@double}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 8, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133702186035936 to {}*) to {} addrspace(10)*)) #13, !dbg !70
  %13 = bitcast {} addrspace(10)* %box.i to double addrspace(10)*, !dbg !70
  store double %12, double addrspace(10)* %13, align 8, !dbg !70, !tbaa !35, !alias.scope !39, !noalias !71
  %box10.i = call noalias nonnull dereferenceable(48) "enzyme_type"="{[-1]:Pointer, [-1,0]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Float@double}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 48, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133697246403216 to {}*) to {} addrspace(10)*)) #13, !dbg !70
  %14 = bitcast {} addrspace(10)* %box10.i to i8 addrspace(10)*, !dbg !70
  store i8 1, i8 addrspace(10)* %14, align 8, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.5.0..sroa_raw_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 1, !dbg !70
  call void @llvm.memcpy.p10i8.p0i8.i64(i8 addrspace(10)* nocapture nofree noundef writeonly align 1 dereferenceable(7) %newstruct7.i.sroa.5.0..sroa_raw_idx, i8* noundef nonnull readonly align 1 dereferenceable(7) %newstruct7.i.sroa.5.0.sroa_idx27, i64 noundef 7, i1 noundef false) #12, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.58.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 8, !dbg !70
  %newstruct7.i.sroa.58.0..sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.58.0..sroa_idx to i64 addrspace(10)*, !dbg !70
  store i64 %0, i64 addrspace(10)* %newstruct7.i.sroa.58.0..sroa_cast, align 8, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 16, !dbg !70
  %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_idx to i64 addrspace(10)*, !dbg !70
  store i64 %0, i64 addrspace(10)* %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_cast, align 8, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 24, !dbg !70
  %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_idx to double addrspace(10)*, !dbg !70
  store double %4, double addrspace(10)* %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_cast, align 8, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 32, !dbg !70
  %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_idx to i64 addrspace(10)*, !dbg !70
  store i64 %0, i64 addrspace(10)* %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_cast, align 8, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 40, !dbg !70
  %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_idx to double addrspace(10)*, !dbg !70
  store double %4, double addrspace(10)* %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_cast, align 8, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %15 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,-1]:Pointer}" {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)*, {} addrspace(10)*, ...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* noundef nonnull @jl_f_tuple, {} addrspace(10)* noundef null, {} addrspace(10)* nofree nonnull %box.i, {} addrspace(10)* nofree nonnull %box10.i, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 133702186035936 to {}*) to {} addrspace(10)*), {} addrspace(10)* nofree nonnull %3) #14, !dbg !70
  %typeof.i = call "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* @julia.typeof({} addrspace(10)* nonnull %15) #15, !dbg !75
  %16 = call nonnull "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)*, {} addrspace(10)*, ...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* noundef nonnull @jl_f_apply_type, {} addrspace(10)* noundef null, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 133702186037408 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 133697131393712 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull %typeof.i) #16, !dbg !75
  %box12.i = call noalias nonnull dereferenceable(8) "enzyme_type"="{[-1]:Pointer, [-1,-1]:Float@double}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 8, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133702186035936 to {}*) to {} addrspace(10)*)) #13, !dbg !75
  %17 = bitcast {} addrspace(10)* %box12.i to double addrspace(10)*, !dbg !75
  store double %12, double addrspace(10)* %17, align 8, !dbg !75, !tbaa !35, !alias.scope !39, !noalias !71
  %box14.i = call noalias nonnull dereferenceable(48) "enzyme_type"="{[-1]:Pointer, [-1,0]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Float@double}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 48, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133697246403216 to {}*) to {} addrspace(10)*)) #13, !dbg !75
  %18 = bitcast {} addrspace(10)* %box14.i to i8 addrspace(10)*, !dbg !75
  store i8 1, i8 addrspace(10)* %18, align 8, !dbg !75, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.5.0..sroa_raw_idx4 = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 1, !dbg !75
  call void @llvm.memcpy.p10i8.p0i8.i64(i8 addrspace(10)* nocapture nofree noundef align 1 dereferenceable(7) %newstruct7.i.sroa.5.0..sroa_raw_idx4, i8* noundef nonnull align 1 dereferenceable(7) %newstruct7.i.sroa.5.0.sroa_idx27, i64 noundef 7, i1 noundef false) #12, !dbg !75, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.58.0..sroa_idx9 = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 8, !dbg !75
  %newstruct7.i.sroa.58.0..sroa_cast10 = bitcast i8 addrspace(10)* %newstruct7.i.sroa.58.0..sroa_idx9 to i64 addrspace(10)*, !dbg !75
  store i64 %0, i64 addrspace(10)* %newstruct7.i.sroa.58.0..sroa_cast10, align 8, !dbg !75, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 16, !dbg !75
  %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_idx to i64 addrspace(10)*, !dbg !75
  store i64 %0, i64 addrspace(10)* %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_cast, align 8, !dbg !75, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 24, !dbg !75
  %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_idx to double addrspace(10)*, !dbg !75
  store double %4, double addrspace(10)* %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_cast, align 8, !dbg !75, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 32, !dbg !75
  %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_idx to i64 addrspace(10)*, !dbg !75
  store i64 %0, i64 addrspace(10)* %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_cast, align 8, !dbg !75, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 40, !dbg !75
  %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_idx to double addrspace(10)*, !dbg !75
  store double %4, double addrspace(10)* %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_cast, align 8, !dbg !75, !tbaa !49, !alias.scope !50, !noalias !74
  %19 = call noalias nonnull "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)*, {} addrspace(10)*, ...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* noundef nonnull @ijl_new_structv, {} addrspace(10)* nonnull %16, {} addrspace(10)* nofree nonnull %box12.i, {} addrspace(10)* nofree nonnull %box14.i, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 133702186035936 to {}*) to {} addrspace(10)*), {} addrspace(10)* nofree nonnull %3) #14, !dbg !75
  %box16.i = call noalias nonnull dereferenceable(16) "enzyme_inactive" "enzyme_type"="{[-1]:Pointer, [-1,-1]:Integer}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 16, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133702113960800 to {}*) to {} addrspace(10)*)) #13, !dbg !70
  %20 = bitcast {} addrspace(10)* %box16.i to i8 addrspace(10)*, !dbg !70
  %newstruct3.i.sroa.0.0..sroa_cast = bitcast {} addrspace(10)* %box16.i to i64 addrspace(10)*, !dbg !70
  store i64 %8, i64 addrspace(10)* %newstruct3.i.sroa.0.0..sroa_cast, align 8, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct3.i.sroa.4.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %20, i64 8, !dbg !70
  %newstruct3.i.sroa.4.0..sroa_cast = bitcast i8 addrspace(10)* %newstruct3.i.sroa.4.0..sroa_idx to i64 addrspace(10)*, !dbg !70
  store i64 %8, i64 addrspace(10)* %newstruct3.i.sroa.4.0..sroa_cast, align 8, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %box18.i = call noalias nonnull dereferenceable(16) "enzyme_inactive" "enzyme_type"="{[-1]:Pointer, [-1,-1]:Integer}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 16, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133702113960800 to {}*) to {} addrspace(10)*)) #13, !dbg !70
  %21 = bitcast {} addrspace(10)* %box18.i to i8 addrspace(10)*, !dbg !70
  %newstruct4.i.sroa.0.0..sroa_cast = bitcast {} addrspace(10)* %box18.i to i64 addrspace(10)*, !dbg !70
  store i64 %1, i64 addrspace(10)* %newstruct4.i.sroa.0.0..sroa_cast, align 8, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %newstruct4.i.sroa.4.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %21, i64 8, !dbg !70
  %newstruct4.i.sroa.4.0..sroa_cast = bitcast i8 addrspace(10)* %newstruct4.i.sroa.4.0..sroa_idx to i64 addrspace(10)*, !dbg !70
  store i64 0, i64 addrspace(10)* %newstruct4.i.sroa.4.0..sroa_cast, align 8, !dbg !70, !tbaa !49, !alias.scope !50, !noalias !74
  %22 = call noalias nonnull "enzyme_inactive" "enzyme_type"="{[-1]:Pointer, [-1,-1]:Integer}" {} addrspace(10)* @ijl_box_int64(i64 signext %0) #17, !dbg !70, !noalias !58
  %23 = call nonnull "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)*, {} addrspace(10)*, ...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* noundef nonnull @ijl_apply_generic, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133702174980784 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull %19, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 133701604737760 to {}*) to {} addrspace(10)*), {} addrspace(10)* nofree nonnull %box16.i, {} addrspace(10)* nofree nonnull %box18.i, {} addrspace(10)* nonnull %22) #18, !dbg !70
  %24 = addrspacecast {} addrspace(10)* %23 to i8 addrspace(11)*, !dbg !70
  %innersret.sroa.0.0..sroa_cast = addrspacecast {} addrspace(10)* %23 to {} addrspace(10)* addrspace(11)*, !dbg !70
  %innersret.sroa.0.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.0.0..sroa_cast, align 1, !dbg !70, !noalias !76
  %innersret.sroa.2.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(11)* %24, i64 8, !dbg !70
  %innersret.sroa.2.0..sroa_cast = bitcast i8 addrspace(11)* %innersret.sroa.2.0..sroa_idx to {} addrspace(10)* addrspace(11)*, !dbg !70
  %innersret.sroa.2.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.2.0..sroa_cast, align 1, !dbg !70, !noalias !76
  %innersret.sroa.3.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(11)* %24, i64 16, !dbg !70
  %innersret.sroa.3.0..sroa_cast = bitcast i8 addrspace(11)* %innersret.sroa.3.0..sroa_idx to {} addrspace(10)* addrspace(11)*, !dbg !70
  %innersret.sroa.3.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.3.0..sroa_cast, align 1, !dbg !70, !noalias !76
  %innersret.sroa.4.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(11)* %24, i64 24, !dbg !70
  %innersret.sroa.4.0..sroa_cast = bitcast i8 addrspace(11)* %innersret.sroa.4.0..sroa_idx to {} addrspace(10)* addrspace(11)*, !dbg !70
  %innersret.sroa.4.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.4.0..sroa_cast, align 1, !dbg !70, !noalias !76
  %innersret.sroa.5.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(11)* %24, i64 32, !dbg !70
  %innersret.sroa.5.0..sroa_cast = bitcast i8 addrspace(11)* %innersret.sroa.5.0..sroa_idx to {} addrspace(10)* addrspace(11)*, !dbg !70
  %innersret.sroa.5.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.5.0..sroa_cast, align 1, !dbg !70, !noalias !76
  %innersret.sroa.6.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(11)* %24, i64 40, !dbg !70
  %innersret.sroa.6.0..sroa_cast = bitcast i8 addrspace(11)* %innersret.sroa.6.0..sroa_idx to {} addrspace(10)* addrspace(11)*, !dbg !70
  %innersret.sroa.6.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.6.0..sroa_cast, align 1, !dbg !70, !noalias !76
  %newstruct7.i.sroa.5.0.sroa_idx3 = getelementptr inbounds [7 x i8], [7 x i8]* %newstruct7.i.sroa.5, i64 0, i64 0, !dbg !70
  call void @llvm.lifetime.end.p0i8(i64 7, i8* %newstruct7.i.sroa.5.0.sroa_idx3), !dbg !70
  %.fca.0.insert = insertvalue [6 x {} addrspace(10)*] poison, {} addrspace(10)* %innersret.sroa.0.0.copyload, 0, !dbg !77
  %.fca.1.insert = insertvalue [6 x {} addrspace(10)*] %.fca.0.insert, {} addrspace(10)* %innersret.sroa.2.0.copyload, 1, !dbg !77
  %.fca.2.insert = insertvalue [6 x {} addrspace(10)*] %.fca.1.insert, {} addrspace(10)* %innersret.sroa.3.0.copyload, 2, !dbg !77
  %.fca.3.insert = insertvalue [6 x {} addrspace(10)*] %.fca.2.insert, {} addrspace(10)* %innersret.sroa.4.0.copyload, 3, !dbg !77
  %.fca.4.insert = insertvalue [6 x {} addrspace(10)*] %.fca.3.insert, {} addrspace(10)* %innersret.sroa.5.0.copyload, 4, !dbg !77
  %.fca.5.insert = insertvalue [6 x {} addrspace(10)*] %.fca.4.insert, {} addrspace(10)* %innersret.sroa.6.0.copyload, 5, !dbg !77
  ret [6 x {} addrspace(10)*] %.fca.5.insert, !dbg !77
}

 Type analysis state: 
<analysis>
  %16 = call nonnull "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)*, {} addrspace(10)*, ...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* noundef nonnull @jl_f_apply_type, {} addrspace(10)* noundef null, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 133702186037408 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 133697131393712 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull %typeof.i) #16, !dbg !52: {[-1]:Pointer}, intvals: {}
  %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_idx to i64 addrspace(10)*, !dbg !52: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Float@double, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double}, intvals: {}
  %.fca.1.insert = insertvalue [6 x {} addrspace(10)*] %.fca.0.insert, {} addrspace(10)* %innersret.sroa.2.0.copyload, 1, !dbg !56: {[0]:Pointer, [8]:Pointer, [16]:Anything, [17]:Anything, [18]:Anything, [19]:Anything, [20]:Anything, [21]:Anything, [22]:Anything, [23]:Anything, [24]:Anything, [25]:Anything, [26]:Anything, [27]:Anything, [28]:Anything, [29]:Anything, [30]:Anything, [31]:Anything, [32]:Anything, [33]:Anything, [34]:Anything, [35]:Anything, [36]:Anything, [37]:Anything, [38]:Anything, [39]:Anything, [40]:Anything, [41]:Anything, [42]:Anything, [43]:Anything, [44]:Anything, [45]:Anything, [46]:Anything, [47]:Anything}, intvals: {}
  %innersret.sroa.5.0..sroa_cast = bitcast i8 addrspace(11)* %innersret.sroa.5.0..sroa_idx to {} addrspace(10)* addrspace(11)*, !dbg !34: {[-1]:Pointer, [-1,0]:Pointer}, intvals: {}
  %innersret.sroa.5.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.5.0..sroa_cast, align 1, !dbg !34, !noalias !55: {[-1]:Pointer}, intvals: {}
i64 0: {[-1]:Anything}, intvals: {0,}
{}* inttoptr (i64 133697246403216 to {}*): {[-1]:Anything}, intvals: {}
  %newstruct7.i.sroa.5.0.sroa_idx3 = getelementptr inbounds [7 x i8], [7 x i8]* %newstruct7.i.sroa.5, i64 0, i64 0, !dbg !34: {[-1]:Pointer}, intvals: {}
  %newstruct7.i.sroa.5 = alloca [7 x i8], align 1: {[-1]:Pointer}, intvals: {}
  %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_idx to i64 addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Float@double, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double}, intvals: {}
  %innersret.sroa.6.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(11)* %24, i64 40, !dbg !34: {[-1]:Pointer}, intvals: {}
  %newstruct3.i.sroa.0.0..sroa_cast = bitcast {} addrspace(10)* %box16.i to i64 addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %innersret.sroa.4.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.4.0..sroa_cast, align 1, !dbg !34, !noalias !55: {}, intvals: {}
  %innersret.sroa.5.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(11)* %24, i64 32, !dbg !34: {[-1]:Pointer, [-1,0]:Pointer}, intvals: {}
  %newstruct7.i.sroa.5.0..sroa_raw_idx4 = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 1, !dbg !52: {[-1]:Pointer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Float@double, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Float@double}, intvals: {}
{}* inttoptr (i64 133702174980784 to {}*): {[-1]:Anything}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 133702174980784 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
  %7 = getelementptr inbounds i64*, i64** %ptls_load.i5152, i64 2: {[-1]:Pointer}, intvals: {}
  %9 = mul i64 %1, %0, !dbg !19: {[-1]:Integer}, intvals: {}
  %19 = call noalias nonnull "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)*, {} addrspace(10)*, ...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* noundef nonnull @ijl_new_structv, {} addrspace(10)* nonnull %16, {} addrspace(10)* nofree nonnull %box12.i, {} addrspace(10)* nofree nonnull %box14.i, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 133702186035936 to {}*) to {} addrspace(10)*), {} addrspace(10)* nofree nonnull %3) #14, !dbg !52: {[-1]:Pointer}, intvals: {}
  %ptls_load.i5152 = load i64**, i64*** %6, align 8, !tbaa !11, !noalias !8: {[-1]:Pointer}, intvals: {}
  %box18.i = call noalias nonnull dereferenceable(16) "enzyme_inactive" "enzyme_type"="{[-1]:Pointer, [-1,-1]:Integer}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 16, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133702113960800 to {}*) to {} addrspace(10)*)) #13, !dbg !34: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 24, !dbg !34: {[-1]:Pointer, [-1,0]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Float@double}, intvals: {}
  %12 = fdiv double %10, %11, !dbg !32: {[-1]:Float@double}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 133697131393712 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
  %current_task1.i = bitcast {}*** %current_task1.i49 to {}**: {[-1]:Pointer}, intvals: {}
  %newstruct3.i.sroa.4.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %20, i64 8, !dbg !34: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %newstruct7.i.sroa.58.0..sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.58.0..sroa_idx to i64 addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Float@double, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Float@double}, intvals: {}
{}* inttoptr (i64 133702113960800 to {}*): {[-1]:Anything}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 133702113960800 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
  %.fca.4.insert = insertvalue [6 x {} addrspace(10)*] %.fca.3.insert, {} addrspace(10)* %innersret.sroa.5.0.copyload, 4, !dbg !56: {[0]:Pointer, [8]:Pointer, [16]:Pointer, [32]:Pointer, [40]:Anything, [41]:Anything, [42]:Anything, [43]:Anything, [44]:Anything, [45]:Anything, [46]:Anything, [47]:Anything}, intvals: {}
  %innersret.sroa.6.0..sroa_cast = bitcast i8 addrspace(11)* %innersret.sroa.6.0..sroa_idx to {} addrspace(10)* addrspace(11)*, !dbg !34: {[-1]:Pointer}, intvals: {}
  %innersret.sroa.6.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.6.0..sroa_cast, align 1, !dbg !34, !noalias !55: {}, intvals: {}
  %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_idx to double addrspace(10)*, !dbg !52: {[-1]:Pointer, [-1,0]:Float@double}, intvals: {}
  %newstruct7.i.sroa.58.0..sroa_idx9 = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 8, !dbg !52: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Float@double, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Float@double}, intvals: {}
  %17 = bitcast {} addrspace(10)* %box12.i to double addrspace(10)*, !dbg !52: {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
  %typeof.i = call "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* @julia.typeof({} addrspace(10)* nonnull %15) #15, !dbg !52: {[-1]:Pointer}, intvals: {}
  %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_idx to i64 addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Float@double}, intvals: {}
  %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_idx to i64 addrspace(10)*, !dbg !52: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Float@double}, intvals: {}
  %.fca.0.insert = insertvalue [6 x {} addrspace(10)*] poison, {} addrspace(10)* %innersret.sroa.0.0.copyload, 0, !dbg !56: {[0]:Pointer, [8]:Anything, [9]:Anything, [10]:Anything, [11]:Anything, [12]:Anything, [13]:Anything, [14]:Anything, [15]:Anything, [16]:Anything, [17]:Anything, [18]:Anything, [19]:Anything, [20]:Anything, [21]:Anything, [22]:Anything, [23]:Anything, [24]:Anything, [25]:Anything, [26]:Anything, [27]:Anything, [28]:Anything, [29]:Anything, [30]:Anything, [31]:Anything, [32]:Anything, [33]:Anything, [34]:Anything, [35]:Anything, [36]:Anything, [37]:Anything, [38]:Anything, [39]:Anything, [40]:Anything, [41]:Anything, [42]:Anything, [43]:Anything, [44]:Anything, [45]:Anything, [46]:Anything, [47]:Anything}, intvals: {}
  %innersret.sroa.0.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.0.0..sroa_cast, align 1, !dbg !34, !noalias !55: {[-1]:Pointer}, intvals: {}
  %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 40, !dbg !52: {[-1]:Pointer, [-1,0]:Float@double}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 133701604737760 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
  %innersret.sroa.2.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(11)* %24, i64 8, !dbg !34: {[-1]:Pointer, [-1,0]:Pointer, [-1,8]:Pointer, [-1,24]:Pointer}, intvals: {}
  %innersret.sroa.2.0..sroa_cast = bitcast i8 addrspace(11)* %innersret.sroa.2.0..sroa_idx to {} addrspace(10)* addrspace(11)*, !dbg !34: {[-1]:Pointer, [-1,0]:Pointer, [-1,8]:Pointer, [-1,24]:Pointer}, intvals: {}
  %innersret.sroa.0.0..sroa_cast = addrspacecast {} addrspace(10)* %23 to {} addrspace(10)* addrspace(11)*, !dbg !34: {[-1]:Pointer, [-1,0]:Pointer, [-1,8]:Pointer, [-1,16]:Pointer, [-1,32]:Pointer}, intvals: {}
  %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx19.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 32, !dbg !52: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Float@double}, intvals: {}
  %innersret.sroa.3.0..sroa_cast = bitcast i8 addrspace(11)* %innersret.sroa.3.0..sroa_idx to {} addrspace(10)* addrspace(11)*, !dbg !34: {[-1]:Pointer, [-1,0]:Pointer, [-1,16]:Pointer}, intvals: {}
  %innersret.sroa.3.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.3.0..sroa_cast, align 1, !dbg !34, !noalias !55: {[-1]:Pointer}, intvals: {}
  %newstruct7.i.sroa.5.0.sroa_idx27 = getelementptr inbounds [7 x i8], [7 x i8]* %newstruct7.i.sroa.5, i64 0, i64 0: {[-1]:Pointer}, intvals: {}
  %innersret.sroa.2.0.copyload = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %innersret.sroa.2.0..sroa_cast, align 1, !dbg !34, !noalias !55: {[-1]:Pointer}, intvals: {}
  %innersret.sroa.3.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(11)* %24, i64 16, !dbg !34: {[-1]:Pointer, [-1,0]:Pointer, [-1,16]:Pointer}, intvals: {}
{}* inttoptr (i64 133701604737760 to {}*): {[-1]:Anything}, intvals: {}
  %21 = bitcast {} addrspace(10)* %box18.i to i8 addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %newstruct4.i.sroa.0.0..sroa_cast = bitcast {} addrspace(10)* %box18.i to i64 addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %ptls_field.i50 = getelementptr inbounds {}**, {}*** %5, i64 2: {[-1]:Pointer, [-1,0]:Pointer}, intvals: {}
  %14 = bitcast {} addrspace(10)* %box10.i to i8 addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,0]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Float@double}, intvals: {}
  %10 = sitofp i64 %9 to double, !dbg !23: {[-1]:Float@double}, intvals: {}
  %15 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,-1]:Pointer}" {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)*, {} addrspace(10)*, ...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* noundef nonnull @jl_f_tuple, {} addrspace(10)* noundef null, {} addrspace(10)* nofree nonnull %box.i, {} addrspace(10)* nofree nonnull %box10.i, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 133702186035936 to {}*) to {} addrspace(10)*), {} addrspace(10)* nofree nonnull %3) #14, !dbg !34: {[-1]:Pointer, [-1,-1]:Pointer}, intvals: {}
  %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_idx to double addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,0]:Float@double}, intvals: {}
[6 x {} addrspace(10)*] poison: {[-1]:Anything}, intvals: {}
  %newstruct7.i.sroa.58.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 8, !dbg !34: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Float@double, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Float@double}, intvals: {}
  %5 = call {}*** @julia.get_pgcstack() #12, !noalias !8: {[-1]:Pointer, [-1,16]:Pointer}, intvals: {}
{}* inttoptr (i64 133697131393712 to {}*): {[-1]:Anything}, intvals: {}
  %innersret.sroa.4.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(11)* %24, i64 24, !dbg !34: {[-1]:Pointer, [-1,8]:Pointer}, intvals: {}
  %innersret.sroa.4.0..sroa_cast = bitcast i8 addrspace(11)* %innersret.sroa.4.0..sroa_idx to {} addrspace(10)* addrspace(11)*, !dbg !34: {[-1]:Pointer, [-1,8]:Pointer}, intvals: {}
  %safepoint.i = load i64*, i64** %7, align 8, !tbaa !15, !noalias !8: {}, intvals: {}
  %newstruct7.i.sroa.7.sroa.0.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 32, !dbg !34: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Float@double}, intvals: {}
  %8 = shl i64 %0, 1, !dbg !19: {[-1]:Integer}, intvals: {}
{}* inttoptr (i64 133702186037408 to {}*): {[-1]:Anything}, intvals: {}
  %.fca.3.insert = insertvalue [6 x {} addrspace(10)*] %.fca.2.insert, {} addrspace(10)* %innersret.sroa.4.0.copyload, 3, !dbg !56: {[0]:Pointer, [8]:Pointer, [16]:Pointer, [32]:Anything, [33]:Anything, [34]:Anything, [35]:Anything, [36]:Anything, [37]:Anything, [38]:Anything, [39]:Anything, [40]:Anything, [41]:Anything, [42]:Anything, [43]:Anything, [44]:Anything, [45]:Anything, [46]:Anything, [47]:Anything}, intvals: {}
  %newstruct7.i.sroa.5.0.sroa_idx2 = getelementptr inbounds [7 x i8], [7 x i8]* %newstruct7.i.sroa.5, i64 0, i64 0: {[-1]:Pointer}, intvals: {}
  %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 16, !dbg !34: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Float@double, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double}, intvals: {}
  %22 = call noalias nonnull "enzyme_inactive" "enzyme_type"="{[-1]:Pointer, [-1,-1]:Integer}" {} addrspace(10)* @ijl_box_int64(i64 signext %0) #17, !dbg !34, !noalias !8: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %24 = addrspacecast {} addrspace(10)* %23 to i8 addrspace(11)*, !dbg !34: {[-1]:Pointer, [-1,0]:Pointer, [-1,8]:Pointer, [-1,16]:Pointer, [-1,32]:Pointer}, intvals: {}
  %20 = bitcast {} addrspace(10)* %box16.i to i8 addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %current_task1.i49 = getelementptr inbounds {}**, {}*** %5, i64 -14: {[-1]:Pointer}, intvals: {}
  %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx.sroa_idx to double addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,0]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Float@double}, intvals: {}
  %11 = sitofp i64 %2 to double, !dbg !23: {[-1]:Float@double}, intvals: {}
  %box14.i = call noalias nonnull dereferenceable(48) "enzyme_type"="{[-1]:Pointer, [-1,0]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Float@double}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 48, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133697246403216 to {}*) to {} addrspace(10)*)) #13, !dbg !52: {[-1]:Pointer, [-1,0]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Float@double}, intvals: {}
  %box12.i = call noalias nonnull dereferenceable(8) "enzyme_type"="{[-1]:Pointer, [-1,-1]:Float@double}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 8, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133702186035936 to {}*) to {} addrspace(10)*)) #13, !dbg !52: {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
  %newstruct4.i.sroa.4.0..sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %21, i64 8, !dbg !34: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %newstruct4.i.sroa.4.0..sroa_cast = bitcast i8 addrspace(10)* %newstruct4.i.sroa.4.0..sroa_idx to i64 addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 24, !dbg !52: {[-1]:Pointer, [-1,0]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Float@double}, intvals: {}
  %.fca.5.insert = insertvalue [6 x {} addrspace(10)*] %.fca.4.insert, {} addrspace(10)* %innersret.sroa.6.0.copyload, 5, !dbg !56: {[0]:Pointer, [8]:Pointer, [16]:Pointer, [32]:Pointer}, intvals: {}
i64 1: {[-1]:Integer}, intvals: {1,}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 133697246403216 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
  %newstruct7.i.sroa.5.0..sroa_raw_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 1, !dbg !34: {[-1]:Pointer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Float@double, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Float@double}, intvals: {}
{}* inttoptr (i64 133702186035936 to {}*): {[-1]:Anything}, intvals: {}
i64 %0: {[-1]:Integer}, intvals: {}
i64 %1: {[-1]:Integer}, intvals: {}
i64 %2: {[-1]:Integer}, intvals: {}
{} addrspace(10)* %3: {[-1]:Pointer}, intvals: {}
double %4: {[-1]:Float@double}, intvals: {}
  %box.i = call noalias nonnull dereferenceable(8) "enzyme_type"="{[-1]:Pointer, [-1,-1]:Float@double}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 8, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133702186035936 to {}*) to {} addrspace(10)*)) #13, !dbg !34: {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
  %box10.i = call noalias nonnull dereferenceable(48) "enzyme_type"="{[-1]:Pointer, [-1,0]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Float@double}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 48, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133697246403216 to {}*) to {} addrspace(10)*)) #13, !dbg !34: {[-1]:Pointer, [-1,0]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Float@double}, intvals: {}
  %newstruct7.i.sroa.58.0..sroa_cast10 = bitcast i8 addrspace(10)* %newstruct7.i.sroa.58.0..sroa_idx9 to i64 addrspace(10)*, !dbg !52: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Float@double, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Float@double}, intvals: {}
  %.fca.2.insert = insertvalue [6 x {} addrspace(10)*] %.fca.1.insert, {} addrspace(10)* %innersret.sroa.3.0.copyload, 2, !dbg !56: {[0]:Pointer, [8]:Pointer, [16]:Pointer, [24]:Anything, [25]:Anything, [26]:Anything, [27]:Anything, [28]:Anything, [29]:Anything, [30]:Anything, [31]:Anything, [32]:Anything, [33]:Anything, [34]:Anything, [35]:Anything, [36]:Anything, [37]:Anything, [38]:Anything, [39]:Anything, [40]:Anything, [41]:Anything, [42]:Anything, [43]:Anything, [44]:Anything, [45]:Anything, [46]:Anything, [47]:Anything}, intvals: {}
  %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_cast = bitcast i8 addrspace(10)* %newstruct7.i.sroa.6.sroa.5.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_idx to double addrspace(10)*, !dbg !52: {[-1]:Pointer, [-1,0]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Float@double}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 133702186037408 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 133702186035936 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
  %18 = bitcast {} addrspace(10)* %box14.i to i8 addrspace(10)*, !dbg !52: {[-1]:Pointer, [-1,0]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Float@double}, intvals: {}
  %box16.i = call noalias nonnull dereferenceable(16) "enzyme_inactive" "enzyme_type"="{[-1]:Pointer, [-1,-1]:Integer}" {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task1.i, i64 noundef 16, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133702113960800 to {}*) to {} addrspace(10)*)) #13, !dbg !34: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %newstruct3.i.sroa.4.0..sroa_cast = bitcast i8 addrspace(10)* %newstruct3.i.sroa.4.0..sroa_idx to i64 addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %6 = bitcast {}*** %ptls_field.i50 to i64***: {[-1]:Pointer, [-1,0]:Pointer}, intvals: {}
  %newstruct7.i.sroa.6.sroa.0.0.newstruct7.i.sroa.6.0..sroa_raw_idx14.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %18, i64 16, !dbg !52: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Float@double, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Float@double}, intvals: {}
  %23 = call nonnull "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)*, {} addrspace(10)*, ...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* noundef nonnull @ijl_apply_generic, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 133702174980784 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull %19, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 133701604737760 to {}*) to {} addrspace(10)*), {} addrspace(10)* nofree nonnull %box16.i, {} addrspace(10)* nofree nonnull %box18.i, {} addrspace(10)* nonnull %22) #18, !dbg !34: {[-1]:Pointer, [-1,0]:Pointer, [-1,8]:Pointer, [-1,16]:Pointer, [-1,32]:Pointer}, intvals: {}
  %13 = bitcast {} addrspace(10)* %box.i to double addrspace(10)*, !dbg !34: {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
  %newstruct7.i.sroa.7.sroa.5.0.newstruct7.i.sroa.7.0..sroa_raw_idx.sroa_idx = getelementptr inbounds i8, i8 addrspace(10)* %14, i64 40, !dbg !34: {[-1]:Pointer, [-1,0]:Float@double}, intvals: {}
</analysis>

Cannot deduce type of copy   call void @llvm.memcpy.p10i8.p0i8.i64(i8 addrspace(10)* nocapture nofree noundef writeonly align 1 dereferenceable(7) %newstruct7.i.sroa.5.0..sroa_raw_idx, i8* noundef nonnull readonly align 1 dereferenceable(7) %newstruct7.i.sroa.5.0.sroa_idx27, i64 noundef 7, i1 noundef false) #12, !dbg !34, !tbaa !49, !alias.scope !50, !noalias !51

Caused by:
Stacktrace:
 [1] #make_sim#1
   @ ~/WaterLily.jl-Examples/test.jl:19
 [2] #make_sim#1
   @ ~/WaterLily.jl-Examples/test.jl:0
within MethodInstance for var"#make_sim#1"(::Int64, ::Int64, ::Int64, ::Type{Array}, ::typeof(make_sim), ::Float64)


Stacktrace:
  [1] throwerr(cstr::Cstring)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/Pljwm/src/compiler.jl:1678
  [2] #make_sim#1
    @ ~/WaterLily.jl-Examples/test.jl:19 [inlined]
  [3] fwddiffejulia__make_sim_1_6187_inner_1wrap
    @ ~/WaterLily.jl-Examples/test.jl:0
  [4] macro expansion
    @ ~/.julia/packages/Enzyme/Pljwm/src/compiler.jl:6630 [inlined]
  [5] enzyme_call(::Val{false}, ::Ptr{Nothing}, ::Type{Enzyme.Compiler.ForwardModeThunk{Ptr{Nothing}, Const{var"##make_sim#1"}, Duplicated{Simulation}, Tuple{Const{Int64}, Const{Int64}, Const{Int64}, Const{Type{Array}}, Const{typeof(make_sim)}, Duplicated{Float64}}, 1, true}}, ::Val{1}, ::Val{true}, ::Type{Tuple{Const{Int64}, Const{Int64}, Const{Int64}, Const{Type{Array}}, Const{typeof(make_sim)}, Duplicated{Float64}}}, ::Type{Duplicated{Simulation}}, ::Const{var"##make_sim#1"}, ::Type{Nothing}, ::Const{Int64}, ::Const{Int64}, ::Const{Int64}, ::Const{Type{Array}}, ::Const{typeof(make_sim)}, ::Duplicated{Float64})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/Pljwm/src/compiler.jl:6231
  [6] (::Enzyme.Compiler.ForwardModeThunk{Ptr{Nothing}, Const{var"##make_sim#1"}, Duplicated{Simulation}, Tuple{Const{Int64}, Const{Int64}, Const{Int64}, Const{Type{Array}}, Const{typeof(make_sim)}, Duplicated{Float64}}, 1, true})(::Const{var"##make_sim#1"}, ::Const{Int64}, ::Vararg{Any})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/Pljwm/src/compiler.jl:6111
  [7] runtime_generic_fwd(activity::Type{Val{(false, false, false, false, false, false, true)}}, width::Val{1}, RT::Val{@NamedTuple{1, 2}}, f::var"##make_sim#1", df::Nothing, primal_1::Int64, shadow_1_1::Nothing, primal_2::Int64, shadow_2_1::Nothing, primal_3::Int64, shadow_3_1::Nothing, primal_4::Type{Array}, shadow_4_1::Nothing, primal_5::typeof(make_sim), shadow_5_1::Nothing, primal_6::Float64, shadow_6_1::Float64)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/Pljwm/src/rules/jitrules.jl:210
  [8] make_sim
    @ ~/WaterLily.jl-Examples/test.jl:10 [inlined]
  [9] dsim
    @ ~/WaterLily.jl-Examples/test.jl:23 [inlined]
 [10] fwddiffejulia_dsim_2908wrap
    @ ~/WaterLily.jl-Examples/test.jl:0
 [11] macro expansion
    @ ~/.julia/packages/Enzyme/Pljwm/src/compiler.jl:6630 [inlined]
 [12] enzyme_call
    @ ~/.julia/packages/Enzyme/Pljwm/src/compiler.jl:6231 [inlined]
 [13] ForwardModeThunk
    @ ~/.julia/packages/Enzyme/Pljwm/src/compiler.jl:6111 [inlined]
 [14] autodiff
    @ ~/.julia/packages/Enzyme/Pljwm/src/Enzyme.jl:427 [inlined]
 [15] autodiff
    @ ~/.julia/packages/Enzyme/Pljwm/src/Enzyme.jl:326 [inlined]
 [16] main()
    @ Main ~/WaterLily.jl-Examples/test.jl:31
 [17] top-level scope
    @ ~/WaterLily.jl-Examples/test.jl:34
in expression starting at /home/b-fg/WaterLily.jl-Examples/test.jl:34

Any hint here would be greatly appreciated. Thanks!

@vchuravy
Copy link
Member

vchuravy commented Jul 15, 2024

You could try making your life a bit simpler and start with:

function dsim(sim, θ)
    sim_step!(sim)
    sum(sim.flow.p)
end

sim = make_sim(#...#)
Enzyme.autodiff(Forward, dsim, Duplicated, Duplicated(sim, Enzyme.make_zero(dsim)), Duplicated(θ, 1.0))

Edit:
Ah I missed the part where θ goes into the simulation, so this won't be helpful.

@wsmoses
Copy link
Member

wsmoses commented Jul 16, 2024

Not sure, but my guess is its the same copy as #1547

@vchuravy is this an issue re layout or something [see my fieldoffset log]

@b-fg
Copy link
Author

b-fg commented Jul 17, 2024

I was not aware of that issues, thanks for pointing it out. It could be related indeed, but I am not sure how to debug this in any case.

@vchuravy
Copy link
Member

Closed as duplicate

@vchuravy vchuravy closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants