]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add support for ArborX in the build system
authorBruno Turcksin <bruno.turcksin@gmail.com>
Fri, 8 Jan 2021 16:54:41 +0000 (16:54 +0000)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Fri, 12 Feb 2021 14:21:38 +0000 (14:21 +0000)
cmake/configure/configure_2_trilinos.cmake
cmake/configure/configure_3_kokkos.cmake [new file with mode: 0644]
cmake/configure/configure_4_arborx.cmake [new file with mode: 0644]
cmake/modules/FindARBORX.cmake [new file with mode: 0644]
cmake/modules/FindKOKKOS.cmake [new file with mode: 0644]
include/deal.II/base/config.h.in

index b6a8d7463ddf454ef8eccaba9d8cea064eec8d52..da61cf9104c2a86ff00e9172c7e6400cd213d9ef 100644 (file)
@@ -171,7 +171,7 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var)
       #
       # Check for modules.
       #
-      FOREACH(_optional_module EpetraExt MueLu ROL Sacado SEACAS Tpetra Zoltan)
+      FOREACH(_optional_module EpetraExt Kokkos MueLu ROL Sacado SEACAS Tpetra Zoltan)
         ITEM_MATCHES(_module_found ${_optional_module} ${Trilinos_PACKAGE_LIST})
         IF(_module_found)
           MESSAGE(STATUS "Found ${_optional_module}")
@@ -197,13 +197,7 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var)
       ENDFOREACH()
     ENDIF()
 
-    IF(DEAL_II_TRILINOS_WITH_TPETRA)
-      #
-      # Check if Tpetra is usable in fact.
-      #
-      LIST(APPEND CMAKE_REQUIRED_INCLUDES ${Trilinos_INCLUDE_DIRS})
-      LIST(APPEND CMAKE_REQUIRED_INCLUDES ${MPI_CXX_INCLUDE_PATH})
-
+    IF(DEAL_II_TRILINOS_WITH_KOKKOS)
       CHECK_SYMBOL_EXISTS(
         "KOKKOS_ENABLE_CUDA_LAMBDA"
         "Kokkos_Macros.hpp"
@@ -213,6 +207,27 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var)
         ADD_FLAGS(CMAKE_REQUIRED_FLAGS "--expt-extended-lambda")
       ENDIF()
 
+      # We need a recent version of Trilinos to use kokkos_check. We want to use
+      # VERSION_GREATER_EQUAL 13.0 but this requires CMake 3.7
+      IF(TRILINOS_VERSION VERSION_GREATER 12.99)
+        SET(KOKKOS_WITH_OPENMP "")
+        kokkos_check(DEVICES OpenMP RETURN_VALUE KOKKOS_WITH_OPENMP)
+        IF(KOKKOS_WITH_OPENMP)
+          FIND_PACKAGE(OpenMP REQUIRED)
+          ADD_FLAGS(DEAL_II_CXX_FLAGS "${OpenMP_CXX_FLAGS}")
+          ADD_FLAGS(DEAL_II_LINKER_FLAGS "${OpenMP_CXX_FLAGS}")
+        ENDIF()
+      ENDIF()
+    ENDIF()
+
+    IF(DEAL_II_TRILINOS_WITH_TPETRA)
+      #
+      # Check if Tpetra is usable in fact.
+      #
+      LIST(APPEND CMAKE_REQUIRED_INCLUDES ${Trilinos_INCLUDE_DIRS})
+      LIST(APPEND CMAKE_REQUIRED_INCLUDES ${MPI_CXX_INCLUDE_PATH})
+
+
       LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${Trilinos_LIBRARIES} ${MPI_LIBRARIES})
 
       CHECK_CXX_SOURCE_COMPILES(
diff --git a/cmake/configure/configure_3_kokkos.cmake b/cmake/configure/configure_3_kokkos.cmake
new file mode 100644 (file)
index 0000000..0cd0d48
--- /dev/null
@@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2021 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE.md at
+## the top level directory of deal.II.
+##
+## ---------------------------------------------------------------------
+
+#
+# Configuration for Kokkos support in deal.II:
+#
+
+CONFIGURE_FEATURE(KOKKOS)
diff --git a/cmake/configure/configure_4_arborx.cmake b/cmake/configure/configure_4_arborx.cmake
new file mode 100644 (file)
index 0000000..dcb1168
--- /dev/null
@@ -0,0 +1,22 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2021 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE.md at
+## the top level directory of deal.II.
+##
+## ---------------------------------------------------------------------
+
+#
+# Configuration for ArborX support in deal.II:
+#
+
+SET(FEATURE_ARBORX_DEPENDS KOKKOS)
+
+CONFIGURE_FEATURE(ARBORX)
diff --git a/cmake/modules/FindARBORX.cmake b/cmake/modules/FindARBORX.cmake
new file mode 100644 (file)
index 0000000..6530856
--- /dev/null
@@ -0,0 +1,44 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2021 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE.md at
+## the top level directory of deal.II.
+##
+## ---------------------------------------------------------------------
+
+#
+# Try to find the ArborX library
+#
+# This module exports
+#
+#   ARBORX_INCLUDE_DIRS
+#   ARBORX_INTERFACE_LINK_FLAGS
+#
+
+SET(ARBORX_DIR "" CACHE PATH "An optional hint to an ArborX installation")
+SET_IF_EMPTY(ARBORX_DIR "$ENV{ARBORX_DIR}")
+
+
+FIND_PACKAGE(ArborX
+  HINTS ${ARBORX_DIR} ${ArborX_DIR} $ENV{ArborX_DIR}
+  )
+
+SET(_libraries "")
+
+IF(ArborX_FOUND)
+  GET_PROPERTY(ARBORX_INSTALL_INCLUDE_DIR TARGET ArborX::ArborX PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+ENDIF()
+
+DEAL_II_PACKAGE_HANDLE(ARBORX
+  LIBRARIES REQUIRED ${_libraries}
+  INCLUDE_DIRS REQUIRED ARBORX_INSTALL_INCLUDE_DIR
+  USER_INCLUDE_DIRS REQUIRED ARBORX_INSTALL_INCLUDE_DIR
+  CLEAR ARBORX_DIR ${_libraries}
+  )
diff --git a/cmake/modules/FindKOKKOS.cmake b/cmake/modules/FindKOKKOS.cmake
new file mode 100644 (file)
index 0000000..05755ef
--- /dev/null
@@ -0,0 +1,79 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2021 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE.md at
+## the top level directory of deal.II.
+##
+## ---------------------------------------------------------------------
+
+#
+# Try to find the Kokkos library
+#
+# This module exports
+#
+#   KOKKOS_INCLUDE_DIRS
+#   KOKKOS_INTERFACE_LINK_FLAGS
+#
+
+SET(KOKKOS_DIR "" CACHE PATH "An optional hint to a Kokkos installation")
+SET_IF_EMPTY(KOKKOS_DIR "$ENV{KOKKOS_DIR}")
+
+
+IF(DEAL_II_TRILINOS_WITH_KOKKOS)
+  # Let ArborX know that we have found Kokkos
+  SET(Kokkos_FOUND ON)
+  # Let deal.II know that we have found Kokkos
+  SET(KOKKOS_FOUND ON)
+ELSE()
+  FIND_PACKAGE(Kokkos
+    HINTS ${KOKKOS_DIR} ${Kokkos_DIR} $ENV{Kokkos_DIR}
+    )
+  
+  IF(Kokkos_FOUND)
+    # We are only interested in Kokkos if it is not part of Trilinos
+    IF(TARGET Kokkos::kokkos)
+      GET_PROPERTY(KOKKOS_INSTALL_INCLUDE_DIR TARGET Kokkos::kokkos PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+      GET_PROPERTY(KOKKOS_EXTRA_LD_FLAGS_FULL TARGET Kokkos::kokkoscore PROPERTY INTERFACE_LINK_OPTIONS)
+      STRING(REGEX REPLACE "\\$<\\$<LINK_LANGUAGE:CXX>:([^>]*)>" "\\1" KOKKOS_EXTRA_LD_FLAGS "${KOKKOS_EXTRA_LD_FLAGS_FULL}")
+      GET_PROPERTY(KOKKOS_COMPILE_FLAGS_FULL TARGET Kokkos::kokkoscore PROPERTY INTERFACE_COMPILE_OPTIONS)
+      STRING(REGEX REPLACE "\\$<\\$<COMPILE_LANGUAGE:CXX>:([^>]*)>" "\\1" KOKKOS_COMPILE_FLAGS "${KOKKOS_COMPILE_FLAGS_FULL}")
+      # In serial the flag is empty but ADD_FLAGS does not support adding an empty
+      # flag
+      IF(KOKKOS_COMPILE_FLAGS)
+        ADD_FLAGS(DEAL_II_CXX_FLAGS ${KOKKOS_COMPILE_FLAGS})
+      ENDIF()
+  
+      DEAL_II_FIND_LIBRARY(KOKKOS_CORE_LIBRARY
+        NAMES kokkoscore
+        HINTS ${KOKKOS_DIR}/lib ${Kokkos_DIR}/lib $ENV{Kokkos_DIR}/lib
+        PATH_SUFFIXES
+          lib${LIB_SUFFIX} lib64 lib
+        )
+      
+      DEAL_II_FIND_LIBRARY(KOKKOS_CONTAINERS_LIBRARY
+        NAMES kokkoscontainers
+        HINTS ${KOKKOS_DIR}/lib ${Kokkos_DIR}/lib $ENV{Kokkos_DIR}/lib
+        PATH_SUFFIXES
+          lib${LIB_SUFFIX} lib64 lib
+        )
+    ELSE()
+      SET(Kokkos_FOUND FALSE)
+    ENDIF()
+  ENDIF()
+  
+  DEAL_II_PACKAGE_HANDLE(KOKKOS
+    LIBRARIES REQUIRED KOKKOS_CORE_LIBRARY KOKKOS_CONTAINERS_LIBRARY
+    INCLUDE_DIRS REQUIRED KOKKOS_INSTALL_INCLUDE_DIR
+    USER_INCLUDE_DIRS REQUIRED KOKKOS_INSTALL_INCLUDE_DIR
+    LINKER_FLAGS OPTIONAL KOKKOS_EXTRA_LD_FLAGS
+    CLEAR KOKKOS_DIR KOKKOS_CORE_LIBRARY KOKKOS_CONTAINERS_LIBRARY
+    )
+  
+ENDIF()
index fba8f32f6909f4a5fe91c7d40ca99bfb90bbaed8..23fe3f3b802c0f93b6ac88e788ecca18599d90f2 100644 (file)
@@ -37,6 +37,7 @@
 #cmakedefine DEAL_II_WITH_64BIT_INDICES
 #cmakedefine DEAL_II_WITH_ADOLC
 #cmakedefine DEAL_II_WITH_ARPACK
+#cmakedefine DEAL_II_WITH_ARBORX
 #cmakedefine DEAL_II_WITH_ASSIMP
 #cmakedefine DEAL_II_WITH_COMPLEX_VALUES
 #cmakedefine DEAL_II_WITH_CUDA
@@ -44,6 +45,7 @@
 #cmakedefine DEAL_II_WITH_GSL
 #cmakedefine DEAL_II_WITH_GMSH
 #cmakedefine DEAL_II_WITH_HDF5
+#cmakedefine DEAL_II_WITH_KOKKOS
 #cmakedefine DEAL_II_WITH_LAPACK
 #cmakedefine LAPACK_WITH_64BIT_BLAS_INDICES
 #cmakedefine DEAL_II_LAPACK_WITH_MKL

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.