Skip to content

Metal.jl sincos intrinsic produces invalid LLVM IR on Julia 1.11+ (GPUCompiler 1.7.6+) #761

@cncastillo

Description

@cncastillo

Using the sincos intrinsic inside a Metal GPU kernel (KernelAbstractions.jl) fails at compile time with an InvalidIRError:

https://buildkite.com/julialang/komamri-dot-jl/builds/1920/steps/canvas?jid=019bfa74-c26d-465b-86c7-ca7e09bcfe74#019bfa74-c26d-465b-86c7-ca7e09bcfe74/L888

Environment:

[dde4c033] + Metal v1.9.1
[0c68f7d7] + GPUArrays v11.3.4
[61eb1bfa] + GPUCompiler v1.8.1

This is a MWE:

using Metal, KernelAbstractions, Adapt

@kernel function sincos_kernel!(x)
    i = @index(Global, Linear)
    s, c = sincos(x[i])
    x[i] = s + c
end

function sincos_caller!(x, backend)
    sincos_kernel!(backend)(x; ndrange=length(x))
    KernelAbstractions.synchronize(backend)
end

backend = MetalBackend()
x  = rand(Float32, 100) |> adapt(backend)

sincos_caller!(x, backend) # <---  InvalidIRError

Related: JuliaHealth/KomaMRI.jl#716

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