mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Update vtkm_configure_device macro
* Support a REQUIRED flag that only gives an error if that flag is given. * Move common configuration required for all devices (such as boost) to a special device named Base. * Make CUDA always capitalized to be consistent with the other CMake variables. * Rather than call include_directories, set a variable named VTKm_INCLUDE_DIRS. This is consistent with how most CMake packages work. * Make a CMake variable named VTKm_LIBRARIES containing all the libraries the configured devices need. * Automatically configure supported devices when loading the VTK-m package in CMake.
This commit is contained in:
parent
1a538ca196
commit
c0f49d6112
48
CMake/UseVTKmBase.cmake
Normal file
48
CMake/UseVTKmBase.cmake
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
##============================================================================
|
||||||
|
## Copyright (c) Kitware, Inc.
|
||||||
|
## All rights reserved.
|
||||||
|
## See LICENSE.txt for details.
|
||||||
|
## This software is distributed WITHOUT ANY WARRANTY; without even
|
||||||
|
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
## PURPOSE. See the above copyright notice for more information.
|
||||||
|
##
|
||||||
|
## Copyright 2015 Sandia Corporation.
|
||||||
|
## Copyright 2015 UT-Battelle, LLC.
|
||||||
|
## Copyright 2015 Los Alamos National Security.
|
||||||
|
##
|
||||||
|
## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||||
|
## the U.S. Government retains certain rights in this software.
|
||||||
|
##
|
||||||
|
## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||||
|
## Laboratory (LANL), the U.S. Government retains certain rights in
|
||||||
|
## this software.
|
||||||
|
##============================================================================
|
||||||
|
|
||||||
|
# This is the base configuration for using the VTK-m library. All other
|
||||||
|
# device configurations rely on this.
|
||||||
|
|
||||||
|
if (VTKm_Base_initialize_complete)
|
||||||
|
return()
|
||||||
|
endif (VTKm_Base_initialize_complete)
|
||||||
|
|
||||||
|
# Find the Boost library.
|
||||||
|
if(NOT Boost_FOUND)
|
||||||
|
find_package(BoostHeaders ${VTKm_REQUIRED_BOOST_VERSION})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT Boost_FOUND)
|
||||||
|
message(STATUS "Boost not found")
|
||||||
|
set(VTKm_Base_FOUND)
|
||||||
|
else()
|
||||||
|
set(VTKm_Base_FOUND TRUE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Set up all these dependent packages (if they were all found).
|
||||||
|
if (VTKm_Base_FOUND)
|
||||||
|
set(VTKm_INCLUDE_DIRS
|
||||||
|
${VTKm_INCLUDE_DIRS}
|
||||||
|
${Boost_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(VTKm_Base_initialize_complete TRUE)
|
||||||
|
endif (VTKm_Base_FOUND)
|
78
CMake/UseVTKmCUDA.cmake
Normal file
78
CMake/UseVTKmCUDA.cmake
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
##============================================================================
|
||||||
|
## Copyright (c) Kitware, Inc.
|
||||||
|
## All rights reserved.
|
||||||
|
## See LICENSE.txt for details.
|
||||||
|
## This software is distributed WITHOUT ANY WARRANTY; without even
|
||||||
|
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
## PURPOSE. See the above copyright notice for more information.
|
||||||
|
##
|
||||||
|
## Copyright 2014 Sandia Corporation.
|
||||||
|
## Copyright 2014 UT-Battelle, LLC.
|
||||||
|
## Copyright 2014 Los Alamos National Security.
|
||||||
|
##
|
||||||
|
## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||||
|
## the U.S. Government retains certain rights in this software.
|
||||||
|
##
|
||||||
|
## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||||
|
## Laboratory (LANL), the U.S. Government retains certain rights in
|
||||||
|
## this software.
|
||||||
|
##============================================================================
|
||||||
|
|
||||||
|
if (VTKm_CUDA_initialize_complete)
|
||||||
|
return()
|
||||||
|
endif (VTKm_CUDA_initialize_complete)
|
||||||
|
|
||||||
|
vtkm_configure_device(Base)
|
||||||
|
|
||||||
|
if (VTKm_Base_FOUND)
|
||||||
|
|
||||||
|
set(VTKm_CUDA_FOUND ${VTKm_ENABLE_CUDA})
|
||||||
|
if (NOT VTKm_CUDA_FOUND)
|
||||||
|
message(STATUS "This build of VTK-m does not include CUDA.")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Find CUDA library.
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
if (VTKm_CUDA_FOUND)
|
||||||
|
find_package(CUDA)
|
||||||
|
mark_as_advanced(CUDA_BUILD_CUBIN
|
||||||
|
CUDA_BUILD_EMULATION
|
||||||
|
CUDA_HOST_COMPILER
|
||||||
|
CUDA_SDK_ROOT_DIR
|
||||||
|
CUDA_SEPARABLE_COMPILATION
|
||||||
|
CUDA_TOOLKIT_ROOT_DIR
|
||||||
|
CUDA_VERBOSE_BUILD
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT CUDA_FOUND)
|
||||||
|
message(STATUS "CUDA not found")
|
||||||
|
set(VTKm_CUDA_FOUND)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Find Thrust library.
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
if (VTKm_CUDA_FOUND)
|
||||||
|
find_package(Thrust)
|
||||||
|
|
||||||
|
if (NOT THRUST_FOUND)
|
||||||
|
message(STATUS "Thrust not found")
|
||||||
|
set(VTKm_CUDA_FOUND)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
endif () # VTKm_Base_FOUND
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Set up all these dependent packages (if they were all found).
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
if (VTKm_CUDA_FOUND)
|
||||||
|
set(VTKm_INCLUDE_DIRS
|
||||||
|
${VTKm_INCLUDE_DIRS}
|
||||||
|
${THRUST_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(VTKm_CUDA_initialize_complete TRUE)
|
||||||
|
endif (VTKm_CUDA_FOUND)
|
@ -1,84 +0,0 @@
|
|||||||
##============================================================================
|
|
||||||
## Copyright (c) Kitware, Inc.
|
|
||||||
## All rights reserved.
|
|
||||||
## See LICENSE.txt for details.
|
|
||||||
## This software is distributed WITHOUT ANY WARRANTY; without even
|
|
||||||
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
## PURPOSE. See the above copyright notice for more information.
|
|
||||||
##
|
|
||||||
## Copyright 2014 Sandia Corporation.
|
|
||||||
## Copyright 2014 UT-Battelle, LLC.
|
|
||||||
## Copyright 2014 Los Alamos National Security.
|
|
||||||
##
|
|
||||||
## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
|
||||||
## the U.S. Government retains certain rights in this software.
|
|
||||||
##
|
|
||||||
## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
||||||
## Laboratory (LANL), the U.S. Government retains certain rights in
|
|
||||||
## this software.
|
|
||||||
##============================================================================
|
|
||||||
|
|
||||||
if (VTKm_Cuda_initialize_complete)
|
|
||||||
return()
|
|
||||||
endif (VTKm_Cuda_initialize_complete)
|
|
||||||
|
|
||||||
set(VTKm_Cuda_FOUND ${VTKm_ENABLE_CUDA})
|
|
||||||
if (NOT VTKm_Cuda_FOUND)
|
|
||||||
message(STATUS "This build of VTKm does not include Cuda.")
|
|
||||||
endif (NOT VTKm_Cuda_FOUND)
|
|
||||||
|
|
||||||
# Find the Boost library.
|
|
||||||
if (VTKm_Cuda_FOUND)
|
|
||||||
if(NOT Boost_FOUND)
|
|
||||||
find_package(BoostHeaders ${VTKm_REQUIRED_BOOST_VERSION})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT Boost_FOUND)
|
|
||||||
message(STATUS "Boost not found")
|
|
||||||
set(VTKm_Cuda_FOUND)
|
|
||||||
endif (NOT Boost_FOUND)
|
|
||||||
endif (VTKm_Cuda_FOUND)
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Find CUDA library.
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
if (VTKm_Cuda_FOUND)
|
|
||||||
find_package(CUDA)
|
|
||||||
mark_as_advanced(CUDA_BUILD_CUBIN
|
|
||||||
CUDA_BUILD_EMULATION
|
|
||||||
CUDA_HOST_COMPILER
|
|
||||||
CUDA_SDK_ROOT_DIR
|
|
||||||
CUDA_SEPARABLE_COMPILATION
|
|
||||||
CUDA_TOOLKIT_ROOT_DIR
|
|
||||||
CUDA_VERBOSE_BUILD
|
|
||||||
)
|
|
||||||
|
|
||||||
if (NOT CUDA_FOUND)
|
|
||||||
message(STATUS "CUDA not found")
|
|
||||||
set(VTKm_Cuda_FOUND)
|
|
||||||
endif (NOT CUDA_FOUND)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Find Thrust library.
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
if (VTKm_Cuda_FOUND)
|
|
||||||
find_package(Thrust)
|
|
||||||
|
|
||||||
if (NOT THRUST_FOUND)
|
|
||||||
message(STATUS "Thrust not found")
|
|
||||||
set(VTKm_Cuda_FOUND)
|
|
||||||
endif (NOT THRUST_FOUND)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# Set up all these dependent packages (if they were all found).
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
if (VTKm_Cuda_FOUND)
|
|
||||||
cuda_include_directories(
|
|
||||||
${Boost_INCLUDE_DIRS}
|
|
||||||
${THRUST_INCLUDE_DIRS}
|
|
||||||
${VTKm_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
set(VTKm_Cuda_initialize_complete TRUE)
|
|
||||||
endif (VTKm_Cuda_FOUND)
|
|
@ -22,26 +22,15 @@ if (VTKm_Serial_initialize_complete)
|
|||||||
return()
|
return()
|
||||||
endif (VTKm_Serial_initialize_complete)
|
endif (VTKm_Serial_initialize_complete)
|
||||||
|
|
||||||
# Find the Boost library.
|
vtkm_configure_device(Base)
|
||||||
if (NOT VTKm_Serial_FOUND)
|
|
||||||
if(NOT Boost_FOUND)
|
if (VTKm_Base_FOUND)
|
||||||
find_package(BoostHeaders ${VTKm_REQUIRED_BOOST_VERSION})
|
# Serial only relies on base configuration
|
||||||
|
set(VTKm_Serial_FOUND TRUE)
|
||||||
|
else () # !VTKm_Base_FOUND
|
||||||
|
set(VTKm_Serial_FOUND)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (NOT Boost_FOUND)
|
|
||||||
message(STATUS "Boost not found")
|
|
||||||
set(VTKm_Serial_FOUND FALSE)
|
|
||||||
else(NOT Boost_FOUND)
|
|
||||||
set(VTKm_Serial_FOUND TRUE)
|
|
||||||
endif (NOT Boost_FOUND)
|
|
||||||
endif (NOT VTKm_Serial_FOUND)
|
|
||||||
|
|
||||||
# Set up all these dependent packages (if they were all found).
|
|
||||||
if (VTKm_Serial_FOUND)
|
if (VTKm_Serial_FOUND)
|
||||||
include_directories(
|
|
||||||
${Boost_INCLUDE_DIRS}
|
|
||||||
${VTKm_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(VTKm_Serial_initialize_complete TRUE)
|
set(VTKm_Serial_initialize_complete TRUE)
|
||||||
endif (VTKm_Serial_FOUND)
|
endif ()
|
||||||
|
@ -22,36 +22,37 @@ if (VTKm_TBB_initialize_complete)
|
|||||||
return()
|
return()
|
||||||
endif (VTKm_TBB_initialize_complete)
|
endif (VTKm_TBB_initialize_complete)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
vtkm_configure_device(Base)
|
||||||
# Find TBB.
|
|
||||||
#-----------------------------------------------------------------------------
|
if (VTKm_Base_FOUND)
|
||||||
|
|
||||||
|
set(VTKm_TBB_FOUND ${VTKm_ENABLE_TBB})
|
||||||
if (NOT VTKm_TBB_FOUND)
|
if (NOT VTKm_TBB_FOUND)
|
||||||
find_package(TBB REQUIRED)
|
message(STATUS "This build of VTK-m does not include TBB.")
|
||||||
set (VTKm_TBB_FOUND ${TBB_FOUND})
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Find the Boost library.
|
# Find TBB.
|
||||||
#-----------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
if (VTKm_TBB_FOUND)
|
if (VTKm_TBB_FOUND)
|
||||||
if(NOT Boost_FOUND)
|
find_package(TBB)
|
||||||
find_package(BoostHeaders ${VTKm_REQUIRED_BOOST_VERSION})
|
if (NOT TBB_FOUND)
|
||||||
|
message(STATUS "TBB not found")
|
||||||
|
set(VTKm_TBB_FOUND)
|
||||||
|
endif ()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT Boost_FOUND)
|
|
||||||
message(STATUS "Boost not found")
|
|
||||||
set(VTKm_TBB_FOUND FALSE)
|
|
||||||
endif()
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Set up all these dependent packages (if they were all found).
|
# Set up all these dependent packages (if they were all found).
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
if (VTKm_TBB_FOUND)
|
if (VTKm_TBB_FOUND)
|
||||||
include_directories(
|
set(VTKm_INCLUDE_DIRS
|
||||||
${Boost_INCLUDE_DIRS}
|
|
||||||
${VTKm_INCLUDE_DIRS}
|
${VTKm_INCLUDE_DIRS}
|
||||||
${TBB_INCLUDE_DIRS}
|
${TBB_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
set(VTKm_LIBRARIES ${TBB_LIBRARIES})
|
||||||
|
|
||||||
set(VTKm_TBB_initialize_complete TRUE)
|
set(VTKm_TBB_initialize_complete TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
@ -18,6 +18,12 @@
|
|||||||
## this software.
|
## this software.
|
||||||
##============================================================================
|
##============================================================================
|
||||||
|
|
||||||
|
# When this file is run by CMake (usually through the find_package command),
|
||||||
|
# The following variables will be defined:
|
||||||
|
#
|
||||||
|
# VTKm_INCLUDE_DIRS - Directories containing VTK-m and dependent headers
|
||||||
|
# VTKm_LIBRARIES - The libraries required when using VTK-m
|
||||||
|
|
||||||
# This file should be installed in the include directory.
|
# This file should be installed in the include directory.
|
||||||
# Find the root directory.
|
# Find the root directory.
|
||||||
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
@ -35,6 +41,19 @@ set(VTKm_REQUIRED_BOOST_VERSION "@VTKm_REQUIRED_BOOST_VERSION@")
|
|||||||
|
|
||||||
set(VTKm_CMAKE_MODULE_PATH "@VTKm_CMAKE_MODULE_PATH_CONFIG@")
|
set(VTKm_CMAKE_MODULE_PATH "@VTKm_CMAKE_MODULE_PATH_CONFIG@")
|
||||||
|
|
||||||
|
set(VTKm_ENABLE_CUDA "@VTKm_ENABLE_CUDA@")
|
||||||
|
set(VTKm_ENABLE_TBB "@VTKm_ENABLE_TBB@")
|
||||||
|
|
||||||
# VTKm requires some CMake Find modules not included with CMake, so
|
# VTKm requires some CMake Find modules not included with CMake, so
|
||||||
# include the CMake modules distributed with VTKm.
|
# include the CMake modules distributed with VTKm.
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
|
include(VTKmMacros)
|
||||||
|
|
||||||
|
vtkm_configure_device(Serial)
|
||||||
|
if(VTKm_ENABLE_CUDA)
|
||||||
|
vtkm_configure_device(CUDA)
|
||||||
|
endif()
|
||||||
|
if(VTKm_ENABLE_TBB)
|
||||||
|
vtkm_configure_device(TBB)
|
||||||
|
endif()
|
||||||
|
@ -553,7 +553,11 @@ macro(vtkm_configure_device device)
|
|||||||
set(VTKm_ENABLE_${device_uppercase} ON)
|
set(VTKm_ENABLE_${device_uppercase} ON)
|
||||||
include("UseVTKm${device}")
|
include("UseVTKm${device}")
|
||||||
if(NOT VTKm_${device}_FOUND)
|
if(NOT VTKm_${device}_FOUND)
|
||||||
|
if ("${ARGV1}" STREQUAL "REQUIRED")
|
||||||
message(SEND_ERROR "Could not configure for using VTKm with ${device}")
|
message(SEND_ERROR "Could not configure for using VTKm with ${device}")
|
||||||
endif(NOT VTKm_${device}_FOUND)
|
else()
|
||||||
|
message(STATUS "Could not configure for using VTKm with ${device}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endmacro(vtkm_configure_device)
|
endmacro(vtkm_configure_device)
|
||||||
|
|
||||||
|
@ -112,12 +112,14 @@ endif()
|
|||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Set up devices selected.
|
# Set up devices selected.
|
||||||
vtkm_configure_device(Serial)
|
vtkm_configure_device(Serial)
|
||||||
if (VTKm_ENABLE_CUDA)
|
|
||||||
vtkm_configure_device(Cuda)
|
|
||||||
endif (VTKm_ENABLE_CUDA)
|
|
||||||
if (VTKm_ENABLE_TBB)
|
if (VTKm_ENABLE_TBB)
|
||||||
vtkm_configure_device(TBB)
|
vtkm_configure_device(TBB REQUIRED)
|
||||||
endif (VTKm_ENABLE_TBB)
|
endif (VTKm_ENABLE_TBB)
|
||||||
|
if (VTKm_ENABLE_CUDA)
|
||||||
|
vtkm_configure_device(CUDA REQUIRED)
|
||||||
|
cuda_include_directories(${VTKm_INCLUDE_DIRS})
|
||||||
|
endif (VTKm_ENABLE_CUDA)
|
||||||
|
include_directories(${VTKm_INCLUDE_DIRS})
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user