[PATCH] D135614: [OpenMP][CUDA][AMDGPU] Accept case insensitive subarchitecture names

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 10 13:08:10 PDT 2022


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, yaxunl, tra.
Herald added subscribers: kosarev, mattd, guansong, hiraditya, t-tye, tpr, dstuttard, kzhuravl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1, wdng.
Herald added projects: clang, LLVM.

The offloading toolchains are typically built by specifing a
subarchitecture during compilation via `--offload-arch=`. This patch
allows users to input subarchitecture names that ignore the case. So if
the user inputs `gfx90A` it will treat it as `gfx90a`. This is primarily
for user convenicence.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135614

Files:
  clang/lib/Basic/Cuda.cpp
  clang/test/Driver/openmp-offload-infer.c
  llvm/lib/Support/TargetParser.cpp


Index: llvm/lib/Support/TargetParser.cpp
===================================================================
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -151,7 +151,7 @@
 
 AMDGPU::GPUKind llvm::AMDGPU::parseArchAMDGCN(StringRef CPU) {
   for (const auto &C : AMDGCNGPUs) {
-    if (CPU == C.Name)
+    if (CPU.equals_insensitive(C.Name))
       return C.Kind;
   }
 
Index: clang/test/Driver/openmp-offload-infer.c
===================================================================
--- clang/test/Driver/openmp-offload-infer.c
+++ clang/test/Driver/openmp-offload-infer.c
@@ -18,6 +18,9 @@
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp \
 // RUN:     --offload-arch=sm_70 --offload-arch=gfx908:sramecc+:xnack- \
 // RUN:     -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NVIDIA-AMDGPU
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp \
+// RUN:     --offload-arch=SM_70 --offload-arch=GFX908:sramecc+:xnack- \
+// RUN:     -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NVIDIA-AMDGPU
 
 // CHECK-NVIDIA-AMDGPU: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[HOST_BC:.+]]"
 // CHECK-NVIDIA-AMDGPU: "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[AMD_BC:.+]]"
Index: clang/lib/Basic/Cuda.cpp
===================================================================
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -155,9 +155,10 @@
 }
 
 CudaArch StringToCudaArch(llvm::StringRef S) {
-  auto result = std::find_if(
-      std::begin(arch_names), std::end(arch_names),
-      [S](const CudaArchToStringMap &map) { return S == map.arch_name; });
+  auto result = std::find_if(std::begin(arch_names), std::end(arch_names),
+                             [S](const CudaArchToStringMap &map) {
+                               return S.equals_insensitive(map.arch_name);
+                             });
   if (result == std::end(arch_names))
     return CudaArch::UNKNOWN;
   return result->arch;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135614.466597.patch
Type: text/x-patch
Size: 2087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221010/b4448481/attachment.bin>


More information about the llvm-commits mailing list