Skip to content

sind in kernels not supported / causes errors #2349

@maximilian-gelbrecht

Description

@maximilian-gelbrecht

I can see in the repo that there's some support for trig functions like sind but they currently don't work in kernels:

using Reactant, KernelAbstractions, CUDA

# get backend 
ReactantKernelAbstractionsExt = Base.get_extension(
    Reactant, :ReactantKernelAbstractionsExt
)
ReactantBackend = ReactantKernelAbstractionsExt.ReactantBackend()

# Simple kernel that uses sind
@kernel function sind_kernel!(out, x)
    i = @index(Global)
    out[i] = sind(x[i]) # this causes an error
    #out[i] = sin(rad2deg(x[i])) # this would work
end

# Create input array
x_cpu = Float32[0, 30, 45, 60, 90]
x_reactant = Reactant.to_rarray(x_cpu)
out_reactant = Reactant.to_rarray(zeros(Float32, 5))

# Launch kernel
kernel! = sind_kernel!(ReactantBackend)
@jit kernel!(out_reactant, x_reactant; ndrange=5)
[10944] signal 4 (1): Illegal instruction: 4
in expression starting at REPL[9]:1
Allocations: 71344590 (Pool: 71343371; Big: 1219); GC: 39
unknown function (ip: 0x1052702c4)
Allocations: 71344590 (Pool: 71343371; Big: 1219); GC: 39
Trace/BPT trap: 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions