[PATCH] D21867: [CUDA] Add utility functions for dealing with CUDA versions / architectures.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 30 12:53:06 PDT 2016


jlebar marked an inline comment as done.

================
Comment at: lib/Basic/Cuda.cpp:8-19
@@ +7,14 @@
+
+const char *CudaVersionToString(CudaVersion V) {
+  switch (V) {
+  case CudaVersion::UNKNOWN:
+    return "unknown";
+  case CudaVersion::CUDA_70:
+    return "7.0";
+  case CudaVersion::CUDA_75:
+    return "7.5";
+  case CudaVersion::CUDA_80:
+    return "8.0";
+  }
+}
+
----------------
tra wrote:
> We seem to do a lot of enum->string and string->enum mapping in this file. 
> Is there something comparable to Boost.bimap in standard c++ library or in LLVM?
> 
Not to my knowledge.

================
Comment at: lib/Driver/Driver.cpp:1026-1028
@@ -1024,4 +1025,5 @@
   } else if (CudaDeviceAction *CDA = dyn_cast<CudaDeviceAction>(A)) {
-    os << '"'
-       << (CDA->getGpuArchName() ? CDA->getGpuArchName() : "(multiple archs)")
+    os << '"' << (CDA->getGpuArch() != CudaArch::UNKNOWN
+                      ? CudaArchToString(CDA->getGpuArch())
+                      : "(multiple archs)")
        << '"' << ", {" << PrintActions1(C, *CDA->input_begin(), Ids) << "}";
----------------
tra wrote:
> I think this could be collapsed to just CudaArchToString(CDA->getGpuArch()).
> "(multiple archs)" is as informative as (and indistinguishable from) "unknown" here.
> 
> 
I'm not crazy about "unknown", since it *is* actually known.  How about we just not output anything?


http://reviews.llvm.org/D21867





More information about the cfe-commits mailing list