2020-06-09 07:17:35 +08:00
# Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
2018-05-17 02:44:56 +08:00
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
# * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2019-11-20 08:55:34 +08:00
cmake_minimum_required ( VERSION 3.12.4 FATAL_ERROR )
2018-05-17 02:44:56 +08:00
2019-11-20 08:55:34 +08:00
if ( cutlass_LOADED )
# If CUTLASS has been previously fetched and loaded, don't do it again.
return ( )
else ( )
set ( cutlass_LOADED ON )
set ( CUTLASS_DIR ${ CMAKE_CURRENT_SOURCE_DIR } CACHE PATH "CUTLASS Repository Directory" )
endif ( )
message ( STATUS "CMake Version: ${CMAKE_VERSION}" )
2020-06-09 07:17:35 +08:00
project ( CUTLASS VERSION 2.2.0 LANGUAGES CXX )
2019-11-20 08:55:34 +08:00
include ( ${ CMAKE_CURRENT_SOURCE_DIR } /CUDA.cmake )
2018-05-17 02:44:56 +08:00
2019-11-20 08:55:34 +08:00
find_package ( Doxygen QUIET )
#
2020-04-08 04:51:25 +08:00
# CUTLASS 2.x requires C++11
2019-11-20 08:55:34 +08:00
#
set ( CMAKE_CXX_STANDARD 11 )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
set ( CMAKE_CXX_EXTENSIONS OFF )
if ( CUTLASS_NATIVE_CUDA )
set ( CMAKE_CUDA_STANDARD 11 )
set ( CMAKE_CUDA_STANDARD_REQUIRED ON )
2018-05-17 02:44:56 +08:00
else ( )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS --std=c++11 )
2019-11-20 08:55:34 +08:00
endif ( )
2018-05-17 02:44:56 +08:00
2019-11-20 08:55:34 +08:00
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
set ( CMAKE_INSTALL_PREFIX install CACHE PATH "Default installation location." FORCE )
2018-05-17 02:44:56 +08:00
endif ( )
2019-11-20 08:55:34 +08:00
message ( STATUS "Default Install Location: ${CMAKE_INSTALL_PREFIX}" )
2018-05-17 02:44:56 +08:00
2020-04-08 04:51:25 +08:00
set ( CUTLASS_ENABLE_HEADERS_ONLY OFF CACHE BOOL "Enable only the header library" )
if ( CUTLASS_ENABLE_HEADERS_ONLY )
set ( CUTLASS_ENABLE_EXAMPLES_INIT OFF )
set ( CUTLASS_ENABLE_TOOLS_INIT OFF )
2019-11-20 08:55:34 +08:00
else ( )
2020-04-08 04:51:25 +08:00
set ( CUTLASS_ENABLE_EXAMPLES_INIT ON )
set ( CUTLASS_ENABLE_TOOLS_INIT ON )
2019-11-20 08:55:34 +08:00
endif ( )
2019-05-03 01:40:05 +08:00
2020-04-08 04:51:25 +08:00
set ( CUTLASS_ENABLE_EXAMPLES ${ CUTLASS_ENABLE_EXAMPLES_INIT } CACHE BOOL "Enable CUTLASS Examples" )
set ( CUTLASS_ENABLE_TOOLS ${ CUTLASS_ENABLE_TOOLS_INIT } CACHE BOOL "Enable CUTLASS Tools" )
if ( ${ CMAKE_PROJECT_NAME } STREQUAL ${ PROJECT_NAME } )
set ( CUTLASS_ENABLE_TESTS_INIT ${ CUTLASS_ENABLE_TOOLS_INIT } )
else ( )
set ( CUTLASS_ENABLE_TESTS_INIT OFF )
endif ( )
set ( CUTLASS_ENABLE_TESTS ${ CUTLASS_ENABLE_TESTS_INIT } CACHE BOOL "Enable CUTLASS Tests" )
2019-11-20 08:55:34 +08:00
if ( CUTLASS_ENABLE_TESTS )
include ( ${ CMAKE_CURRENT_SOURCE_DIR } /cmake/googletest.cmake )
endif ( )
set ( CUTLASS_NVCC_ARCHS_SUPPORTED "" )
if ( NOT CUDA_VERSION VERSION_LESS 7.5 )
2020-06-09 07:17:35 +08:00
list ( APPEND CUTLASS_NVCC_ARCHS_SUPPORTED 53 )
2019-11-20 08:55:34 +08:00
endif ( )
if ( NOT CUDA_VERSION VERSION_LESS 8.0 )
list ( APPEND CUTLASS_NVCC_ARCHS_SUPPORTED 60 61 )
endif ( )
if ( NOT CUDA_VERSION VERSION_LESS 9.0 )
list ( APPEND CUTLASS_NVCC_ARCHS_SUPPORTED 70 )
endif ( )
if ( NOT CUDA_VERSION VERSION_LESS 9.2 )
list ( APPEND CUTLASS_NVCC_ARCHS_SUPPORTED 72 )
endif ( )
if ( NOT CUDA_VERSION VERSION_LESS 10.0 )
list ( APPEND CUTLASS_NVCC_ARCHS_SUPPORTED 75 )
2019-05-03 01:40:05 +08:00
endif ( )
2020-06-09 07:17:35 +08:00
if ( NOT CUDA_VERSION VERSION_LESS 11.0 )
list ( APPEND CUTLASS_NVCC_ARCHS_SUPPORTED 80 )
endif ( )
2019-11-20 08:55:34 +08:00
set ( CUTLASS_NVCC_ARCHS ${ CUTLASS_NVCC_ARCHS_SUPPORTED } CACHE STRING "The SM architectures requested." )
set ( CUTLASS_NVCC_ARCHS_ENABLED ${ CUTLASS_NVCC_ARCHS } CACHE STRING "The SM architectures to build code for." )
# Special policy introduced in CMake 3.13
if ( POLICY CMP0076 )
cmake_policy ( SET CMP0076 NEW )
2020-04-08 04:51:25 +08:00
endif ( )
2019-11-20 08:55:34 +08:00
2020-04-08 04:51:25 +08:00
if ( NOT CMAKE_SIZEOF_VOID_P EQUAL 8 )
2018-05-17 02:44:56 +08:00
message ( FATAL_ERROR "CUTLASS requires a 64-bit compiler!" )
endif ( )
2019-11-20 08:55:34 +08:00
include ( GNUInstallDirs )
2018-05-17 02:44:56 +08:00
2020-04-08 04:51:25 +08:00
link_directories ( ${ CUDA_TOOLKIT_ROOT_DIR } /lib64/stubs )
2018-09-19 07:58:03 +08:00
###################################################################################################
#
# Configure CMake variables
#
###################################################################################################
2019-11-20 08:55:34 +08:00
message ( STATUS "CUDA Compilation Architectures: ${CUTLASS_NVCC_ARCHS_ENABLED}" )
2018-09-19 07:58:03 +08:00
2018-05-17 02:44:56 +08:00
if ( NOT ( CMAKE_BUILD_TYPE OR CONFIGURATION_TYPES ) )
2020-04-08 04:51:25 +08:00
# By default we want to build in Release mode to ensure that we're getting best performance.
2018-05-17 02:44:56 +08:00
set ( CMAKE_BUILD_TYPE Release CACHE STRING "Choose build level" FORCE )
2018-09-19 07:58:03 +08:00
set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "RelWithDebInfo" "Release" )
2018-05-17 02:44:56 +08:00
endif ( )
2020-04-08 04:51:25 +08:00
set ( CMAKE_POSITION_INDEPENDENT_CODE ON )
set ( CUTLASS_LIBRARY_DEBUG_POSTFIX ".debug" CACHE STRING "Default postfix value for debug libraries" )
2018-05-17 02:44:56 +08:00
if ( WIN32 )
# On Windows we link against the shared (DLL) runtime. Change gtest settings to match this.
set ( gtest_force_shared_crt ON CACHE BOOL "Use shared (DLL) run-time lib even when Google Test is built as static lib" FORCE )
endif ( )
if ( WIN32 )
2019-03-21 01:49:17 +08:00
# Enable more warnings and treat as errors
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS -Xcompiler=/W3 -Xcompiler=/WX )
2018-05-17 02:44:56 +08:00
2019-03-21 01:49:17 +08:00
# Disable warning on Unicode characters
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS -Xcompiler=/wd4819 )
2018-05-17 02:44:56 +08:00
2019-03-21 01:49:17 +08:00
# Disable excess x86 floating point precision that can lead to results being labeled incorrectly
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS -Xcompiler=/fp:strict )
2018-05-17 02:44:56 +08:00
endif ( WIN32 )
2019-11-20 08:55:34 +08:00
if ( ${ CUTLASS_NVCC_VERBOSE } )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS -v )
2019-03-21 01:49:17 +08:00
endif ( )
2018-09-19 07:58:03 +08:00
set ( CUTLASS_NVCC_EMBED_CUBIN ON CACHE BOOL "Embed compiled CUDA kernel binaries into executables." )
set ( CUTLASS_NVCC_EMBED_PTX ON CACHE BOOL "Embed compiled PTX into executables." )
set ( CUTLASS_NVCC_KEEP OFF CACHE BOOL "Keep intermediate files generated by NVCC." )
2020-06-09 07:17:35 +08:00
set ( CUTLASS_ENABLE_F16C OFF CACHE BOOL "Enable F16C x86 extensions in host code." )
2020-04-08 04:51:25 +08:00
#
# CUTLASS generator cmake configuration
#
set ( CUTLASS_LIBRARY_OPERATIONS "all" CACHE STRING "Comma delimited list of operation name filters. Default '' means all operations are enabled." )
set ( CUTLASS_LIBRARY_KERNELS "" CACHE STRING "Comma delimited list of kernel name filters. If unspecified, only the largest tile size is enabled. If 'all' is specified, all kernels are enabled." )
2019-11-20 08:55:34 +08:00
# Test Levels L0, L1, L2
set ( CUTLASS_TEST_LEVEL "0" CACHE STRING "Level of tests to compile." )
set_property ( CACHE CUTLASS_TEST_LEVEL PROPERTY STRINGS 0 1 2 )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS -DCUTLASS_TEST_LEVEL= ${ CUTLASS_TEST_LEVEL } )
2018-09-19 07:58:03 +08:00
2019-11-20 08:55:34 +08:00
#
2019-03-21 01:49:17 +08:00
# CUDA 10.1 introduces "mma" in PTX performing collective matrix multiply operations.
2019-11-20 08:55:34 +08:00
#
2019-03-21 01:49:17 +08:00
if ( CUDA_VERSION VERSION_LESS 10.1 )
set ( CUTLASS_ENABLE_TENSOR_CORE_MMA_DEFAULT OFF )
else ( )
set ( CUTLASS_ENABLE_TENSOR_CORE_MMA_DEFAULT ON )
endif ( )
2020-04-08 04:51:25 +08:00
set ( CUTLASS_ENABLE_TENSOR_CORE_MMA ${ CUTLASS_ENABLE_TENSOR_CORE_MMA_DEFAULT } CACHE BOOL
2019-03-21 01:49:17 +08:00
" E n a b l e P T X m m a i n s t r u c t i o n f o r c o l l e c t i v e m a t r i x m u l t i p l y o p e r a t i o n s . " )
2018-09-19 07:58:03 +08:00
#
# NOTE: running with asan and CUDA requires the following environment variable:
#
# ASAN_OPTIONS=protect_shadow_gap=0:replace_intrin=0:detect_leaks=0
#
# without the above environment setting, an error like the following may be generated:
#
# *** Error: Could not detect active GPU device ID [out of memory]
# ...
# ==9149==ERROR: LeakSanitizer: detected memory leaks
# ...
#
if ( ENABLE_ASAN ) # https://github.com/google/sanitizers/wiki/AddressSanitizer
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS --compiler-options=-fsanitize=address --compiler-options=-fno-omit-frame-pointer )
2018-09-19 07:58:03 +08:00
string ( APPEND CMAKE_EXE_LINKER_FLAGS " -fsanitize=address" )
endif ( )
2018-05-17 02:44:56 +08:00
2018-09-19 07:58:03 +08:00
###################################################################################################
#
# Configure CUDA build options
#
###################################################################################################
2019-05-03 01:40:05 +08:00
if ( CUTLASS_NVCC_EMBED_PTX )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_CLANG_FLAGS --cuda-include-ptx=all )
2019-05-03 01:40:05 +08:00
endif ( )
2019-03-21 01:49:17 +08:00
if ( CUTLASS_ENABLE_TENSOR_CORE_MMA )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_FLAGS -DCUTLASS_ENABLE_TENSOR_CORE_MMA=1 )
2019-03-21 01:49:17 +08:00
endif ( )
2019-11-20 08:55:34 +08:00
if ( NOT MSVC AND CUTLASS_NVCC_KEEP )
# MSVC flow handles caching already, but for other generators we handle it here.
set ( CUTLASS_NVCC_KEEP_DIR ${ CMAKE_CURRENT_BINARY_DIR } /tmp CACHE PATH "Location to store NVCC scratch files" )
file ( MAKE_DIRECTORY ${ CUTLASS_NVCC_KEEP_DIR } )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS --keep ) # --keep-dir may not work with nvcc for some directories.
list ( APPEND CUTLASS_CUDA_CLANG_FLAGS -save-temps= ${ CUTLASS_NVCC_KEEP_DIR } )
2019-03-21 01:49:17 +08:00
endif ( )
2020-04-08 04:51:25 +08:00
if ( CUTLASS_ENABLE_F16C AND NOT CMAKE_CROSSCOMPILING )
list ( APPEND CUTLASS_CUDA_FLAGS -DCUTLASS_ENABLE_F16C=1 )
2019-11-20 08:55:34 +08:00
if ( ( CMAKE_CXX_COMPILER_ID MATCHES "GNU" ) OR ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS -Xcompiler=-mf16c )
2019-11-20 08:55:34 +08:00
elseif ( ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" ) )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS -Xcompiler=/arch:AVX2 )
2019-11-20 08:55:34 +08:00
endif ( )
2019-03-21 01:49:17 +08:00
endif ( )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS $< $<BOOL:${UNIX} > :-Xcompiler=-Wconversion> )
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS $< $<BOOL:${UNIX} > :-Xcompiler=-fno-strict-aliasing> )
2018-05-17 02:44:56 +08:00
2020-04-08 04:51:25 +08:00
# Don't leak lineinfo in release builds
if ( NOT CMAKE_BUILD_TYPE MATCHES "Release" )
list ( APPEND CUTLASS_CUDA_CLANG_FLAGS -gmlt )
list ( APPEND CUTLASS_CUDA_NVCC_FLAGS -lineinfo )
2018-10-27 05:38:46 +08:00
endif ( )
2019-11-20 08:55:34 +08:00
if ( CUDA_COMPILER MATCHES "[Cc]lang" )
2020-04-08 04:51:25 +08:00
if ( NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
message ( FATAL_ERROR "Clang CUDA compilation requires Clang CXX compilation. Currently CMAKE_CXX_COMPILER is ${CMAKE_CXX_COMPILER_ID}" )
endif ( )
if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0 )
message ( FATAL_ERROR "Clang 7.0+ required for GPU compilation" )
endif ( )
list ( APPEND CUTLASS_CUDA_CLANG_FLAGS --cuda-path= ${ CUDA_TOOLKIT_ROOT_DIR } )
2020-06-09 07:17:35 +08:00
list ( APPEND CUTLASS_CUDA_CLANG_FLAGS -mllvm -pragma-unroll-threshold=100000 )
list ( APPEND CUTLASS_CUDA_CLANG_FLAGS -mllvm -unroll-threshold=5000 )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_CLANG_FLAGS -Wno-unused-command-line-argument )
2018-05-17 02:44:56 +08:00
2019-11-21 01:52:11 +08:00
string ( REPLACE "." ";" CUDA_VERSION_PARTS ${ CMAKE_CUDA_COMPILER_VERSION } )
list ( GET CUDA_VERSION_PARTS 0 CUDA_VERSION_MAJOR )
list ( GET CUDA_VERSION_PARTS 1 CUDA_VERSION_MINOR )
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_CLANG_FLAGS -D__CUDACC_VER_MAJOR__= ${ CUDA_VERSION_MAJOR } -D__CUDACC_VER_MINOR__= ${ CUDA_VERSION_MINOR } )
2019-11-21 01:52:11 +08:00
2019-11-20 08:55:34 +08:00
# needed for libcublasLt.so in case it's installed in the same location as libcudart.so
# dynamic linker can find it if linker sets RPATH (forced by --disable-new-tags)
# Otherwise linker uses RUNPATH and that does not propagate to loaded libs.
2020-04-08 04:51:25 +08:00
list ( APPEND CUTLASS_CUDA_CLANG_FLAGS -Wl,--disable-new-dtags )
2018-05-17 02:44:56 +08:00
2019-11-20 08:55:34 +08:00
link_libraries ( nvidia::cudart )
endif ( )
2020-04-08 04:51:25 +08:00
function ( cutlass_apply_cuda_gencode_flags TARGET )
set ( NVCC_FLAGS )
set ( CLANG_FLAGS )
foreach ( ARCH ${ CUTLASS_NVCC_ARCHS_ENABLED } )
2020-06-09 07:17:35 +08:00
list ( APPEND CLANG_FLAGS --cuda-gpu-arch=sm_ ${ ARCH } )
2020-04-08 04:51:25 +08:00
set ( CODES )
if ( CUTLASS_NVCC_EMBED_CUBIN )
list ( APPEND CODES sm_ ${ ARCH } )
endif ( )
if ( CUTLASS_NVCC_EMBED_PTX )
list ( APPEND CODES compute_ ${ ARCH } )
endif ( )
list ( JOIN CODES "," CODES_STR )
list ( APPEND NVCC_FLAGS -gencode=arch=compute_ ${ ARCH } ,code=[ ${ CODES_STR } ] )
endforeach ( )
if ( CUDA_COMPILER MATCHES "[Cc]lang" )
target_compile_options (
$ { T A R G E T }
P R I V A T E
$ < $ < C O M P I L E _ L A N G U A G E : C X X > : $ { C L A N G _ F L A G S } >
)
else ( )
target_compile_options (
$ { T A R G E T }
P R I V A T E
$ < $ < C O M P I L E _ L A N G U A G E : C U D A > : $ { N V C C _ F L A G S } >
)
endif ( )
endfunction ( )
function ( cutlass_apply_standard_compile_options TARGET )
if ( CUDA_COMPILER MATCHES "[Cc]lang" )
set ( CUDA_COMPILE_LANGUAGE CXX )
set ( _FLAGS ${ CUTLASS_CUDA_FLAGS } ${ CUTLASS_CUDA_CLANG_FLAGS } )
set ( _FLAGS_RELEASE ${ CUTLASS_CUDA_FLAGS_RELEASE } ${ CUTLASS_CUDA_CLANG_FLAGS_RELEASE } )
set ( _FLAGS_RELWITHDEBINFO ${ CUTLASS_CUDA_FLAGS_RELWITHDEBINFO } ${ CUTLASS_CUDA_CLANG_FLAGS_RELWITHDEBINFO } )
set ( _FLAGS_DEBUG ${ CUTLASS_CUDA_FLAGS_DEBUG } ${ CUTLASS_CUDA_CLANG_FLAGS_DEBUG } )
else ( )
set ( CUDA_COMPILE_LANGUAGE CUDA )
set ( _FLAGS ${ CUTLASS_CUDA_FLAGS } ${ CUTLASS_CUDA_NVCC_FLAGS } )
set ( _FLAGS_RELEASE ${ CUTLASS_CUDA_FLAGS_RELEASE } ${ CUTLASS_CUDA_NVCC_FLAGS_RELEASE } )
set ( _FLAGS_RELWITHDEBINFO ${ CUTLASS_CUDA_FLAGS_RELWITHDEBINFO } ${ CUTLASS_CUDA_NVCC_FLAGS_RELWITHDEBINFO } )
set ( _FLAGS_DEBUG ${ CUTLASS_CUDA_FLAGS_DEBUG } ${ CUTLASS_CUDA_NVCC_FLAGS_DEBUG } )
endif ( )
target_compile_options (
$ { T A R G E T }
P R I V A T E
$ < $ < C O M P I L E _ L A N G U A G E : $ { C U D A _ C O M P I L E _ L A N G U A G E } > : $ { _ F L A G S } >
$ < $ < C O M P I L E _ L A N G U A G E : $ { C U D A _ C O M P I L E _ L A N G U A G E } > : $ < $ < C O N F I G : R E L E A S E > : $ { _ F L A G S _ R E L E A S E } > >
$ < $ < C O M P I L E _ L A N G U A G E : $ { C U D A _ C O M P I L E _ L A N G U A G E } > : $ < $ < C O N F I G : R E L W I T H D E B I N F O > : $ { _ F L A G S _ R E L W I T H D E B I N F O } > >
$ < $ < C O M P I L E _ L A N G U A G E : $ { C U D A _ C O M P I L E _ L A N G U A G E } > : $ < $ < C O N F I G : D E B U G > : $ { _ F L A G S _ D E B U G } > >
)
endfunction ( )
2018-05-17 02:44:56 +08:00
#
# The following items should eventually be pushed into cutlass/CMakeLists.txt
#
# GLOB for CUTLASS header files. Should we use a static list instead?
2019-11-20 08:55:34 +08:00
file ( GLOB_RECURSE CUTLASS_INCLUDE RELATIVE ${ CMAKE_CURRENT_SOURCE_DIR } include/cutlass/*.h )
file ( GLOB_RECURSE CUTLASS_CUTLASS RELATIVE ${ CMAKE_CURRENT_SOURCE_DIR } /include include/cutlass/*.h )
file ( GLOB_RECURSE CUTLASS_NVRTC RELATIVE ${ CMAKE_CURRENT_SOURCE_DIR } /test test/unit/nvrtc/kernel/*.h )
2018-10-27 05:38:46 +08:00
2018-09-19 07:58:03 +08:00
###################################################################################################
#
# Define build targets
#
###################################################################################################
2018-05-17 02:44:56 +08:00
2019-11-20 08:55:34 +08:00
source_group ( TREE ${ CMAKE_CURRENT_SOURCE_DIR } /include REGULAR_EXPRESSION ".*\.h" )
2018-05-17 02:44:56 +08:00
add_library ( CUTLASS INTERFACE )
2019-11-20 08:55:34 +08:00
add_library ( nvidia::cutlass::cutlass ALIAS CUTLASS )
set_target_properties ( CUTLASS PROPERTIES EXPORT_NAME cutlass )
set ( CUTLASS_INCLUDE_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /include CACHE PATH "CUTLASS Header Library" )
set ( CUTLASS_GENERATOR_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /tools/library/ )
# The following utility directory is needed even if the tools build is disabled, so it exists here.
set ( CUTLASS_TOOLS_UTIL_INCLUDE_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /tools/util/include CACHE INTERNAL "" )
include_directories ( ${ CUTLASS_INCLUDE_DIR } )
target_compile_features ( CUTLASS INTERFACE cxx_std_11 )
if ( NOT DEFINED CUTLASS_REVISION )
find_package ( Git QUIET )
execute_process (
C O M M A N D $ { G I T _ E X E C U T A B L E } r e v - p a r s e - - s h o r t H E A D
R E S U L T _ V A R I A B L E C U T L A S S _ R E V I S I O N _ R E S U L T
O U T P U T _ V A R I A B L E C U T L A S S _ R E V I S I O N
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
)
if ( CUTLASS_REVISION_RESULT )
message ( STATUS "CUTLASS Revision: Unable to detect, Git returned code ${CUTLASS_REVISION_RESULT}." )
else ( )
message ( STATUS "CUTLASS Revision: ${CUTLASS_REVISION}" )
endif ( )
2019-03-21 01:49:17 +08:00
endif ( )
2019-11-20 08:55:34 +08:00
configure_file (
2020-04-08 04:51:25 +08:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / v e r s i o n . h . i n
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e / c u t l a s s / v e r s i o n . h
2019-11-20 08:55:34 +08:00
@ O N L Y )
target_include_directories (
C U T L A S S
I N T E R F A C E
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e >
$ < B U I L D _ I N T E R F A C E : $ { C U T L A S S _ I N C L U D E _ D I R } >
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e >
$ < B U I L D _ I N T E R F A C E : $ { C U D A _ T O O L K I T _ R O O T _ D I R } / i n c l u d e >
)
install (
2020-04-08 04:51:25 +08:00
D I R E C T O R Y
$ { C U T L A S S _ I N C L U D E _ D I R } /
2019-11-20 08:55:34 +08:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n c l u d e /
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R }
)
install (
T A R G E T S C U T L A S S
E X P O R T N v i d i a C u t l a s s
P U B L I C _ H E A D E R D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R }
)
################################################################################
2018-05-17 02:44:56 +08:00
# Doxygen is available. Generate documentation
if ( DOXYGEN_FOUND )
# DOT is available. Enable graph generation in the documentation
if ( DOXYGEN_DOT_EXECUTABLE )
2018-09-19 07:58:03 +08:00
set ( CUTLASS_ENABLE_DOXYGEN_DOT ON CACHE BOOL "Use dot to generate graphs in the doxygen documentation." )
2018-05-17 02:44:56 +08:00
else ( )
2018-09-19 07:58:03 +08:00
set ( CUTLASS_ENABLE_DOXYGEN_DOT OFF CACHE BOOL "Use dot to generate graphs in the doxygen documentation." FORCE )
2018-05-17 02:44:56 +08:00
endif ( )
if ( CUTLASS_ENABLE_DOXYGEN_DOT )
set ( HAVE_DOT "YES" )
else ( )
set ( HAVE_DOT "NO" )
endif ( )
# Add custom target for Doxygen.
add_custom_target ( cutlass_docs ${ CMAKE_COMMAND } -E env
" D O T _ P A T H = $ { D O X Y G E N _ D O T _ E X E C U T A B L E } "
" H A V E _ D O T = $ { H A V E _ D O T } "
$ { D O X Y G E N _ E X E C U T A B L E } $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / D o x y f i l e
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
V E R B A T I M
)
endif ( )
2019-11-20 08:55:34 +08:00
if ( NOT WIN32 )
# Add common library search paths so executables and libraries can load and run
# without LD_LIBRARY_PATH being set.
link_libraries (
" - W l , - r p a t h , ' $ O R I G I N ' "
" - W l , - r p a t h , ' $ O R I G I N / . . / l i b 6 4 ' "
" - W l , - r p a t h , ' $ O R I G I N / . . / l i b ' "
" - W l , - r p a t h , ' $ { C U D A _ T O O L K I T _ R O O T _ D I R } / l i b 6 4 ' "
" - W l , - r p a t h , ' $ { C U D A _ T O O L K I T _ R O O T _ D I R } / l i b ' "
)
endif ( )
################################################################################
include ( ${ CMAKE_CURRENT_SOURCE_DIR } /cuBLAS.cmake )
if ( CUTLASS_ENABLE_CUBLAS )
target_compile_definitions ( CUTLASS INTERFACE CUTLASS_ENABLE_CUBLAS=1 )
endif ( )
################################################################################
if ( CUTLASS_ENABLE_TOOLS )
add_subdirectory ( tools )
endif ( )
if ( CUTLASS_ENABLE_EXAMPLES )
add_subdirectory ( examples )
endif ( )
if ( CUTLASS_ENABLE_TESTS )
include ( CTest )
enable_testing ( )
add_subdirectory ( test )
endif ( )
################################################################################
install (
F I L E S $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / N v i d i a C u t l a s s C o n f i g . c m a k e
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } / c m a k e /
)
install (
E X P O R T N v i d i a C u t l a s s
N A M E S P A C E n v i d i a : : c u t l a s s : :
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } / c m a k e /
F I L E N v i d i a C u t l a s s T a r g e t s . c m a k e
)
################################################################################
include ( ${ CMAKE_CURRENT_SOURCE_DIR } /cmake/NvidiaCutlassPackageConfig.cmake )