From cf32b430dc6435975b587397da4d2e2a0f5be7af Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 16 Sep 2015 16:58:10 -0400 Subject: [PATCH 1/5] Teach Configure.h to store if TBB and CUDA are enabled. --- CMakeLists.txt | 8 ++++++++ vtkm/internal/Configure.h.in | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f819e410..14e6f46d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,6 +200,10 @@ endif(VTKm_BUILD_EXAMPLES) set(VTKM_USE_DOUBLE_PRECISION ${VTKm_USE_DOUBLE_PRECISION}) set(VTKM_USE_64BIT_IDS ${VTKm_USE_64BIT_IDS}) + +set(VTKM_ENABLE_CUDA ${VTKm_ENABLE_CUDA}) +set(VTKM_ENABLE_TBB ${VTKm_ENABLE_TBB}) + set(VTKM_ENABLE_OPENGL_INTEROP ${VTKm_ENABLE_OPENGL_INTEROP}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/vtkm/internal/Configure.h.in @@ -209,6 +213,10 @@ vtkm_install_headers( vtkm/internal ${CMAKE_CURRENT_BINARY_DIR}/vtkm/internal/Configure.h) unset(VTKM_ENABLE_OPENGL_INTEROP) + +unset(VTKM_ENABLE_TBB) +unset(VTKM_ENABLE_CUDA) + unset(VTKM_USE_64BIT_IDS) unset(VTKM_USE_DOUBLE_PRECISION) diff --git a/vtkm/internal/Configure.h.in b/vtkm/internal/Configure.h.in index a28ff1f57..1d0d15dad 100644 --- a/vtkm/internal/Configure.h.in +++ b/vtkm/internal/Configure.h.in @@ -131,6 +131,15 @@ #define VTKM_THIRDPARTY_POST_INCLUDE #endif +//Mark if we are building with CUDA enabled +#ifndef VTKM_ENABLE_CUDA +#cmakedefine VTKM_ENABLE_CUDA +#endif +//Mark if we are building with TBB enabled +#ifndef VTKM_ENABLE_TBB +#cmakedefine VTKM_ENABLE_TBB +#endif + //Mark if we are building with interop enabled #ifndef VTKM_ENABLE_OPENGL_INTEROP #cmakedefine VTKM_ENABLE_OPENGL_INTEROP From 4d635d642b0f0a0560416b4b3a55bc489a12789f Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 16 Sep 2015 16:59:28 -0400 Subject: [PATCH 2/5] DeviceAdapter Tags now always exist, and contain if the device is valid. Previously it was really hard to verify if a device adapter was valid. Since you would have to check for the existence of the tag. Now the tag always exists, but instead you query the traits of the DeviceAdapter to see if it is a valid adapter. This makes compiling with multiple backends alot easier. --- vtkm/cont/cuda/DeviceAdapterCuda.h | 3 ++ .../cont/cuda/internal/DeviceAdapterTagCuda.h | 10 +++++-- vtkm/cont/internal/DeviceAdapterError.h | 2 +- vtkm/cont/internal/DeviceAdapterTag.h | 28 ++++++++++++++++++- vtkm/cont/internal/DeviceAdapterTagSerial.h | 2 +- vtkm/cont/tbb/DeviceAdapterTBB.h | 3 ++ vtkm/cont/tbb/internal/DeviceAdapterTagTBB.h | 10 +++++-- .../UnitTestDeviceAdapterAlgorithmGeneral.cxx | 2 +- 8 files changed, 52 insertions(+), 8 deletions(-) diff --git a/vtkm/cont/cuda/DeviceAdapterCuda.h b/vtkm/cont/cuda/DeviceAdapterCuda.h index 4138d9f5b..5f37dc62e 100644 --- a/vtkm/cont/cuda/DeviceAdapterCuda.h +++ b/vtkm/cont/cuda/DeviceAdapterCuda.h @@ -21,7 +21,10 @@ #define vtk_m_cont_cuda_DeviceAdapterCuda_h #include + +#ifdef VTKM_ENABLE_CUDA #include #include +#endif #endif //vtk_m_cont_cuda_DeviceAdapterCuda_h diff --git a/vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h b/vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h index fea9d3fe8..4f6d1acad 100644 --- a/vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h +++ b/vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h @@ -22,7 +22,13 @@ #include - -VTKM_CREATE_DEVICE_ADAPTER(Cuda); +//We always create the cuda tag when included, but we only mark it as +//a valid tag when VTKM_ENABLE_CUDA is true. This is for easier development +//of multi-backend systems +#ifdef VTKM_ENABLE_CUDA +VTKM_VALID_DEVICE_ADAPTER(Cuda); +#else +VTKM_INVALID_DEVICE_ADAPTER(Cuda); +#endif #endif //vtk_m_cont_cuda_internal_DeviceAdapterTagCuda_h diff --git a/vtkm/cont/internal/DeviceAdapterError.h b/vtkm/cont/internal/DeviceAdapterError.h index 846a852c9..85e772c67 100644 --- a/vtkm/cont/internal/DeviceAdapterError.h +++ b/vtkm/cont/internal/DeviceAdapterError.h @@ -27,6 +27,6 @@ /// point, you have to specify an appropriate DeviceAdapter or else get a /// compile error. /// -VTKM_CREATE_DEVICE_ADAPTER(Error); +VTKM_VALID_DEVICE_ADAPTER(Error); #endif //vtk_m_cont_internal_DeviceAdapterError_h diff --git a/vtkm/cont/internal/DeviceAdapterTag.h b/vtkm/cont/internal/DeviceAdapterTag.h index 966a33b70..2b746d9fc 100644 --- a/vtkm/cont/internal/DeviceAdapterTag.h +++ b/vtkm/cont/internal/DeviceAdapterTag.h @@ -61,7 +61,7 @@ struct DeviceAdapterTagCheck /// Creates a tag named vtkm::cont::DeviceAdapterTagName and associated MPL /// structures to use this tag. Always use this macro (in the base namespace) /// when creating a device adapter. -#define VTKM_CREATE_DEVICE_ADAPTER(Name) \ +#define VTKM_VALID_DEVICE_ADAPTER(Name) \ namespace vtkm { \ namespace cont { \ struct DeviceAdapterTag##Name { }; \ @@ -71,6 +71,7 @@ struct DeviceAdapterTagCheck static DeviceAdapterId GetId() { \ return DeviceAdapterId(#Name); \ } \ + static const bool Valid = true;\ }; \ template<> \ struct DeviceAdapterTagCheck { \ @@ -80,6 +81,31 @@ struct DeviceAdapterTagCheck } \ } +/// Marks the tag named vtkm::cont::DeviceAdapterTagName and associated +/// structures as valid to use. Always use this macro (in the base namespace) +/// when creating a device adapter. +#define VTKM_INVALID_DEVICE_ADAPTER(Name) \ + namespace vtkm { \ + namespace cont { \ + struct DeviceAdapterTag##Name { }; \ + namespace internal { \ + template<> \ + struct DeviceAdapterTraits { \ + static DeviceAdapterId GetId() { \ + return DeviceAdapterId(#Name); \ + } \ + static const bool Valid = false;\ + }; \ + template<> \ + struct DeviceAdapterTagCheck { \ + static const bool Valid = false; \ + }; \ + } \ + } \ + } + + + /// Checks that the argument is a proper device adapter tag. This is a handy /// concept check for functions and classes to make sure that a template /// argument is actually a device adapter tag. (You can get weird errors diff --git a/vtkm/cont/internal/DeviceAdapterTagSerial.h b/vtkm/cont/internal/DeviceAdapterTagSerial.h index 6fcf0a852..b86218ccb 100644 --- a/vtkm/cont/internal/DeviceAdapterTagSerial.h +++ b/vtkm/cont/internal/DeviceAdapterTagSerial.h @@ -22,6 +22,6 @@ #include -VTKM_CREATE_DEVICE_ADAPTER(Serial); +VTKM_VALID_DEVICE_ADAPTER(Serial); #endif //vtk_m_cont_internal_DeviceAdapterTagSerial_h diff --git a/vtkm/cont/tbb/DeviceAdapterTBB.h b/vtkm/cont/tbb/DeviceAdapterTBB.h index 3d13f4bf8..f783e9e9f 100644 --- a/vtkm/cont/tbb/DeviceAdapterTBB.h +++ b/vtkm/cont/tbb/DeviceAdapterTBB.h @@ -21,7 +21,10 @@ #define vtk_m_cont_tbb_DeviceAdapterTBB_h #include + +#ifdef VTKM_ENABLE_TBB #include #include +#endif #endif //vtk_m_cont_tbb_DeviceAdapterTBB_h diff --git a/vtkm/cont/tbb/internal/DeviceAdapterTagTBB.h b/vtkm/cont/tbb/internal/DeviceAdapterTagTBB.h index b40edd0c5..ba415625f 100644 --- a/vtkm/cont/tbb/internal/DeviceAdapterTagTBB.h +++ b/vtkm/cont/tbb/internal/DeviceAdapterTagTBB.h @@ -22,7 +22,13 @@ #include - -VTKM_CREATE_DEVICE_ADAPTER(TBB); +//We always create the tbb tag when included, but we only mark it as +//a valid tag when VTKM_ENABLE_TBB is true. This is for easier development +//of multi-backend systems +#ifdef VTKM_ENABLE_TBB +VTKM_VALID_DEVICE_ADAPTER(TBB); +#else +VTKM_INVALID_DEVICE_ADAPTER(TBB); +#endif #endif //vtk_m_cont_tbb_internal_DeviceAdapterTagTBB_h diff --git a/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx b/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx index 3e448033c..b8f71c4b9 100644 --- a/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx +++ b/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx @@ -33,7 +33,7 @@ #include -VTKM_CREATE_DEVICE_ADAPTER(TestAlgorithmGeneral); +VTKM_VALID_DEVICE_ADAPTER(TestAlgorithmGeneral); namespace vtkm { namespace cont { From fc0ff69d04c68e9f0ab8ef6d77f59fb20ac8a429 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 16 Sep 2015 17:15:02 -0400 Subject: [PATCH 3/5] Methods with try/catch need to be host only. When compiling with cuda and tbb enabled in a single translation unit you need to make sure all try/catch blocks are marked as host only otherwise the cuda compiler will error out. --- vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h b/vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h index 78c13db16..e84c54ca5 100644 --- a/vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h +++ b/vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h @@ -389,7 +389,7 @@ private: this->Functor.SetErrorMessageBuffer(errorMessage); } - VTKM_EXEC_EXPORT + VTKM_CONT_EXPORT void operator()(const ::tbb::blocked_range &range) const { // The TBB device adapter causes array classes to be shared between // control and execution environment. This means that it is possible for @@ -461,7 +461,7 @@ private: this->Functor.SetErrorMessageBuffer(errorMessage); } - VTKM_EXEC_EXPORT + VTKM_CONT_EXPORT void operator()(const ::tbb::blocked_range3d &range) const { try { @@ -568,7 +568,7 @@ private: OutputPortal(outputPortal) { } - VTKM_EXEC_EXPORT + VTKM_CONT_EXPORT void operator()(const ::tbb::blocked_range &range) const { // The TBB device adapter causes array classes to be shared between From b1663b24b78fc074d42066eea958b8c21b367fad Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 16 Sep 2015 17:16:07 -0400 Subject: [PATCH 4/5] Add an example of using multiple backends from a single translation unit. --- examples/CMakeLists.txt | 3 +- examples/multi_backend/CMakeLists.txt | 33 +++++ examples/multi_backend/MultiBackend.cu | 25 ++++ examples/multi_backend/MultiBackend.cxx | 158 ++++++++++++++++++++++++ 4 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 examples/multi_backend/CMakeLists.txt create mode 100755 examples/multi_backend/MultiBackend.cu create mode 100644 examples/multi_backend/MultiBackend.cxx diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 2d70243ae..c0194caec 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -21,4 +21,5 @@ ##============================================================================= add_subdirectory(hello_world) -add_subdirectory(isosurface) \ No newline at end of file +add_subdirectory(isosurface) +add_subdirectory(multi_backend) \ No newline at end of file diff --git a/examples/multi_backend/CMakeLists.txt b/examples/multi_backend/CMakeLists.txt new file mode 100644 index 000000000..82a33fd8d --- /dev/null +++ b/examples/multi_backend/CMakeLists.txt @@ -0,0 +1,33 @@ +##============================================================================= +## +## 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. +## +##============================================================================= + +cmake_minimum_required(VERSION 2.8.11) + +if(VTKm_Cuda_FOUND) + cuda_add_executable(MultiBackend MultiBackend.cu) +else() + add_executable(MultiBackend MultiBackend.cxx) +endif() + +if(VTKm_TBB_FOUND) + target_link_libraries(MultiBackend ${TBB_LIBRARIES}) +endif() diff --git a/examples/multi_backend/MultiBackend.cu b/examples/multi_backend/MultiBackend.cu new file mode 100755 index 000000000..67247727a --- /dev/null +++ b/examples/multi_backend/MultiBackend.cu @@ -0,0 +1,25 @@ +//============================================================================ +// 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. +//============================================================================ + +#define BOOST_SP_DISABLE_THREADS + +//This file merely exists so that we can simplify the logic for invoking +//nvcc telling that cuda code exists. +#include "MultiBackend.cxx" \ No newline at end of file diff --git a/examples/multi_backend/MultiBackend.cxx b/examples/multi_backend/MultiBackend.cxx new file mode 100644 index 000000000..db1e59613 --- /dev/null +++ b/examples/multi_backend/MultiBackend.cxx @@ -0,0 +1,158 @@ +//============================================================================ +// 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. +//============================================================================ +#include + +#include +#include +#include +#include + +#include +#include + +struct GenerateSurfaceWorklet : public vtkm::worklet::WorkletMapField +{ + vtkm::Float32 t; + GenerateSurfaceWorklet(vtkm::Float32 st) : t(st) {} + + typedef void ControlSignature( FieldIn<>, FieldOut<>, FieldOut<> ); + typedef void ExecutionSignature( _1, _2, _3 ); + + template + VTKM_EXEC_EXPORT + void operator()( const vtkm::Vec< T, 3 > & input, + vtkm::Vec & output, + vtkm::Vec& color ) const + { + output[0] = input[0]; + output[1] = 0.25f * vtkm::Sin( input[0] * 10.f + t ) * vtkm::Cos( input[2] * 10.f + t ); + output[2] = input[2]; + + color[0] = 0; + color[1] = 160 + static_cast(96 * vtkm::Sin( input[0] * 10.f + t ) ); + color[2] = 160 + static_cast(96 * vtkm::Cos( input[2] * 5.f + t ) ); + color[3] = 255; + } +}; + +template struct CanRun; + +template +void run_if_valid(vtkm::cont::ArrayHandle< vtkm::Vec< T, 3 > > inHandle, + vtkm::cont::ArrayHandle< vtkm::Vec< T, 3 > > outCoords, + vtkm::cont::ArrayHandle< vtkm::Vec< vtkm::UInt8, 4 > > outColors, + DeviceAdapterTag tag) +{ + typedef vtkm::cont::internal::DeviceAdapterTraits + DeviceAdapterTraits; + + if(DeviceAdapterTraits::Valid) + { + std::cout << "Running a worklet on device adapter: " + << DeviceAdapterTraits::GetId() << std::endl; + } + else + { + std::cout << "Unable to run a worklet on device adapter: " + << DeviceAdapterTraits::GetId() << std::endl; + } + + CanRun::run(inHandle,outCoords,outColors,tag); +} + + +//Implementation that we call on device adapters we don't have support +//enabled for +template<> +struct CanRun +{ + template + static void run(vtkm::cont::ArrayHandle< vtkm::Vec< T, 3 > > vtkmNotUsed(inHandle), + vtkm::cont::ArrayHandle< vtkm::Vec< T, 3 > > vtkmNotUsed(outCoords), + vtkm::cont::ArrayHandle< vtkm::Vec< vtkm::UInt8, 4 > > vtkmNotUsed(outColors), + DeviceAdapterTag) + { + } +}; + +//Implementation that we call on device adapters we do have support +//enabled for +template<> +struct CanRun +{ + template + static void run(vtkm::cont::ArrayHandle< vtkm::Vec< T, 3 > > inHandle, + vtkm::cont::ArrayHandle< vtkm::Vec< T, 3 > > outCoords, + vtkm::cont::ArrayHandle< vtkm::Vec< vtkm::UInt8, 4 > > outColors, + DeviceAdapterTag) + { + typedef vtkm::worklet::DispatcherMapField DispatcherType; + + GenerateSurfaceWorklet worklet( 0.05f ); + DispatcherType(worklet).Invoke( inHandle, + outCoords, + outColors); + } +}; + +template +std::vector< vtkm::Vec > make_testData(int size) +{ + std::vector< vtkm::Vec< T, 3 > > data; + data.reserve( static_cast(size*size) ); + for (int i = 0; i < size; ++i ) + { + for (int j = 0; j < size; ++j ) + { + data.push_back( vtkm::Vec( 2.f * i / size - 1.f, + 0.f, + 2.f * j / size - 1.f ) ); + } + } + return data; +} + + +int main(int, char**) +{ + typedef vtkm::Vec< vtkm::Float32, 3 > FloatVec3; + typedef vtkm::Vec< vtkm::UInt8, 4 > Uint8Vec4; + + std::vector< FloatVec3 > data = make_testData(1024); + + typedef ::vtkm::cont::DeviceAdapterTagSerial SerialTag; + typedef ::vtkm::cont::DeviceAdapterTagTBB TBBTag; + typedef ::vtkm::cont::DeviceAdapterTagCuda CudaTag; + + //make array handles for the data + vtkm::cont::ArrayHandle< FloatVec3 > in = vtkm::cont::make_ArrayHandle(data); + vtkm::cont::ArrayHandle< FloatVec3 > out; + vtkm::cont::ArrayHandle< Uint8Vec4 > color; + + //Run the algorithm on all backends that we have compiled support for. + run_if_valid(in, out, color, SerialTag()); + run_if_valid(in, out, color, CudaTag()); + run_if_valid(in, out, color, TBBTag()); + + +} + + From fd685210664f1a768a431664e4cf99adccfe1899 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 17 Sep 2015 09:23:53 -0400 Subject: [PATCH 5/5] Always install all device headers even when device isn't enabled. vtkm_declare_headers now is able to not test headers, by using the TESTABLE keyword. --- CMake/VTKmMacros.cmake | 13 +++++++++++-- vtkm/cont/CMakeLists.txt | 8 ++------ vtkm/cont/cuda/CMakeLists.txt | 14 +++++++++----- vtkm/cont/cuda/internal/CMakeLists.txt | 7 +++++-- vtkm/cont/tbb/CMakeLists.txt | 7 +++++-- vtkm/cont/tbb/internal/CMakeLists.txt | 2 +- vtkm/exec/CMakeLists.txt | 4 +--- vtkm/exec/cuda/CMakeLists.txt | 9 --------- vtkm/exec/cuda/internal/CMakeLists.txt | 13 +++++-------- 9 files changed, 39 insertions(+), 38 deletions(-) diff --git a/CMake/VTKmMacros.cmake b/CMake/VTKmMacros.cmake index 999010b00..2c5d82b61 100644 --- a/CMake/VTKmMacros.cmake +++ b/CMake/VTKmMacros.cmake @@ -153,17 +153,26 @@ endfunction(vtkm_requires_thrust_to_test) # compiled and show up in an IDE. function(vtkm_declare_headers) set(options CUDA) - set(oneValueArgs) + set(oneValueArgs TESTABLE) set(multiValueArgs) cmake_parse_arguments(VTKm_DH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + + #The testable keyword allows the caller to turn off the header testing, + #mainly used so that backends can be installed even when they can't be + #built on the machine. + #Since this is an optional property not setting it means you do want testing + if(NOT DEFINED VTKm_DH_TESTABLE) + set(VTKm_DH_TESTABLE ON) + endif() + set(hfiles ${VTKm_DH_UNPARSED_ARGUMENTS}) vtkm_get_kit_name(name dir_prefix) #only do header testing if enable testing is turned on - if (VTKm_ENABLE_TESTING) + if (VTKm_ENABLE_TESTING AND VTKm_DH_TESTABLE) vtkm_add_header_build_test( "${name}" "${dir_prefix}" "${VTKm_DH_CUDA}" ${hfiles}) endif() diff --git a/vtkm/cont/CMakeLists.txt b/vtkm/cont/CMakeLists.txt index 23a86abd2..a8e9b5562 100644 --- a/vtkm/cont/CMakeLists.txt +++ b/vtkm/cont/CMakeLists.txt @@ -68,12 +68,8 @@ add_subdirectory(arg) vtkm_declare_headers(${impl_headers} ${headers}) -if (VTKm_ENABLE_CUDA) - add_subdirectory(cuda) -endif () -if (VTKm_ENABLE_TBB) - add_subdirectory(tbb) -endif () +add_subdirectory(cuda) +add_subdirectory(tbb) #----------------------------------------------------------------------------- add_subdirectory(testing) diff --git a/vtkm/cont/cuda/CMakeLists.txt b/vtkm/cont/cuda/CMakeLists.txt index 444aabb4e..512055480 100644 --- a/vtkm/cont/cuda/CMakeLists.txt +++ b/vtkm/cont/cuda/CMakeLists.txt @@ -23,14 +23,18 @@ set(headers DeviceAdapterCuda.h ) -vtkm_disable_troublesome_thrust_warnings() +#----------------------------------------------------------------------------- +if (VTKm_ENABLE_CUDA) + vtkm_disable_troublesome_thrust_warnings() + CUDA_INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) +endif() #----------------------------------------------------------------------------- -CUDA_INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) - add_subdirectory(internal) +vtkm_declare_headers(CUDA ${headers} TESTABLE ${VTKm_ENABLE_CUDA}) #----------------------------------------------------------------------------- -vtkm_declare_headers(CUDA ${headers}) +if (VTKm_ENABLE_CUDA) + add_subdirectory(testing) +endif() -add_subdirectory(testing) diff --git a/vtkm/cont/cuda/internal/CMakeLists.txt b/vtkm/cont/cuda/internal/CMakeLists.txt index e2b48cd8c..fb9f1acdd 100644 --- a/vtkm/cont/cuda/internal/CMakeLists.txt +++ b/vtkm/cont/cuda/internal/CMakeLists.txt @@ -28,6 +28,9 @@ set(headers ThrustExceptionHandler.h ) -vtkm_declare_headers(CUDA ${headers}) +vtkm_declare_headers(CUDA ${headers} TESTABLE ${VTKm_ENABLE_CUDA}) -add_subdirectory(testing) +#----------------------------------------------------------------------------- +if (VTKm_ENABLE_CUDA) + add_subdirectory(testing) +endif() diff --git a/vtkm/cont/tbb/CMakeLists.txt b/vtkm/cont/tbb/CMakeLists.txt index 3817a32c0..3b8efd2d8 100644 --- a/vtkm/cont/tbb/CMakeLists.txt +++ b/vtkm/cont/tbb/CMakeLists.txt @@ -24,6 +24,9 @@ set(headers add_subdirectory(internal) -vtkm_declare_headers(${headers}) +vtkm_declare_headers(${headers} TESTABLE ${VTKm_ENABLE_TBB}) -add_subdirectory(testing) +#----------------------------------------------------------------------------- +if (VTKm_ENABLE_TBB) + add_subdirectory(testing) +endif() diff --git a/vtkm/cont/tbb/internal/CMakeLists.txt b/vtkm/cont/tbb/internal/CMakeLists.txt index 6bff99df0..bf7c6a06e 100644 --- a/vtkm/cont/tbb/internal/CMakeLists.txt +++ b/vtkm/cont/tbb/internal/CMakeLists.txt @@ -31,4 +31,4 @@ if("${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR}" VERSION_LESS 4.3) set(headers ${headers} parallel_sort.h) endif() -vtkm_declare_headers(${headers}) +vtkm_declare_headers(${headers} TESTABLE ${VTKm_ENABLE_TBB}) diff --git a/vtkm/exec/CMakeLists.txt b/vtkm/exec/CMakeLists.txt index 25f37b692..af407ef2f 100644 --- a/vtkm/exec/CMakeLists.txt +++ b/vtkm/exec/CMakeLists.txt @@ -39,9 +39,7 @@ vtkm_declare_headers(${impl_headers} ${headers}) #----------------------------------------------------------------------------- -if (VTKm_ENABLE_CUDA) - add_subdirectory(cuda) -endif () +add_subdirectory(cuda) #----------------------------------------------------------------------------- diff --git a/vtkm/exec/cuda/CMakeLists.txt b/vtkm/exec/cuda/CMakeLists.txt index df4aa52cb..7d49d725b 100644 --- a/vtkm/exec/cuda/CMakeLists.txt +++ b/vtkm/exec/cuda/CMakeLists.txt @@ -18,14 +18,5 @@ ## this software. ##============================================================================ -set(headers - ) - #----------------------------------------------------------------------------- add_subdirectory(internal) - -# vtkm_declare_headers(${impl_headers} ${headers}) - - -#----------------------------------------------------------------------------- -# add_subdirectory(testing) diff --git a/vtkm/exec/cuda/internal/CMakeLists.txt b/vtkm/exec/cuda/internal/CMakeLists.txt index f84a88ee9..7bd279bcd 100644 --- a/vtkm/exec/cuda/internal/CMakeLists.txt +++ b/vtkm/exec/cuda/internal/CMakeLists.txt @@ -24,13 +24,10 @@ set(headers WrappedOperators.h ) -vtkm_disable_troublesome_thrust_warnings() - #----------------------------------------------------------------------------- -CUDA_INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) +if (VTKm_ENABLE_CUDA) + vtkm_disable_troublesome_thrust_warnings() + CUDA_INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) +endif() -vtkm_declare_headers(CUDA ${headers}) - - -#----------------------------------------------------------------------------- -# add_subdirectory(testing) +vtkm_declare_headers(CUDA ${headers} TESTABLE ${VTKm_ENABLE_CUDA})