Skip to content

[flang][openmp] target construct segfaults with amdgpu #132982

@VeeEM

Description

@VeeEM

Programs with a target construct without any additional directives segfault when compiled with flang for amdgpu. clang works fine, only flang is affected.

A program with just a target region is enough to reproduce:

program crash
!$omp target
!$omp end target
end program
$ flang -fopenmp --offload-arch=gfx1100 crash.f90 
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
$ ./a.out 
Segmentation fault

Stacktrace from gdb shows:

#0  0x00007ffff3d4fef5 in llvm::omp::target::plugin::AMDGPUKernelTy::launchImpl(llvm::omp::target::plugin::GenericDeviceTy&, unsigned int*, unsigned int*, KernelArgsTy&, KernelLaunchParamsTy, llvm::omp::target::plugin::AsyncInfoWrapperTy&) const
    () from /home/acc/install_llvm2/lib/x86_64-unknown-linux-gnu/libomptarget.so.21.0git
#1  0x00007ffff3d143a5 in llvm::omp::target::plugin::GenericKernelTy::launch(llvm::omp::target::plugin::GenericDeviceTy&, void**, long*, KernelArgsTy&, llvm::omp::target::plugin::AsyncInfoWrapperTy&) const ()
   from /home/acc/install_llvm2/lib/x86_64-unknown-linux-gnu/libomptarget.so.21.0git
#2  0x00007ffff3d1ae04 in llvm::omp::target::plugin::GenericDeviceTy::launchKernel(void*, void**, long*, KernelArgsTy&, __tgt_async_info*) () from /home/acc/install_llvm2/lib/x86_64-unknown-linux-gnu/libomptarget.so.21.0git
#3  0x00007ffff3d1e092 in llvm::omp::target::plugin::GenericPluginTy::launch_kernel(int, void*, void**, long*, KernelArgsTy*, __tgt_async_info*) () from /home/acc/install_llvm2/lib/x86_64-unknown-linux-gnu/libomptarget.so.21.0git
#4  0x00007ffff3becd17 in DeviceTy::launchKernel(void*, void**, long*, KernelArgsTy&, AsyncInfoTy&) () from /home/acc/install_llvm2/lib/x86_64-unknown-linux-gnu/libomptarget.so.21.0git
#5  0x00007ffff3bf847c in target(ident_t*, DeviceTy&, void*, KernelArgsTy&, AsyncInfoTy&) () from /home/acc/install_llvm2/lib/x86_64-unknown-linux-gnu/libomptarget.so.21.0git
#6  0x00007ffff3beff59 in __tgt_target_kernel () from /home/acc/install_llvm2/lib/x86_64-unknown-linux-gnu/libomptarget.so.21.0git
#7  0x000055555555675c in _QQmain ()
#8  0x0000555555556782 in main ()

Tested at f7f5aa2.

Machine specs: Ubuntu 24.04.1, rocm 6.3.0, Ryzen 9 9900X, RX 7900 GRE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions