2021-02-26 22:58:26 +08:00
|
|
|
# Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
|
2019-11-20 08:55:34 +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,
|
2021-07-28 08:58:30 +08:00
|
|
|
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2019-11-20 08:55:34 +08:00
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2020-06-09 07:17:35 +08:00
|
|
|
find_package(Python3 3.5 COMPONENTS Interpreter REQUIRED)
|
2019-11-20 08:55:34 +08:00
|
|
|
|
|
|
|
add_library(cutlass_library_includes INTERFACE)
|
|
|
|
add_library(nvidia::cutlass::library::includes ALIAS cutlass_library_includes)
|
|
|
|
set_target_properties(cutlass_library_includes PROPERTIES EXPORT_NAME library::includes)
|
|
|
|
|
|
|
|
target_include_directories(
|
|
|
|
cutlass_library_includes
|
|
|
|
INTERFACE
|
|
|
|
$<INSTALL_INTERFACE:include>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(
|
|
|
|
cutlass_library_includes
|
|
|
|
INTERFACE
|
|
|
|
CUTLASS
|
|
|
|
cutlass_tools_util_includes
|
|
|
|
)
|
|
|
|
|
|
|
|
install(
|
|
|
|
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/
|
|
|
|
)
|
|
|
|
|
|
|
|
#
|
|
|
|
# CUTLASS Deliverables Library
|
|
|
|
#
|
|
|
|
|
|
|
|
cutlass_add_library(
|
2020-04-08 04:51:25 +08:00
|
|
|
cutlass_library_objs
|
|
|
|
OBJECT
|
|
|
|
src/handle.cu
|
2019-11-20 08:55:34 +08:00
|
|
|
src/manifest.cpp
|
2020-04-08 04:51:25 +08:00
|
|
|
src/operation_table.cu
|
|
|
|
src/singleton.cu
|
|
|
|
src/util.cu
|
2020-06-09 07:17:35 +08:00
|
|
|
|
2020-09-24 05:00:58 +08:00
|
|
|
src/reference/gemm.cu
|
|
|
|
src/reference/initialize_reference_operations.cu
|
|
|
|
|
2020-11-20 13:25:25 +08:00
|
|
|
|
|
|
|
# cutlass reduction instances in cutlass library
|
|
|
|
src/reduction/reduction_device.cu
|
|
|
|
src/reduction/init_reduction_operations.cu
|
|
|
|
|
|
|
|
# cutlass conv reference instances in cutlass library
|
|
|
|
src/reference/conv2d.cu
|
|
|
|
src/reference/conv3d.cu
|
|
|
|
|
2019-11-20 08:55:34 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
file(GLOB_RECURSE GENERATOR_PYTHON_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/*.py)
|
|
|
|
|
|
|
|
#
|
|
|
|
# auto-instantiation of CUTLASS kernels
|
|
|
|
#
|
|
|
|
|
2020-04-08 04:51:25 +08:00
|
|
|
# set cutlass generator compiler version to filter kernels in the generator not supported by a specific toolkit.
|
|
|
|
set(CUTLASS_GENERATOR_CUDA_COMPILER_VERSION ${CMAKE_CUDA_COMPILER_VERSION})
|
|
|
|
|
2019-11-20 08:55:34 +08:00
|
|
|
execute_process(
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts
|
|
|
|
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generator.py
|
2020-04-08 04:51:25 +08:00
|
|
|
--operations "${CUTLASS_LIBRARY_OPERATIONS}"
|
2019-11-20 08:55:34 +08:00
|
|
|
--build-dir ${PROJECT_BINARY_DIR}
|
|
|
|
--curr-build-dir ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
--generator-target library
|
|
|
|
--architectures "${CUTLASS_NVCC_ARCHS_ENABLED}"
|
|
|
|
--kernels "${CUTLASS_LIBRARY_KERNELS}"
|
2020-09-24 05:00:58 +08:00
|
|
|
--ignore-kernels "${CUTLASS_LIBRARY_IGNORE_KERNELS}"
|
2020-04-08 04:51:25 +08:00
|
|
|
--cuda-version "${CUTLASS_GENERATOR_CUDA_COMPILER_VERSION}"
|
2019-11-20 08:55:34 +08:00
|
|
|
RESULT_VARIABLE cutlass_lib_INSTANCE_GENERATION_RESULT
|
|
|
|
OUTPUT_VARIABLE cutlass_lib_INSTANCE_GENERATION_OUTPUT
|
|
|
|
OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/library_instance_generation.log
|
|
|
|
ERROR_FILE ${CMAKE_CURRENT_BINARY_DIR}/library_instance_generation.log
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT cutlass_lib_INSTANCE_GENERATION_RESULT EQUAL 0)
|
|
|
|
message(FATAL_ERROR "Error generating library instances. See ${CMAKE_CURRENT_BINARY_DIR}/library_instance_generation.log")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# include auto-instantiated kernels in he CUTLASS Deliverables Library
|
|
|
|
set(CUTLASS_LIBRARY_MANIFEST_CMAKE_FILE ${CMAKE_CURRENT_BINARY_DIR}/generated/manifest.cmake)
|
|
|
|
if(EXISTS "${CUTLASS_LIBRARY_MANIFEST_CMAKE_FILE}")
|
|
|
|
include(${CUTLASS_LIBRARY_MANIFEST_CMAKE_FILE})
|
|
|
|
else()
|
|
|
|
message(STATUS "auto-generated library manifest cmake file (${CUTLASS_LIBRARY_MANIFEST_CMAKE_FILE}) not found.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_include_directories(
|
2020-04-08 04:51:25 +08:00
|
|
|
cutlass_library_objs
|
2019-11-20 08:55:34 +08:00
|
|
|
PRIVATE
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(
|
2020-04-08 04:51:25 +08:00
|
|
|
cutlass_library_objs
|
2019-11-20 08:55:34 +08:00
|
|
|
PUBLIC
|
2020-04-08 04:51:25 +08:00
|
|
|
cutlass_library_includes
|
2019-11-20 08:55:34 +08:00
|
|
|
)
|
|
|
|
|
2020-04-08 04:51:25 +08:00
|
|
|
function(cutlass_add_cutlass_library)
|
|
|
|
|
|
|
|
set(options)
|
|
|
|
set(oneValueArgs NAME TYPE EXPORT_NAME)
|
|
|
|
set(multiValueArgs)
|
|
|
|
cmake_parse_arguments(_ "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
|
|
|
|
cutlass_add_library(
|
|
|
|
${__NAME}
|
|
|
|
${__TYPE}
|
|
|
|
EXPORT_NAME ${__EXPORT_NAME}
|
|
|
|
$<TARGET_OBJECTS:cutlass_library_objs>
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(
|
|
|
|
${__NAME}
|
|
|
|
PUBLIC
|
|
|
|
cutlass_library_includes
|
|
|
|
)
|
|
|
|
|
2020-11-20 13:25:25 +08:00
|
|
|
set_target_properties(${__NAME} PROPERTIES DEBUG_POSTFIX "${CUTLASS_LIBRARY_DEBUG_POSTFIX}")
|
2020-04-08 04:51:25 +08:00
|
|
|
|
|
|
|
set(OUTPUT_NAME cutlass)
|
|
|
|
|
|
|
|
if (WIN32 AND ${__TYPE} STREQUAL "STATIC")
|
|
|
|
set(OUTPUT_NAME "${OUTPUT_NAME}.static")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set_target_properties(
|
|
|
|
${__NAME}
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME ${OUTPUT_NAME}
|
|
|
|
WINDOWS_EXPORT_ALL_SYMBOLS 1
|
|
|
|
)
|
|
|
|
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
cutlass_add_cutlass_library(NAME cutlass_lib TYPE SHARED EXPORT_NAME library)
|
|
|
|
cutlass_add_cutlass_library(NAME cutlass_library_static TYPE STATIC EXPORT_NAME library_static)
|
|
|
|
|
2019-11-20 08:55:34 +08:00
|
|
|
install(
|
2020-04-08 04:51:25 +08:00
|
|
|
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
2019-11-20 08:55:34 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
install(
|
2020-04-08 04:51:25 +08:00
|
|
|
TARGETS
|
|
|
|
cutlass_lib
|
|
|
|
cutlass_library_static
|
|
|
|
cutlass_library_includes
|
2019-11-20 08:55:34 +08:00
|
|
|
EXPORT NvidiaCutlass
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
2020-04-08 04:51:25 +08:00
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
2019-11-20 08:55:34 +08:00
|
|
|
)
|