[flang-commits] [clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

Joseph Huber via flang-commits flang-commits at lists.llvm.org
Wed Jul 24 09:08:22 PDT 2024


jhuber6 wrote:

> I reproduced this locally. The output is:
> 
> ```
> $ /home/meinersbur/build/llvm-project/release/bin/flang-new -S -### /c/Users/meinersbur/src/llvm-project/flang/test/Driver/omp-driver-offload-amdgpu.f90 -o /home/meinersbur/build/llvm-project/release/tools/flang/test/Driver/Output/omp-driver-offload-amdgpu.f90.tmp 2>&1  -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa  --target=x86_64-unknown-linux-gnu
> flang-new version 20.0.0git (/home/meinersbur/src/llvm-project/clang f2ec205140a214accd161919c40a966d5695c536)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> InstalledDir: /home/meinersbur/build/llvm-project/release/bin
> Build config: +assertions
> flang-new: error: cannot determine amdgcn architecture: /home/meinersbur/build/llvm-project/release/bin/amdgpu-arch: ; consider passing it via '-march'
>  "/home/meinersbur/build/llvm-project/release/bin/flang-new" "-fc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "x86-64" "-fopenmp" "-resource-dir" "/home/meinersbur/build/llvm-project/release/lib/clang/20" "-fopenmp-targets=amdgcn-amd-amdhsa" "-mframe-pointer=all" "-o" "/tmp/meinersbur/omp-driver-offload-amdgpu-e54e29.bc" "-x" "f95-cpp-input" "/c/Users/meinersbur/src/llvm-project/flang/test/Driver/omp-driver-offload-amdgpu.f90"
>  "/home/meinersbur/build/llvm-project/release/bin/flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" "-emit-llvm-bc" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-target-cpu" "gfx906" "-fopenmp" "-res urce-dir" "/home/meinersbur/build/llvm-project/release/lib/clang/20" "-fopenmp-host-ir-file-path" "/tmp/meinersbur/omp-driver-offload-amdgpu-e54e29.bc" "-fopenmp-is-target-device" "-mframe-pointer=all" "-o" "/tmp/meinersbur/omp-driver-offload-amdgpu-479864.bc" "-x" "f95-cpp-input" "/c/Users/meinersbur/src/llvm-project/flang/test/Driver/omp-driver-offload-amdgpu.f90"
>  "/home/meinersbur/build/llvm-project/release/bin/clang-offload-packager" "-o" "/tmp/meinersbur/omp-driver-offload-amdgpu-7a81eb.out" "--image=file=/tmp/meinersbur/omp-driver-offload-amdgpu-479864.bc,triple=amdgcn-amd-amdhsa,arch=gfx906,kind=openmp"
>  "/home/meinersbur/build/llvm-project/release/bin/flang-new" "-fc1" "-triple" "x86_64-unknown-linux-gnu" "-S" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "x86-64" "-fopenmp" "-resource-dir" "/home/meinersbur/build/llvm-project/release/lib/clang/20" "-fembed-offload-object=/tmp/meinersbur/omp-driver-offload-amdgpu-7a81eb.out" "-fopenmp-targets=amdgcn-amd-amdhsa" "-mframe-pointer=all" "-o" "/home/meinersbur/build/llvm-project/release/tools/flang/test/Driver/Output/omp-driver-offload-amdgpu.f90.tmp" "-x" "ir" "/tmp/meinersbur/omp-driver-offload-amdgpu-e54e29.bc"      
> ```
> 
> amdgpu-arch fails with:
> 
> ```
> $ bin/amdgpu-arch
> Failed to 'dlopen' libhsa-runtime64.so
> Failed to load libamdhip64.so: libamdhip64.so: cannot open shared object file: No such file or directory        
> ```

`amdgpu-arch` is the utility used to infer the target triple when one isn't provided (as is customary with `-fopenmp-target=amdgcn-amd-amdhsa`. The solution is to pass an argument manually because we don't want to use it for tests.

https://github.com/llvm/llvm-project/pull/100152


More information about the flang-commits mailing list