Skip to content

Commit

Permalink
update the required cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
mkstoyanov committed Oct 28, 2022
1 parent c474089 commit 865e774
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 1,608 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.19)

cmake_policy(VERSION 3.10)
cmake_policy(VERSION 3.19)
project(Tasmanian VERSION 7.10.0 LANGUAGES CXX)
set(Tasmanian_version_comment " (development)") # e.g., " (release candidate)", " (development)", ""
set(Tasmanian_license "BSD 3-Clause with UT-Battelle disclaimer") # used in some headers and python modules (only human readable)
Expand Down Expand Up @@ -99,6 +99,10 @@ else()
set(Tasmanian_export_name "Tasmanian-export" CACHE STRING "Specify the export variable name when merging Tasmanian into an external project")
endif()

if (Tasmanian_ENABLE_CUDA AND NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES "OFF" CACHE STRING "CUDA architectures to compile, e.g., -DCMAKE_CUDA_ARCHITECTURES=70;72")
endif()


########################################################################
# Sanity check, xSDK compatibility, and find_package() calls are all
Expand Down
45 changes: 0 additions & 45 deletions Config/CMakeIncludes/FindTasmanianCudaMathLibs.cmake

This file was deleted.

68 changes: 0 additions & 68 deletions Config/CMakeIncludes/FindTasmanianRocm.cmake

This file was deleted.

16 changes: 10 additions & 6 deletions Config/CMakeIncludes/add_dependencies_target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ list(APPEND Tasmanian_rpath "${Tasmanian_final_install_path}/lib")
if (Tasmanian_ENABLE_OPENMP)
target_link_libraries(Tasmanian_dependencies INTERFACE ${OpenMP_CXX_LIBRARIES})
Tasmanian_find_rpath(LIBRARIES ${OpenMP_CXX_LIBRARIES} LIST rpath)
if (Tasmanian_ENABLE_HIP)
# needs to be added to the ENV script for the post-install testing
Tasmanian_find_rpath(LIBRARIES ${OpenMP_CXX_LIBRARIES} LIST hipomp_rpath)
endif()
else()
target_link_libraries(Tasmanian_dependencies INTERFACE ${CMAKE_THREAD_LIBS_INIT})
Tasmanian_find_rpath(LIBRARIES ${CMAKE_THREAD_LIBS_INIT} LIST rpath)
Expand All @@ -34,15 +38,15 @@ if (Tasmanian_ENABLE_BLAS)
endif()

if (Tasmanian_ENABLE_CUDA)
target_link_libraries(Tasmanian_dependencies INTERFACE ${Tasmanian_cudamathlibs})
Tasmanian_find_rpath(LIBRARIES ${Tasmanian_cublas} ${Tasmanian_cusparse} ${Tasmaniana_cusolver} LIST rpath)
target_link_libraries(Tasmanian_dependencies INTERFACE CUDA::cublas CUDA::cusparse CUDA::cusolver CUDA::cudart)
Tasmanian_find_rpath(TARGETS CUDA::cublas CUDA::cusparse CUDA::cusolver CUDA::cudart LIST rpath)
endif()

if (Tasmanian_ENABLE_HIP)
target_link_libraries(Tasmanian_dependencies INTERFACE ${Tasmanian_hiplibs})
list(APPEND Tasmanian_rpath ${Tasmanian_hip_rpath})

target_include_directories(Tasmanian_dependencies INTERFACE $<BUILD_INTERFACE:${Tasmanian_hiproot}/include/>)
foreach(_tsg_rocm_dep ${Tasmanian_rocm_dependencies})
target_link_libraries(Tasmanian_dependencies INTERFACE roc::${_tsg_rocm_dep})
Tasmanian_find_rpath(INCLUDES ${_tsg_rocm_dep}_INCLUDE_DIR LIST rpath)
endforeach()
endif()

if (Tasmanian_ENABLE_MAGMA)
Expand Down
23 changes: 21 additions & 2 deletions Config/CMakeIncludes/helper_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,34 @@ endmacro()
# will find the rpaths for each library in the BLAS_LIBRARIES list
# and will append the rpath to a list called Tasmanian_rpath
macro(Tasmanian_find_rpath)
cmake_parse_arguments(Tasmanian_findrpath "" "LIST" "LIBRARIES" ${ARGN})
cmake_parse_arguments(Tasmanian_findrpath "" "LIST" "LIBRARIES;TARGETS;INCLUDES" ${ARGN})

foreach(_tsg_lib ${Tasmanian_findrpath_LIBRARIES})
get_filename_component(_tsg_libpath ${_tsg_lib} DIRECTORY)
list(APPEND Tasmanian_${Tasmanian_findrpath_LIST} ${_tsg_libpath})
#message(STATUS "rpath for ${_tsg_lib} => ${_tsg_libpath}")
endforeach()

foreach(_tsg_lib LIST LIBRARIES) # cleanup
foreach(_tsg_lib ${Tasmanian_findrpath_TARGETS})
get_property(_tsg_locatoin TARGET ${_tsg_lib} PROPERTY IMPORTED_LOCATION)
if (_tsg_locatoin)
get_filename_component(_tsg_libpath ${_tsg_locatoin} DIRECTORY)
list(APPEND Tasmanian_${Tasmanian_findrpath_LIST} ${_tsg_libpath})
endif()
unset(_tsg_locatoin)
#message(STATUS "rpath for ${_tsg_lib} => ${_tsg_libpath}")
endforeach()

foreach(_tsg_lib ${Tasmanian_findrpath_INCLUDES})
get_filename_component(_tsg_libpath ${${_tsg_lib}} DIRECTORY)
if (EXISTS "${_tsg_libpath}/lib")
list(APPEND Tasmanian_${Tasmanian_findrpath_LIST} "${_tsg_libpath}/lib")
endif()
unset(_tsg_locatoin)
#message(STATUS "rpath for ${_tsg_lib} => ${_tsg_libpath}/lib")
endforeach()

foreach(_tsg_lib LIST LIBRARIES TARGETS) # cleanup
unset(Tasmanian_${_tsg_lib})
endforeach()
unset(_tsg_lib)
Expand Down
52 changes: 31 additions & 21 deletions Config/CMakeIncludes/sanity_check_and_xsdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ if (SKBUILD)
endif()
if (NOT "$ENV{Tasmanian_ENABLE_HIP}" STREQUAL "")
set(Tasmanian_ENABLE_HIP ON)
set(CMAKE_CXX_COMPILER "$ENV{Tasmanian_ENABLE_HIP}")
endif()
if (NOT "$ENV{Tasmanian_ENABLE_DPCPP}" STREQUAL "")
set(Tasmanian_ENABLE_DPCPP ON)
Expand Down Expand Up @@ -49,7 +48,7 @@ if (Tasmanian_ENABLE_SWIG AND NOT Tasmanian_ENABLE_FORTRAN)
endif()

# OpenMP setup
if ((Tasmanian_ENABLE_OPENMP OR Tasmanian_ENABLE_RECOMMENDED) AND NOT (Tasmanian_ENABLE_HIP OR Tasmanian_ENABLE_DPCPP))
if ((Tasmanian_ENABLE_OPENMP OR Tasmanian_ENABLE_RECOMMENDED) AND NOT Tasmanian_ENABLE_DPCPP)
if (Tasmanian_ENABLE_OPENMP)
find_package(OpenMP REQUIRED) # OpenMP requested explicitly, require regardless of ENABLE_RECOMMENDED
else()
Expand Down Expand Up @@ -104,23 +103,24 @@ endif()

# Python setup, look for python
if (Tasmanian_ENABLE_PYTHON OR (Tasmanian_ENABLE_RECOMMENDED AND BUILD_SHARED_LIBS))
find_package(PythonInterp)

if (PYTHONINTERP_FOUND)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/Config/CMakeIncludes/PythonImportTest.py"
RESULT_VARIABLE Tasmanian_python_has_numpy OUTPUT_QUIET)
else()
set(Tasmanian_python_has_numpy "1") # 1 is error code if the script above fails
endif()

if (NOT "${Tasmanian_python_has_numpy}" STREQUAL "0")
if (NOT Tasmanian_ENABLE_PYTHON) # means we are using RECOMMENDED only
message(STATUS "Tasmanian could not find Python with numpy and ctypes modules, the python interface will not be installed and some tests will be omitted")
else()
message(FATAL_ERROR "-D Tasmanian_ENABLE_PYTHON is ON, but either find_package(PythonInterp) failed python executable could not 'import numpy, ctypes'\nuse -D PYTHON_EXECUTABLE:PATH to specify suitable python interpreter")
find_package(Python 3.0 COMPONENTS Interpreter)

if (Python_FOUND)
# manually test for NumPy, the cmake native lookup for NumPy is not reliable when using non-native cmake in Ubuntu
# the search itself is designed to find the NumPy headers for compiling with C and not just the import numpy
execute_process(COMMAND "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/Config/CMakeIncludes/PythonImportTest.py"
RESULT_VARIABLE Tasmanian_python_has_numpy)
if (NOT "${Tasmanian_python_has_numpy}" STREQUAL "0") # exit code 0 means all OK
if (Tasmanian_ENABLE_PYTHON)
message(FATAL_ERROR "CMake found Python, but simple 'import numpy' failed. Probably missing numpy module.")
endif()
else() # found python and numpy
set(Tasmanian_ENABLE_PYTHON ON)
endif()
else()
set(Tasmanian_ENABLE_PYTHON ON) # just in case we are using RECOMMENDED only
if (Tasmanian_ENABLE_PYTHON)
message(FATAL_ERROR "CMake could not find Python")
endif()
endif()
endif()

Expand All @@ -132,20 +132,30 @@ if ((Tasmanian_ENABLE_CUDA AND Tasmanian_ENABLE_HIP) OR
endif()

# using the Tasmanian find modules requires the path
if (Tasmanian_ENABLE_CUDA OR Tasmanian_ENABLE_HIP OR Tasmanian_ENABLE_DPCPP OR Tasmanian_ENABLE_MAGMA)
if (Tasmanian_ENABLE_DPCPP OR Tasmanian_ENABLE_MAGMA)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Config/CMakeIncludes/")
endif()

# Tasmanian_ENABLE_CUDA support
if (Tasmanian_ENABLE_CUDA)
enable_language(CUDA)

find_package(TasmanianCudaMathLibs REQUIRED)
find_package(CUDAToolkit REQUIRED)
endif()

# AMD HIP support
if (Tasmanian_ENABLE_HIP)
find_package(TasmanianRocm REQUIRED)
if (CMAKE_VERSION VERSION_LESS 3.21)
message(FATAL_ERROR "Tasmanian HIP/ROCm GPU backend requires CMake version 3.21 or newer")
endif()
list (APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
enable_language(HIP)
set(Tasmanian_rocm_dependencies rocblas rocsparse rocsolver)
if (Tasmanian_ENABLE_MAGMA)
set(Tasmanian_rocm_dependencies "${Tasmanian_rocm_dependencies} hipblas hipsparse")
endif()
foreach(_tsg_roclib ${Tasmanian_rocm_dependencies})
find_package(${_tsg_roclib} REQUIRED)
endforeach()
endif()

# Intel DPC++ support
Expand Down
22 changes: 7 additions & 15 deletions Config/TasmanianConfig.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ set_property(TARGET Tasmanian::tasgrid PROPERTY IMPORTED_LOCATION "@Tasmanian_fi
add_library(Tasmanian::Tasmanian INTERFACE IMPORTED GLOBAL) # master target
target_link_libraries(Tasmanian::Tasmanian INTERFACE Tasmanian_master)

if (NOT CMAKE_VERSION VERSION_LESS 3.17)
if (@Tasmanian_ENABLE_CUDA@)
find_package(CUDAToolkit REQUIRED)
if (@Tasmanian_ENABLE_CUDA@)
cmake_policy(SET CMP0074 NEW)
if (NOT CUDAToolkit_ROOT)
set(CUDAToolkit_ROOT "@CUDAToolkit_LIBRARY_ROOT@")
endif()
find_package(CUDAToolkit REQUIRED)
endif()

if (@BUILD_SHARED_LIBS@)
Expand All @@ -51,23 +53,13 @@ else()
if (NOT CMAKE_CUDA_COMPILER)
set_target_properties(Tasmanian_libsparsegrid PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX")
set_target_properties(Tasmanian_libsparsegrid PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX")
get_target_property(_TasLibs Tasmanian_libsparsegrid INTERFACE_LINK_LIBRARIES)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set_target_properties(Tasmanian_libsparsegrid PROPERTIES INTERFACE_LINK_LIBRARIES "${_TasLibs};@Tasmanian_cudaruntime@")
else()
set_target_properties(Tasmanian_libsparsegrid PROPERTIES INTERFACE_LINK_LIBRARIES "${_TasLibs};@Tasmanian_cudaruntime@;dl")
endif()
unset(_TasLibs)
endif()
endif()
endif()

if (@Tasmanian_ENABLE_HIP@)
if (NOT "@Tasmanian_ROCM_ROOT@" STREQUAL "")
list(APPEND CMAKE_PREFIX_PATH "@Tasmanian_ROCM_ROOT@")
endif()
list(APPEND CMAKE_PREFIX_PATH "@Tasmanian_hiproot@")
foreach(_tsg_package hip rocblas rocsparse rocsolver @Tasmanian_extra_magma_libs@)
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
foreach(_tsg_package hip @Tasmanian_rocm_dependencies@)
find_package(${_tsg_package} REQUIRED)
endforeach()
endif()
Expand Down
24 changes: 12 additions & 12 deletions InterfacePython/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
########################################################################

if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(Tasmanian_python_default_path "${CMAKE_INSTALL_PREFIX}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}/site-packages")
set(Tasmanian_python_default_path "${CMAKE_INSTALL_PREFIX}/python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}/site-packages")
else()
set(Tasmanian_python_default_path "${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
set(Tasmanian_python_default_path "${CMAKE_INSTALL_PREFIX}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages")
endif()

if (NOT "${Tasmanian_python_install_path}" STREQUAL "${Tasmanian_python_default_path}")
Expand Down Expand Up @@ -135,16 +135,16 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/example_optimization.in.py" "${CMAKE
########################################################################
# Testing
########################################################################
add_test(NAME PythonIO COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testBasicIO)
add_test(NAME PythonAcceleration COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testAcceleratedEvaluate)
add_test(NAME PythonExceptions COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testBasicException)
add_test(NAME PythonMakeUpdate COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testAMakeUpdate)
add_test(NAME PythonRefine COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testBRefinement)
add_test(NAME PythonLearning COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testCUnsructuredData)
add_test(NAME PythonMisc COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testZMisc)
add_test(NAME PythonAddons COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testAddons)
add_test(NAME PythonDream COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testDream)
add_test(NAME PythonOptimization COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testOptimization)
add_test(NAME PythonIO COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testBasicIO)
add_test(NAME PythonAcceleration COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testAcceleratedEvaluate)
add_test(NAME PythonExceptions COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testBasicException)
add_test(NAME PythonMakeUpdate COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testAMakeUpdate)
add_test(NAME PythonRefine COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testBRefinement)
add_test(NAME PythonLearning COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testCUnsructuredData)
add_test(NAME PythonMisc COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testZMisc)
add_test(NAME PythonAddons COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testAddons)
add_test(NAME PythonDream COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testDream)
add_test(NAME PythonOptimization COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/testTSG.py" TestTasmanian.testOptimization)
set_tests_properties(PythonIO PROPERTIES RUN_SERIAL ON) # IO and Refine read/write to potentially the same files
set_tests_properties(PythonRefine PROPERTIES RUN_SERIAL ON)
Tasmanian_set_test_properties(TESTS PythonIO PythonAcceleration PythonExceptions PythonMakeUpdate PythonRefine PythonLearning PythonMisc PythonAddons PythonDream)
Expand Down
Loading

0 comments on commit 865e774

Please sign in to comment.