Skip to content

Calculating cell time scale in triply bounded ImmersedBoundaryGrid errors on GPU #4663

@tomchor

Description

@tomchor

On main, trying to use TimeStepWizard fails due to a GPU-related error when calculating cell_advection_timescale. Here's a MWE:

using Oceananigans
using CUDA

N = 8
underlying_grid = RectilinearGrid(GPU(), topology = (Bounded, Bounded, Bounded), size = (N, N, N), extent = (1, 1, 1))

immersed_bottom = GridFittedBottom(-1/2)
model = NonhydrostaticModel(grid = ImmersedBoundaryGrid(underlying_grid, immersed_bottom))
simulation = Simulation(model; Δt = 1, stop_time = 1)

wizard = TimeStepWizard(cfl=0.2)
wizard(simulation)

This fails with

ERROR: Number of threads per block exceeds kernel limit (384 > 256).
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] diagnose_launch_failure(f::CuFunction, err::CuError; blockdim::CuDim3, threaddim::CuDim3, shmem::Int64)
    @ CUDA ~/.julia/packages/CUDA/ja0IX/lib/cudadrv/execution.jl:126
  [3] launch(::CuFunction, ::CUDA.KernelState, ::CartesianIndices{…}, ::CartesianIndices{…}, ::CuDeviceArray{…}, ::Oceananigans.AbstractOperations.ConditionalOperation{…}; blocks::Int64, threads::Int64, cooperative::Bool, shmem::Int64, stream::CuStream)
    @ CUDA ~/.julia/packages/CUDA/ja0IX/lib/cudadrv/execution.jl:79
  [4] launch
    @ ~/.julia/packages/CUDA/ja0IX/lib/cudadrv/execution.jl:58 [inlined]
  [5] #1007
    @ ~/.julia/packages/CUDA/ja0IX/lib/cudadrv/execution.jl:195 [inlined]
  [6] macro expansion
    @ ~/.julia/packages/CUDA/ja0IX/lib/cudadrv/execution.jl:155 [inlined]
  [7] macro expansion
    @ ./none:0 [inlined]
  [8] convert_arguments
    @ ./none:0 [inlined]
  [9] #cudacall#1006
    @ ~/.julia/packages/CUDA/ja0IX/lib/cudadrv/execution.jl:197 [inlined]
 [10] cudacall
    @ ~/.julia/packages/CUDA/ja0IX/lib/cudadrv/execution.jl:193 [inlined]
 [11] macro expansion
    @ ~/.julia/packages/CUDA/ja0IX/src/compiler/execution.jl:272 [inlined]
 [12] macro expansion
    @ ./none:0 [inlined]
 [13] (::CUDA.HostKernel{…})(::typeof(identity), ::typeof(min), ::Nothing, ::CartesianIndices{…}, ::CartesianIndices{…}, ::Val{…}, ::CuDeviceArray{…}, ::Oceananigans.AbstractOperations.ConditionalOperation{…}; convert::Val{…}, call_kwargs::@Kwargs{…})
    @ CUDA ./none:0
 [14] AbstractKernel
    @ ./none:0 [inlined]
 [15] macro expansion
    @ ~/.julia/packages/CUDA/ja0IX/src/compiler/execution.jl:114 [inlined]
 [16] mapreducedim!(f::typeof(identity), op::typeof(min), R::SubArray{…}, A::Oceananigans.AbstractOperations.ConditionalOperation{…}; init::Nothing)
    @ CUDA ~/.julia/packages/CUDA/ja0IX/src/mapreduce.jl:266
 [17] mapreducedim!(f::typeof(identity), op::typeof(min), R::SubArray{…}, A::Oceananigans.AbstractOperations.ConditionalOperation{…})
    @ CUDA ~/.julia/packages/CUDA/ja0IX/src/mapreduce.jl:169
 [18] mapreducedim!(f::Function, op::Function, R::SubArray{…}, A::Oceananigans.AbstractOperations.ConditionalOperation{…})
    @ GPUArrays ~/.julia/packages/GPUArrays/u6tui/src/host/mapreduce.jl:10
 [19] minimum!(f::Function, r::SubArray{…}, A::Oceananigans.AbstractOperations.ConditionalOperation{…}; init::Bool)
    @ Base ./reducedim.jl:1036
 [20] minimum(f::Function, c::KernelFunctionOperation{…}; condition::Nothing, mask::Float64, dims::Function)
    @ Oceananigans.Fields /mnt/storage1/tomaschor/Oceananigans.jl/src/Fields/field.jl:728
 [21] minimum
    @ /mnt/storage1/tomaschor/Oceananigans.jl/src/Fields/field.jl:717 [inlined]
 [22] minimum
    @ /mnt/storage1/tomaschor/Oceananigans.jl/src/Fields/field.jl:737 [inlined]
 [23] cell_advection_timescale
    @ /mnt/storage1/tomaschor/Oceananigans.jl/src/Advection/cell_advection_timescale.jl:16 [inlined]
 [24] cell_advection_timescale
    @ /mnt/storage1/tomaschor/Oceananigans.jl/src/Models/NonhydrostaticModels/NonhydrostaticModels.jl:81 [inlined]
 [25] new_time_step(old_Δt::Float64, wizard::TimeStepWizard{…}, model::NonhydrostaticModel{…})
    @ Oceananigans.Simulations /mnt/storage1/tomaschor/Oceananigans.jl/src/Simulations/time_step_wizard.jl:103
 [26] (::TimeStepWizard{…})(simulation::Simulation{…})
    @ Oceananigans.Simulations /mnt/storage1/tomaschor/Oceananigans.jl/src/Simulations/time_step_wizard.jl:117
 [27] top-level scope
    @ REPL[10]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions