|
| 1 | +# Copyright (c) Facebook, Inc. and its affiliates. |
| 2 | +# |
| 3 | +# This source code is licensed under the MIT license found in the |
| 4 | +# LICENSE file in the root directory of this source tree. |
| 5 | +# ============================================================================= |
| 6 | +# Copyright (c) 2021-2023, NVIDIA CORPORATION. |
| 7 | +# |
| 8 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
| 9 | +# in compliance with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software distributed under the License |
| 14 | +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 15 | +# or implied. See the License for the specific language governing permissions and limitations under |
| 16 | +# the License. |
| 17 | +# ============================================================================= |
| 18 | + |
| 19 | +function(find_and_configure_cutlass) |
| 20 | + set(oneValueArgs VERSION REPOSITORY PINNED_TAG) |
| 21 | + cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) |
| 22 | + |
| 23 | + # if(RAFT_ENABLE_DIST_DEPENDENCIES OR RAFT_COMPILE_LIBRARIES) |
| 24 | + set(CUTLASS_ENABLE_HEADERS_ONLY |
| 25 | + ON |
| 26 | + CACHE BOOL "Enable only the header library" |
| 27 | + ) |
| 28 | + set(CUTLASS_NAMESPACE |
| 29 | + "raft_cutlass" |
| 30 | + CACHE STRING "Top level namespace of CUTLASS" |
| 31 | + ) |
| 32 | + set(CUTLASS_ENABLE_CUBLAS |
| 33 | + OFF |
| 34 | + CACHE BOOL "Disable CUTLASS to build with cuBLAS library." |
| 35 | + ) |
| 36 | + |
| 37 | + if (CUDA_STATIC_RUNTIME) |
| 38 | + set(CUDART_LIBRARY "${CUDA_cudart_static_LIBRARY}" CACHE FILEPATH "fixing cutlass cmake code" FORCE) |
| 39 | + endif() |
| 40 | + |
| 41 | + rapids_cpm_find( |
| 42 | + NvidiaCutlass ${PKG_VERSION} |
| 43 | + GLOBAL_TARGETS nvidia::cutlass::cutlass |
| 44 | + CPM_ARGS |
| 45 | + GIT_REPOSITORY ${PKG_REPOSITORY} |
| 46 | + GIT_TAG ${PKG_PINNED_TAG} |
| 47 | + GIT_SHALLOW TRUE |
| 48 | + OPTIONS "CUDAToolkit_ROOT ${CUDAToolkit_LIBRARY_DIR}" |
| 49 | + ) |
| 50 | + |
| 51 | + if(TARGET CUTLASS AND NOT TARGET nvidia::cutlass::cutlass) |
| 52 | + add_library(nvidia::cutlass::cutlass ALIAS CUTLASS) |
| 53 | + endif() |
| 54 | + |
| 55 | + if(NvidiaCutlass_ADDED) |
| 56 | + rapids_export( |
| 57 | + BUILD NvidiaCutlass |
| 58 | + EXPORT_SET NvidiaCutlass |
| 59 | + GLOBAL_TARGETS nvidia::cutlass::cutlass |
| 60 | + NAMESPACE nvidia::cutlass:: |
| 61 | + ) |
| 62 | + endif() |
| 63 | + # endif() |
| 64 | + |
| 65 | + # We generate the cutlass-config files when we built cutlass locally, so always do |
| 66 | + # `find_dependency` |
| 67 | + rapids_export_package( |
| 68 | + BUILD NvidiaCutlass raft-distance-exports GLOBAL_TARGETS nvidia::cutlass::cutlass |
| 69 | + ) |
| 70 | + rapids_export_package( |
| 71 | + INSTALL NvidiaCutlass raft-distance-exports GLOBAL_TARGETS nvidia::cutlass::cutlass |
| 72 | + ) |
| 73 | + rapids_export_package( |
| 74 | + BUILD NvidiaCutlass raft-nn-exports GLOBAL_TARGETS nvidia::cutlass::cutlass |
| 75 | + ) |
| 76 | + rapids_export_package( |
| 77 | + INSTALL NvidiaCutlass raft-nn-exports GLOBAL_TARGETS nvidia::cutlass::cutlass |
| 78 | + ) |
| 79 | + |
| 80 | + # Tell cmake where it can find the generated NvidiaCutlass-config.cmake we wrote. |
| 81 | + include("${rapids-cmake-dir}/export/find_package_root.cmake") |
| 82 | + rapids_export_find_package_root( |
| 83 | + INSTALL NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}/../]=] raft-distance-exports |
| 84 | + ) |
| 85 | + rapids_export_find_package_root( |
| 86 | + BUILD NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}]=] raft-distance-exports |
| 87 | + ) |
| 88 | + include("${rapids-cmake-dir}/export/find_package_root.cmake") |
| 89 | + rapids_export_find_package_root( |
| 90 | + INSTALL NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}/../]=] raft-nn-exports |
| 91 | + ) |
| 92 | + rapids_export_find_package_root( |
| 93 | + BUILD NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}]=] raft-nn-exports |
| 94 | + ) |
| 95 | +endfunction() |
| 96 | + |
| 97 | +if(NOT RAFT_CUTLASS_GIT_TAG) |
| 98 | + set(RAFT_CUTLASS_GIT_TAG v2.9.1) |
| 99 | +endif() |
| 100 | + |
| 101 | +if(NOT RAFT_CUTLASS_GIT_REPOSITORY) |
| 102 | + set(RAFT_CUTLASS_GIT_REPOSITORY https://github.com/NVIDIA/cutlass.git) |
| 103 | +endif() |
| 104 | + |
| 105 | +find_and_configure_cutlass( |
| 106 | + VERSION 2.9.1 REPOSITORY ${RAFT_CUTLASS_GIT_REPOSITORY} PINNED_TAG ${RAFT_CUTLASS_GIT_TAG} |
| 107 | +) |
0 commit comments