[all-commits] [llvm/llvm-project] a6786c: [HIPSPV][3/4] Enable SPIR-V emission for HIP

Yaxun (Sam) Liu via All-commits all-commits at lists.llvm.org
Mon Dec 20 08:01:04 PST 2021

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a6786cdd575701ec1a1bc42adc086cfb70201ad3
  Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M clang/include/clang/Basic/Cuda.h
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/include/clang/Driver/Driver.h
    M clang/include/clang/Driver/Options.td
    M clang/lib/Basic/Cuda.cpp
    M clang/lib/Basic/Targets/NVPTX.cpp
    M clang/lib/Basic/Targets/NVPTX.h
    M clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
    M clang/lib/Driver/Driver.cpp
    A clang/test/Driver/Inputs/hipspv-dev-lib/a/a.bc
    A clang/test/Driver/Inputs/hipspv-dev-lib/b/b.bc
    A clang/test/Driver/Inputs/hipspv-dev-lib/hipspv-spirv64.bc
    A clang/test/Driver/Inputs/hipspv/bin/.hipVersion
    A clang/test/Driver/Inputs/hipspv/lib/hip-device-lib/hipspv-spirv64.bc
    A clang/test/Driver/Inputs/hipspv/lib/libLLVMHipSpvPasses.so
    A clang/test/Driver/Inputs/pass-plugin.so
    A clang/test/Driver/hipspv-device-libs.hip
    A clang/test/Driver/hipspv-pass-plugin.hip
    A clang/test/Driver/hipspv-toolchain-rdc.hip
    A clang/test/Driver/hipspv-toolchain.hip
    A clang/test/Driver/invalid-offload-options.cpp

  Log Message:
  [HIPSPV][3/4] Enable SPIR-V emission for HIP

This patch enables SPIR-V binary emission for HIP device code via the
HIPSPV tool chain.

‘--offload’ option, which is envisioned in [1], is added for specifying
offload targets. This option is used to override default device target
(amdgcn-amd-amdhsa) for HIP compilation for emitting device code as
SPIR-V binary. The option is handled in getHIPOffloadTargetTriple().

getOffloadingDeviceToolChain() function (based on the design in the
SYCL repository) is added to select HIPSPVToolChain when HIP offload
target is ‘spirv64’.

The HIPActionBuilder is modified to produce LLVM IR at the backend
phase. HIPSPV tool chain expects to receive HIP device code as LLVM
IR so it can run external LLVM passes over them. HIPSPV TC is also
responsible for emitting the SPIR-V binary.

A Cuda GPU architecture ‘generic’ is added. The name is picked from
the LLVM SPIR-V Backend. In the HIPSPV code path the architecture
name is inserted to the bundle entry ID as target ID. Target ID is
expected to be always present so a component in the target triple
is not mistaken as target ID.

Tests are added for checking the HIPSPV tool chain.

[1]: https://lists.llvm.org/pipermail/cfe-dev/2020-December/067362.html

Patch by: Henry Linjamäki

Reviewed by: Yaxun Liu, Artem Belevich, Alexey Bader

Differential Revision: https://reviews.llvm.org/D110622

More information about the All-commits mailing list