[PATCH] D130193: [LLVM][Docs] Document the new driver for CUDA compilation

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 11:53:27 PDT 2022


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tra.
Herald added subscribers: mattd, yaxunl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch adds some small documentation for RDC support in clang using
the current default and the new driver. Previously there was not any
information on wherther or not this was supported in Clang so this
should help that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130193

Files:
  llvm/docs/CompileCudaWithLLVM.rst


Index: llvm/docs/CompileCudaWithLLVM.rst
===================================================================
--- llvm/docs/CompileCudaWithLLVM.rst
+++ llvm/docs/CompileCudaWithLLVM.rst
@@ -134,6 +134,32 @@
 
   This is implied by ``-ffast-math``.
 
+RDC-mode compilation
+--------------------
+
+Relocatable device code allows for CUDA device symbols to be linked between
+multiple CUDA files. clang by default does not support RDC-mode compilation,
+instead relying on `external tools<
+https://cmake.org/cmake/help/latest/prop_tgt/CUDA_SEPARABLE_COMPILATION.html>`
+to perform the necessary steps to link the device. However, experimental driver
+support exists in clang since llvm 15.0.
+
+The experimental driver can be invoked using the ``--offload-new-driver`` flag.
+This enables support for RDC-mode compilation via ``-fgpu-rdc``, device LTO via
+``-foffload-lto``, and static libraries containing device code. Compiling CUDA
+code using the experimental driver should cause RDC-mode compilation to behave
+like compilation on the host. An example is shown below.
+
+.. code-block:: console
+
+  $ clang++ foo.cu bar.cu -fgpu-rdc --offload-arch=<GPU arch> -c
+  $ clang++ foo.o bar.o --offload-link -L<CUDA install path>/<lib64 or lib> \
+      -lcudart_static -ldl -lrt -pthread
+
+Note that this new driver is not ABI compatible with binaries created by nvcc
+and is only supported on Unix machines. Additionally, the experimental driver
+does not emit PTX and will not be able to JIT incompatible device images.
+
 Standard library support
 ========================
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130193.446227.patch
Type: text/x-patch
Size: 1579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220720/166f6029/attachment.bin>


More information about the llvm-commits mailing list