ZQPei commented on a change in pull request #9544:
URL: https://github.com/apache/tvm/pull/9544#discussion_r755648386



##########
File path: src/target/target_kind.cc
##########
@@ -143,6 +143,33 @@ void CheckOrSetAttr(Map<String, ObjectRef>* attrs, const 
String& name, const Str
 
 /**********  Target kind attribute updaters  **********/
 
+/*!
+ * \brief Update the attributes in the CUDA target.
+ * \param attrs The original attributes
+ * \return The updated attributes
+ */
+Map<String, ObjectRef> UpdateCUDAAttrs(Map<String, ObjectRef> attrs) {
+  // Update -arch=sm_xx
+  int archInt;
+  if (attrs.count("arch")) {
+    // If -arch has been specified, validate the correctness
+    String archStr = Downcast<String>(attrs.at("arch"));
+    archInt = ExtractIntWithPrefix(archStr, "sm_");
+    ICHECK(archInt != -1) << "ValueError: CUDA target gets an invalid CUDA 
arch: -arch=" << archStr;
+  } else {
+    // Use the compute version of the first CUDA GPU instead
+    TVMRetValue version;
+    if (!DetectDeviceFlag({kDLCUDA, 0}, runtime::kComputeVersion, &version)) {
+      LOG(WARNING) << "Unable to detect CUDA version, default to 
\"-arch=sm_20\" instead";
+      archInt = 20;

Review comment:
       1. To keep consistent with the `LLVM NVPTX target`, 
https://github.com/apache/tvm/blob/4bb6f3133ef7122543a861ea7d2610515e8e9a68/src/target/target_kind.cc#L164
   
   2. `sm_20` is the lowerest CUDA arch. This arch will finally result in an 
compilation error in `nvcc.py` since it is no longer be supported by most of NV 
devices. It will be an another way to remind users to specify cuda arch 
manually. lol




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to