Commit 8a050d83 authored by Sujin Philip's avatar Sujin Philip

Update to latest VTK-m master

We now require that `VTK::AcceleratorsVTKm` module be compiled as static
whenever cuda is enabled.
parent 2c8d6083
......@@ -18,7 +18,11 @@ list(INSERT 0 CMAKE_MODULE_PATH
"${VTK_SOURCE_DIR}/ThirdParty/vtkm/vtkvtkm/vtk-m/CMake")
set(sources)
set(headers)
set(headers
vtkmFilterPolicy.h
vtkmTags.h)
set(private_headers
vtkmlib/DataSetConverters.h
vtkmlib/Portals.hxx
......@@ -54,13 +58,13 @@ set(impl_classes
set(private_impl_classes
vtkmlib/ArrayConverters
vtkmlib/CellSetConverters
vtkmlib/DataSetConverters
vtkmlib/ImageDataConverter
vtkmlib/ImplicitFunctionConverter
vtkmlib/PolyDataConverter
vtkmlib/Portals
vtkmlib/Storage
vtkmlib/UnstructuredGridConverter
vtkmlib/DataSetConverters
vtkmlib/ImplicitFunctionConverter
vtkmlib/Portals)
vtkmlib/UnstructuredGridConverter)
foreach (class IN LISTS impl_classes)
list(APPEND sources "${class}.cxx")
......@@ -74,9 +78,6 @@ endforeach ()
if (TARGET vtkm::cuda)
set_source_files_properties(${sources} PROPERTIES LANGUAGE "CUDA")
#The vtkmlib/CellSetConverters need to be built always as CXX
#as the worklets used by them require access to vtk classes
set_source_files_properties(vtkmlib/CellSetConverters.cxx PROPERTIES LANGUAGE "CXX")
endif ()
set(VTKM_FILTER_INCLUDE_AOS ${VTK_DISPATCH_AOS_ARRAYS})
......@@ -117,7 +118,10 @@ if (TARGET vtkm::cuda)
get_property(arch_flags
TARGET vtkm::cuda
PROPERTY VTKm_CUDA_Architecture_Flags)
PROPERTY INTERFACE_CUDA_Architecture_Flags)
if(NOT arch_flags)
message(FATAL_ERROR "VTK-m CUDA Architecture flags can't be found. This means we can't safely compile CUDA code")
endif()
string(APPEND CMAKE_CUDA_FLAGS " ${arch_flags}")
# Temporarily suppress "has address taken but no possible call to it" warnings,
......@@ -127,10 +131,20 @@ if (TARGET vtkm::cuda)
string(APPEND CMAKE_CUDA_FLAGS " -Xnvlink -w")
endif ()
vtk_module_add_module(VTK::AcceleratorsVTKm
SOURCES ${sources}
HEADERS ${headers}
PRIVATE_HEADERS ${private_headers})
if(TARGET vtkm::cuda AND BUILD_SHARED_LIBS)
message("Cuda is enabled. Module VTK::AcceleratorsVTKm will be forced to build as static.")
vtk_module_add_module(VTK::AcceleratorsVTKm
FORCE_STATIC
SOURCES ${sources}
HEADERS ${headers}
PRIVATE_HEADERS ${private_headers})
else()
vtk_module_add_module(VTK::AcceleratorsVTKm
SOURCES ${sources}
HEADERS ${headers}
PRIVATE_HEADERS ${private_headers})
endif()
vtk_module_set_property(VTK::AcceleratorsVTKm
PROPERTY JOB_POOL_COMPILE
VALUE vtkm_pool)
......
......@@ -310,7 +310,7 @@ void RunBenchmark(int gridSize)
#ifdef FORCE_VTKM_DEVICE
vtkm::cont::RuntimeDeviceTracker tracker =
vtkm::cont::GetGlobalRuntimeDeviceTracker();
vtkm::cont::GetRuntimeDeviceTracker();
// Run VTKm
vtkSmartPointer<vtkPolyData> vtkmResultSerial;
......
......@@ -208,6 +208,45 @@ private:
namespace vtkm {
namespace cont {
//------------------------------------------------------------------------------
vtkm::IdComponent vtkmCellSetExplicitAOS::GetNumberOfPointsInCell(vtkm::Id index) const
{
return this->Connectivity.GetPortalConstControl().Get(
this->IndexOffsets.GetPortalConstControl().Get(index));
}
vtkm::UInt8 vtkmCellSetExplicitAOS::GetCellShape(vtkm::Id index) const
{
return this->Shapes.GetPortalConstControl().Get(index);
}
void vtkmCellSetExplicitAOS::GetCellPointIds(vtkm::Id id, vtkm::Id *ptids) const
{
auto connPortal = this->Connectivity.GetPortalConstControl();
auto start = this->IndexOffsets.GetPortalConstControl().Get(id);
auto count = connPortal.Get(start++);
for (vtkm::Id i = 0; i < count; ++i)
{
ptids[i] = connPortal.Get(i + start);
}
}
std::shared_ptr<CellSet> vtkmCellSetExplicitAOS::NewInstance() const
{
return std::make_shared<vtkmCellSetExplicitAOS>();
}
void vtkmCellSetExplicitAOS::DeepCopy(const CellSet* src)
{
const auto* other = dynamic_cast<const vtkmCellSetExplicitAOS*>(src);
if (!other)
{
throw vtkm::cont::ErrorBadType("Incorrect type passed to CellSetExplicit::DeepCopy");
}
this->Fill(other->NumberOfPoints, other->Shapes, other->Connectivity, other->IndexOffsets);
}
//------------------------------------------------------------------------------
void vtkmCellSetExplicitAOS::Fill(
vtkm::Id numberOfPoints,
......
......@@ -110,9 +110,14 @@ public:
return this->GetNumberOfPoints();
}
vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id index) const;
vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id index) const override;
vtkm::Id GetCellShape(vtkm::Id index) const;
vtkm::UInt8 GetCellShape(vtkm::Id index) const override;
void GetCellPointIds(vtkm::Id id, vtkm::Id *ptids) const override;
std::shared_ptr<CellSet> NewInstance() const override;
void DeepCopy(const CellSet* src) override;
/// Assigns the array handles to the explicit connectivity. This is
/// the way you can fill the memory from another system without copying
......
......@@ -124,6 +124,43 @@ public:
return this->GetNumberOfPoints();
}
vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id) const override
{
return this->DetermineNumberOfPoints();
}
vtkm::UInt8 GetCellShape(vtkm::Id) const override
{
return static_cast<vtkm::UInt8>(this->CellTypeAsId);
}
void GetCellPointIds(vtkm::Id id, vtkm::Id *ptids) const override
{
vtkm::Id count = this->DetermineNumberOfPoints();
vtkm::Id start = id * (count + 1);
auto portal = this->Connectivity.GetPortalConstControl();
for (vtkm::Id i = 0; i < count; ++i)
{
ptids[i] = portal.Get(i + start);
}
}
std::shared_ptr<CellSet> NewInstance() const override
{
return std::make_shared<vtkmCellSetSingleType>();
}
void DeepCopy(const CellSet* src) override
{
const auto* other = dynamic_cast<const vtkmCellSetSingleType*>(src);
if (!other)
{
throw vtkm::cont::ErrorBadType("Incorrect type passed to CellSetExplicit::DeepCopy");
}
this->Fill(other->NumberOfPoints, other->Connectivity);
}
// This is the way you can fill the memory from another system without copying
void Fill(
vtkm::Id numberOfPoints,
......
......@@ -104,9 +104,9 @@ int vtkmClip::RequestData(vtkInformation *,
vtkInformationVector **inInfoVec,
vtkInformationVector *outInfoVec)
{
vtkm::cont::ScopedGlobalRuntimeDeviceTracker tracker;
vtkm::cont::ScopedRuntimeDeviceTracker tracker;
(void)tracker;
vtkm::cont::GetGlobalRuntimeDeviceTracker().DisableDevice(
vtkm::cont::GetRuntimeDeviceTracker().DisableDevice(
vtkm::cont::DeviceAdapterTagCuda{});
vtkInformation* inInfo = inInfoVec[0]->GetInformationObject(0);
......
......@@ -18,7 +18,6 @@
// this software.
//============================================================================
#include "vtkmlib/Storage.h"
#include "vtkmConnectivityExec.h"
namespace vtkm {
......
......@@ -23,6 +23,7 @@
#ifndef VTK_WRAPPING_CXX
#include "vtkmTags.h"
#include "vtkmlib/Storage.h"
#include <vtkm/CellShape.h>
#include <vtkm/TopologyElementTag.h>
......
......@@ -60,9 +60,9 @@ int vtkmContour::RequestData(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
vtkm::cont::ScopedGlobalRuntimeDeviceTracker tracker;
vtkm::cont::ScopedRuntimeDeviceTracker tracker;
(void)tracker;
vtkm::cont::GetGlobalRuntimeDeviceTracker().DisableDevice(
vtkm::cont::GetRuntimeDeviceTracker().DisableDevice(
vtkm::cont::DeviceAdapterTagCuda{});
vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
......
......@@ -39,8 +39,10 @@ public:
using ValueType = typename vtkPortalTraits<Type>::Type;
using ComponentType = typename vtkPortalTraits<Type>::ComponentType;
VTKM_EXEC_CONT
vtkArrayPortal();
VTKM_CONT
vtkArrayPortal(VTKDataArrayType* array, vtkm::Id size);
VTKM_SUPPRESS_EXEC_WARNINGS
......@@ -61,16 +63,19 @@ public:
typedef vtkm::cont::internal::IteratorFromArrayPortal<vtkArrayPortal>
IteratorType;
VTKM_CONT
IteratorType GetIteratorBegin() const
{
return IteratorType(*this, 0);
}
VTKM_CONT
IteratorType GetIteratorEnd() const
{
return IteratorType(*this, this->Size);
}
VTKM_CONT
VTKDataArrayType* GetVtkData() const
{
return this->VTKData;
......@@ -89,8 +94,10 @@ public:
using ValueType = typename vtkPortalTraits<Type>::Type;
using ComponentType = typename vtkPortalTraits<Type>::ComponentType;
VTKM_EXEC_CONT
vtkPointsPortal();
VTKM_CONT
vtkPointsPortal(vtkPoints* points, vtkm::Id size);
VTKM_SUPPRESS_EXEC_WARNINGS
......@@ -111,16 +118,19 @@ public:
typedef vtkm::cont::internal::IteratorFromArrayPortal<vtkPointsPortal>
IteratorType;
VTKM_CONT
IteratorType GetIteratorBegin() const
{
return IteratorType(*this, 0);
}
VTKM_CONT
IteratorType GetIteratorEnd() const
{
return IteratorType(*this, this->Size);
}
VTKM_CONT
vtkPoints* GetVtkData() const
{
return Points;
......
......@@ -30,6 +30,7 @@ namespace {
template <int N> struct fillComponents
{
template <typename T, typename Tuple>
VTKM_EXEC
void operator()(T* t, const Tuple& tuple) const
{
fillComponents<N - 1>()(t, tuple);
......@@ -40,6 +41,7 @@ template <int N> struct fillComponents
template <> struct fillComponents<1>
{
template <typename T, typename Tuple>
VTKM_EXEC
void operator()(T* t, const Tuple& tuple) const
{
t[0] = vtkm::VecTraits<Tuple>::GetComponent(tuple, 0);
......@@ -51,6 +53,7 @@ namespace tovtkm {
//------------------------------------------------------------------------------
template <typename VType, typename VTKDataArrayType>
VTKM_EXEC_CONT
vtkArrayPortal<VType, VTKDataArrayType>::vtkArrayPortal()
: VTKData(nullptr), Size(0)
{
......@@ -58,6 +61,7 @@ vtkArrayPortal<VType, VTKDataArrayType>::vtkArrayPortal()
//------------------------------------------------------------------------------
template <typename VType, typename VTKDataArrayType>
VTKM_CONT
vtkArrayPortal<VType, VTKDataArrayType>::vtkArrayPortal(VTKDataArrayType* array,
vtkm::Id size)
: VTKData(array), Size(size)
......@@ -68,6 +72,7 @@ vtkArrayPortal<VType, VTKDataArrayType>::vtkArrayPortal(VTKDataArrayType* array,
//------------------------------------------------------------------------------
template <typename VType, typename VTKDataArrayType>
typename vtkArrayPortal<VType, VTKDataArrayType>::ValueType
VTKM_EXEC
vtkArrayPortal<VType, VTKDataArrayType>::Get(vtkm::Id index) const
{
VTKM_ASSUME(this->VTKData->GetNumberOfComponents() == NUM_COMPONENTS);
......@@ -83,6 +88,7 @@ vtkArrayPortal<VType, VTKDataArrayType>::Get(vtkm::Id index) const
//------------------------------------------------------------------------------
template <typename VType, typename VTKDataArrayType>
VTKM_EXEC
void vtkArrayPortal<VType, VTKDataArrayType>::Set(vtkm::Id index,
const ValueType& value) const
{
......@@ -97,12 +103,14 @@ void vtkArrayPortal<VType, VTKDataArrayType>::Set(vtkm::Id index,
//------------------------------------------------------------------------------
template <typename Type>
VTKM_EXEC_CONT
vtkPointsPortal<Type>::vtkPointsPortal() : Points(nullptr), Array(nullptr), Size(0)
{
}
//------------------------------------------------------------------------------
template <typename Type>
VTKM_CONT
vtkPointsPortal<Type>::vtkPointsPortal(vtkPoints* points, vtkm::Id size)
: Points(points),
Array(static_cast<ComponentType*>(points->GetVoidPointer(0))),
......@@ -114,6 +122,7 @@ vtkPointsPortal<Type>::vtkPointsPortal(vtkPoints* points, vtkm::Id size)
//------------------------------------------------------------------------------
template <typename Type>
typename vtkPointsPortal<Type>::ValueType
VTKM_EXEC
vtkPointsPortal<Type>::Get(vtkm::Id index) const
{
const ComponentType* const raw = this->Array + (index * NUM_COMPONENTS);
......@@ -122,6 +131,7 @@ vtkPointsPortal<Type>::Get(vtkm::Id index) const
//------------------------------------------------------------------------------
template <typename Type>
VTKM_EXEC
void vtkPointsPortal<Type>::Set(vtkm::Id index, const ValueType& value) const
{
ComponentType* rawArray = this->Array + (index * NUM_COMPONENTS);
......
vtk_module_third_party_internal(
LICENSE_FILES "vtkvtkm/vtk-m/LICENSE.txt"
VERSION "master"
SUBDIRECTORY vtkvtkm
STANDARD_INCLUDE_DIRS
INTERFACE)
NAME
VTK::vtkm
LIBRARY_NAME
vtkvtkm
PRIVATE_DEPENDS
# While not needed to satisfy symbols, this is necessary to guarantee that
# VTK_SMP_IMPLEMENTATION_TYPE is available when configuring vtk-m.
......
......@@ -50,11 +50,10 @@ if (VTKm_ENABLE_CUDA AND CMAKE_VERSION VERSION_LESS 3.11)
set(CMAKE_CUDA_STANDARD_REQUIRED True)
endif ()
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(vtk-m)
vtk_module_add_module(VTK::vtkm
HEADER_ONLY)
target_link_libraries(vtkm
INTERFACE
vtkm
vtkm_cont)
vtk_module_link(VTK::vtkm INTERFACE vtkm_cont vtkm_filter)
Subproject commit e0c0e4b3dae46297a9c1f29fe90f63ddf90c33c3
Subproject commit 4fd7682e412384215d37707136bd3a07d31b2fb6
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment