chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache
|
||||
|
||||
if(DEFINED CMAKE_C_COMPILER_LAUNCHER)
|
||||
if("${USE_CCACHE}" STREQUAL "AUTO")
|
||||
message(STATUS "CMAKE_C_COMPILER_LAUNCHER already defined. Not using ccache.")
|
||||
elseif("${USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
|
||||
message(FATAL_ERROR "CMAKE_C_COMPILER_LAUNCHER already defined. Refusing to override with ccache. Either unset or disable ccache.")
|
||||
endif()
|
||||
|
||||
elseif(DEFINED CMAKE_CXX_COMPILER_LAUNCHER)
|
||||
if("${USE_CCACHE}" STREQUAL "AUTO")
|
||||
message(STATUS "CMAKE_CXX_COMPILER_LAUNCHER already defined. Not using ccache.")
|
||||
elseif("${USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
|
||||
message(FATAL_ERROR "CMAKE_CXX_COMPILER_LAUNCHER already defined. Refusing to override with ccache. Either unset or disable ccache.")
|
||||
endif()
|
||||
|
||||
elseif(DEFINED CMAKE_CUDA_COMPILER_LAUNCHER)
|
||||
if("${USE_CCACHE}" STREQUAL "AUTO")
|
||||
message(STATUS "CMAKE_CUDA_COMPILER_LAUNCHER already defined. Not using ccache.")
|
||||
elseif("${USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
|
||||
message(FATAL_ERROR "CMAKE_CUDA_COMPILER_LAUNCHER already defined. Refusing to override with ccache. Either unset or disable ccache.")
|
||||
endif()
|
||||
|
||||
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(CMAKE_CXX_COMPILER_LAUNCHER "${PATH_TO_CCACHE}")
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${PATH_TO_CCACHE}")
|
||||
set(CMAKE_CUDA_COMPILER_LAUNCHER "${PATH_TO_CCACHE}")
|
||||
endif()
|
||||
endif()
|
||||
endif(USE_CCACHE)
|
||||
@@ -0,0 +1,143 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
#######################################################
|
||||
# Enhanced version of find CUDA.
|
||||
#
|
||||
# Usage:
|
||||
# find_cuda(${USE_CUDA} ${USE_CUDNN})
|
||||
#
|
||||
# - When USE_CUDA=ON, use auto search
|
||||
# - When USE_CUDA=/path/to/cuda-path, use the CUDA path
|
||||
# - When USE_CUDNN=ON, use auto search
|
||||
# - When USE_CUDNN=/path/to/cudnn-path, use the cudnn path
|
||||
#
|
||||
# Provide variables:
|
||||
#
|
||||
# - CUDA_FOUND
|
||||
# - CUDA_INCLUDE_DIRS
|
||||
# - CUDA_TOOLKIT_ROOT_DIR
|
||||
# - CUDA_CUDA_LIBRARY
|
||||
# - CUDA_CUDART_LIBRARY
|
||||
# - CUDA_CUDNN_INCLUDE_DIRS
|
||||
# - CUDA_CUDNN_LIBRARY
|
||||
# - CUDA_CUBLAS_LIBRARY
|
||||
#
|
||||
macro(find_cuda use_cuda use_cudnn)
|
||||
set(__use_cuda ${use_cuda})
|
||||
if(${__use_cuda} MATCHES ${IS_TRUE_PATTERN})
|
||||
find_package(CUDA QUIET)
|
||||
elseif(IS_DIRECTORY ${__use_cuda})
|
||||
set(CUDA_TOOLKIT_ROOT_DIR ${__use_cuda})
|
||||
message(STATUS "Custom CUDA_PATH=" ${CUDA_TOOLKIT_ROOT_DIR})
|
||||
set(CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_ROOT_DIR}/include)
|
||||
set(CUDA_FOUND TRUE)
|
||||
if(MSVC)
|
||||
find_library(CUDA_CUDART_LIBRARY cudart
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32)
|
||||
else(MSVC)
|
||||
find_library(CUDA_CUDART_LIBRARY cudart
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib64
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib)
|
||||
endif(MSVC)
|
||||
endif()
|
||||
|
||||
# additional libraries
|
||||
if(CUDA_FOUND)
|
||||
if(MSVC)
|
||||
find_library(CUDA_CUDA_LIBRARY cuda
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32)
|
||||
find_library(CUDA_CUBLAS_LIBRARY cublas
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32)
|
||||
find_library(CUDA_CUBLASLT_LIBRARY cublaslt
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32)
|
||||
else(MSVC)
|
||||
find_library(_CUDA_CUDA_LIBRARY cuda
|
||||
PATHS ${CUDA_TOOLKIT_ROOT_DIR}
|
||||
PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs lib64/stubs lib/x86_64-linux-gnu
|
||||
NO_DEFAULT_PATH)
|
||||
if(_CUDA_CUDA_LIBRARY)
|
||||
set(CUDA_CUDA_LIBRARY ${_CUDA_CUDA_LIBRARY})
|
||||
endif()
|
||||
find_library(CUDA_CURAND_LIBRARY curand
|
||||
PATHS ${CUDA_TOOLKIT_ROOT_DIR}
|
||||
PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs lib64/stubs lib/x86_64-linux-gnu
|
||||
NO_DEFAULT_PATH)
|
||||
find_library(CUDA_CUBLAS_LIBRARY cublas
|
||||
PATHS ${CUDA_TOOLKIT_ROOT_DIR}
|
||||
PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs lib64/stubs lib/x86_64-linux-gnu
|
||||
NO_DEFAULT_PATH)
|
||||
# search default path if cannot find cublas in non-default
|
||||
find_library(CUDA_CUBLAS_LIBRARY cublas)
|
||||
find_library(CUDA_CUBLASLT_LIBRARY
|
||||
NAMES cublaslt cublasLt
|
||||
PATHS ${CUDA_TOOLKIT_ROOT_DIR}
|
||||
PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs lib64/stubs lib/x86_64-linux-gnu
|
||||
NO_DEFAULT_PATH)
|
||||
find_library(CUDA_NVTX_LIBRARY
|
||||
NAMES nvToolsExt nvTools nvtoolsext nvtools nvtx NVTX nvtx3interop
|
||||
PATHS "${CUDA_CUDART_LIBRARY_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}" ENV LD_LIBRARY_PATH
|
||||
PATH_SUFFIXES "lib64" "common/lib64" "common/lib" "lib"
|
||||
DOC "Location of the CUDA Toolkit Extension (NVTX) library"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
# search default path if cannot find cublaslt in non-default
|
||||
find_library(CUDA_CUBLASLT_LIBRARY NAMES cublaslt cublasLt)
|
||||
endif(MSVC)
|
||||
|
||||
# find cuDNN
|
||||
set(__use_cudnn ${use_cudnn})
|
||||
if(${__use_cudnn} MATCHES ${IS_TRUE_PATTERN})
|
||||
set(CUDA_CUDNN_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
|
||||
if(MSVC)
|
||||
find_library(CUDA_CUDNN_LIBRARY cudnn
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64
|
||||
${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32)
|
||||
else(MSVC)
|
||||
find_library(CUDA_CUDNN_LIBRARY cudnn
|
||||
PATHS ${CUDA_TOOLKIT_ROOT_DIR}
|
||||
PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs lib64/stubs lib/x86_64-linux-gnu
|
||||
NO_DEFAULT_PATH)
|
||||
# search default path if cannot find cudnn in non-default
|
||||
find_library(CUDA_CUDNN_LIBRARY cudnn)
|
||||
endif(MSVC)
|
||||
elseif(IS_DIRECTORY ${__use_cudnn})
|
||||
# cuDNN doesn't necessarily live in the CUDA dir
|
||||
set(CUDA_CUDNN_ROOT_DIR ${__use_cudnn})
|
||||
set(CUDA_CUDNN_INCLUDE_DIRS ${CUDA_CUDNN_ROOT_DIR}/include)
|
||||
find_library(CUDA_CUDNN_LIBRARY cudnn
|
||||
${CUDA_CUDNN_ROOT_DIR}/lib64
|
||||
${CUDA_CUDNN_ROOT_DIR}/lib
|
||||
NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
message(STATUS "Found CUDA_TOOLKIT_ROOT_DIR=" ${CUDA_TOOLKIT_ROOT_DIR})
|
||||
message(STATUS "Found CUDA_CUDA_LIBRARY=" ${CUDA_CUDA_LIBRARY})
|
||||
message(STATUS "Found CUDA_CUDART_LIBRARY=" ${CUDA_CUDART_LIBRARY})
|
||||
message(STATUS "Found CUDA_CUDNN_INCLUDE_DIRS=" ${CUDA_CUDNN_INCLUDE_DIRS})
|
||||
message(STATUS "Found CUDA_CUDNN_LIBRARY=" ${CUDA_CUDNN_LIBRARY})
|
||||
message(STATUS "Found CUDA_CUBLAS_LIBRARY=" ${CUDA_CUBLAS_LIBRARY})
|
||||
message(STATUS "Found CUDA_CURAND_LIBRARY=" ${CUDA_CURAND_LIBRARY})
|
||||
message(STATUS "Found CUDA_CUBLASLT_LIBRARY=" ${CUDA_CUBLASLT_LIBRARY})
|
||||
message(STATUS "Found CUDA_NVTX_LIBRARY=" ${CUDA_NVTX_LIBRARY})
|
||||
message(STATUS "Found CUDA_nvToolsExt_LIBRARY=" ${CUDA_nvToolsExt_LIBRARY})
|
||||
endif(CUDA_FOUND)
|
||||
endmacro(find_cuda)
|
||||
@@ -0,0 +1,280 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
#######################################################
|
||||
# Enhanced version of find llvm.
|
||||
#
|
||||
# Usage:
|
||||
# find_llvm(${USE_LLVM} [${LLVM_VERSION}])
|
||||
#
|
||||
# - When USE_LLVM=ON, use auto search
|
||||
# - When USE_LLVM=/path/to/llvm-config, use corresponding config
|
||||
# - The optional LLVM_VERSION=<required version> which will find a matching version
|
||||
# If LLVM_VERSION=10 then it will find 10.X.X, any version of 10
|
||||
# If LLVM_VERSION=10.2 then it will find 10.2.X
|
||||
#
|
||||
# Provide variables:
|
||||
# - LLVM_INCLUDE_DIRS
|
||||
# - LLVM_LIBS
|
||||
# - LLVM_DEFINITIONS
|
||||
# - TVM_LLVM_VERSION
|
||||
#
|
||||
macro(find_llvm use_llvm)
|
||||
if(${use_llvm} MATCHES ${IS_FALSE_PATTERN})
|
||||
return()
|
||||
endif()
|
||||
set(LLVM_CONFIG ${use_llvm})
|
||||
if(${ARGC} EQUAL 2)
|
||||
set(llvm_version_required ${ARGV1})
|
||||
endif()
|
||||
|
||||
if(${LLVM_CONFIG} MATCHES ${IS_TRUE_PATTERN})
|
||||
# This is a workaround for an upstream LLVM issue [0], in which
|
||||
# the `CMAKE_INSTALL_LIBDIR` variable is used before definition.
|
||||
# While there is an LLVM PR to resolve this fix [1], as of
|
||||
# 2024-08-19 it has not yet been merged to LLVM.
|
||||
#
|
||||
# [0] https://github.com/llvm/llvm-project/issues/83802
|
||||
# [1] https://github.com/llvm/llvm-project/pull/83807
|
||||
include(GNUInstallDirs)
|
||||
|
||||
find_package(LLVM ${llvm_version_required} REQUIRED CONFIG)
|
||||
llvm_map_components_to_libnames(LLVM_LIBS "all")
|
||||
if (NOT LLVM_LIBS)
|
||||
message(STATUS "Not found - LLVM_LIBS")
|
||||
message(STATUS "Fall back to using llvm-config")
|
||||
set(LLVM_CONFIG "${LLVM_TOOLS_BINARY_DIR}/llvm-config")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(LLVM_LIBS) # check if defined, not if it is true
|
||||
list (FIND LLVM_LIBS "LLVM" _llvm_dynlib_index)
|
||||
if (${_llvm_dynlib_index} GREATER -1)
|
||||
set(LLVM_LIBS LLVM)
|
||||
message(STATUS "Link with dynamic LLVM library")
|
||||
else()
|
||||
list(REMOVE_ITEM LLVM_LIBS LTO)
|
||||
message(STATUS "Link with static LLVM libraries")
|
||||
endif()
|
||||
set(TVM_LLVM_VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR})
|
||||
set(TVM_LLVM_HAS_AARCH64_TARGET 0)
|
||||
if(DEFINED LLVM_TARGETS_TO_BUILD AND "AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
|
||||
set(TVM_LLVM_HAS_AARCH64_TARGET 1)
|
||||
endif()
|
||||
else()
|
||||
# use llvm config
|
||||
message(STATUS "Use llvm-config=" ${LLVM_CONFIG})
|
||||
separate_arguments(LLVM_CONFIG)
|
||||
execute_process(COMMAND ${LLVM_CONFIG} --libfiles
|
||||
RESULT_VARIABLE __llvm_exit_code
|
||||
OUTPUT_VARIABLE __llvm_libfiles_space
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT "${__llvm_exit_code}" STREQUAL "0")
|
||||
message(FATAL_ERROR "Fatal error executing: ${LLVM_CONFIG} --libfiles")
|
||||
endif()
|
||||
execute_process(COMMAND ${LLVM_CONFIG} --system-libs
|
||||
RESULT_VARIABLE __llvm_exit_code
|
||||
OUTPUT_VARIABLE __llvm_system_libs
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT "${__llvm_exit_code}" STREQUAL "0")
|
||||
message(FATAL_ERROR "Fatal error executing: ${LLVM_CONFIG} --system-libs")
|
||||
endif()
|
||||
execute_process(COMMAND ${LLVM_CONFIG} --cxxflags
|
||||
RESULT_VARIABLE __llvm_exit_code
|
||||
OUTPUT_VARIABLE __llvm_cxxflags_space
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT "${__llvm_exit_code}" STREQUAL "0")
|
||||
message(FATAL_ERROR "Fatal error executing: ${LLVM_CONFIG} --cxxflags")
|
||||
endif()
|
||||
execute_process(COMMAND ${LLVM_CONFIG} --version
|
||||
RESULT_VARIABLE __llvm_exit_code
|
||||
OUTPUT_VARIABLE __llvm_version
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT "${__llvm_exit_code}" STREQUAL "0")
|
||||
message(FATAL_ERROR "Fatal error executing: ${LLVM_CONFIG} --version")
|
||||
endif()
|
||||
execute_process(COMMAND ${LLVM_CONFIG} --prefix
|
||||
RESULT_VARIABLE __llvm_exit_code
|
||||
OUTPUT_VARIABLE __llvm_prefix
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT "${__llvm_exit_code}" STREQUAL "0")
|
||||
message(FATAL_ERROR "Fatal error executing: ${LLVM_CONFIG} --prefix")
|
||||
endif()
|
||||
execute_process(COMMAND ${LLVM_CONFIG} --libdir
|
||||
RESULT_VARIABLE __llvm_exit_code
|
||||
OUTPUT_VARIABLE __llvm_libdir
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT "${__llvm_exit_code}" STREQUAL "0")
|
||||
message(FATAL_ERROR "Fatal error executing: ${LLVM_CONFIG} --libdir")
|
||||
endif()
|
||||
message(STATUS "LLVM libdir: ${__llvm_libdir}")
|
||||
execute_process(COMMAND ${LLVM_CONFIG} --cmakedir
|
||||
RESULT_VARIABLE __llvm_exit_code
|
||||
OUTPUT_VARIABLE __llvm_cmakedir
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT "${__llvm_exit_code}" STREQUAL "0")
|
||||
message(FATAL_ERROR "Fatal error executing: ${LLVM_CONFIG} --cmakedir")
|
||||
endif()
|
||||
execute_process(COMMAND ${LLVM_CONFIG} --targets-built
|
||||
RESULT_VARIABLE __llvm_exit_code
|
||||
OUTPUT_VARIABLE __llvm_targets_built
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT "${__llvm_exit_code}" STREQUAL "0")
|
||||
message(FATAL_ERROR "Fatal error executing: ${LLVM_CONFIG} --targets-built")
|
||||
endif()
|
||||
cmake_path(SET "__llvm_cmakedir" "${__llvm_cmakedir}")
|
||||
message(STATUS "LLVM cmakedir: ${__llvm_cmakedir}")
|
||||
# map prefix => $
|
||||
# to handle the case when the prefix contains space.
|
||||
string(REPLACE ${__llvm_prefix} "$" __llvm_cxxflags ${__llvm_cxxflags_space})
|
||||
string(REPLACE ${__llvm_prefix} "$" __llvm_libfiles ${__llvm_libfiles_space})
|
||||
# llvm version
|
||||
string(REGEX REPLACE "^([^.]+)\.([^.])+\.[^.]+.*$" "\\1\\2" TVM_LLVM_VERSION ${__llvm_version})
|
||||
string(STRIP ${TVM_LLVM_VERSION} TVM_LLVM_VERSION)
|
||||
# definitions
|
||||
string(REGEX MATCHALL "(^| )-D[A-Za-z0-9_]*" __llvm_defs ${__llvm_cxxflags})
|
||||
set(LLVM_DEFINITIONS "")
|
||||
foreach(__flag IN ITEMS ${__llvm_defs})
|
||||
string(STRIP "${__flag}" __llvm_def)
|
||||
list(APPEND LLVM_DEFINITIONS "${__llvm_def}")
|
||||
endforeach()
|
||||
# include dir
|
||||
string(REGEX MATCHALL "(^| )-I[^ ]*" __llvm_include_flags ${__llvm_cxxflags})
|
||||
set(LLVM_INCLUDE_DIRS "")
|
||||
foreach(__flag IN ITEMS ${__llvm_include_flags})
|
||||
string(REGEX REPLACE "(^| )-I" "" __dir "${__flag}")
|
||||
# map $ => prefix
|
||||
string(REPLACE "$" ${__llvm_prefix} __dir_with_prefix "${__dir}")
|
||||
list(APPEND LLVM_INCLUDE_DIRS "${__dir_with_prefix}")
|
||||
endforeach()
|
||||
# libfiles
|
||||
set(LLVM_LIBS "")
|
||||
separate_arguments(__llvm_libfiles)
|
||||
foreach(__flag IN ITEMS ${__llvm_libfiles})
|
||||
# map $ => prefix
|
||||
string(REPLACE "$" ${__llvm_prefix} __lib_with_prefix "${__flag}")
|
||||
list(APPEND LLVM_LIBS "${__lib_with_prefix}")
|
||||
endforeach()
|
||||
# targets built
|
||||
set(TVM_LLVM_HAS_AARCH64_TARGET 0)
|
||||
separate_arguments(BUILT_TARGET_LIST NATIVE_COMMAND ${__llvm_targets_built})
|
||||
if("AArch64" IN_LIST BUILT_TARGET_LIST)
|
||||
set(TVM_LLVM_HAS_AARCH64_TARGET 1)
|
||||
endif()
|
||||
if (${USE_MLIR})
|
||||
if (EXISTS "${__llvm_libdir}/libMLIRPresburger.a")
|
||||
if (EXISTS "${__llvm_libdir}/libMLIRSupport.a")
|
||||
message(STATUS "Found MLIR")
|
||||
list(APPEND LLVM_LIBS "${__llvm_libdir}/libMLIRPresburger.a")
|
||||
list(APPEND LLVM_LIBS "${__llvm_libdir}/libMLIRSupport.a")
|
||||
set(TVM_MLIR_VERSION ${TVM_LLVM_VERSION})
|
||||
message(STATUS "Build with MLIR")
|
||||
message(STATUS "Set TVM_MLIR_VERSION=" ${TVM_MLIR_VERSION})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
separate_arguments(__llvm_system_libs)
|
||||
foreach(__flag IN ITEMS ${__llvm_system_libs})
|
||||
if("${__flag}" STREQUAL "-lm")
|
||||
message(STATUS "LLVM links against math")
|
||||
list(APPEND LLVM_LIBS "m")
|
||||
elseif(("${__flag}" STREQUAL "-lz") OR ("${__flag}" STREQUAL "z.lib"))
|
||||
message(STATUS "LLVM links against zlib")
|
||||
find_package(ZLIB REQUIRED)
|
||||
list(APPEND LLVM_LIBS "ZLIB::ZLIB")
|
||||
elseif("${__flag}" STREQUAL "-lzstd")
|
||||
list(APPEND CMAKE_MODULE_PATH "${__llvm_cmakedir}")
|
||||
find_package(zstd REQUIRED)
|
||||
if (TARGET "zstd::libzstd_static")
|
||||
message(STATUS "LLVM links against static zstd")
|
||||
list(APPEND LLVM_LIBS "zstd::libzstd_static")
|
||||
else()
|
||||
message(STATUS "LLVM links against shared zstd")
|
||||
list(APPEND LLVM_LIBS "zstd::libzstd_shared")
|
||||
endif()
|
||||
elseif("${__flag}" STREQUAL "-lxml2")
|
||||
message(STATUS "LLVM links against xml2")
|
||||
list(APPEND LLVM_LIBS "-lxml2")
|
||||
elseif("${__flag}" STREQUAL "zstd.dll.lib")
|
||||
if (EXISTS "${__llvm_libdir}/zstd_static.lib")
|
||||
message(STATUS "LLVM links against static zstd")
|
||||
list(APPEND LLVM_LIBS "${__llvm_libdir}/zstd_static.lib")
|
||||
else()
|
||||
message(STATUS "LLVM linker flag under LLVM libdir: ${__llvm_libdir}/zstd.lib")
|
||||
list(APPEND LLVM_LIBS "${__llvm_libdir}/zstd.lib")
|
||||
endif()
|
||||
elseif((__flag MATCHES ".lib$") AND (EXISTS "${__llvm_libdir}/${__flag}"))
|
||||
# If the library file ends in .lib try to also search the llvm_libdir
|
||||
message(STATUS "LLVM linker flag under LLVM libdir: ${__llvm_libdir}/${__flag}")
|
||||
list(APPEND LLVM_LIBS "${__llvm_libdir}/${__flag}")
|
||||
elseif((__flag MATCHES ".lib$") AND (EXISTS "${__llvm_libdir}/lib${__flag}"))
|
||||
# If the library file ends in .lib try to also search the llvm_libdir with lib prefix
|
||||
message(STATUS "LLVM linker flag under LLVM libdir: ${__llvm_libdir}/lib${__flag}")
|
||||
list(APPEND LLVM_LIBS "${__llvm_libdir}/lib${__flag}")
|
||||
else()
|
||||
message(STATUS "LLVM linker flag: ${__flag}")
|
||||
list(APPEND LLVM_LIBS "${__flag}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
message(STATUS "Found LLVM_INCLUDE_DIRS=" "${LLVM_INCLUDE_DIRS}")
|
||||
message(STATUS "Found LLVM_DEFINITIONS=" "${LLVM_DEFINITIONS}")
|
||||
message(STATUS "Found LLVM_LIBS=" "${LLVM_LIBS}")
|
||||
message(STATUS "Found TVM_LLVM_VERSION=" ${TVM_LLVM_VERSION})
|
||||
if (${TVM_LLVM_VERSION} LESS 150)
|
||||
message(FATAL_ERROR "TVM requires LLVM 15.0 or higher.")
|
||||
endif()
|
||||
message(STATUS "Found TVM_LLVM_HAS_AARCH64_TARGET=" ${TVM_LLVM_HAS_AARCH64_TARGET})
|
||||
|
||||
# Detect whether DIBuilder insertion APIs (insertDeclare,
|
||||
# insertDbgValueIntrinsic) accept BasicBlock::iterator as the insertion point
|
||||
# (upstream LLVM 20+) vs Instruction* (pre-LLVM 20 and ROCm-bundled LLVM 20,
|
||||
# which reports version 200 but retains the legacy Instruction* overload).
|
||||
if (${TVM_LLVM_VERSION} GREATER_EQUAL 200)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CMakePushCheckState)
|
||||
cmake_push_check_state(RESET)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${LLVM_INCLUDE_DIRS})
|
||||
# Only force -std= when the outer project hasn't already selected a
|
||||
# standard; signature-only probe does not need -fno-rtti. Use the
|
||||
# compiler-appropriate form so the probe works under MSVC as well.
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
if(MSVC)
|
||||
set(CMAKE_REQUIRED_FLAGS "/std:c++20")
|
||||
else()
|
||||
set(CMAKE_REQUIRED_FLAGS "-std=c++20")
|
||||
endif()
|
||||
endif()
|
||||
check_cxx_source_compiles("
|
||||
#include <llvm/IR/DIBuilder.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
void f(llvm::DIBuilder* b, llvm::Value* v, llvm::DILocalVariable* var,
|
||||
llvm::DIExpression* e, const llvm::DILocation* dl,
|
||||
llvm::Instruction* i) {
|
||||
b->insertDeclare(v, var, e, dl, llvm::BasicBlock::iterator(i));
|
||||
b->insertDbgValueIntrinsic(v, var, e, dl, llvm::BasicBlock::iterator(i));
|
||||
}
|
||||
" TVM_LLVM_DIBUILDER_USES_ITERATOR)
|
||||
cmake_pop_check_state()
|
||||
if(TVM_LLVM_DIBUILDER_USES_ITERATOR)
|
||||
add_definitions(-DTVM_LLVM_DIBUILDER_USES_ITERATOR=1)
|
||||
message(STATUS "LLVM DIBuilder insertion APIs use BasicBlock::iterator")
|
||||
else()
|
||||
message(STATUS "LLVM DIBuilder insertion APIs use Instruction* (ROCm or older LLVM 20)")
|
||||
endif()
|
||||
endif()
|
||||
endmacro(find_llvm)
|
||||
@@ -0,0 +1,57 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Variables used by this module, they can change the default behaviour and need
|
||||
# to be set before calling find_package:
|
||||
#
|
||||
# NCCL_ROOT - When set, this path is inspected instead of standard library
|
||||
# locations as the root of the NCCL installation.
|
||||
# The environment variable NCCL_ROOT overrides this variable.
|
||||
#
|
||||
# This module defines
|
||||
# Nccl_FOUND, whether nccl has been found
|
||||
# NCCL_INCLUDE_DIR, directory containing header
|
||||
# NCCL_LIBRARY, directory containing nccl library
|
||||
# This module assumes that the user has already called find_package(CUDA)
|
||||
|
||||
macro(find_nccl use_nccl)
|
||||
if(${use_nccl} MATCHES ${IS_FALSE_PATTERN})
|
||||
return()
|
||||
endif()
|
||||
set(NCCL_LIB_NAME nccl_static)
|
||||
if(${use_nccl} MATCHES ${IS_TRUE_PATTERN})
|
||||
find_path(NCCL_INCLUDE_DIR NAMES nccl.h)
|
||||
find_library(NCCL_LIBRARY NAMES nccl_static)
|
||||
else()
|
||||
find_path(NCCL_INCLUDE_DIR NAMES nccl.h HINTS ${use_nccl} ${use_nccl}/include)
|
||||
find_library(NCCL_LIBRARY NAMES nccl_static HINTS ${use_nccl} ${use_nccl}/lib)
|
||||
endif()
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Nccl DEFAULT_MSG NCCL_INCLUDE_DIR NCCL_LIBRARY)
|
||||
if (Nccl_FOUND)
|
||||
message(STATUS "Found NCCL_LIBRARY: ${NCCL_LIBRARY}")
|
||||
message(STATUS "Found NCCL_INCLUDE_DIR: ${NCCL_INCLUDE_DIR}")
|
||||
add_library(nccl SHARED IMPORTED)
|
||||
set_target_properties(nccl
|
||||
PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${NCCL_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${NCCL_LIBRARY}")
|
||||
else()
|
||||
message(STATUS "NCCL not found")
|
||||
endif()
|
||||
mark_as_advanced(NCCL_INCLUDE_DIR NCCL_LIBRARY)
|
||||
endmacro(find_nccl)
|
||||
@@ -0,0 +1,52 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
#######################################################
|
||||
# Enhanced version of find NVSHMEM.
|
||||
#
|
||||
# Usage:
|
||||
# find_nvshmem(${USE_NVSHMEM})
|
||||
#
|
||||
# - When USE_NVSHMEM=ON, use auto search
|
||||
# - When USE_NVSHMEM=/path/to/installed/nvshmem, use the installed nvshmem path.
|
||||
# Can be useful when nvshmem is installed at specified location.
|
||||
#
|
||||
# Provide variables:
|
||||
#
|
||||
# - NVSHMEM_FOUND
|
||||
# - NVSHMEM_INCLUDE_DIR
|
||||
# - NVSHMEM_LIB_DIR
|
||||
#
|
||||
|
||||
macro(find_nvshmem use_nvshmem)
|
||||
set(__use_nvshmem ${use_nvshmem})
|
||||
if(IS_DIRECTORY ${__use_nvshmem})
|
||||
set(__nvshmem_path ${__use_nvshmem})
|
||||
message(STATUS "Custom NVSHMEM PATH=" ${__use_nvshmem})
|
||||
elseif(IS_DIRECTORY $ENV{NVSHMEM_HOME})
|
||||
set(__nvshmem_path $ENV{NVSHMEM_HOME})
|
||||
else()
|
||||
set(__nvshmem_path "")
|
||||
endif()
|
||||
|
||||
find_package(NVSHMEM HINTS ${__nvshmem_path}/lib/cmake/nvshmem/)
|
||||
|
||||
if(NVSHMEM_FOUND)
|
||||
message(STATUS "NVSHMEM_INCLUDE_DIR=" ${NVSHMEM_INCLUDE_DIR})
|
||||
message(STATUS "NVSHMEM_LIB_DIR=" ${NVSHMEM_LIB_DIR})
|
||||
endif(NVSHMEM_FOUND)
|
||||
endmacro(find_nvshmem)
|
||||
@@ -0,0 +1,72 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
#######################################################
|
||||
# Enhanced version of find OpenCL.
|
||||
#
|
||||
# Usage:
|
||||
# find_opencl(${USE_OPENCL})
|
||||
#
|
||||
# - When USE_OPENCL=ON, use OpenCL wrapper for dynamic linking
|
||||
# - When USE_OPENCL=/path/to/opencl-sdk-path, use the sdk.
|
||||
# Can be useful when cross compiling and cannot rely on
|
||||
# CMake to provide the correct library as part of the
|
||||
# requested toolchain.
|
||||
#
|
||||
# Provide variables:
|
||||
#
|
||||
# - OpenCL_FOUND
|
||||
# - OpenCL_INCLUDE_DIRS
|
||||
# - OpenCL_LIBRARIES
|
||||
#
|
||||
|
||||
macro(find_opencl use_opencl)
|
||||
set(__use_opencl ${use_opencl})
|
||||
if(IS_DIRECTORY ${__use_opencl})
|
||||
set(__opencl_sdk ${__use_opencl})
|
||||
message(STATUS "Custom OpenCL SDK PATH=" ${__use_opencl})
|
||||
elseif(IS_DIRECTORY $ENV{OPENCL_SDK})
|
||||
set(__opencl_sdk $ENV{OPENCL_SDK})
|
||||
else()
|
||||
set(__opencl_sdk "")
|
||||
endif()
|
||||
|
||||
if(__opencl_sdk)
|
||||
set(OpenCL_INCLUDE_DIRS ${__opencl_sdk}/include ${__opencl_sdk})
|
||||
if (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY STREQUAL "ONLY")
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
|
||||
endif()
|
||||
# we are in the section dedicated to the explicit pointing of OpenCL SDK path, we must not
|
||||
# look for the OpenCL library by default path, but should be limited by provided SDK
|
||||
find_library(OpenCL_LIBRARIES NAMES OpenCL NO_DEFAULT_PATH PATHS ${__opencl_sdk}/lib ${__opencl_sdk}/lib64 ${__opencl_sdk}/lib/x64/)
|
||||
if(OpenCL_LIBRARIES)
|
||||
set(OpenCL_FOUND TRUE)
|
||||
endif()
|
||||
endif(__opencl_sdk)
|
||||
|
||||
# No user provided OpenCL include/libs found
|
||||
if(NOT OpenCL_FOUND)
|
||||
if(${__use_opencl} MATCHES ${IS_TRUE_PATTERN})
|
||||
find_package(OpenCL QUIET)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(OpenCL_FOUND)
|
||||
message(STATUS "OpenCL_INCLUDE_DIRS=" ${OpenCL_INCLUDE_DIRS})
|
||||
message(STATUS "OpenCL_LIBRARIES=" ${OpenCL_LIBRARIES})
|
||||
endif(OpenCL_FOUND)
|
||||
endmacro(find_opencl)
|
||||
@@ -0,0 +1,52 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Variables used by this module, they can change the default behaviour and need
|
||||
# to be set before calling find_package:
|
||||
#
|
||||
# This module defines
|
||||
# Rccl_FOUND, whether rccl has been found
|
||||
# RCCL_INCLUDE_DIR, directory containing header
|
||||
# RCCL_LIBRARY, directory containing rccl library
|
||||
# This module assumes that the user has already called find_package(rocm)
|
||||
|
||||
macro(find_rccl use_rccl)
|
||||
if(${use_rccl} MATCHES ${IS_FALSE_PATTERN})
|
||||
return()
|
||||
endif()
|
||||
if(${use_rccl} MATCHES ${IS_TRUE_PATTERN})
|
||||
find_path(RCCL_INCLUDE_DIR NAMES rccl.h)
|
||||
find_library(RCCL_LIBRARY NAMES rccl)
|
||||
else()
|
||||
find_path(RCCL_INCLUDE_DIR NAMES rccl.h HINTS ${use_rccl} ${use_rccl}/include ${use_rccl}/include/rccl)
|
||||
find_library(RCCL_LIBRARY NAMES rccl HINTS ${use_rccl} ${use_rccl}/lib)
|
||||
endif()
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Rccl DEFAULT_MSG RCCL_INCLUDE_DIR RCCL_LIBRARY)
|
||||
if (Rccl_FOUND)
|
||||
message(STATUS "Found RCCL_LIBRARY: ${RCCL_LIBRARY}")
|
||||
message(STATUS "Found RCCL_INCLUDE_DIR: ${RCCL_INCLUDE_DIR}")
|
||||
add_library(rccl SHARED IMPORTED)
|
||||
set_target_properties(rccl
|
||||
PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${RCCL_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${RCCL_LIBRARY}")
|
||||
else()
|
||||
message(STATUS "RCCL not found")
|
||||
endif()
|
||||
mark_as_advanced(RCCL_INCLUDE_DIR RCCL_LIBRARY)
|
||||
endmacro(find_rccl)
|
||||
@@ -0,0 +1,68 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
#######################################################
|
||||
# Enhanced version of find rocm.
|
||||
#
|
||||
# Usage:
|
||||
# find_rocm(${USE_ROCM})
|
||||
#
|
||||
# - When USE_ROCM=ON, use auto search
|
||||
# - When USE_ROCM=/path/to/rocm-sdk-path, use the sdk
|
||||
#
|
||||
# Provide variables:
|
||||
#
|
||||
# - ROCM_FOUND
|
||||
# - ROCM_INCLUDE_DIRS
|
||||
# - ROCM_HIPHCC_LIBRARY
|
||||
#
|
||||
|
||||
macro(find_rocm use_rocm)
|
||||
set(__use_rocm ${use_rocm})
|
||||
if(IS_DIRECTORY ${__use_rocm})
|
||||
set(__rocm_sdk ${__use_rocm})
|
||||
message(STATUS "Custom ROCM SDK PATH=" ${__use_rocm})
|
||||
elseif(IS_DIRECTORY $ENV{ROCM_PATH})
|
||||
set(__rocm_sdk $ENV{ROCM_PATH})
|
||||
elseif(IS_DIRECTORY /opt/rocm)
|
||||
set(__rocm_sdk /opt/rocm)
|
||||
else()
|
||||
set(__rocm_sdk "")
|
||||
endif()
|
||||
|
||||
if(__rocm_sdk)
|
||||
set(ROCM_INCLUDE_DIRS ${__rocm_sdk}/include)
|
||||
find_library(ROCM_HIPHCC_LIBRARY amdhip64 ${__rocm_sdk}/lib)
|
||||
# Backward compatible with before ROCm3.7
|
||||
if(NOT ROCM_HIPHCC_LIBRARY)
|
||||
find_library(ROCM_HIPHCC_LIBRARY hip_hcc ${__rocm_sdk}/lib)
|
||||
endif()
|
||||
find_library(ROCM_HIPBLAS_LIBRARY hipblas ${__rocm_sdk}/lib)
|
||||
find_library(ROCM_HIPBLASLT_LIBRARY hipblaslt ${__rocm_sdk}/lib)
|
||||
find_library(ROCM_HSA_LIBRARY hsa-runtime64 ${__rocm_sdk}/lib)
|
||||
|
||||
if(ROCM_HIPHCC_LIBRARY)
|
||||
set(ROCM_FOUND TRUE)
|
||||
endif()
|
||||
endif(__rocm_sdk)
|
||||
if(ROCM_FOUND)
|
||||
message(STATUS "Found ROCM_INCLUDE_DIRS=" ${ROCM_INCLUDE_DIRS})
|
||||
message(STATUS "Found ROCM_HIPHCC_LIBRARY=" ${ROCM_HIPHCC_LIBRARY})
|
||||
message(STATUS "Found ROCM_HIPBLAS_LIBRARY=" ${ROCM_HIPBLAS_LIBRARY})
|
||||
message(STATUS "Found ROCM_HIPBLASLT_LIBRARY=" ${ROCM_HIPBLASLT_LIBRARY})
|
||||
endif(ROCM_FOUND)
|
||||
endmacro(find_rocm)
|
||||
@@ -0,0 +1,98 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
#######################################################
|
||||
# Enhanced version of find Vulkan.
|
||||
#
|
||||
# Usage:
|
||||
# find_vulkan(${USE_VULKAN})
|
||||
#
|
||||
# - When USE_VULKAN=ON, use auto search
|
||||
# - When USE_VULKAN=/path/to/vulkan-sdk-path, use the sdk
|
||||
#
|
||||
# Provide variables:
|
||||
#
|
||||
# - Vulkan_FOUND
|
||||
# - Vulkan_INCLUDE_DIRS
|
||||
# - Vulkan_LIBRARY
|
||||
# - Vulkan_SPIRV_TOOLS_LIBRARY
|
||||
#
|
||||
|
||||
macro(find_vulkan use_vulkan use_khronos_spirv)
|
||||
set(__use_vulkan ${use_vulkan})
|
||||
if(IS_DIRECTORY ${__use_vulkan})
|
||||
set(__vulkan_sdk ${__use_vulkan})
|
||||
message(STATUS "Custom Vulkan SDK PATH=" ${__use_vulkan})
|
||||
elseif(IS_DIRECTORY $ENV{VULKAN_SDK})
|
||||
set(__vulkan_sdk $ENV{VULKAN_SDK})
|
||||
else()
|
||||
set(__vulkan_sdk "")
|
||||
endif()
|
||||
|
||||
|
||||
if(IS_DIRECTORY ${use_khronos_spirv})
|
||||
set(__use_khronos_spirv ${use_khronos_spirv})
|
||||
message(STATUS "Custom khronos spirv PATH=" ${__use_khronos_spirv})
|
||||
else()
|
||||
set(__use_khronos_spirv "")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
set(VULKAN_NDK_SRC ${CMAKE_ANDROID_NDK}/sources/third_party/vulkan/src)
|
||||
set(Vulkan_INCLUDE_DIRS ${VULKAN_NDK_SRC}/include)
|
||||
set(Vulkan_FOUND TRUE)
|
||||
message(STATUS "Android Vulkan_INCLUDE_DIRS=" ${Vulkan_INCLUDE_DIRS})
|
||||
message(STATUS "Skip finding SPIRV in Android, make sure you only build tvm runtime.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(__vulkan_sdk)
|
||||
set(Vulkan_INCLUDE_DIRS ${__vulkan_sdk}/include)
|
||||
find_library(Vulkan_LIBRARY NAMES vulkan vulkan-1 PATHS ${__vulkan_sdk}/lib)
|
||||
if(Vulkan_LIBRARY)
|
||||
set(Vulkan_FOUND TRUE)
|
||||
endif()
|
||||
endif(__vulkan_sdk)
|
||||
|
||||
# resort to find vulkan of option is on
|
||||
if(NOT Vulkan_FOUND)
|
||||
if(${__use_vulkan} MATCHES ${IS_TRUE_PATTERN})
|
||||
find_package(Vulkan QUIET)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(Vulkan_FOUND)
|
||||
get_filename_component(VULKAN_LIBRARY_PATH ${Vulkan_LIBRARY} DIRECTORY)
|
||||
if (WIN32)
|
||||
find_library(Vulkan_SPIRV_TOOLS_LIBRARY SPIRV-Tools
|
||||
HINTS ${__use_khronos_spirv}/spirv-tools/lib ${VULKAN_LIBRARY_PATH} ${VULKAN_LIBRARY_PATH}/spirv-tools ${VULKAN_SDK}/lib)
|
||||
find_path(_libspirv libspirv.h HINTS ${__use_khronos_spirv}/spirv-tools/include ${Vulkan_INCLUDE_DIRS} PATH_SUFFIXES vulkan spirv-tools)
|
||||
find_path(_spirv spirv.hpp HINTS ${__use_khronos_spirv}/SPIRV-Headers/include ${Vulkan_INCLUDE_DIRS} PATH_SUFFIXES vulkan SPIRV spirv/unified1 spirv-headers)
|
||||
else()
|
||||
find_library(Vulkan_SPIRV_TOOLS_LIBRARY SPIRV-Tools
|
||||
HINTS ${__use_khronos_spirv}/lib ${VULKAN_LIBRARY_PATH} ${VULKAN_LIBRARY_PATH}/spirv-tools ${VULKAN_SDK}/lib)
|
||||
find_path(_libspirv libspirv.h HINTS ${__use_khronos_spirv}/include ${Vulkan_INCLUDE_DIRS} PATH_SUFFIXES vulkan spirv-tools)
|
||||
find_path(_spirv spirv.hpp HINTS ${__use_khronos_spirv}/include ${Vulkan_INCLUDE_DIRS} PATH_SUFFIXES vulkan SPIRV spirv/unified1 spirv-headers)
|
||||
endif()
|
||||
|
||||
find_path(_glsl_std GLSL.std.450.h HINTS ${Vulkan_INCLUDE_DIRS} PATH_SUFFIXES vulkan SPIRV spirv/unified1 spirv-headers)
|
||||
list(APPEND Vulkan_INCLUDE_DIRS ${_libspirv} ${_spirv} ${_glsl_std})
|
||||
message(STATUS "Vulkan_INCLUDE_DIRS=" ${Vulkan_INCLUDE_DIRS})
|
||||
message(STATUS "Vulkan_LIBRARY=" ${Vulkan_LIBRARY})
|
||||
message(STATUS "Vulkan_SPIRV_TOOLS_LIBRARY=" ${Vulkan_SPIRV_TOOLS_LIBRARY})
|
||||
endif(Vulkan_FOUND)
|
||||
endmacro(find_vulkan)
|
||||
@@ -0,0 +1,86 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# Helpers for configuring library targets.
|
||||
|
||||
# Hide symbols from static archives linked into a shared library. This prevents
|
||||
# downstream libraries from accidentally binding to private archive symbols such
|
||||
# as those from libstdc++_nonshared.a.
|
||||
function(tvm_hide_static_linked_lib_symbols target_name)
|
||||
if(HIDE_PRIVATE_SYMBOLS
|
||||
AND CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD|OpenBSD"
|
||||
AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"
|
||||
)
|
||||
target_link_options(${target_name} PRIVATE "-Wl,--exclude-libs,ALL")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#######################################################
|
||||
# tvm_configure_target_library(target_name [RUNTIME_MODULE])
|
||||
#
|
||||
# Configure a TVM library target. The target always gets a relative rpath
|
||||
# ($ORIGIN / @loader_path) so that sibling shared libraries in the same
|
||||
# directory resolve each other regardless of the install location (e.g. inside a
|
||||
# Python wheel).
|
||||
#
|
||||
# For shared libraries and runtime modules, hide symbols that come from linked
|
||||
# static archives so downstream libraries cannot accidentally bind to private
|
||||
# archive symbols such as those from libstdc++_nonshared.a.
|
||||
#
|
||||
# With the RUNTIME_MODULE option -- used for the optional runtime backend
|
||||
# libraries (tvm_runtime_cuda, tvm_runtime_vulkan, ...) -- the target is also
|
||||
# emitted into the build "lib" directory and installed; when building the Python
|
||||
# module it is additionally installed into the package "lib" directory. Targets
|
||||
# that manage their own output directory / install rules (tvm_compiler,
|
||||
# tvm_runtime, ...) omit the option and take only the rpath.
|
||||
#
|
||||
# No-op if the target does not exist.
|
||||
function(tvm_configure_target_library target_name)
|
||||
if(NOT TARGET ${target_name})
|
||||
return()
|
||||
endif()
|
||||
cmake_parse_arguments(ARG "RUNTIME_MODULE" "" "" ${ARGN})
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
BUILD_RPATH "@loader_path"
|
||||
INSTALL_RPATH "@loader_path"
|
||||
)
|
||||
elseif(UNIX)
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
BUILD_RPATH "\$ORIGIN"
|
||||
INSTALL_RPATH "\$ORIGIN"
|
||||
)
|
||||
endif()
|
||||
|
||||
get_target_property(TVM_TARGET_TYPE ${target_name} TYPE)
|
||||
if(TVM_TARGET_TYPE STREQUAL "SHARED_LIBRARY" OR TVM_TARGET_TYPE STREQUAL "MODULE_LIBRARY")
|
||||
tvm_hide_static_linked_lib_symbols(${target_name})
|
||||
endif()
|
||||
|
||||
if(ARG_RUNTIME_MODULE)
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
)
|
||||
install(TARGETS ${target_name} DESTINATION lib${LIB_SUFFIX})
|
||||
if(TVM_BUILD_PYTHON_MODULE)
|
||||
install(TARGETS ${target_name} DESTINATION "lib")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -0,0 +1,65 @@
|
||||
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
#######################################################
|
||||
function(find_and_set_linker use_alternative_linker)
|
||||
if(${use_alternative_linker} MATCHES ${IS_FALSE_PATTERN})
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
|
||||
# mold and lld only support clang and gcc
|
||||
return()
|
||||
endif()
|
||||
|
||||
macro(add_to_linker_flags flag)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}" PARENT_SCOPE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${flag}" PARENT_SCOPE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${flag}" PARENT_SCOPE)
|
||||
message(STATUS "Added \"${flag}\" to linker flags " ${CMAKE_SHARED_LINKER_FLAGS})
|
||||
endmacro(add_to_linker_flags)
|
||||
|
||||
find_program(MOLD_BIN "mold")
|
||||
find_program(LLD_BIN "lld")
|
||||
|
||||
if(MOLD_BIN)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1)
|
||||
get_filename_component(MOLD_INSTALLATION_PREFIX "${MOLD_BIN}" DIRECTORY)
|
||||
get_filename_component(MOLD_INSTALLATION_PREFIX "${MOLD_INSTALLATION_PREFIX}" DIRECTORY)
|
||||
find_path(
|
||||
MOLD_LIBEXEC_DIR "ld"
|
||||
NO_DEFAULT_PATH
|
||||
HINTS "${MOLD_INSTALLATION_PREFIX}"
|
||||
PATH_SUFFIXES "libexec/mold" "lib/mold" "lib64/mold"
|
||||
NO_CACHE
|
||||
)
|
||||
if(MOLD_LIBEXEC_DIR)
|
||||
add_to_linker_flags(" -B \"${MOLD_LIBEXEC_DIR}\"")
|
||||
return()
|
||||
endif()
|
||||
else()
|
||||
add_to_linker_flags("-fuse-ld=mold")
|
||||
return()
|
||||
endif()
|
||||
elseif(LLD_BIN)
|
||||
add_to_linker_flags("-fuse-ld=lld")
|
||||
elseif(${use_alternative_linker} MATCHES ${IS_TRUE_PATTERN})
|
||||
message(FATAL_ERROR "Could not find 'mold' or 'lld' executable but USE_ALTERNATIVE_LINKER was set to ON")
|
||||
endif()
|
||||
|
||||
endfunction(find_and_set_linker)
|
||||
@@ -0,0 +1,77 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
function(pad_string output str padchar length)
|
||||
string(LENGTH "${str}" _strlen)
|
||||
math(EXPR _strlen "${length} - ${_strlen}")
|
||||
|
||||
if(_strlen GREATER 0)
|
||||
unset(_pad)
|
||||
foreach(_i RANGE 1 ${_strlen}) # inclusive
|
||||
string(APPEND _pad ${padchar})
|
||||
endforeach()
|
||||
string(APPEND str ${_pad})
|
||||
endif()
|
||||
|
||||
set(${output} "${str}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
macro(print_summary)
|
||||
message(STATUS " ---------------- Summary ----------------")
|
||||
|
||||
# Show some basic system information
|
||||
message(STATUS " CMake version : ${CMAKE_VERSION}")
|
||||
message(STATUS " CMake executable : ${CMAKE_COMMAND}")
|
||||
message(STATUS " Generator : ${CMAKE_GENERATOR}")
|
||||
message(STATUS " System : ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS " C++ compiler : ${CMAKE_CXX_COMPILER}")
|
||||
message(STATUS " C++ compiler ID : ${CMAKE_CXX_COMPILER_ID}")
|
||||
message(STATUS " C++ compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
message(STATUS " CXX flags : ${CMAKE_CXX_FLAGS}")
|
||||
message(STATUS " CXX launcher : ${CMAKE_CXX_COMPILER_LAUNCHER}")
|
||||
message(STATUS " Linker flags : ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
|
||||
get_directory_property(READABLE_COMPILE_DEFS DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)
|
||||
message(STATUS " Compile definitions : ${READABLE_COMPILE_DEFS}")
|
||||
|
||||
list(SORT TVM_ALL_OPTIONS)
|
||||
message(STATUS " Options:")
|
||||
|
||||
# Compute padding necessary for options
|
||||
set(MAX_LENGTH 0)
|
||||
foreach(OPTION ${TVM_ALL_OPTIONS})
|
||||
string(LENGTH ${OPTION} OPTIONLENGTH)
|
||||
if(${OPTIONLENGTH} GREATER ${MAX_LENGTH})
|
||||
set(MAX_LENGTH ${OPTIONLENGTH})
|
||||
endif()
|
||||
endforeach()
|
||||
math(EXPR PADDING_LENGTH "${MAX_LENGTH} + 3")
|
||||
|
||||
# Print each of the options (padded out so they're all aligned)
|
||||
foreach(OPTION ${TVM_ALL_OPTIONS})
|
||||
set(OPTION_VALUE "${${OPTION}}")
|
||||
pad_string(OUT " ${OPTION}" " " ${PADDING_LENGTH})
|
||||
message(STATUS ${OUT} " : " ${OPTION_VALUE})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
function(dump_options_to_file tvm_options)
|
||||
file(REMOVE ${CMAKE_BINARY_DIR}/TVMBuildOptions.txt)
|
||||
foreach(option ${tvm_options})
|
||||
file(APPEND ${CMAKE_BINARY_DIR}/TVMBuildOptions.txt "${option} ${${option}} \n")
|
||||
endforeach()
|
||||
endfunction()
|
||||
@@ -0,0 +1,104 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
macro(__tvm_option variable description value)
|
||||
if(NOT DEFINED ${variable})
|
||||
set(${variable} ${value} CACHE STRING ${description})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
set(TVM_ALL_OPTIONS)
|
||||
|
||||
#######################################################
|
||||
# An option that the user can select. Can accept condition to control when option is available for user.
|
||||
# Usage:
|
||||
# tvm_option(<option_variable> "doc string" <initial value or boolean expression> [IF <condition>])
|
||||
macro(tvm_option variable description value)
|
||||
set(__value ${value})
|
||||
set(__condition "")
|
||||
set(__varname "__value")
|
||||
list(APPEND TVM_ALL_OPTIONS ${variable})
|
||||
foreach(arg ${ARGN})
|
||||
if(arg STREQUAL "IF" OR arg STREQUAL "if")
|
||||
set(__varname "__condition")
|
||||
else()
|
||||
list(APPEND ${__varname} ${arg})
|
||||
endif()
|
||||
endforeach()
|
||||
unset(__varname)
|
||||
if("${__condition}" STREQUAL "")
|
||||
set(__condition 2 GREATER 1)
|
||||
endif()
|
||||
|
||||
if(${__condition})
|
||||
if("${__value}" MATCHES ";")
|
||||
# list values directly pass through
|
||||
__tvm_option(${variable} "${description}" "${__value}")
|
||||
elseif(DEFINED ${__value})
|
||||
if(${__value})
|
||||
__tvm_option(${variable} "${description}" ON)
|
||||
else()
|
||||
__tvm_option(${variable} "${description}" OFF)
|
||||
endif()
|
||||
else()
|
||||
__tvm_option(${variable} "${description}" "${__value}")
|
||||
endif()
|
||||
else()
|
||||
unset(${variable} CACHE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(assign_source_group group)
|
||||
foreach(_source IN ITEMS ${ARGN})
|
||||
if (IS_ABSOLUTE "${_source}")
|
||||
file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
|
||||
else()
|
||||
set(_source_rel "${_source}")
|
||||
endif()
|
||||
get_filename_component(_source_path "${_source_rel}" PATH)
|
||||
string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
|
||||
source_group("${group}\\${_source_path_msvc}" FILES "${_source}")
|
||||
endforeach()
|
||||
endfunction(assign_source_group)
|
||||
|
||||
# From CMake documentation:
|
||||
# True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number.
|
||||
# False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, the empty string, or ends in the suffix -NOTFOUND.
|
||||
# Named boolean constants are case-insensitive.
|
||||
#
|
||||
# While this regex does contain a check for an empty string that check does not work
|
||||
# CMake's regex is weak
|
||||
set(IS_FALSE_PATTERN "^[Oo][Ff][Ff]$|^0$|^[Ff][Aa][Ll][Ss][Ee]$|^[Nn][Oo]$|^[Nn][Oo][Tt][Ff][Oo][Uu][Nn][Dd]$|.*-[Nn][Oo][Tt][Ff][Oo][Uu][Nn][Dd]$|^$")
|
||||
set(IS_TRUE_PATTERN "^[Oo][Nn]$|^[1-9][0-9]*$|^[Tt][Rr][Uu][Ee]$|^[Yy][Ee][Ss]$|^[Yy]$")
|
||||
|
||||
# Custom file() macro that automatically uses CONFIGURE_DEPENDS if CMake
|
||||
# supports it. CONFIGURE_DEPENDS scans the globbed directories on each build to
|
||||
# check if any files have been added/removed. This has a small build overhead,
|
||||
# but ensures that you don't manually have to rerun cmake if files were added.
|
||||
# The macro should be used like so:
|
||||
# tvm_file_glob(GLOB VARIABLE_NAME dir/*.cc dir/*c)
|
||||
# or
|
||||
# tvm_file_glob(GLOB_RECURSE VARIABLE_NAME dir/*/*.cc)
|
||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
|
||||
macro(tvm_file_glob glob variable)
|
||||
file(${glob} ${variable} CONFIGURE_DEPENDS ${ARGN})
|
||||
endmacro()
|
||||
else()
|
||||
macro(tvm_file_glob)
|
||||
file(${glob} ${variable} ${ARGN})
|
||||
endmacro()
|
||||
endif()
|
||||
Reference in New Issue
Block a user