Skip to content

ContinuousForcing not compiling on GPU with hydrostatic model on a lat-lon grid #4165

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

Open
ali-ramadhan opened this issue Mar 5, 2025 · 18 comments
Labels
bug 🐞 Even a perfect program still has bugs

Comments

@ali-ramadhan
Copy link
Member

Seems that even simple ContinuousForcing functions don't want to compile on the GPU.

I haven't been able to debug why this is happening but I first encountered this issue a few months ago so it's been around for some time. I couldn't really figure out what ijl_get_nth_field_checked does as there are very few results online.

It's not the most urgent issue since DiscreteForcing is an option and it works. But would be nice to use ContinuousForcing so I'm opening this issue in case anyone has any ideas on what's going on.

MWE:

using Oceananigans

grid = LatitudeLongitudeGrid(GPU();
    topology = (Bounded, Bounded, Bounded),
    size = (10, 10, 10),
    longitude = (0, 10),
    latitude = (-5, 5),
    z = (-100, 0)
)

@inline relax(x, y, z, t, u, p) = - p.rate * (u - p.u★)

params = (
    rate = 1.0,
    u★ = 0.0
)

u_forcing = Forcing(relax; parameters=params, field_dependencies=:u)

forcing = (;
    u = u_forcing
)

model = HydrostaticFreeSurfaceModel(; grid, forcing)

simulation = Simulation(model, Δt=0.01, stop_iteration=1)

run!(simulation)

Error:

ERROR: LoadError: InvalidIRError: compiling MethodInstance for Oceananigans.Models.HydrostaticFreeSurfaceModels.gpu_compute_hydrostatic_free_surface_Gu!(::KernelAbstractions.CompilerMetadata{…}, ::OffsetArrays.OffsetArray{…}, ::LatitudeLongitudeGrid{…}, ::Nothing, ::Tuple{…}) resulted in invalid LLVM IR
Reason: unsupported call to an unknown function (call to ijl_get_nth_field_checked)
Stacktrace:
 [1] getindex
   @ ./namedtuple.jl:167
 [2] field_arguments
   @ ~/.julia/packages/Oceananigans/wwTjd/src/Utils/user_function_arguments.jl:1
 [3] user_function_arguments
   @ ~/.julia/packages/Oceananigans/wwTjd/src/Utils/user_function_arguments.jl:31
 [4] ContinuousForcing
   @ ~/.julia/packages/Oceananigans/wwTjd/src/Forcings/continuous_forcing.jl:137
 [5] hydrostatic_free_surface_u_velocity_tendency
   @ ~/.julia/packages/Oceananigans/wwTjd/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl:47
 [6] gpu_compute_hydrostatic_free_surface_Gu!
   @ ~/.julia/packages/KernelAbstractions/sWSE0/src/macros.jl:322
 [7] gpu_compute_hydrostatic_free_surface_Gu!
   @ ./none:0
Hint: catch this exception as `err` and call `code_typed(err; interactive = true)` to introspect the erronous code with Cthulhu.jl
Stacktrace:
  [1] check_ir(job::GPUCompiler.CompilerJob{GPUCompiler.PTXCompilerTarget, CUDA.CUDACompilerParams}, args::LLVM.Module)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/validation.jl:167
  [2] macro expansion
    @ ~/.julia/packages/GPUCompiler/OGnEB/src/driver.jl:381 [inlined]
  [3] emit_llvm(job::GPUCompiler.CompilerJob; toplevel::Bool, libraries::Bool, optimize::Bool, cleanup::Bool, validate::Bool, only_entry::Bool)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/utils.jl:110
  [4] emit_llvm
    @ ~/.julia/packages/GPUCompiler/OGnEB/src/utils.jl:108 [inlined]
  [5] 
    @ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/driver.jl:100
  [6] codegen
    @ ~/.julia/packages/GPUCompiler/OGnEB/src/driver.jl:82 [inlined]
  [7] compile(target::Symbol, job::GPUCompiler.CompilerJob; kwargs::@Kwargs{})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/driver.jl:79
  [8] compile
    @ ~/.julia/packages/GPUCompiler/OGnEB/src/driver.jl:74 [inlined]
  [9] #1147
    @ ~/.julia/packages/CUDA/1kIOw/src/compiler/compilation.jl:250 [inlined]
 [10] JuliaContext(f::CUDA.var"#1147#1150"{GPUCompiler.CompilerJob{GPUCompiler.PTXCompilerTarget, CUDA.CUDACompilerParams}}; kwargs::@Kwargs{})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/driver.jl:34
 [11] JuliaContext(f::Function)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/driver.jl:25
 [12] compile(job::GPUCompiler.CompilerJob)
    @ CUDA ~/.julia/packages/CUDA/1kIOw/src/compiler/compilation.jl:249
 [13] actual_compilation(cache::Dict{…}, src::Core.MethodInstance, world::UInt64, cfg::GPUCompiler.CompilerConfig{…}, compiler::typeof(CUDA.compile), linker::typeof(CUDA.link))
    @ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/execution.jl:237
 [14] cached_compilation(cache::Dict{…}, src::Core.MethodInstance, cfg::GPUCompiler.CompilerConfig{…}, compiler::Function, linker::Function)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/OGnEB/src/execution.jl:151
 [15] macro expansion
    @ ~/.julia/packages/CUDA/1kIOw/src/compiler/execution.jl:380 [inlined]
 [16] macro expansion
    @ ./lock.jl:267 [inlined]
 [17] cufunction(f::typeof(Oceananigans.Models.HydrostaticFreeSurfaceModels.gpu_compute_hydrostatic_free_surface_Gu!), tt::Type{…}; kwargs::@Kwargs{…})
    @ CUDA ~/.julia/packages/CUDA/1kIOw/src/compiler/execution.jl:375
 [18] macro expansion
    @ ~/.julia/packages/CUDA/1kIOw/src/compiler/execution.jl:112 [inlined]
 [19] (::KernelAbstractions.Kernel{…})(::Field{…}, ::Vararg{…}; ndrange::Nothing, workgroupsize::Nothing)
    @ CUDA.CUDAKernels ~/.julia/packages/CUDA/1kIOw/src/CUDAKernels.jl:103
 [20] (::KernelAbstractions.Kernel{…})(::Field{…}, ::Vararg{…})
    @ CUDA.CUDAKernels ~/.julia/packages/CUDA/1kIOw/src/CUDAKernels.jl:89
 [21] _launch!(::GPU{…}, ::LatitudeLongitudeGrid{…}, ::Symbol, ::Function, ::Field{…}, ::LatitudeLongitudeGrid{…}, ::Vararg{…}; exclude_periphery::Bool, reduced_dimensions::Tuple{}, active_cells_map::Nothing)
    @ Oceananigans.Utils ~/.julia/packages/Oceananigans/wwTjd/src/Utils/kernel_launching.jl:298
 [22] _launch!
    @ ~/.julia/packages/Oceananigans/wwTjd/src/Utils/kernel_launching.jl:275 [inlined]
 [23] launch!
    @ ~/.julia/packages/Oceananigans/wwTjd/src/Utils/kernel_launching.jl:258 [inlined]
 [24] compute_hydrostatic_momentum_tendencies!(model::HydrostaticFreeSurfaceModel{…}, velocities::@NamedTuple{…}, kernel_parameters::Symbol; active_cells_map::Nothing)
    @ Oceananigans.Models.HydrostaticFreeSurfaceModels ~/.julia/packages/Oceananigans/wwTjd/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl:149
 [25] compute_hydrostatic_momentum_tendencies!
    @ ~/.julia/packages/Oceananigans/wwTjd/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl:121 [inlined]
 [26] #compute_hydrostatic_free_surface_tendency_contributions!#30
    @ ~/.julia/packages/Oceananigans/wwTjd/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl:73 [inlined]
 [27] compute_hydrostatic_free_surface_tendency_contributions!
    @ ~/.julia/packages/Oceananigans/wwTjd/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl:68 [inlined]
 [28] compute_tendencies!(model::HydrostaticFreeSurfaceModel{…}, callbacks::Vector{…})
    @ Oceananigans.Models.HydrostaticFreeSurfaceModels ~/.julia/packages/Oceananigans/wwTjd/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl:33
 [29] #apply_regionally!#56
    @ ~/.julia/packages/Oceananigans/wwTjd/src/Utils/multi_region_transformation.jl:121 [inlined]
 [30] apply_regionally!
    @ ~/.julia/packages/Oceananigans/wwTjd/src/Utils/multi_region_transformation.jl:118 [inlined]
 [31] macro expansion
    @ ~/.julia/packages/Oceananigans/wwTjd/src/Utils/multi_region_transformation.jl:206 [inlined]
 [32] update_state!(model::HydrostaticFreeSurfaceModel{…}, grid::LatitudeLongitudeGrid{…}, callbacks::Vector{…}; compute_tendencies::Bool)
    @ Oceananigans.Models.HydrostaticFreeSurfaceModels ~/.julia/packages/Oceananigans/wwTjd/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl:53
 [33] update_state!
    @ ~/.julia/packages/Oceananigans/wwTjd/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl:32 [inlined]
 [34] update_state! (repeats 2 times)
    @ ~/.julia/packages/Oceananigans/wwTjd/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl:29 [inlined]
 [35] initialize!(sim::Simulation{…})
    @ Oceananigans.Simulations ~/.julia/packages/Oceananigans/wwTjd/src/Simulations/run.jl:211
 [36] time_step!(sim::Simulation{…})
    @ Oceananigans.Simulations ~/.julia/packages/Oceananigans/wwTjd/src/Simulations/run.jl:138
 [37] run!(sim::Simulation{…}; pickup::Bool)
    @ Oceananigans.Simulations ~/.julia/packages/Oceananigans/wwTjd/src/Simulations/run.jl:104
 [38] run!(sim::Simulation{…})
    @ Oceananigans.Simulations ~/.julia/packages/Oceananigans/wwTjd/src/Simulations/run.jl:91
 [39] top-level scope
    @ ~/debug_gpu_continuous_sponge.jl:28
 [40] include(fname::String)
    @ Base.MainInclude ./client.jl:494
 [41] top-level scope
    @ REPL[1]:1
in expression starting at /home/alir/debug_gpu_continuous_sponge.jl:28
Some type information was truncated. Use `show(err)` to see complete types.


Environment: Oceananigans v0.95.17 with

julia> versioninfo()
Julia Version 1.10.8
Commit 4c16ff44be8 (2025-01-22 10:06 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 48 × AMD Ryzen Threadripper 7960X 24-Cores
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 16 default, 0 interactive, 8 GC (on 48 virtual cores)
Environment:
  LD_PRELOAD = /usr/NX/lib/libnxegl.so
julia> CUDA.versioninfo()
CUDA runtime 12.6, artifact installation
CUDA driver 12.8
NVIDIA driver 570.86.16

CUDA libraries: 
- CUBLAS: 12.6.4
- CURAND: 10.3.7
- CUFFT: 11.3.0
- CUSOLVER: 11.7.1
- CUSPARSE: 12.5.4
- CUPTI: 2024.3.2 (API 24.0.0)
- NVML: 12.0.0+570.86.16

Julia packages: 
- CUDA: 5.6.1
- CUDA_Driver_jll: 0.10.4+0
- CUDA_Runtime_jll: 0.15.5+0

Toolchain:
- Julia: 1.10.8
- LLVM: 15.0.7

1 device:
  0: NVIDIA GeForce RTX 4090 (sm_89, 19.706 GiB / 23.988 GiB available)
@ali-ramadhan ali-ramadhan added the bug 🐞 Even a perfect program still has bugs label Mar 5, 2025
@ali-ramadhan
Copy link
Member Author

And confirming that the rectilinear + non-hydrostatic case works fine and does not error:

using Oceananigans

grid = RectilinearGrid(GPU();
    topology = (Bounded, Bounded, Bounded),
    size = (10, 10, 10),
    x = (0, 10),
    y = (-5, 5),
    z = (-100, 0)
)

@inline relax(x, y, z, t, u, p) = - p.rate * (u - p.u★)

params = (
    rate = 1.0,
    u★ = 0.0
)

u_forcing = Forcing(relax; parameters=params, field_dependencies=:u)

forcing = (;
    u = u_forcing
)

model = NonhydrostaticModel(; grid, forcing)

simulation = Simulation(model, Δt=0.01, stop_iteration=1)

run!(simulation)

@ali-ramadhan
Copy link
Member Author

Also confirming that rectilinear + hydrostatic case works fine and does not error:

using Oceananigans

grid = RectilinearGrid(GPU();
    topology = (Bounded, Bounded, Bounded),
    size = (10, 10, 10),
    x = (0, 10),
    y = (-5, 5),
    z = (-100, 0)
)

@inline relax(x, y, z, t, u, p) = - p.rate * (u - p.u★)

params = (
    rate = 1.0,
    u★ = 0.0
)

u_forcing = Forcing(relax; parameters=params, field_dependencies=:u)

forcing = (;
    u = u_forcing
)

model = HydrostaticFreeSurfaceModel(; grid, forcing)

simulation = Simulation(model, Δt=0.01, stop_iteration=1)

run!(simulation)

@ali-ramadhan
Copy link
Member Author

Hmmm, I wonder if it has anything to do with field_dependencies not being adapted to the GPU, but I don't see it being used anywhere in the stack trace. And I'm not sure if it can be adapted because it contains Symbols.

Adapt.adapt_structure(to, forcing::ContinuousForcing{LX, LY, LZ}) where {LX, LY, LZ} =
ContinuousForcing{LX, LY, LZ}(Adapt.adapt(to, forcing.func),
Adapt.adapt(to, forcing.parameters),
nothing,
Adapt.adapt(to, forcing.field_dependencies_indices),
Adapt.adapt(to, forcing.field_dependencies_interp))

@simone-silvestri
Copy link
Collaborator

The problem is fixed in #4008. Sorry that PR has been taking quite some time because the tests do not want to pass

@simone-silvestri
Copy link
Collaborator

But I wonder actually now that I see that you are trying to use u as a field dependency (which should work regardless), if this bug is another bug which is exactly why I am not able to merge #4008

@glwagner
Copy link
Member

glwagner commented Mar 5, 2025

Hmmm, I wonder if it has anything to do with field_dependencies not being adapted to the GPU, but I don't see it being used anywhere in the stack trace. And I'm not sure if it can be adapted because it contains Symbols.

Oceananigans.jl/src/Forcings/continuous_forcing.jl

Lines 158 to 163 in 7afb057

Adapt.adapt_structure(to, forcing::ContinuousForcing{LX, LY, LZ}) where {LX, LY, LZ} =
ContinuousForcing{LX, LY, LZ}(Adapt.adapt(to, forcing.func),
Adapt.adapt(to, forcing.parameters),
nothing,
Adapt.adapt(to, forcing.field_dependencies_indices),
Adapt.adapt(to, forcing.field_dependencies_interp))

This seems like a type inference problem.

As for field_dependencies, that's right it cannot be used on GPU. This is why ContinuousForcing goes through the rigamarole of deducing the "indices" of the field dependencies (within model_fields), using the regularize_* in the model constructor.

One thing I'm not sure is why LX, LY, LZ are needed in adapt. The more we throw away I think the easier type inference gets?

@glwagner
Copy link
Member

glwagner commented Mar 5, 2025

Does ContinuousForcing work on RectilinearGrid and hydrostatic? The fact that it would be specific to lat-lon points clearly to a compile heuristic of some kind.

@glwagner
Copy link
Member

glwagner commented Mar 5, 2025

Might be worth getting rid of the splatting here:

return forcing.func(X..., clock.time, args...)

we've had trouble with that before.

@ali-ramadhan
Copy link
Member Author

Does ContinuousForcing work on RectilinearGrid and hydrostatic? The fact that it would be specific to lat-lon points clearly to a compile heuristic of some kind.

Yes! I agree it feels like something weird is happening with the LatitudeLongitudeGrid...

@ali-ramadhan
Copy link
Member Author

Thanks for the suggestions @simone-silvestri and @glwagner! I'll try them and see if I can get the MWE to compile.

@ali-ramadhan
Copy link
Member Author

@simone-silvestri Just confirming that the MWE from this issue still produces the same error on PR #4008 so it might be a different cause :(

@ali-ramadhan
Copy link
Member Author

Hmmm, this didn't help unfortunately but will try a few more tricks to help ease type inference.

diff --git a/src/Forcings/continuous_forcing.jl b/src/Forcings/continuous_forcing.jl
index 388ed3958..c6c14188e 100644
--- a/src/Forcings/continuous_forcing.jl
+++ b/src/Forcings/continuous_forcing.jl
@@ -136,9 +136,9 @@ end
 
     args = user_function_arguments(i, j, k, grid, model_fields, forcing.parameters, forcing)
 
-    X = node(i, j, k, grid, LX(), LY(), LZ())
+    x, y, z = node(i, j, k, grid, LX(), LY(), LZ())
 
-    return forcing.func(X..., clock.time, args...)
+    return forcing.func(x, y, z, clock.time, args...)
 end
 
 """Show the innards of a `ContinuousForcing` in the REPL."""
@@ -155,12 +155,12 @@ Base.show(io::IO, forcing::ContinuousForcing{Nothing, Nothing, Nothing, P}) wher
         "├── parameters: $(forcing.parameters)", "\n",
         "└── field dependencies: $(forcing.field_dependencies)")
 
-Adapt.adapt_structure(to, forcing::ContinuousForcing{LX, LY, LZ}) where {LX, LY, LZ} =
-    ContinuousForcing{LX, LY, LZ}(Adapt.adapt(to, forcing.func),
-                                  Adapt.adapt(to, forcing.parameters),
-                                  nothing,
-                                  Adapt.adapt(to, forcing.field_dependencies_indices),
-                                  Adapt.adapt(to, forcing.field_dependencies_interp))
+Adapt.adapt_structure(to, forcing::ContinuousForcing)=
+    ContinuousForcing{Nothing, Nothing, Nothing}(Adapt.adapt(to, forcing.func),
+                                                 Adapt.adapt(to, forcing.parameters),
+                                                 nothing,
+                                                 Adapt.adapt(to, forcing.field_dependencies_indices),
+                                                 Adapt.adapt(to, forcing.field_dependencies_interp))
 
 on_architecture(to, forcing::ContinuousForcing{LX, LY, LZ}) where {LX, LY, LZ} =
     ContinuousForcing{LX, LY, LZ}(on_architecture(to, forcing.func),
@@ -168,4 +168,3 @@ on_architecture(to, forcing::ContinuousForcing{LX, LY, LZ}) where {LX, LY, LZ} =
                                   on_architecture(to, forcing.field_dependencies),
                                   on_architecture(to, forcing.field_dependencies_indices),
                                   on_architecture(to, forcing.field_dependencies_interp))

@ali-ramadhan
Copy link
Member Author

No luck with ]add CUDA#master and ] add GPUCompilers#master.

@darosaj
Copy link

darosaj commented Mar 10, 2025

Hi, I'm new to Oceananigans and Julia, so I'm not sure if this is the same issue.

However, I also have issues when trying to compile continuous forcing functions on the GPU.

In addition to the LatitudeLongitudeGrid issue you mention, I also cannot compile when having an ImmersedBoundaryGrid on the RectilinearGrid.

Specifically, when I try to have forcing included with u, or v as field_dependencies I get that same error.

When using a different Forcing, (such as a tidal forcing) that doesn't have a field dependency, I don't get any error.
Or if I don't have an immersed boundary, I also do not get any error.

I'm using Oceananigans v0.95.20.

Here is my Script:

using Oceananigans
using Oceananigans.Units
using Oceananigans.Units: minute, minutes, hour
using Printf

bot = 10meters
architecture = GPU() 

underlying_grid = RectilinearGrid(architecture, topology = (Bounded, Bounded, Bounded),
                       size = (10, 10, 10),
                       x = (-5meters, 5meters),
                       y = (-5meters, 5meters),
                       z = (-bot, 0)) 


# Create a 2D bottom height function depending on both x and y
bottom(x, y) = -bot + 2 

grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom))
#grid = underlying_grid


"""
Tidal Forcing / Internal forcing input
"""
coriolis = FPlane(f=1e-4)

T₂ = 12.421hours

ω₂ = 2π / T₂ # radians/sec

U_tidal = 0.1 

tidal_forcing_amplitude = U_tidal * (ω₂^2 - coriolis.f^2) / ω₂

@inline tidal_forcing(x, y, z, t, p) = p.tidal_forcing_amplitude * sin(p.ω₂ * t)

u_tidal_forcing = Forcing(tidal_forcing, parameters=(; tidal_forcing_amplitude, ω₂))


"""
Relaxation forcing
"""

@inline relax_u(x, y, z, t, u, p) = - p.rate * (u - p.u★)
u_params = (
    rate = 1.0,
    u★ = 0.0
)

u_sponge_forcing = Forcing(relax_u; parameters=u_params, field_dependencies=:u)

u_forcing = u_sponge_forcing #u_tidal_forcing #u_sponge_forcing

model = HydrostaticFreeSurfaceModel(; grid,
                            forcing = (; u = u_forcing))


simulation = Simulation(model, Δt=0.01, stop_iteration=1)

run!(simulation)

And Here is my Error:

ERROR: InvalidIRError: compiling MethodInstance for Oceananigans.Models.HydrostaticFreeSurfaceModels.gpu_compute_hydrostatic_free_surface_Gu!(::KernelAbstractions.CompilerMetadata{…}, ::OffsetArrays.OffsetArray{…}, ::ImmersedBoundaryGrid{…}, ::Nothing, ::Tuple{…}) resulted in invalid LLVM IR
Reason: unsupported call to an unknown function (call to ijl_get_nth_field_checked)
Stacktrace:

@ali-ramadhan
Copy link
Member Author

Hey @darosaj! If you can share the full error stacktrace we can confirm but it seems like the same error.

Unfortunately I don't know how to fix this issue yet, but the fully working alternative is to use DiscreteForcing instead.

@darosaj
Copy link

darosaj commented Mar 10, 2025

Hi @ali-ramadhan, thank you for the help!

I'll use the discrete forcing in the meantime.

This is the full error trace:

ERROR: InvalidIRError: compiling MethodInstance for Oceananigans.Models.HydrostaticFreeSurfaceModels.gpu_compute_hydrostatic_free_surface_Gu!(::KernelAbstractions.CompilerMetadata{…}, ::OffsetArrays.OffsetArray{…}, ::ImmersedBoundaryGrid{…}, ::Nothing, ::Tuple{…}) resulted in invalid LLVM IR
Reason: unsupported call to an unknown function (call to ijl_get_nth_field_checked)
Stacktrace:
 [1] getindex
   @ .\namedtuple.jl:167
 [2] field_arguments
   @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Utils\user_function_arguments.jl:1
 [3] user_function_arguments
   @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Utils\user_function_arguments.jl:31
 [4] ContinuousForcing
   @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Forcings\continuous_forcing.jl:137
 [5] hydrostatic_free_surface_u_velocity_tendency
   @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Models\HydrostaticFreeSurfaceModels\hydrostatic_free_surface_tendency_kernel_functions.jl:47
 [6] gpu_compute_hydrostatic_free_surface_Gu!
   @ C:\Users\JDAROSA\.julia\packages\KernelAbstractions\sWSE0\src\macros.jl:322
 [7] gpu_compute_hydrostatic_free_surface_Gu!
   @ .\none:0
Hint: catch this exception as `err` and call `code_typed(err; interactive = true)` to introspect the erronous code with Cthulhu.jl
Stacktrace:
  [1] check_ir(job::GPUCompiler.CompilerJob{GPUCompiler.PTXCompilerTarget, CUDA.CUDACompilerParams}, args::LLVM.Module)
    @ GPUCompiler C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\validation.jl:167
  [2] macro expansion
    @ C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\driver.jl:381 [inlined]
  [3]
    @ GPUCompiler C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\utils.jl:110
  [4] emit_llvm
    @ C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\utils.jl:108 [inlined]
  [5]
    @ GPUCompiler C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\driver.jl:100
  [6] codegen
    @ C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\driver.jl:82 [inlined]
  [7] compile(target::Symbol, job::GPUCompiler.CompilerJob; kwargs::@Kwargs{})
    @ GPUCompiler C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\driver.jl:79
  [8] compile
    @ C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\driver.jl:74 [inlined]
  [9] #1147
    @ C:\Users\JDAROSA\.julia\packages\CUDA\1kIOw\src\compiler\compilation.jl:250 [inlined]
 [10] JuliaContext(f::CUDA.var"#1147#1150"{GPUCompiler.CompilerJob{…}}; kwargs::@Kwargs{})
    @ GPUCompiler C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\driver.jl:34
 [11] JuliaContext(f::Function)
    @ GPUCompiler C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\driver.jl:25
 [12] compile(job::GPUCompiler.CompilerJob)
    @ CUDA C:\Users\JDAROSA\.julia\packages\CUDA\1kIOw\src\compiler\compilation.jl:249
 [13] actual_compilation(cache::Dict{…}, src::Core.MethodInstance, world::UInt64, cfg::GPUCompiler.CompilerConfig{…}, compiler::typeof(CUDA.compile), linker::typeof(CUDA.link))
    @ GPUCompiler C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\execution.jl:237
 [14] cached_compilation(cache::Dict{…}, src::Core.MethodInstance, cfg::GPUCompiler.CompilerConfig{…}, compiler::Function, linker::Function)
    @ GPUCompiler C:\Users\JDAROSA\.julia\packages\GPUCompiler\OGnEB\src\execution.jl:151
 [15] macro expansion
    @ C:\Users\JDAROSA\.julia\packages\CUDA\1kIOw\src\compiler\execution.jl:380 [inlined]
 [16] macro expansion
    @ .\lock.jl:267 [inlined]
 [17] cufunction(f::typeof(Oceananigans.Models.HydrostaticFreeSurfaceModels.gpu_compute_hydrostatic_free_surface_Gu!), tt::Type{…}; kwargs::@Kwargs{…})
    @ CUDA C:\Users\JDAROSA\.julia\packages\CUDA\1kIOw\src\compiler\execution.jl:375
 [18] macro expansion
    @ C:\Users\JDAROSA\.julia\packages\CUDA\1kIOw\src\compiler\execution.jl:112 [inlined]
 [19] (::KernelAbstractions.Kernel{…})(::Field{…}, ::Vararg{…}; ndrange::Nothing, workgroupsize::Nothing) 
    @ CUDA.CUDAKernels C:\Users\JDAROSA\.julia\packages\CUDA\1kIOw\src\CUDAKernels.jl:103
 [20] (::KernelAbstractions.Kernel{…})(::Field{…}, ::Vararg{…})
    @ CUDA.CUDAKernels C:\Users\JDAROSA\.julia\packages\CUDA\1kIOw\src\CUDAKernels.jl:89
 [21] _launch!(::GPU{…}, ::ImmersedBoundaryGrid{…}, ::Symbol, ::Function, ::Field{…}, ::ImmersedBoundaryGrid{…}, ::Vararg{…}; exclude_periphery::Bool, reduced_dimensions::Tuple{}, active_cells_map::Nothing)      
    @ Oceananigans.Utils C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Utils\kernel_launching.jl:298
 [22] _launch!
    @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Utils\kernel_launching.jl:275 [inlined]     
 [23] launch!
    @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Utils\kernel_launching.jl:258 [inlined]     
 [24] compute_hydrostatic_momentum_tendencies!(model::HydrostaticFreeSurfaceModel{…}, velocities::@NamedTuple{…}, kernel_parameters::Symbol; active_cells_map::Nothing)
    @ Oceananigans.Models.HydrostaticFreeSurfaceModels C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Models\HydrostaticFreeSurfaceModels\compute_hydrostatic_free_surface_tendencies.jl:149
 [25] compute_hydrostatic_momentum_tendencies!
    @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Models\HydrostaticFreeSurfaceModels\compute_hydrostatic_free_surface_tendencies.jl:121 [inlined]
 [26] #compute_hydrostatic_free_surface_tendency_contributions!#30
    @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Models\HydrostaticFreeSurfaceModels\compute_hydrostatic_free_surface_tendencies.jl:73 [inlined]
 [27] compute_hydrostatic_free_surface_tendency_contributions!
    @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Models\HydrostaticFreeSurfaceModels\compute_hydrostatic_free_surface_tendencies.jl:68 [inlined]
 [28] compute_tendencies!(model::HydrostaticFreeSurfaceModel{…}, callbacks::Vector{…})
    @ Oceananigans.Models.HydrostaticFreeSurfaceModels C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Models\HydrostaticFreeSurfaceModels\compute_hydrostatic_free_surface_tendencies.jl:33
 [29] #apply_regionally!#56
    @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Utils\multi_region_transformation.jl:121 [inlined]
 [30] apply_regionally!
    @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Utils\multi_region_transformation.jl:118 [inlined]
 [31] macro expansion
    @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Utils\multi_region_transformation.jl:206 [inlined]
 [32] update_state!(model::HydrostaticFreeSurfaceModel{…}, grid::ImmersedBoundaryGrid{…}, callbacks::Vector{…}; compute_tendencies::Bool)
    @ Oceananigans.Models.HydrostaticFreeSurfaceModels C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Models\HydrostaticFreeSurfaceModels\update_hydrostatic_free_surface_model_state.jl:53
 [33] update_state!
    @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Models\HydrostaticFreeSurfaceModels\update_hydrostatic_free_surface_model_state.jl:32 [inlined]
 [34] update_state! (repeats 2 times)
    @ C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Models\HydrostaticFreeSurfaceModels\update_hydrostatic_free_surface_model_state.jl:29 [inlined]
 [35] initialize!(sim::Simulation{…})
    @ Oceananigans.Simulations C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Simulations\run.jl:211
 [36] time_step!(sim::Simulation{…})
    @ Oceananigans.Simulations C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Simulations\run.jl:138
 [37] run!(sim::Simulation{…}; pickup::Bool)
    @ Oceananigans.Simulations C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Simulations\run.jl:104
 [38] run!(sim::Simulation{…})
    @ Oceananigans.Simulations C:\Users\JDAROSA\.julia\packages\Oceananigans\bQ79p\src\Simulations\run.jl:91
 [39] top-level scope
    @ c:\Users\JDAROSA\code-repos\SpongeLayerRectTestSimple.jl:77
Some type information was truncated. Use `show(err)` to see complete types.

@glwagner
Copy link
Member

I believe the fix is on #4008

@ali-ramadhan
Copy link
Member Author

I believe the fix is on #4008

I'd be curious if it fixes the issue with @darosaj's code!

Unfortunately it did not fix the MWE from this issue's original post: #4165 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Even a perfect program still has bugs
Projects
None yet
Development

No branches or pull requests

4 participants