[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1031540: libamdhip64-dev: hip-lang cmake support is broken



Package: libamdhip64-dev
Version: 5.2.3-4
Severity: normal
X-Debbugs-Cc: cgmb@slerp.xyz

Dear Maintainer,

The CMake support for the HIP language is badly broken. Consider a
sample project:

CMakeLists.txt

    CMakeLists.txt 
    cmake_minimum_required(VERSION 3.22)
    project(example LANGUAGES HIP)
    add_executable(ex main.hip)

main.hip:

    #include <hip/hip_runtime.h>
    #include <stdio.h>
    
    #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);                   \
      }                                       \
    } 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;
    }

Build log:

    # HIPCXX=clang++-15 cmake -S. -Bbuild
    -- The HIP compiler identification is unknown
    CMake Error at /usr/share/cmake-3.25/Modules/CMakeDetermineHIPCompiler.cmake:106 (message):
      The ROCm root directory:
    
       /usr
    
      does not contain the HIP runtime CMake package, expected at:
    
       /usr/lib/cmake/hip-lang/hip-lang-config.cmake
    
    Call Stack (most recent call first):
      CMakeLists.txt:2 (project)
    
    
    -- Configuring incomplete, errors occurred!
    See also "/root/hipsample/build/CMakeFiles/CMakeOutput.log".
    See also "/root/hipsample/build/CMakeFiles/CMakeError.log".

With a lot of patches, extra flags and environment variables, I was
able to get cmake support for the HIP langauge working, but it required
changes to both the libamdhip64-dev and cmake-data packages. Ideally,
there would also be changes to clang++-15 to search the Debian paths
by default for libamdhip64 and the rocm-device-libs.

-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-3-amd64 (SMP w/32 CPU threads; PREEMPT)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect

Versions of packages libamdhip64-dev depends on:
ii  libamdhip64-5        5.2.3-4
ii  libhiprtc-builtins5  5.2.3-4

libamdhip64-dev recommends no packages.

libamdhip64-dev suggests no packages.

-- no debconf information


Reply to: