Skip to content

[HIPIFY][Issue] No warning for libcu++ headers that libhipcxx does not provide (cuda/barrier, cuda/pipeline) #2811

Open

Description

@yassinsolim

Problem Description

hipify-perl and hipify-clang pass #include <cuda/barrier> and #include <cuda/pipeline> through with no diagnostic. libhipcxx does not provide a working version of those headers. In amd-develop of ROCm/libhipcxx (24a4802), include/cuda/barrier stops with #error barrier is not supported on AMD hardware and should not be included under __HIP_PLATFORM_AMD__, and cuda/pipeline includes cuda/barrier. cuda/semaphore and cuda/ptx have the same kind of stub, and some other public libcu++ headers are absent from libhipcxx. So the conversion looks clean and the failure only shows up later at compile time.

Input barrier_in.cu:

#include <cuda/barrier>
#include <cooperative_groups.h>

__global__ void sync_kernel(int *out) {
  __shared__ cuda::barrier<cuda::thread_scope_block> bar;
  if (threadIdx.x == 0) {
    init(&bar, blockDim.x);
  }
  __syncthreads();
  out[threadIdx.x] = threadIdx.x;
  bar.arrive_and_wait();
}

On amd-develop at 9a85980, hipify-perl prints no warning for this file, and for pipeline_in.cu (#include <cuda/pipeline>) and for the public CUDA samples simpleAWBarrier.cu and bf16TensorCoreGemm.cu. hipify-clang prints no header warning for pipeline_in.cu and bf16TensorCoreGemm.cu. The #include lines stay as they are, which is expected, since libhipcxx uses the same paths.

Compiling the hipify-perl output against libhipcxx:

$ hipcc -I<libhipcxx>/include --offload-arch=gfx942 --cuda-device-only -c barrier_in.hip -o /dev/null
<libhipcxx>/include/cuda/barrier:38:2: error: barrier is not supported on AMD hardware and should not be included

pipeline_in, simpleAWBarrier and bf16TensorCoreGemm fail with the same error at cuda/barrier:38:2.

Control: a file that includes only cuda/std/array and cuda/std/type_traits converts with no warning and compiles against the same libhipcxx (rc 0). So the include line itself is fine for headers libhipcxx provides.

Possible fix: print a warning at conversion time for includes of libcu++ headers that libhipcxx does not provide.

Operating System

Ubuntu 24.04 LTS (Noble Numbat)

CPU

Intel(R) Xeon(R) Gold 6130 CPU @ 2.10GHz

ROCm Version

ROCm 7.1.0 hipcc (HIP 7.1.25424). The ROCm version list in the template stops at 6.3.1.

ROCm Component

HIPIFY

Steps to Reproduce

  1. Build hipify-clang from amd-develop (9a85980) with LLVM 20.1.8 and CUDA 12.8, and clone ROCm/libhipcxx (amd-develop, 24a4802).
  2. hipify-perl barrier_in.cu > barrier_in.hip
  3. hipcc -I<libhipcxx>/include --offload-arch=gfx942 --cuda-device-only -c barrier_in.hip -o /dev/null

Additional Information

No GPU is needed, only compilation. hipify-clang itself fails on barrier_in.cu and simpleAWBarrier.cu with error: initialization is not supported for __shared__ variables when it parses the cuda::barrier shared variable, before and after the change that adds the warning, so the hipify-clang half of this report uses pipeline_in.cu and bf16TensorCoreGemm.cu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions