[PATCH] D154123: [HIP] Start document HIP support by clang

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 25 05:39:19 PDT 2023


yaxunl marked 3 inline comments as done.
yaxunl added inline comments.


================
Comment at: clang/docs/HIPSupport.rst:30
+
+Clang provides partial HIP support on Intel GPUs using the CHIP-Star project `<https://github.com/CHIP-SPV/chipStar>`_. CHIP-Star implements the HIP runtime over oneAPI Level Zero or OpenCL runtime. The Clang driver uses the HIPSPV toolchain to compile HIP device code into LLVM IR, which is subsequently translated to SPIRV via the SPIRV backend or the out-of-tree LLVM-SPIRV translator. The SPIRV is then bundled and embedded into the host executables.
+
----------------
keryell wrote:
> Fix the spelling when we talk about the Khronos SPIR-V standard, by opposition to tool names.
> Perhaps you can split the line in shorter ones so the diff are more obvious.
> Fix the spelling when we talk about the Khronos SPIR-V standard, by opposition to tool names.
> Perhaps you can split the line in shorter ones so the diff are more obvious.

will do


================
Comment at: clang/docs/HIPSupport.rst:65
+
+   clang++ --offload-arch=gfx906 -xhip sample.cpp -o sample
+
----------------
keryell wrote:
> yaxunl wrote:
> > arsenm wrote:
> > > scchan wrote:
> > > > missing --hip-link
> > > What does hip-link do? Why is it needed? I never use it and it works
> > It indicates HIP offloading at the linking stage and creates the HIP toolchain.
> > 
> > For -fno-gpu-rdc mode, it locates the HIP runtime library and links it.
> > 
> > For -fgpu-rdc mode, it unbundles object files and does device linking and embedding.
> I am a little lost here.
> I have the feeling that the newbie syntax (compile+link in one invocation) should be
> ```
> clang++ --offload-arch=gfx906 -xhip sample.cpp -o sample
> ```
> since it should be obvious to the Driver that we want to produce a working program for a GPU.
> Or does this work producing a working program with another meaning?
Currently, the linker will only link HIP runtime library when --hip-link is specified.

The linker does not see `-xhip sample.cpp`. It only sees the intermediate obj files passed to it, therefore it does not know it is for HIP.

This could be improved by letting the clang driver add an implicit `--hip-link` option to the linker when the driver sees the linking of HIP input files. However, this needs a separate patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154123/new/

https://reviews.llvm.org/D154123



More information about the cfe-commits mailing list