[PATCH] D100552: [HIP] Diagnose compiling kernel without offload arch

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 15 05:11:37 PDT 2021


yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: kerbowa, tpr, nhaehnle, jvesely.
Herald added a reviewer: aaron.ballman.
yaxunl requested review of this revision.

AMDGPU does not have a common processor (GPU arch). A HIP kernel
must be compiled with a specified processor to be able to be launched
on that processor.

However we cannot simply diagnose missing --offload-arch in clang
driver since a valid HIP program can contain no kernel, which can be
compiled without specifying offload arch and executed on machines
without AMDGPU.

Therefore only HIP programs containing kernels should be diagnosed
when compiled without offload arch.

This patch changes clang driver so that when offload arch is not specified
for HIP, no target CPU is specified for clang -cc1. If HIP program contains
kernel, FE will diagnose it as a fatal error so that the diagnostics will be
emitted only once.  This way, we allow HIP programs without kernels to
be compiled without offload arch whereas forbid HIP programs with
kernels to be compiled without offload arch.


https://reviews.llvm.org/D100552

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
  clang/test/CodeGenCUDA/kernel-amdgcn.cu
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/CodeGenCUDA/kernel-dbg-info.cu
  clang/test/CodeGenCUDA/lambda-reference-var.cu
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/CodeGenCUDA/managed-var.cu
  clang/test/CodeGenCUDA/norecurse.cu
  clang/test/CodeGenCUDA/static-device-var-no-rdc.cu
  clang/test/CodeGenCUDA/static-device-var-rdc.cu
  clang/test/CodeGenCUDA/unnamed-types.cu
  clang/test/Driver/cuda-flush-denormals-to-zero.cu
  clang/test/Driver/hip-default-gpu-arch.hip
  clang/test/SemaCUDA/kernel-no-gpu.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100552.337721.patch
Type: text/x-patch
Size: 15465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210415/aa46c724/attachment-0001.bin>


More information about the cfe-commits mailing list