[PATCH] D92363: [HIP] Warn no --offload-arch option
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 30 21:14:08 PST 2020
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.
This patch let clang emit a warning when no --offload-arch option is specified, which
usually indicates that users forget to specify this option.
https://reviews.llvm.org/D92363
Files:
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/hip-no-offload-arch.hip
Index: clang/test/Driver/hip-no-offload-arch.hip
===================================================================
--- /dev/null
+++ clang/test/Driver/hip-no-offload-arch.hip
@@ -0,0 +1,9 @@
+// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target, nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu -nogpuinc -nogpulib \
+// RUN: %s 2>&1 | FileCheck -check-prefix=WARN %s
+// WARN: warning: no offload arch is specified. Assuming gfx803. Use --offload-arch=<arch> to specify offload arch [-Whip-option-missing]
+
+// RUN: %clang -### -target x86_64-linux-gnu -nogpuinc -nogpulib \
+// RUN: -x cuda %s 2>&1 | FileCheck -check-prefix=NOWARN %s
+// NOWARN-NOT: warning
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2646,8 +2646,12 @@
// Default to sm_20 which is the lowest common denominator for
// supported GPUs. sm_20 code should work correctly, if
// suboptimally, on all newer GPUs.
- if (GpuArchList.empty())
+ if (GpuArchList.empty()) {
GpuArchList.push_back(DefaultCudaArch);
+ if (AssociatedOffloadKind == Action::OFK_HIP)
+ C.getDriver().Diag(clang::diag::warn_drv_no_offload_arch)
+ << CudaArchToString(DefaultCudaArch);
+ }
return Error;
}
Index: clang/include/clang/Basic/DiagnosticGroups.td
===================================================================
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1174,6 +1174,9 @@
// ignored by CUDA.
def HIPOnly : DiagGroup<"hip-only">;
+// A warning group for warnings about missing HIP options.
+def HIPOptionMising : DiagGroup<"hip-option-missing">;
+
// Warnings which cause linking of the runtime libraries like
// libc and the CRT to be skipped.
def AVRRtlibLinkingQuirks : DiagGroup<"avr-rtlib-linking-quirks">;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -82,6 +82,8 @@
"by colon, e.g. 'gfx908:sram-ecc+:xnack-')">;
def err_drv_bad_offload_arch_combo : Error<"Invalid offload arch combinations: %0 and %1 (For a specific "
"processor, a feature should either exist in all offload archs, or not exist in any offload archs)">;
+def warn_drv_no_offload_arch : Warning<"no offload arch is specified. Assuming %0. Use --offload-arch=<arch> to"
+ " specify offload arch">, InGroup<HIPOptionMising>;
def err_drv_invalid_thread_model_for_target : Error<
"invalid thread model '%0' in '%1' for this target">;
def err_drv_invalid_linker_name : Error<
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92363.308527.patch
Type: text/x-patch
Size: 2838 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201201/26d8213f/attachment.bin>
More information about the cfe-commits
mailing list