RemoteSensingTools / vSmartMOM.jl

A full end-to-end modular software suite for radiative transfer and related atmospheric analysis
Apache License 2.0
43 stars 11 forks source link

Example in documentation fails with nested task error. #169

Closed deszoeke closed 6 months ago

deszoeke commented 9 months ago

To Reproduce

  1. Run example
  2. model_from_parameters call errors:

    
    julia> model = model_from_parameters(parameters)
    Computing profile for O2 with vmr 0.21 for band #1
    ERROR: TaskFailedException
    Stacktrace:
    [1] wait
    @ Base ./task.jl:352 [inlined]
    [2] wait
    @ KernelAbstractions ~/.julia/packages/KernelAbstractions/dy5oz/src/cpu.jl:65 [inlined]
    [3] wait(::KernelAbstractions.CPU, ev::KernelAbstractions.CPUEvent)
    @ KernelAbstractions ~/.julia/packages/KernelAbstractions/dy5oz/src/cpu.jl:64
    [4] compute_absorption_cross_section(model::vSmartMOM.Absorption.HitranModel, grid::Vector{…}, pressure::Float64, temperature::Float64; wavelength_flag::Bool)
    @ vSmartMOM.Absorption ~/.julia/packages/vSmartMOM/2Sx8l/src/Absorption/compute_absorption_cross_section.jl:116
    [5] compute_absorption_cross_section
    @ ~/.julia/packages/vSmartMOM/2Sx8l/src/Absorption/compute_absorption_cross_section.jl:19 [inlined]
    [6] absorption_cross_section(model::vSmartMOM.Absorption.HitranModel, grid::Vector{…}, pressure::Float64, temperature::Float64; autodiff::Bool, wavelength_flag::Bool)
    @ vSmartMOM.Absorption ~/.julia/packages/vSmartMOM/2Sx8l/src/Absorption/autodiff_helper.jl:50
    [7] absorption_cross_section
    @ ~/.julia/packages/vSmartMOM/2Sx8l/src/Absorption/autodiff_helper.jl:17 [inlined]
    [8] macro expansion
    @ ~/.julia/packages/vSmartMOM/2Sx8l/src/CoreRT/atmo_prof.jl:357 [inlined]
    [9] macro expansion
    @ ~/.julia/packages/ProgressMeter/vnCY0/src/ProgressMeter.jl:957 [inlined]
    [10] compute_absorption_profile!(τ_abs::Matrix{…}, absorption_model::vSmartMOM.Absorption.HitranModel, grid::Vector{…}, vmr::Float64, profile::vSmartMOM.CoreRT.AtmosphericProfile{…})
    @ vSmartMOM.CoreRT ~/.julia/packages/vSmartMOM/2Sx8l/src/CoreRT/atmo_prof.jl:346
    [11] macro expansion
    @ ~/.julia/packages/TimerOutputs/RsWnF/src/TimerOutput.jl:237 [inlined]
    [12] model_from_parameters(params::vSmartMOM.CoreRT.vSmartMOM_Parameters{Float64})
    @ vSmartMOM.CoreRT ~/.julia/packages/vSmartMOM/2Sx8l/src/CoreRT/model_from_parameters.jl:75
    [13] top-level scope
    @ REPL[13]:1
    [14] top-level scope
    @ ~/.julia/packages/CUDA/BbliS/src/initialization.jl:52
    
    nested task error: The function body AST defined by this @generated function is not pure. This likely means it contains a closure, a comprehension or a generator.
    Stacktrace:
     [1] __thread_run(tid::Int64, len::Int64, rem::Int64, obj::KernelAbstractions.Kernel{…}, ndrange::Tuple{…}, iterspace::KernelAbstractions.NDIteration.NDRange{…}, args::Tuple{…}, dynamic::KernelAbstractions.NDIteration.DynamicCheck)
       @ KernelAbstractions ~/.julia/packages/KernelAbstractions/dy5oz/src/cpu.jl:157
     [2] __run(obj::KernelAbstractions.Kernel{…}, ndrange::Tuple{…}, iterspace::KernelAbstractions.NDIteration.NDRange{…}, args::Tuple{…}, dynamic::KernelAbstractions.NDIteration.DynamicCheck)
       @ KernelAbstractions ~/.julia/packages/KernelAbstractions/dy5oz/src/cpu.jl:130
     [3] (::KernelAbstractions.var"#37#38"{Nothing, Nothing, typeof(KernelAbstractions.__run), Tuple{…}})()
       @ KernelAbstractions ~/.julia/packages/KernelAbstractions/dy5oz/src/cpu.jl:22
    Some type information was truncated. Use `show(err)` to see complete types.

julia> show(err) 1-element ExceptionStack: TaskFailedException Stacktrace: [1] wait @ Base ./task.jl:352 [inlined] [2] wait @ KernelAbstractions ~/.julia/packages/KernelAbstractions/dy5oz/src/cpu.jl:65 [inlined] [3] wait(::KernelAbstractions.CPU, ev::KernelAbstractions.CPUEvent) @ KernelAbstractions ~/.julia/packages/KernelAbstractions/dy5oz/src/cpu.jl:64 [4] compute_absorption_cross_section(model::vSmartMOM.Absorption.HitranModel, grid::Vector{Float64}, pressure::Float64, temperature::Float64; wavelength_flag::Bool) @ vSmartMOM.Absorption ~/.julia/packages/vSmartMOM/2Sx8l/src/Absorption/compute_absorption_cross_section.jl:116 [5] compute_absorption_cross_section @ ~/.julia/packages/vSmartMOM/2Sx8l/src/Absorption/compute_absorption_cross_section.jl:19 [inlined] [6] absorption_cross_section(model::vSmartMOM.Absorption.HitranModel, grid::Vector{Float64}, pressure::Float64, temperature::Float64; autodiff::Bool, wavelength_flag::Bool) @ vSmartMOM.Absorption ~/.julia/packages/vSmartMOM/2Sx8l/src/Absorption/autodiff_helper.jl:50 [7] absorption_cross_section @ ~/.julia/packages/vSmartMOM/2Sx8l/src/Absorption/autodiff_helper.jl:17 [inlined] [8] macro expansion @ ~/.julia/packages/vSmartMOM/2Sx8l/src/CoreRT/atmo_prof.jl:357 [inlined] [9] macro expansion @ ~/.julia/packages/ProgressMeter/vnCY0/src/ProgressMeter.jl:957 [inlined] [10] compute_absorption_profile!(τ_abs::Matrix{Float64}, absorption_model::vSmartMOM.Absorption.HitranModel, grid::Vector{Float64}, vmr::Float64, profile::vSmartMOM.CoreRT.AtmosphericProfile{Float64, Union{Real, Vector}}) @ vSmartMOM.CoreRT ~/.julia/packages/vSmartMOM/2Sx8l/src/CoreRT/atmo_prof.jl:346 [11] macro expansion @ ~/.julia/packages/TimerOutputs/RsWnF/src/TimerOutput.jl:237 [inlined] [12] model_from_parameters(params::vSmartMOM.CoreRT.vSmartMOM_Parameters{Float64}) @ vSmartMOM.CoreRT ~/.julia/packages/vSmartMOM/2Sx8l/src/CoreRT/model_from_parameters.jl:75 [13] top-level scope @ REPL[13]:1 [14] top-level scope @ ~/.julia/packages/CUDA/BbliS/src/initialization.jl:52

nested task error: The function body AST defined by this @generated function is not pure. This likely means it contains a closure, a comprehension or a generator.
Stacktrace:
 [1] __thread_run(tid::Int64, len::Int64, rem::Int64, obj::KernelAbstractions.Kernel{KernelAbstractions.CPU, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, typeof(vSmartMOM.Absorption.cpu_line_shape!)}, ndrange::Tuple{Int64}, iterspace::KernelAbstractions.NDIteration.NDRange{1, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}}, args::Tuple{SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}, Vector{Float64}, Float64, Float64, Float64, Float64, Float64, vSmartMOM.Absorption.Voigt, vSmartMOM.Absorption.HumlicekWeidemann32SDErrorFunction}, dynamic::KernelAbstractions.NDIteration.DynamicCheck)
   @ KernelAbstractions ~/.julia/packages/KernelAbstractions/dy5oz/src/cpu.jl:157
 [2] __run(obj::KernelAbstractions.Kernel{KernelAbstractions.CPU, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, typeof(vSmartMOM.Absorption.cpu_line_shape!)}, ndrange::Tuple{Int64}, iterspace::KernelAbstractions.NDIteration.NDRange{1, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}}, args::Tuple{SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}, Vector{Float64}, Float64, Float64, Float64, Float64, Float64, vSmartMOM.Absorption.Voigt, vSmartMOM.Absorption.HumlicekWeidemann32SDErrorFunction}, dynamic::KernelAbstractions.NDIteration.DynamicCheck)
   @ KernelAbstractions ~/.julia/packages/KernelAbstractions/dy5oz/src/cpu.jl:130
 [3] (::KernelAbstractions.var"#37#38"{Nothing, Nothing, typeof(KernelAbstractions.__run), Tuple{KernelAbstractions.Kernel{KernelAbstractions.CPU, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, typeof(vSmartMOM.Absorption.cpu_line_shape!)}, Tuple{Int64}, KernelAbstractions.NDIteration.NDRange{1, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}}, Tuple{SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}, Vector{Float64}, Float64, Float64, Float64, Float64, Float64, vSmartMOM.Absorption.Voigt, vSmartMOM.Absorption.HumlicekWeidemann32SDErrorFunction}, KernelAbstractions.NDIteration.DynamicCheck}})()
   @ KernelAbstractions ~/.julia/packages/KernelAbstractions/dy5oz/src/cpu.jl:22


**Expected behavior**
Generate a `model` structure.

**Desktop architecture**
 - MacBook-Pro arm64
 - OS: MacOS Darwin 23.2.0
 - Julia v1.10.0
deszoeke commented 9 months ago

The example works in julia 1.9.4. I'm not sure what the breaking change is in 1.10. Perhaps the new parser?

cfranken commented 6 months ago

Am trying to fix this now as it happens with Juliaup

cfranken commented 6 months ago

This should work now