Skip to content

Commit

Permalink
Merge Pull Request #11093 from bartlettroscoe/Trilinos/10954-nalu-win…
Browse files Browse the repository at this point in the history
…d-fix-cuda

Automatically Merged using Trilinos Pull Request AutoTester
PR Title: Change TriBITS/Trilinos TPLs to use find_package(CUDATookit) to fix builds with downstream customers using find_package(CUDATookit) (#10954)
PR Author: bartlettroscoe
  • Loading branch information
trilinos-autotester committed Oct 5, 2022
2 parents 9b6d588 + a2eded0 commit 78c0387
Show file tree
Hide file tree
Showing 59 changed files with 1,850 additions and 1,623 deletions.
21 changes: 5 additions & 16 deletions cmake/TPLs/FindTPLCUBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,8 @@
# ************************************************************************
# @HEADER

IF (NOT TPL_ENABLE_CUDA)
MESSAGE(FATAL_ERROR "\nCUBLAS: This TPL requires CUDA")
ELSE()
find_library(CUDA_cublas_LIBRARY
cublas
HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib
)
IF(CUDA_cublas_LIBRARY STREQUAL "CUDA_cublas_LIBRARY-NOTFOUND")
MESSAGE(FATAL_ERROR "\nCUBLAS: could not find cublas library.")
ENDIF()
SET(TPL_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY})
ENDIF()

tribits_tpl_find_include_dirs_and_libraries(CUBLAS REQUIRED_LIBS_NAMES cublas)

unset(TPL_CUBLAS_LIBRARIES)
tribits_extpkg_create_imported_all_libs_target_and_config_file( CUBLAS
INNER_FIND_PACKAGE_NAME CUDAToolkit
IMPORTED_TARGETS_FOR_ALL_LIBS CUDA::cublas )
# Above, the CUDA TPL should have already found CUDAToolkit so we just need to
# grab the target from it to form the CUSPARSE::all_libs target.
2 changes: 2 additions & 0 deletions cmake/TPLs/FindTPLCUBLASDependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tribits_extpkg_define_dependencies( CUBLAS
DEPENDENCIES CUDA)
26 changes: 5 additions & 21 deletions cmake/TPLs/FindTPLCUSPARSE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,8 @@
# ************************************************************************
# @HEADER

# Check for CUDA support

IF (NOT TPL_ENABLE_CUDA OR CUDA_VERSION VERSION_LESS "4.1")
MESSAGE(FATAL_ERROR "\nCUSPARSE: did not find acceptable version of CUDA libraries (4.1 or greater)")
ELSE()
IF(CMAKE_VERSION VERSION_LESS "2.8.8")
# FindCUDA before CMake 2.8.8 does not find cusparse library; therefore, we must
find_library(CUDA_cusparse_LIBRARY
cusparse
HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib
)
IF(CUDA_cusparse_LIBRARY STREQUAL "CUDA_cusparse_LIBRARY-NOTFOUND")
MESSAGE(FATAL_ERROR "\nCUSPARSE: could not find cuspasre library.")
ENDIF()
ENDIF(CMAKE_VERSION VERSION_LESS "2.8.8")
SET(TPL_CUSPARSE_LIBRARIES ${CUDA_cusparse_LIBRARY})
ENDIF()

tribits_tpl_find_include_dirs_and_libraries(CUSPARSE REQUIRED_LIBS_NAMES cusparse)

unset(TPL_CUSPARSE_LIBRARIES)
tribits_extpkg_create_imported_all_libs_target_and_config_file( CUSPARSE
INNER_FIND_PACKAGE_NAME CUDAToolkit
IMPORTED_TARGETS_FOR_ALL_LIBS CUDA::cusparse )
# Above, the CUDA TPL should have already found CUDAToolkit so we just need to
# grab the target from it to form the CUSPARSE::all_libs target.
2 changes: 1 addition & 1 deletion cmake/TPLs/FindTPLCUSPARSEDependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
tribits_extpkg_define_dependencies( CUSPARSE
DEPENDENCIES CUBLAS)
DEPENDENCIES CUDA)
28 changes: 28 additions & 0 deletions cmake/tribits/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@
ChangeLog for TriBITS
----------------------------------------

## 2022-10-02:

* **Changed:** The TriBITS FindTPLCUDA.cmake module changed
`find_package(CUDA)` to `find_package(CUDAToolkit)` (the former is
deprecated as of CMake 3.17). This avoids imported target namespace
conflicts with downstream CMake projects that call
`find_package(CUDAToolkit)` (see [Trilinos
#10954](https://github.com/trilinos/Trilinos/issues/10954)).


## 2022-09-16:

* **Changed:** Changed nomenclature for packages and TPLs (see updated
"Maintainers Guide" section "TriBITS System Data Structures"): "TPLs" =>
"External Packages/TPLs"; "Packages" => "Internal Top-Level Packages"; "SE
Packages" => "Internal Packages". This impacted many internal variables as
well as printed qualities. Behavior should otherwise be identical
w.r.t. input state. The only observable change that users should see is the
text used to describe the different sets of packages and TPLs. (This is
working towards a uniform handling of packages and TPLs (see [TriBITS
#63](https://github.com/TriBITSPub/TriBITS/issues/63)).

* **Deprecated:** The rarely used input var
`<Project>_GENERATE_EXPORT_FILES_FOR_ONLY_LISTED_SE_PACKAGES` is deprecated
and the new var name
`<Project>_GENERATE_EXPORT_FILES_FOR_ONLY_LISTED_PACKAGES` should be used
instead.

## 2022-08-22:

* **Added:** Added support for exporting cache variables for packages in their
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function(tribits_dump_deps_xml_file)
"<PackageDependencies project=\"${PROJECT_NAME}\" baseDirName=\"${PROJECT_BASE_DIR_NAME}\">\n"
)

foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_SE_PACKAGES})
foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_DEFINED_INTERNAL_PACKAGES})

#message("")
#print_var(TRIBITS_PACKAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
r"""get-tribits-packages-from-files-list.py --deps-xml-file=<DEPS_XML_FILE> \
--files-list-file=<FILES_LIST_FILE> [--project-dir=<projectDir>]
This script returns a comma-seprated list of all of the project's TriBITS SE
This script returns a comma-seprated list of all of the project's TriBITS
packages that must be directly tested for changes in the input list of files.
This may also include the special package name 'ALL_PACKAGES' which means that
at least one changed file (e.g. <projectDir>/CMakeLists.txt) should result in
Expand Down
2 changes: 1 addition & 1 deletion cmake/tribits/ci_support/get-tribits-packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
--only-top-level-packages=[on|off]
This script returns a comma-separated list of all of the project's top-level
or packages or the full set of SE packages (i.e. parent and subpackages).
or packages or the full set of packages (i.e. parent and subpackages).
"""

from optparse import OptionParser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ include(PrintVar)
# defined in `Test case Pass/Fail (tribits_add_advanced_test())`_) in order
# for the overall test to pass.
#
# Finally, the test is only added if tests are enabled for the SE package
# Finally, the test is only added if tests are enabled for the package
# (i.e. `${PACKAGE_NAME}_ENABLE_TESTS`_ ``= ON``) or the parent package (if
# this is a subpackage) (i.e. ``${PARENT_PACKAGE_NAME}_ENABLE_TESTS=ON``) or
# if other criteria are met (see some of the arguments in `Overall Arguments
Expand Down
30 changes: 15 additions & 15 deletions cmake/tribits/core/package_arch/TribitsAddExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ include(CMakeParseArguments)
# ``TESTONLYLIBS <lib0> <lib1> ...``
#
# Specifies extra test-only libraries defined in this CMake project that
# will be linked to the executable using ``target_link_libraries()``. Note
# that regular libraries (i.e. not ``TESTONLY``) defined in the current SE
# package or any upstream SE packages can *NOT* be listed! TriBITS
# will be linked to the executable using ``target_link_libraries()``.
# Note that regular libraries (i.e. not ``TESTONLY``) defined in the
# current package or any upstream packages can *NOT* be listed! TriBITS
# automatically links non ``TESTONLY`` libraries in this package and
# upstream packages to the executable. The only libraries that should be
# listed in this argument are either ``TESTONLY`` libraries.
Expand Down Expand Up @@ -587,10 +587,10 @@ function(tribits_add_executable_assert_testonlylibs)
tribits_lib_is_testonly(${prefixedTestOnlyLib} libIsTestOnlyLib)
if (NOT libIsTestOnlyLib)
message(FATAL_ERROR "ERROR: '${testOnlyLib}' in TESTONLYLIBS not a TESTONLY lib!"
" If this a regular library in this SE package or in an dependent upstream SE"
" If this a regular library in this package or in an dependent upstream"
" package then TriBITS will link automatically to it. If you remove this and it"
" does not link, then you need to add a new SE package dependency to"
" this SE package's dependencies file"
" does not link, then you need to add a new package dependency to"
" this package's dependencies file"
" ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake")
elseif(PARSE_INSTALLABLE)
message(FATAL_ERROR "ERROR: TESTONLY lib '${testOnlyLib}' not allowed with"
Expand Down Expand Up @@ -626,18 +626,18 @@ function(tribits_add_executable_assert_importedlibs)
if (NOT foundPrefixedImportedLibInPkgLibs_idx EQUAL -1)
message(FATAL_ERROR
"ERROR: Lib '${importedLib}' in IMPORTEDLIBS is in"
" this SE package and is *not* an external lib!"
" this package and is *not* an external lib!"
" TriBITS takes care of linking against libs the current"
" SE package automatically. Please remove '${importedLib}' from IMPORTEDLIBS!")
" package automatically. Please remove '${importedLib}' from IMPORTEDLIBS!")
elseif (TARGET ${prefixedImportedLib})
message(FATAL_ERROR
"ERROR: Lib '${importedLib}' being passed through"
" IMPORTEDLIBS is *not* an external library but instead is a library"
" defined in this CMake project!"
" TriBITS takes care of linking against libraries in dependent upstream"
" SE packages. If you want to link to a library in an upstream SE"
" package then add the SE package name for that library to the appropriate"
" list in this SE package's dependencies file"
" packages. If you want to link to a library in an upstream"
" package then add the package name for that library to the appropriate"
" list in this package's dependencies file"
" ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake")
endif()
endforeach()
Expand Down Expand Up @@ -666,10 +666,10 @@ macro(tribits_add_executable_convert_from_deplibs)
" is deprecated! The library '${depLib}' appears to be a"
" library defined in this CMake project."
" TriBITS takes care of linking against libraries in dependent upstream"
" SE packages. Therefore, please remove '${depLib}' from this list."
" If you want to link to a library from an upstream SE"
" package, then add the SE package name to the appropriate category"
" in this SE package's dependencies file: "
" packages. Therefore, please remove '${depLib}' from this list."
" If you want to link to a library from an upstream"
" package, then add the package name to the appropriate category"
" in this package's dependencies file: "
" ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake")
# ToDo: Convert the above 'WARNING' to 'SEND_ERROR'
else()
Expand Down
20 changes: 10 additions & 10 deletions cmake/tribits/core/package_arch/TribitsAddLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,16 @@ include(SetAndIncDirs)
#
# ``DEPLIBS <deplib0> <deplib1> ...``
#
# List of dependent libraries that are built in the current SE package
# that this library is dependent on. These libraries are passed into
# List of dependent libraries that are built in the current package that
# this library is dependent on. These libraries are passed into
# ``target_link_libraries(<libTargetName> ...)`` so that CMake knows about
# the dependency structure of the libraries within this SE package.
# **NOTE:** One must **not** list libraries in other upstream `TriBITS SE
# the dependency structure of the libraries within this package.
# **NOTE:** One must **not** list libraries in other upstream `TriBITS
# Packages`_ or libraries built externally from this TriBITS CMake project
# in ``DEPLIBS``. The TriBITS system automatically handles linking to
# libraries in upstream TriBITS SE packages. External libraries need to
# be listed in the ``IMPORTEDLIBS`` argument instead if they are not
# already specified automatically using a `TriBITS TPL`_.
# libraries in upstream TriBITS packages. External libraries need to be
# listed in the ``IMPORTEDLIBS`` argument instead if they are not already
# specified automatically using a `TriBITS TPL`_.
#
# ``IMPORTEDLIBS <ideplib0> <ideplib1> ...``
#
Expand All @@ -172,8 +172,8 @@ include(SetAndIncDirs)
# will be created. If both ``STATIC`` and ``SHARED`` are passed in (which
# is obviously a mistake), then a shared library will be created.
# WARNING: Once you mark a library with ``STATIC``, then all of the
# downstream libraries in the current SE package and all downstream SE
# packages must also be also be marked with ``STATIC``. That is because,
# downstream libraries in the current package and all downstream packages
# must also be also be marked with ``STATIC``. That is because,
# generally, one can not link a link a static lib against a downstream
# shared lib since that is not portable (but can be done on some platforms
# if, for example, ``-fPIC`` is specified). So be careful to use
Expand Down Expand Up @@ -202,7 +202,7 @@ include(SetAndIncDirs)
# ``add_library()`` where ``cuda_add_library()`` is assumed to be defined
# by the standard ``FindCUDA.cmake`` module as processed using the
# standard TriBITS ``FindTPLCUDA.cmake`` file (see `Standard TriBITS
# TPLs`_). For this option to work, this SE package must have an enabled
# TPLs`_). For this option to work, this package must have an enabled
# direct or indirect dependency on the TriBITS CUDA TPL or a
# configure-time error may occur about not knowing about
# ``cuda_all_library()``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ macro(tribits_add_option_and_define USER_OPTION_NAME MACRO_DEFINE_NAME
)
#message("TRIBITS_ADD_OPTION_AND_DEFINE: '${USER_OPTION_NAME}' '${MACRO_DEFINE_NAME}' '${DEFAULT_VALUE}'")
set( ${USER_OPTION_NAME} "${DEFAULT_VALUE}" CACHE BOOL "${DOCSTRING}" )
if(NOT ${MACRO_DEFINE_NAME} STREQUAL "")
if(NOT "${MACRO_DEFINE_NAME}" STREQUAL "")
if(${USER_OPTION_NAME})
global_set(${MACRO_DEFINE_NAME} ON)
else()
global_set(${MACRO_DEFINE_NAME} OFF)
endif()
endif()
tribits_pkg_export_cache_var(${USER_OPTION_NAME})
if(NOT ${MACRO_DEFINE_NAME} STREQUAL "")
if(NOT "${MACRO_DEFINE_NAME}" STREQUAL "")
tribits_pkg_export_cache_var(${MACRO_DEFINE_NAME})
endif()
endmacro()
Expand Down
2 changes: 1 addition & 1 deletion cmake/tribits/core/package_arch/TribitsAddTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ include(TribitsAddTestHelpers)
# [ADDED_TESTS_NAMES_OUT <testsNames>]
# )
#
# The tests are only added if tests are enabled for the SE package
# The tests are only added if tests are enabled for the package
# (i.e. `${PACKAGE_NAME}_ENABLE_TESTS`_) or the parent package (if this is a
# subpackage) (i.e. ``${PARENT_PACKAGE_NAME}_ENABLE_TESTS``). (NOTE: A more
# efficient way to optionally enable tests is to put them in a ``test/``
Expand Down
Loading

0 comments on commit 78c0387

Please sign in to comment.