[PATCH] D21867: [CUDA] Add utility functions for dealing with CUDA versions / architectures.
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 30 09:50:56 PDT 2016
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.
LGTM.
================
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";
+ }
+}
+
----------------
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?
================
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) << "}";
----------------
I think this could be collapsed to just CudaArchToString(CDA->getGpuArch()).
"(multiple archs)" is as informative as (and indistinguishable from) "unknown" here.
http://reviews.llvm.org/D21867
More information about the cfe-commits
mailing list