** Description changed:

+ [Impact]
+ 
  # What happened?
  
  On my gfx1103 laptop building and running a HIP program from source:
  
  ```
  $ sudo apt install hipcc cmake build-essential
  $ cat > main.cpp <<EOF
  #include <stdio.h>
  #include <stdlib.h>
  #include <hip/hip_runtime.h>
  
- #define CHECK_HIP(expr) do {              \
-   hipError_t result = (expr);             \
-   if (result != hipSuccess) {             \
-     fprintf(stderr, "%s:%d: %s (%d)\n",   \
-       __FILE__, __LINE__,                 \
+ #define CHECK_HIP(expr) do { \
+   hipError_t result = (expr); \
+   if (result != hipSuccess) { \
+     fprintf(stderr, "%s:%d: %s (%d)\n", \
+       __FILE__, __LINE__, \
        hipGetErrorString(result), result); \
-     exit(EXIT_FAILURE);                   \
-   }                                       \
+     exit(EXIT_FAILURE); \
+   } \
  } while(0)
  
  __global__ void sq_arr(float *arr, int n) {
    int tid = blockDim.x*blockIdx.x + threadIdx.x;
    if (tid < n) {
      arr[tid] = arr[tid] * arr[tid];
    }
  }
  
  int main() {
    enum { N = 5 };
    float hArr[N] = { 1, 2, 3, 4, 5 };
    float *dArr;
    CHECK_HIP(hipMalloc(&dArr, sizeof(float) * N));
    CHECK_HIP(hipMemcpy(dArr, hArr, sizeof(float) * N, hipMemcpyHostToDevice));
    sq_arr<<<dim3(1), dim3(32,1,1), 0, 0>>>(dArr, N);
    CHECK_HIP(hipMemcpy(hArr, dArr, sizeof(float) * N, hipMemcpyDeviceToHost));
    for (int i = 0; i < N; ++i) {
      printf("%f\n", hArr[i]);
    }
    CHECK_HIP(hipFree(dArr));
    return 0;
  }
  EOF
  $ cat > CMakeLists.txt <<EOF
  cmake_minimum_required(VERSION 3.22)
  project(example LANGUAGES CXX)
  
  find_package(hip REQUIRED)
  
  add_executable(ex main.cpp)
  target_link_libraries(ex PRIVATE hip::device)
  EOF
  $ CXX=clang++-21 cmake -S. -Bbuild
  CXX=clang++-21 cmake -S. -Bbuild
  -- The CXX compiler identification is Clang 21.1.8
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/clang++-21 - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
  -- Found Threads: TRUE
  -- hip::amdhip64 is SHARED_LIBRARY
  -- Performing Test HIP_CLANG_SUPPORTS_PARALLEL_JOBS
  -- Performing Test HIP_CLANG_SUPPORTS_PARALLEL_JOBS - Failed
  -- Configuring done (0.5s)
  -- Generating done (0.0s)
  -- Build files have been written to: /root/build
  $ VERBOSE=1 make -C build
  make: Entering directory '/root/build'
  /usr/bin/cmake -S/root -B/root/build --check-build-system 
CMakeFiles/Makefile.cmake 0
  /usr/bin/cmake -E cmake_progress_start /root/build/CMakeFiles 
/root/build//CMakeFiles/progress.marks
- make  -f CMakeFiles/Makefile2 all
+ make -f CMakeFiles/Makefile2 all
  make[1]: Entering directory '/root/build'
- make  -f CMakeFiles/ex.dir/build.make CMakeFiles/ex.dir/depend
+ make -f CMakeFiles/ex.dir/build.make CMakeFiles/ex.dir/depend
  make[2]: Entering directory '/root/build'
  cd /root/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root 
/root /root/build /root/build /root/build/CMakeFiles/ex.dir/DependInfo.cmake 
"--color="
  make[2]: Leaving directory '/root/build'
- make  -f CMakeFiles/ex.dir/build.make CMakeFiles/ex.dir/build
+ make -f CMakeFiles/ex.dir/build.make CMakeFiles/ex.dir/build
  make[2]: Entering directory '/root/build'
  [ 50%] Building CXX object CMakeFiles/ex.dir/main.cpp.o
- /usr/bin/clang++-21 -DUSE_PROF_API=1 -D__HIP_PLATFORM_AMD__=1  -x hip -MD -MT 
CMakeFiles/ex.dir/main.cpp.o -MF CMakeFiles/ex.dir/main.cpp.o.d -o 
CMakeFiles/ex.dir/main.cpp.o -c /root/main.cpp
+ /usr/bin/clang++-21 -DUSE_PROF_API=1 -D__HIP_PLATFORM_AMD__=1 -x hip -MD -MT 
CMakeFiles/ex.dir/main.cpp.o -MF CMakeFiles/ex.dir/main.cpp.o.d -o 
CMakeFiles/ex.dir/main.cpp.o -c /root/main.cpp
  [100%] Linking CXX executable ex
  /usr/bin/cmake -E cmake_link_script CMakeFiles/ex.dir/link.txt --verbose=1
- /usr/bin/clang++-21 -Xlinker --dependency-file=CMakeFiles/ex.dir/link.d 
CMakeFiles/ex.dir/main.cpp.o -o ex  
/usr/lib/x86_64-linux-gnu/libamdhip64.so.7.1.52801 --hip-link 
/usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.builtins-x86_64.a
+ /usr/bin/clang++-21 -Xlinker --dependency-file=CMakeFiles/ex.dir/link.d 
CMakeFiles/ex.dir/main.cpp.o -o ex 
/usr/lib/x86_64-linux-gnu/libamdhip64.so.7.1.52801 --hip-link 
/usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.builtins-x86_64.a
  make[2]: Leaving directory '/root/build'
  [100%] Built target ex
  make[1]: Leaving directory '/root/build'
  /usr/bin/cmake -E cmake_progress_start /root/build/CMakeFiles 0
  make: Leaving directory '/root/build'
  $ build/ex
- Segmentation fault         (core dumped) build/ex
- $ grep GPU build/CMakeCache.txt 
+ Segmentation fault (core dumped) build/ex
+ $ grep GPU build/CMakeCache.txt
  //GPU targets to compile for
  GPU_BUILD_TARGETS:STRING=
  $ llvm-objdump-21 --offloading build/ex
  
- build/ex:     file format elf64-x86-64
+ build/ex: file format elf64-x86-64
  Extracting offload bundle: build/ex.0.host-x86_64-unknown-linux-gnu-
  Extracting offload bundle: build/ex.0.hipv4-amdgcn-amd-amdhsa--gfx906
  ```
  
  # What was expected?
  
  The CMake GPU detection should succeed, resulting in different output
  from the make command onward:
  
  ```
  $ VERBOSE=1 make -C build
  make: Entering directory '/root/build'
  /usr/bin/cmake -S/root -B/root/build --check-build-system 
CMakeFiles/Makefile.cmake 0
  /usr/bin/cmake -E cmake_progress_start /root/build/CMakeFiles 
/root/build//CMakeFiles/progress.marks
- make  -f CMakeFiles/Makefile2 all
+ make -f CMakeFiles/Makefile2 all
  make[1]: Entering directory '/root/build'
- make  -f CMakeFiles/ex.dir/build.make CMakeFiles/ex.dir/depend
+ make -f CMakeFiles/ex.dir/build.make CMakeFiles/ex.dir/depend
  make[2]: Entering directory '/root/build'
  cd /root/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root 
/root /root/build /root/build /root/build/CMakeFiles/ex.dir/DependInfo.cmake 
"--color="
  make[2]: Leaving directory '/root/build'
- make  -f CMakeFiles/ex.dir/build.make CMakeFiles/ex.dir/build
+ make -f CMakeFiles/ex.dir/build.make CMakeFiles/ex.dir/build
  make[2]: Entering directory '/root/build'
  [ 50%] Building CXX object CMakeFiles/ex.dir/main.cpp.o
- /usr/bin/clang++-21 -DUSE_PROF_API=1 -D__HIP_PLATFORM_AMD__=1  -x hip 
--offload-arch=gfx1103 -MD -MT CMakeFiles/ex.dir/main.cpp.o -MF 
CMakeFiles/ex.dir/main.cpp.o.d -o CMakeFiles/ex.dir/main.cpp.o -c /root/main.cpp
+ /usr/bin/clang++-21 -DUSE_PROF_API=1 -D__HIP_PLATFORM_AMD__=1 -x hip 
--offload-arch=gfx1103 -MD -MT CMakeFiles/ex.dir/main.cpp.o -MF 
CMakeFiles/ex.dir/main.cpp.o.d -o CMakeFiles/ex.dir/main.cpp.o -c /root/main.cpp
  [100%] Linking CXX executable ex
  /usr/bin/cmake -E cmake_link_script CMakeFiles/ex.dir/link.txt --verbose=1
- /usr/bin/clang++-21 -Xlinker --dependency-file=CMakeFiles/ex.dir/link.d 
CMakeFiles/ex.dir/main.cpp.o -o ex  
/usr/lib/x86_64-linux-gnu/libamdhip64.so.7.1.52801 --hip-link 
--offload-arch=gfx1103 
/usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.builtins-x86_64.a
+ /usr/bin/clang++-21 -Xlinker --dependency-file=CMakeFiles/ex.dir/link.d 
CMakeFiles/ex.dir/main.cpp.o -o ex 
/usr/lib/x86_64-linux-gnu/libamdhip64.so.7.1.52801 --hip-link 
--offload-arch=gfx1103 
/usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.builtins-x86_64.a
  make[2]: Leaving directory '/root/build'
  [100%] Built target ex
  make[1]: Leaving directory '/root/build'
  /usr/bin/cmake -E cmake_progress_start /root/build/CMakeFiles 0
  make: Leaving directory '/root/build'
  $ build/ex
  1.000000
  4.000000
  9.000000
  16.000000
  25.000000
- $ grep GPU build/CMakeCache.txt 
+ $ grep GPU build/CMakeCache.txt
  //GPU targets to compile for
  GPU_BUILD_TARGETS:STRING=gfx1103
  GPU_TARGETS:UNINITIALIZED=gfx1103
  $ llvm-objdump-21 --offloading build/ex
  
- build/ex:     file format elf64-x86-64
+ build/ex: file format elf64-x86-64
  Extracting offload bundle: build/ex.0.host-x86_64-unknown-linux-gnu-
  Extracting offload bundle: build/ex.0.hipv4-amdgcn-amd-amdhsa--gfx1103
  ```
  
  Libraries 'linked' against hip::device should be built for the user's
  GPU. This is detected using amdgpu-arch from llvm-tools, but the paths
  don't seem to be set up correctly.
  
  If the user's GPU is not detected, it seems that ROCm does not set a
  value, and LLVM defaults to building for gfx906. This is almost
  certainly the wrong architecture, and will result in a segfault when
  users attempt to run the program.
  
  Matthias Urlichs points out a similar problem in Debian, stating:
  
      The culprit appears to be line 58 in
      usr/lib/x86_64-linux-gnu/cmake/hip/hip-config-amd.cmake ::
  
      set(HIP_CLANG_ROOT "${ROCM_PATH}/llvm")
  
      Removing the /llvm part fixes the problem.
  
+ [Test Plan]
+ 
+ Addressed in https://bugs.launchpad.net/ubuntu/+source/rocm-
+ hipamd/+bug/2156375
+ 
+ [Where problems could occur]
+ 
+ Addressed in https://bugs.launchpad.net/ubuntu/+source/rocm-
+ hipamd/+bug/2156375
+ 
+ [Other Info]
+ 
  # System Info
  
  ## lsb_release -rd
  Description: Ubuntu Resolute Raccoon (development branch)
  Release: 26.04
  
  # apt-cache policy libamdhip64-dev
  libamdhip64-dev:
    Installed: 7.1.0-0ubuntu2
    Candidate: 7.1.0-0ubuntu2
    Version table:
   *** 7.1.0-0ubuntu2 500
          500 http://archive.ubuntu.com/ubuntu resolute/universe amd64 Packages
          100 /var/lib/dpkg/status
+ 
+ This fix was included in the resolute SRU tracked at:
+ https://bugs.launchpad.net/ubuntu/+source/rocm-hipamd/+bug/2156375

** Summary changed:

- libamdhip64-dev cannot find amdgpu-arch
+ SRU: libamdhip64-dev cannot find amdgpu-arch (ref.: #2156375)

** Summary changed:

- SRU: libamdhip64-dev cannot find amdgpu-arch (ref.: #2156375)
+ SRU: libamdhip64-dev cannot find amdgpu-arch (see also: #2156375)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2143597

Title:
  SRU: libamdhip64-dev cannot find amdgpu-arch (see also: #2156375)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/rocm-hipamd/+bug/2143597/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to