Skip to content

Field type inconsistency with Reactant #5837

Description

@dkytezab
using Reactant
using CUDA
using Oceananigans
using Oceananigans.Architectures: ReactantState
using Oceananigans.Fields: CenterField, compute!

grid = RectilinearGrid(
    ReactantState();
    size = (4, 4, 4), halo = (3, 3, 3), extent = (1, 1, 1),
    topology = (Periodic, Periodic, Bounded)
)

field = CenterField(grid)

eltypes(f) = @show eltype(f), eltype(CenterField(f.grid))

operate(f) = compute!(Field(f + CenterField(f.grid)))

@compile eltypes(field)
@compile raise = true operate(field)
(eltype(f), eltype(CenterField(f.grid))) = (Float64, Reactant.TracedRNumber{Float64})
ERROR: LoadError: InvalidIRError: compiling MethodInstance for Oceananigans.AbstractOperations.gpu__compute!(::KernelAbstractions.CompilerMetadata{…}, ::OffsetArrays.OffsetArray{…}, ::Oceananigans.AbstractOperations.BinaryOperation{…}) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to getindex)
Stacktrace:
 [1] gpu__compute!
   @ ~/.julia/packages/KernelAbstractions/scVtc/src/macros.jl:332
 [2] gpu__compute!
   @ ./none:0
Hint: catch this exception as `err` and call `code_typed(err; interactive = true)` to introspect the erroneous code with Cthulhu.jl
Stacktrace
...

cc @Pangoraw

Metadata

Metadata

Assignees

No one assigned

    Labels

    reactant ∇all day I dream about MLIR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions