From 109e139589a57bca650d044d83e53d806bc8cb6a Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Sat, 13 May 2017 22:58:30 -0400 Subject: [PATCH] Modify CMake for CUDA matrix-free. --- cmake/macros/macro_deal_ii_add_test.cmake | 16 +++++++++++++++- cmake/macros/macro_deal_ii_pickup_tests.cmake | 3 +++ include/CMakeLists.txt | 8 ++++++++ source/base/CMakeLists.txt | 1 + source/matrix_free/CMakeLists.txt | 15 +++++++++++++++ tests/run_testsuite.cmake | 2 +- 6 files changed, 43 insertions(+), 2 deletions(-) diff --git a/cmake/macros/macro_deal_ii_add_test.cmake b/cmake/macros/macro_deal_ii_add_test.cmake index 5662338ce3..b1dfff8c61 100644 --- a/cmake/macros/macro_deal_ii_add_test.cmake +++ b/cmake/macros/macro_deal_ii_add_test.cmake @@ -168,6 +168,15 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) # IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_test_name}.cc") + SET(_source_file "${_test_name}.cc") + + SET(_target ${_test_name}.${_build_lowercase}) # target name + SET(_run_args "$") # the command to issue + + ELSEIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_test_name}.cu") + + SET(_source_file "${_test_name}.cu") + SET(_target ${_test_name}.${_build_lowercase}) # target name SET(_run_args "$") # the command to issue @@ -240,9 +249,14 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target}/interrupt_guard.cc COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${_target}/interrupt_guard.cc ) + + FIND_PACKAGE(CUDA) + CUDA_INCLUDE_DIRECTORIES("${DEAL_II_INCLUDE_DIRS}") + CUDA_WRAP_SRCS( ${_target} OBJ _generated_files ${_source_file} ) ADD_EXECUTABLE(${_target} EXCLUDE_FROM_ALL - ${_test_name}.cc + ${_generated_files} + ${_source_file} ${CMAKE_CURRENT_BINARY_DIR}/${_target}/interrupt_guard.cc ) diff --git a/cmake/macros/macro_deal_ii_pickup_tests.cmake b/cmake/macros/macro_deal_ii_pickup_tests.cmake index 2bfbd2c4c4..220399bcf9 100644 --- a/cmake/macros/macro_deal_ii_pickup_tests.cmake +++ b/cmake/macros/macro_deal_ii_pickup_tests.cmake @@ -81,6 +81,9 @@ MACRO(DEAL_II_PICKUP_TESTS) # Necessary external interpreters and programs: # + FIND_PACKAGE(CUDA) + SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -std=c++11 -arch=sm_35) + FIND_PACKAGE(Perl REQUIRED) FIND_PROGRAM(DIFF_EXECUTABLE diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 436e048d7c..9df8bac90a 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -34,6 +34,14 @@ INSTALL(DIRECTORY deal.II FILES_MATCHING PATTERN "*.h" ) +IF(DEAL_II_WITH_CUDA) + INSTALL(DIRECTORY deal.II + DESTINATION ${DEAL_II_INCLUDE_RELDIR} + COMPONENT library + FILES_MATCHING PATTERN "*.cuh" + ) +ENDIF() + # # and don't forget to install all generated header files, too: # diff --git a/source/base/CMakeLists.txt b/source/base/CMakeLists.txt index b2c0efd786..4b8d56ade9 100644 --- a/source/base/CMakeLists.txt +++ b/source/base/CMakeLists.txt @@ -87,6 +87,7 @@ SET(_inst FILE(GLOB _header ${CMAKE_SOURCE_DIR}/include/deal.II/base/*.h + ${CMAKE_SOURCE_DIR}/include/deal.II/base/*.cuh ) DEAL_II_ADD_LIBRARY(obj_base OBJECT ${_src} ${_header} ${_inst} diff --git a/source/matrix_free/CMakeLists.txt b/source/matrix_free/CMakeLists.txt index 1558ab49bb..04b9927961 100644 --- a/source/matrix_free/CMakeLists.txt +++ b/source/matrix_free/CMakeLists.txt @@ -27,5 +27,20 @@ FILE(GLOB _header ${CMAKE_SOURCE_DIR}/include/deal.II/matrix_free/*.h ) +IF(DEAL_II_WITH_CUDA) + SET(_src + cuda_matrix_free.cu + ${_src} + ) + SET(_inst + cuda_matrix_free.inst.in + ${_inst} + ) + FILE(GLOB _header + ${CMAKE_SOURCE_DIR}/include/deal.II/matrix_free/*.cuh + ${_header} + ) +ENDIF() + DEAL_II_ADD_LIBRARY(obj_matrix_free OBJECT ${_src} ${_header} ${_inst}) EXPAND_INSTANTIATIONS(obj_matrix_free "${_inst}") diff --git a/tests/run_testsuite.cmake b/tests/run_testsuite.cmake index 4d0b2825ed..42b890a398 100644 --- a/tests/run_testsuite.cmake +++ b/tests/run_testsuite.cmake @@ -271,7 +271,7 @@ FOREACH(_var ${_variables}) _var MATCHES "^(DOCUMENTATION|EXAMPLES)" OR _var MATCHES "^(ARPACK|BOOST|OPENCASCADE|MUPARSER|HDF5|METIS|MPI)_" OR _var MATCHES "^(NETCDF|P4EST|PETSC|SLEPC|THREADS|TBB|TRILINOS)_" OR - _var MATCHES "^(UMFPACK|ZLIB|LAPACK|MUPARSER)_" OR + _var MATCHES "^(UMFPACK|ZLIB|LAPACK|MUPARSER|CUDA)_" OR _var MATCHES "^(CMAKE|DEAL_II)_(C|CXX|Fortran|BUILD)_(COMPILER|FLAGS)" OR _var MATCHES "^CMAKE_BUILD_TYPE$" OR _var MATCHES "MAKEOPTS" OR -- 2.39.5