Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ tvm_option(USE_PAPI "Use Performance Application Programming Interface (PAPI) to
tvm_option(USE_GTEST "Use GoogleTest for C++ sanity tests" AUTO)
tvm_option(USE_CUSTOM_LOGGING "Use user-defined custom logging, tvm::runtime::detail::LogFatalImpl and tvm::runtime::detail::LogMessageImpl must be implemented" OFF)
tvm_option(USE_ALTERNATIVE_LINKER "Use 'mold' or 'lld' if found when invoking compiler to link artifact" AUTO)
tvm_option(USE_CCACHE "Use ccache if found when invoking compiler" AUTO)

# 3rdparty libraries
tvm_option(DLPACK_PATH "Path to DLPACK" "3rdparty/dlpack/include")
Expand Down Expand Up @@ -460,6 +461,42 @@ if(USE_PIPELINE_EXECUTOR)
list(APPEND RUNTIME_SRCS ${RUNTIME_PIPELINE_SRCS})
endif(USE_PIPELINE_EXECUTOR)

#Caches the build.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spaces after comment #

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be ERROR if USE_CCACHE is on?

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})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possible to collapse this with the previous if case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic is clearer this way.

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}")
endif()
endif()
endif(USE_CCACHE)

# Module rules
include(cmake/modules/VTA.cmake)
include(cmake/modules/StandaloneCrt.cmake)
Expand Down
11 changes: 11 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,17 @@ set(USE_LIBBACKTRACE AUTO)
# runtime functions to be unavailable to the program.
set(BUILD_STATIC_RUNTIME OFF)

# Caches the build so that building is faster when switching between branches.
# If you switch branches, build and then encounter a linking error, you may
# need to regenerate the build tree through "make .." (the cache will
# still provide significant speedups).
# Possible values:
# - AUTO: search for path to ccache, disable if not found.
# - ON: enable ccache by searching for the path to ccache, report an error if not found
# - OFF: disable ccache
# - /path/to/ccache: use specific path to ccache
set(USE_CCACHE AUTO)

# Whether to enable PAPI support in profiling. PAPI provides access to hardware
# counters while profiling.
# Possible values:
Expand Down
2 changes: 2 additions & 0 deletions docs/install/from_source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ The configuration of TVM can be modified by editing `config.cmake` and/or by pas
- On supported platforms, the `Ccache compiler wrapper <https://ccache.dev/>`_ may be helpful for
reducing TVM's build time. There are several ways to enable CCache in TVM builds:

- Leave `USE_CCACHE=AUTO` in `build/config.cmake`. CCache will be used if it is found.

- Ccache's Masquerade mode. This is typically enabled during the Ccache installation process.
To have TVM use Ccache in masquerade, simply specify the appropriate C/C++ compiler
paths when configuring TVM's build system. For example:
Expand Down