Skip to content
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

reshape(view(...)) inside a GPU kernel triggers InvalidIRError #736

Open
omlins opened this issue Feb 27, 2025 · 3 comments
Open

reshape(view(...)) inside a GPU kernel triggers InvalidIRError #736

omlins opened this issue Feb 27, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@omlins
Copy link
Contributor

omlins commented Feb 27, 2025

Description

When calling reshape(view(...)) inside an AMDGPU kernel, it fails with an InvalidIRError.

Minimal Working Example (MWE)

using AMDGPU

function kernel!(A)
    i = workitemIdx().x
    B = reshape(view(A, :, i), (size(A, 1),))  # ❌ This triggers InvalidIRError
    B[1] = 9.0
    return
end

# Create a ROCArray on the host (it will be converted automatically)
A = ROCArray{Float64}(undef, 4, 4)

# Launch kernel
@roc groupsize=4 kernel!(A)
AMDGPU.synchronize()

Expected Behavior

The kernel should execute without errors, and reshape(view(...)) should produce a valid ROCDeviceArray.

Actual Behavior

The following error occurs:

ERROR: InvalidIRError: compiling MethodInstance for kernel!(::ROCDeviceArray{Float64, 2}) resulted in invalid LLVM IR
Reason: unsupported call to an external C function

System Information

  • Julia Version: 1.11.2
  • AMDGPU.jl Version: master
@omlins
Copy link
Contributor Author

omlins commented Feb 28, 2025

@pxl-th the equivalent works in CUDA.jl

@pxl-th pxl-th added the bug Something isn't working label Feb 28, 2025
@pxl-th pxl-th self-assigned this Feb 28, 2025
@pxl-th
Copy link
Member

pxl-th commented Feb 28, 2025

@omlins I'll take a look

@omlins
Copy link
Contributor Author

omlins commented Feb 28, 2025

@omlins I'll take a look

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants