driazati commented on code in PR #12839:
URL: https://github.com/apache/tvm/pull/12839#discussion_r974555026


##########
CMakeLists.txt:
##########
@@ -460,6 +460,42 @@ if(USE_PIPELINE_EXECUTOR)
   list(APPEND RUNTIME_SRCS ${RUNTIME_PIPELINE_SRCS})
 endif(USE_PIPELINE_EXECUTOR)
 
+#Caches the build.
+#Note that ccache-3.x doesn't support nvcc well, so CUDA kernels may never hit 
the cache and still
+#need to be re-compiled every time. Using ccache 4.0+ can resolve this issue.
+
+if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache

Review Comment:
   this should be a `tvm_option` that defaults to `auto`



##########
CMakeLists.txt:
##########
@@ -460,6 +460,42 @@ if(USE_PIPELINE_EXECUTOR)
   list(APPEND RUNTIME_SRCS ${RUNTIME_PIPELINE_SRCS})
 endif(USE_PIPELINE_EXECUTOR)
 
+#Caches the build.
+#Note that ccache-3.x doesn't support nvcc well, so CUDA kernels may never hit 
the cache and still
+#need to be re-compiled every time. Using ccache 4.0+ can resolve this issue.
+
+if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache
+  if(DEFINED CXX_COMPILER_LAUNCHER OR DEFINED C_COMPILER_LAUNCHER)
+    message(STATUS "CXX_COMPILER_LAUNCHER or C_COMPILER_LAUNCHER already 
defined, not using ccache")
+  else()
+    if("${USE_CCACHE}" STREQUAL "AUTO") # Auto mode
+      find_program(CCACHE_FOUND ccache)
+      if(CCACHE_FOUND)
+        message(STATUS "Found the path to ccache, enabling ccache")
+        set(PATH_TO_CCACHE ccache)
+      else()
+        message(STATUS "Didn't find the path to CCACHE, disabling ccache")
+      endif(CCACHE_FOUND)
+    elseif("${USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
+      find_program(CCACHE_FOUND ccache)
+      if(CCACHE_FOUND)
+        message(STATUS "Found the path to ccache, enabling ccache")
+        set(PATH_TO_CCACHE ccache)
+      else()
+        message(FATAL_ERROR "Cannot find ccache. Set USE_CCACHE mode to AUTO 
or OFF to build without ccache. USE_CCACHE=" "${USE_CCACHE}")
+      endif(CCACHE_FOUND)
+    else() # /path/to/ccache
+      set(PATH_TO_CCACHE USE_CCACHE)
+      message(STATUS "Setting ccache path to " "${PATH_TO_CCACHE}")
+    endif()
+    # Set the flag for ccache
+    if(DEFINED PATH_TO_CCACHE)
+      set(CXX_COMPILER_LAUNCHER PATH_TO_CCACHE)
+      set(C_COMPILER_LAUNCHER PATH_TO_CCACHE)

Review Comment:
   I think these set `C_COMPILER_LAUNCHER` to the text `PATH_TO_CCACHE`, not 
the contents of the variable



-- 
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: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to