-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Flang][OpenMP] Allocatables in a nested series of BLOCK with a do loop wrapping the inner BLOCK prompts a crash with HLFIR flow when used inside of a !$omp target #82368
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
Comments
@llvm/issue-subscribers-backend-amdgpu Author: None (agozillon)
The below small test will crash for device compilation on AMDGPU instruction selection currently for the new-ish HLFIR flow, but passes using the `-flang-deprecated-no-hlfir` option:
The crash dump:
This seems unrelated to the other allocatable issue I posted here: #74603 in the sense that it's not alloca related and that switching the kernel to optnone or bumping the optimisation level will not fix the issue, it still however seems to have the same root cause of incompatible code with AMDGPU ISEL |
…s space when generating intrinsics This PR aims to factor in the allocation address space provided by an architectures data layout when generating the intrinsic instructions, this allows them to be lowered later with the address spaces in tow. This aligns the intrinsic creation with the LLVM IRBuilder's https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/IRBuilder.h#L1053 This is also necessary for the below example to compile for OpenMP AMD GPU and not ICE the compiler in ISEL as AMD's stackrestore and stacksave are expected to have the appropriate allocation address space for AMD GPU. program main integer(4), allocatable :: test allocate(test) !$omp target map(tofrom:test) do i = 1, 10 test = test + 50 end do !$omp end target deallocate(test) end program The PR also fixes the issue I opened a while ago which hits the same error when compiling for AMDGPU: llvm#82368 Although, you have to have the appropriate GPU LIBC and Fortran offload runtime (both compiled for AMDGPU) added to the linker for the command or it will reach another ISEL error and ICE weirdly. But with the pre-requisites it works fine with this PR.
…s space when generating intrinsics (#96836) This PR aims to factor in the allocation address space provided by an architectures data layout when generating the intrinsic instructions, this allows them to be lowered later with the address spaces in tow. This aligns the intrinsic creation with the LLVM IRBuilder's https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/IRBuilder.h#L1053 This is also necessary for the below example to compile for OpenMP AMD GPU and not ICE the compiler in ISEL as AMD's stackrestore and stacksave are expected to have the appropriate allocation address space for AMD GPU. program main integer(4), allocatable :: test allocate(test) !$omp target map(tofrom:test) do i = 1, 10 test = test + 50 end do !$omp end target deallocate(test) end program The PR also fixes the issue I opened a while ago which hits the same error when compiling for AMDGPU: #82368 Although, you have to have the appropriate GPU LIBC and Fortran offload runtime (both compiled for AMDGPU) added to the linker for the command or it will reach another ISEL error and ICE weirdly. But with the pre-requisites it works fine with this PR.
This should now be fixed after the landing of: #96836 If it re-emerges again in Flang, it's possible we're adding stackreclaim/stacksave without the appropriate allocation address space in some other manner than the stack reclaim pass and we should address it similarly, by making sure the operations take into account the allocation address space. |
…s space when generating intrinsics (llvm#96836) This PR aims to factor in the allocation address space provided by an architectures data layout when generating the intrinsic instructions, this allows them to be lowered later with the address spaces in tow. This aligns the intrinsic creation with the LLVM IRBuilder's https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/IRBuilder.h#L1053 This is also necessary for the below example to compile for OpenMP AMD GPU and not ICE the compiler in ISEL as AMD's stackrestore and stacksave are expected to have the appropriate allocation address space for AMD GPU. program main integer(4), allocatable :: test allocate(test) !$omp target map(tofrom:test) do i = 1, 10 test = test + 50 end do !$omp end target deallocate(test) end program The PR also fixes the issue I opened a while ago which hits the same error when compiling for AMDGPU: llvm#82368 Although, you have to have the appropriate GPU LIBC and Fortran offload runtime (both compiled for AMDGPU) added to the linker for the command or it will reach another ISEL error and ICE weirdly. But with the pre-requisites it works fine with this PR.
The below small test will crash for device compilation on AMDGPU instruction selection currently for the new-ish HLFIR flow, but passes using the
-flang-deprecated-no-hlfir
option:The crash dump:
This seems unrelated to the other allocatable issue I posted here: #74603 in the sense that it's not alloca related and that switching the kernel to optnone or bumping the optimisation level will not fix the issue, it still however seems to have the same root cause of incompatible code with AMDGPU ISEL
The text was updated successfully, but these errors were encountered: