Commit 448ec292 authored by Robert Maynard's avatar Robert Maynard Committed by Kitware Robot

Merge topic 'virtual_fancy_handles'

19c623bf Add changelogs for ArrayHandleVirtual and VariantArrayHandle
3445047f Refactor vtkm::cont::ArrayHandleAny into vtkm::cont::ArrayHandleVirtual
7a5e32be Update VTKmCompilerFlags to suppress stack-size-warnings on CUDA 9+
bef70820 Update new worklets to work with ArrayHandleVariant
1f2abbc9 vtkm::cont::IsType and vtkm::cont::Cast support VariantArrayHandle
acf825b2 Correct IsType and Cast on ArrayHandleVirtual to work on OSX.
7b9fa975 Rename: IsVirtualType to IsValueType.
deb4946a Make sure vtk-m libraries under CUDA 8 are always built statically
...
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Kenneth Moreland's avatarKenneth Moreland <kmorel@sandia.gov>
Merge-request: !1454
parents ecd6e368 19c623bf
......@@ -101,7 +101,7 @@ if(VTKM_COMPILER_IS_MSVC)
#Setup MSVC warnings with CUDA and CXX
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-wd4702 -wd4505>)
if(TARGET vtkm::cuda)
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-wd4702,-wd4505 -Xcudafe=--display_error_number,--diag_suppress=1394,--diag_suppress=766>)
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-wd4702,-wd4505 -Xcudafe=--diag_suppress=1394,--diag_suppress=766>)
endif()
if(MSVC_VERSION LESS 1900)
......@@ -124,7 +124,7 @@ elseif(VTKM_COMPILER_IS_ICC)
elseif(VTKM_COMPILER_IS_GNU OR VTKM_COMPILER_IS_CLANG)
set(cxx_flags -Wall -Wno-long-long -Wcast-align -Wconversion -Wchar-subscripts -Wextra -Wpointer-arith -Wformat -Wformat-security -Wshadow -Wunused-parameter -fno-common)
set(cuda_flags -Xcudafe=--display_error_number -Xcompiler=-Wall,-Wno-unknown-pragmas,-Wno-unused-local-typedefs,-Wno-unused-local-typedefs,-Wno-unused-function,-Wno-long-long,-Wcast-align,-Wconversion,-Wchar-subscripts,-Wpointer-arith,-Wformat,-Wformat-security,-Wshadow,-Wunused-parameter,-fno-common)
set(cuda_flags -Xcompiler=-Wall,-Wno-unknown-pragmas,-Wno-unused-local-typedefs,-Wno-unused-local-typedefs,-Wno-unused-function,-Wno-long-long,-Wcast-align,-Wconversion,-Wchar-subscripts,-Wpointer-arith,-Wformat,-Wformat-security,-Wshadow,-Wunused-parameter,-fno-common)
#GCC 5, 6 don't properly handle strict-overflow suppression through pragma's.
#Instead of suppressing around the location of the strict-overflow you
......@@ -142,6 +142,19 @@ elseif(VTKM_COMPILER_IS_GNU OR VTKM_COMPILER_IS_CLANG)
endif()
endif()
#common warnings for all platforms when building cuda
if(TARGET vtkm::cuda)
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER 8.99.0)
#nvcc 9 introduced specific controls to disable the stack size warning
#otherwise we let the warning occur. We have to set this in CMAKE_CUDA_FLAGS
#as it is passed to the device link step, unlike compile_options
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xnvlink=--suppress-stack-size-warning")
endif()
set(display_error_nums -Xcudafe=--display_error_number)
target_compile_options(vtkm_developer_flags INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:${suppress_nvlink_stack_size_warnings} ${display_error_nums}>)
endif()
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
install(TARGETS vtkm_compiler_flags vtkm_developer_flags EXPORT ${VTKm_EXPORT_NAME})
endif()
......@@ -134,6 +134,17 @@ if(VTKm_ENABLE_CUDA AND NOT TARGET vtkm::cuda)
add_library(vtkm::cuda UNKNOWN IMPORTED GLOBAL)
endif()
# Workaround issue with CUDA 8.X where virtual don't work when building
# VTK-m as shared. We don't want to force BUILD_SHARED_LIBS to a specific
# value as that could impact other projects that embed VTK-m. Instead what
# we do is make sure that libraries built by vtkm_library() are static
# if they use cuda
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0)
set_target_properties(vtkm::cuda PROPERTIES REQUIRES_STATIC_BUILDS TRUE)
else()
set_target_properties(vtkm::cuda PROPERTIES REQUIRES_STATIC_BUILDS FALSE)
endif()
set_target_properties(vtkm::cuda PROPERTIES
INTERFACE_COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr>
)
......
......@@ -269,6 +269,7 @@ endfunction(vtkm_declare_headers)
# [WRAP_FOR_CUDA <source_list>]
# )
function(vtkm_library)
set(options STATIC SHARED)
set(oneValueArgs NAME)
set(multiValueArgs SOURCES HEADERS TEMPLATE_SOURCES WRAP_FOR_CUDA)
cmake_parse_arguments(VTKm_LIB
......@@ -281,19 +282,46 @@ function(vtkm_library)
endif()
set(lib_name ${VTKm_LIB_NAME})
if(VTKm_LIB_STATIC)
set(VTKm_LIB_type STATIC)
else()
if(VTKm_LIB_SHARED)
set(VTKm_LIB_type SHARED)
endif()
#if cuda requires static libaries force
#them no matter what
if(TARGET vtkm::cuda)
get_target_property(force_static vtkm::cuda REQUIRES_STATIC_BUILDS)
if(force_static)
set(VTKm_LIB_type STATIC)
message("Forcing ${lib_name} to be built statically as we are using CUDA 8.X, which doesn't support virtuals sufficiently in dynamic libraries.")
endif()
endif()
endif()
if(TARGET vtkm::cuda)
vtkm_compile_as_cuda(cu_srcs ${VTKm_LIB_WRAP_FOR_CUDA})
set(VTKm_LIB_WRAP_FOR_CUDA ${cu_srcs})
endif()
add_library(${lib_name}
${VTKm_LIB_type}
${VTKm_LIB_SOURCES}
${VTKm_LIB_HEADERS}
${VTKm_LIB_TEMPLATE_SOURCES}
${VTKm_LIB_WRAP_FOR_CUDA}
)
#when building either static or shared we want pic code
set_target_properties(${lib_name} PROPERTIES POSITION_INDEPENDENT_CODE ON)
#specify when building with cuda we want separable compilation
set_property(TARGET ${lib_name} PROPERTY CUDA_SEPARABLE_COMPILATION ON)
#specify where to place the built library
set_property(TARGET ${lib_name} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH})
set_property(TARGET ${lib_name} PROPERTY LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH})
......@@ -446,11 +474,20 @@ function(vtkm_unit_tests)
endif()
add_executable(${test_prog} ${test_prog}.cxx ${VTKm_UT_SOURCES})
set_property(TARGET ${test_prog} PROPERTY CUDA_SEPARABLE_COMPILATION ON)
set_property(TARGET ${test_prog} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH})
set_property(TARGET ${test_prog} PROPERTY LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH})
set_property(TARGET ${test_prog} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH})
target_link_libraries(${test_prog} PRIVATE vtkm_cont ${VTKm_UT_LIBRARIES})
#Starting in CMake 3.13, cmake will properly drop duplicate libraries
#from the link line so this workaround can be dropped
if (CMAKE_VERSION VERSION_LESS 3.13 AND "vtkm_rendering" IN_LIST VTKm_UT_LIBRARIES)
list(REMOVE_ITEM VTKm_UT_LIBRARIES "vtkm_cont")
target_link_libraries(${test_prog} PRIVATE ${VTKm_UT_LIBRARIES})
else()
target_link_libraries(${test_prog} PRIVATE vtkm_cont ${VTKm_UT_LIBRARIES})
endif()
foreach(current_backend ${all_backends})
set (device_command_line_argument --device=${current_backend})
......
......@@ -37,6 +37,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
"CONTRIBUTING.md.*warning"
"CodingConventions.md.*warning"
# disable PTX warning about recursive functions. These look like they can't be silenced
# without disabling all PTX warnings, show hide them on the dashboard.
# We explicitly only suppress specific worklets so we can see when new recursive
......@@ -45,4 +46,13 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
"ptxas warning : Stack size for entry function.*BoundingIntervalHierarchy.*"
"ptxas warning : Stack size for entry function.*CoordinatesPortal.*"
"ptxas warning : Stack size for entry function.*CellRangesExtracter.*"
# disable nvlink warnings about virtual functions. The Stack size warnings can only
# be silenced in CUDA >=9, without disabling all nvlink warnings.
"nvlink warning : Stack size for entry function.*NearestNeighborSearch.*"
"nvlink warning : Stack size for entry function.*ArrayPortalRef.*"
"nvlink warning : Stack size for entry function.*ArrayPortalWrapper.*"
"nvlink warning : .*ArrayPortalWrapper.* has address taken but no possible call to it"
"nvlink warning : .*ArrayPortalVirtual.* has address taken but no possible call to it"
)
......@@ -23,9 +23,9 @@
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/ImplicitFunctionHandle.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/VariantArrayHandle.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
......@@ -309,7 +309,6 @@ struct ValueTypes : vtkm::ListTagBase<vtkm::Float32, vtkm::Float64>
struct InterpValueTypes : vtkm::ListTagBase<vtkm::Float32, vtkm::Vec<vtkm::Float32, 3>>
{
};
using StorageListTag = ::vtkm::cont::StorageListTagBasic;
/// This class runs a series of micro-benchmarks to measure
/// performance of different field operations
......@@ -318,14 +317,11 @@ class BenchmarkFieldAlgorithms
{
using StorageTag = vtkm::cont::StorageTagBasic;
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>;
using Timer = vtkm::cont::Timer<DeviceAdapterTag>;
using ValueDynamicHandle = vtkm::cont::DynamicArrayHandleBase<ValueTypes, StorageListTag>;
using InterpDynamicHandle = vtkm::cont::DynamicArrayHandleBase<InterpValueTypes, StorageListTag>;
using IdDynamicHandle =
vtkm::cont::DynamicArrayHandleBase<vtkm::TypeListTagIndex, StorageListTag>;
using ValueVariantHandle = vtkm::cont::VariantArrayHandleBase<ValueTypes>;
using InterpVariantHandle = vtkm::cont::VariantArrayHandleBase<InterpValueTypes>;
using IdVariantHandle = vtkm::cont::VariantArrayHandleBase<vtkm::TypeListTagIndex>;
private:
template <typename Value>
......@@ -402,9 +398,9 @@ private:
VTKM_CONT
vtkm::Float64 operator()()
{
ValueDynamicHandle dstocks(this->StockPrice);
ValueDynamicHandle dstrikes(this->OptionStrike);
ValueDynamicHandle doptions(this->OptionYears);
ValueVariantHandle dstocks(this->StockPrice);
ValueVariantHandle dstrikes(this->OptionStrike);
ValueVariantHandle doptions(this->OptionYears);
vtkm::cont::ArrayHandle<Value> callResultHandle, putResultHandle;
const Value RISKFREE = 0.02f;
......@@ -488,9 +484,9 @@ private:
vtkm::cont::ArrayHandle<Value> temp1;
vtkm::cont::ArrayHandle<Value> temp2;
vtkm::cont::DynamicArrayHandleBase<MathTypes, StorageListTag> dinput(this->InputHandle);
ValueDynamicHandle dtemp1(temp1);
ValueDynamicHandle dtemp2(temp2);
vtkm::cont::VariantArrayHandleBase<MathTypes> dinput(this->InputHandle);
ValueVariantHandle dtemp1(temp1);
ValueVariantHandle dtemp2(temp2);
Timer timer;
......@@ -564,7 +560,7 @@ private:
{
using MathTypes = vtkm::ListTagBase<vtkm::Vec<vtkm::Float32, 3>, vtkm::Vec<vtkm::Float64, 3>>;
vtkm::cont::DynamicArrayHandleBase<MathTypes, StorageListTag> dinput(this->InputHandle);
vtkm::cont::VariantArrayHandleBase<MathTypes> dinput(this->InputHandle);
vtkm::cont::ArrayHandle<Value, StorageTag> result;
......@@ -666,9 +662,9 @@ private:
VTKM_CONT
vtkm::Float64 operator()()
{
InterpDynamicHandle dfield(this->FieldHandle);
InterpDynamicHandle dweight(this->WeightHandle);
IdDynamicHandle dedges(this->EdgePairHandle);
InterpVariantHandle dfield(this->FieldHandle);
InterpVariantHandle dweight(this->WeightHandle);
IdVariantHandle dedges(this->EdgePairHandle);
vtkm::cont::ArrayHandle<Value> result;
Timer timer;
......
......@@ -147,8 +147,6 @@ using FieldTypes = vtkm::ListTagBase<vtkm::Float32,
vtkm::Vec<vtkm::Float32, 3>,
vtkm::Vec<vtkm::Float64, 3>>;
using FieldStorage = vtkm::ListTagBase<vtkm::cont::StorageTagBasic>;
using StructuredCellList = vtkm::ListTagBase<vtkm::cont::CellSetStructured<3>>;
using UnstructuredCellList =
......@@ -158,26 +156,16 @@ using AllCellList = vtkm::ListTagJoin<StructuredCellList, UnstructuredCellList>;
using CoordinateList = vtkm::ListTagBase<vtkm::Vec<vtkm::Float32, 3>, vtkm::Vec<vtkm::Float64, 3>>;
using CoordinateStorage =
vtkm::ListTagBase<vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag,
vtkm::cont::StorageTagBasic>;
using DeviceAdapters = vtkm::ListTagBase<Device>;
class BenchmarkFilterPolicy : public vtkm::filter::PolicyBase<BenchmarkFilterPolicy>
{
public:
using FieldTypeList = FieldTypes;
using FieldStorageList = FieldStorage;
using StructuredCellSetList = StructuredCellList;
using UnstructuredCellSetList = UnstructuredCellList;
using AllCellSetList = AllCellList;
using CoordinateTypeList = CoordinateList;
using CoordinateStorageList = CoordinateStorage;
using DeviceAdapterList = DeviceAdapters;
};
// Class implementing all filter benchmarks:
......@@ -852,7 +840,7 @@ public:
}
};
// Get the number of components in a DynamicArrayHandle, ArrayHandle, or Field's
// Get the number of components in a VariantArrayHandle, ArrayHandle, or Field's
// ValueType.
struct NumberOfComponents
{
......
......@@ -136,7 +136,6 @@ struct ValueTypes
: vtkm::ListTagBase<vtkm::UInt32, vtkm::Int32, vtkm::Int64, vtkm::Float32, vtkm::Float64>
{
};
using StorageListTag = ::vtkm::cont::StorageListTagBasic;
/// This class runs a series of micro-benchmarks to measure
/// performance of different field operations
......@@ -145,11 +144,9 @@ class BenchmarkTopologyAlgorithms
{
using StorageTag = vtkm::cont::StorageTagBasic;
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>;
using Timer = vtkm::cont::Timer<DeviceAdapterTag>;
using ValueDynamicHandle = vtkm::cont::DynamicArrayHandleBase<ValueTypes, StorageListTag>;
using ValueVariantHandle = vtkm::cont::VariantArrayHandleBase<ValueTypes>;
private:
template <typename T, typename Enable = void>
......@@ -245,7 +242,7 @@ private:
vtkm::cont::CellSetStructured<3> cellSet;
cellSet.SetPointDimensions(vtkm::Id3(CUBE_SIZE, CUBE_SIZE, CUBE_SIZE));
ValueDynamicHandle dinput(this->InputHandle);
ValueVariantHandle dinput(this->InputHandle);
vtkm::cont::ArrayHandle<Value, StorageTag> result;
Timer timer;
......@@ -324,7 +321,7 @@ private:
vtkm::cont::CellSetStructured<3> cellSet;
cellSet.SetPointDimensions(vtkm::Id3(CUBE_SIZE, CUBE_SIZE, CUBE_SIZE));
ValueDynamicHandle dinput(this->InputHandle);
ValueVariantHandle dinput(this->InputHandle);
vtkm::cont::ArrayHandle<Value, StorageTag> result;
Timer timer;
......@@ -372,7 +369,7 @@ private:
cellSet.SetPointDimensions(vtkm::Id3(CUBE_SIZE, CUBE_SIZE, CUBE_SIZE));
vtkm::cont::ArrayHandle<vtkm::IdComponent, StorageTag> result;
ValueDynamicHandle dinput(this->InputHandle);
ValueVariantHandle dinput(this->InputHandle);
Timer timer;
......
......@@ -17,7 +17,7 @@
## Laboratory (LANL), the U.S. Government retains certain rights in
## this software.
##============================================================================
function(add_benchmark name files)
function(add_benchmark name files lib)
set(benchmarks )
add_executable(${name}_SERIAL ${files})
......@@ -49,7 +49,7 @@ function(add_benchmark name files)
endif()
foreach(benchmark ${benchmarks})
target_link_libraries(${benchmark} PRIVATE vtkm_cont)
target_link_libraries(${benchmark} PRIVATE ${lib})
set_target_properties(${benchmark} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH}
)
......@@ -69,19 +69,9 @@ set(benchmarks
)
foreach (benchmark ${benchmarks})
add_benchmark(${benchmark} ${benchmark}.cxx)
add_benchmark(${benchmark} ${benchmark}.cxx vtkm_cont)
endforeach ()
if(TARGET vtkm_rendering)
add_benchmark(BenchmarkRayTracing BenchmarkRayTracing.cxx)
target_link_libraries(BenchmarkRayTracing_SERIAL PRIVATE vtkm_rendering)
if(TARGET BenchmarkRayTracing_TBB)
target_link_libraries(BenchmarkRayTracing_TBB PRIVATE vtkm_rendering)
endif()
if(TARGET BenchmarkRayTracing_OPENMP)
target_link_libraries(BenchmarkRayTracing_OPENMP PRIVATE vtkm_rendering)
endif()
if(TARGET BenchmarkRayTracing_CUDA)
target_link_libraries(BenchmarkRayTracing_CUDA PRIVATE vtkm_rendering)
endif()
add_benchmark(BenchmarkRayTracing BenchmarkRayTracing.cxx vtkm_rendering)
endif()
# Add vtkm::cont::ArrayHandleVirtual
Added a new class named `ArrayHandleVirtual` that allows you to type erase an
ArrayHandle storage type by using virtual calls. This simplification makes
storing `Fields` and `Coordinates` significantly easier as VTK-m doesn't
need to deduce both the storage and value type when executing worklets.
To construct an `ArrayHandleVirtual` one can do one of the following:
```cpp
vtkm::cont::ArrayHandle<vtkm::Float32> pressure;
vtkm::cont::ArrayHandleConstant<vtkm::Float32> constant(42.0f);
// constrcut from an array handle
vtkm::cont::ArrayHandleVirtual<vtkm::Float32> v(pressure);
// or assign from an array handle
v = constant;
```
To help maintain performance `ArrayHandleVirtual` provides a collection of helper
functions/methods to query and cast back to the concrete storage and value type:
```cpp
vtkm::cont::ArrayHandleConstant<vtkm::Float32> constant(42.0f);
vtkm::cont::ArrayHandleVirtual<vtkm::Float32> v = constant;
bool isConstant = vtkm::cont::IsType< decltype(constant) >(v);
if(isConstant)
vtkm::cont::ArrayHandleConstant<vtkm::Float32> t = vtkm::cont::Cast< decltype(constant) >(v);
```
Lastly, a common operation of calling code using `ArrayHandleVirtual` is a desire to construct a new instance
of an existing virtual handle with the same storage type. This can be done by using the `NewInstance` method
as seen below
```cpp
vtkm::cont::ArrayHandle<vtkm::Float32> pressure;
vtkm::cont::ArrayHandleVirtual<vtkm::Float32> v = pressure;
vtkm::cont::ArrayHandleVirtual<vtkm::Float32> newArray = v->NewInstance();
bool isConstant = vtkm::cont::IsType< vtkm::cont::ArrayHandle<vtkm::Float32> >(newArray); //will be true
```
# vtkm::cont::ArrayHandleZip provides a consistent API even with non-writable handles
Previously ArrayHandleZip could not wrap an implicit handle and provide a consistent experience.
The primary issue was that if you tried to use the PortalType returned by GetPortalControl() you
would get a compile failure. This would occur as the PortalType returned would try to call `Set`
on an ImplicitPortal which doesn't have a set method.
Now with this change, the `ZipPortal` use SFINAE to determine if `Set` and `Get` should call the
underlying zipped portals.
# VTK-m now requires CUDA separable compilation to build
With the introduction of `vtkm::cont::ArrayHandleVirtual` and the related infrastructure, vtk-m now
requires that all CUDA code be compiled using separable compilation ( -rdc ).
# vtkm::cont::VariantArrayHandle replaces vtkm::cont::DynamicArrayHandle
`ArrayHandleVariant` replaces `DynamicArrayHandle` as the primary method
for holding onto a type erased `vtkm::cont::ArrayHandle`. The major difference
between the two implementations is how they handle the Storage component of
an array handle.
`DynamicArrayHandle` approach was to find the fully deduced type of the `ArrayHandle`
meaning it would check all value and storage types it knew about until it found a match.
This cross product of values and storages would cause significant compilation times when
a `DynamicArrayHandle` had multiple storage types.
`VariantArrayHandle` approach is to only deduce the value type of the `ArrayHandle` and
return a `vtkm::cont::ArrayHandleVirtual` which uses polymorpishm to hide the actual
storage type. This approach allows for better compile times, and for calling code
to always expect an `ArrayHandleVirtual` instead of the fully deduced type. This conversion
to `ArrayHandleVirtual` is usually done internally within VTK-m when a worklet or filter
is invoked.
In certain cases users of `VariantArrayHandle` want to be able to access the concrete
`ArrayHandle<T,S>` and not have it wrapped in a `ArrayHandleVirtual`. For those occurrences
`VariantArrayHandle` provides a collection of helper functions/methods to query and
cast back to the concrete storage and value type:
```cpp
vtkm::cont::ArrayHandleConstant<vtkm::Float32> constant(42.0f);
vtkm::cont::ArrayHandleVariant v(constant);
bool isConstant = vtkm::cont::IsType< decltype(constant) >(v);
if(isConstant)
vtkm::cont::ArrayHandleConstant<vtkm::Float32> t = vtkm::cont::Cast< decltype(constant) >(v);
```
Lastly, a common operation of calling code using `VariantArrayHandle` is a desire to construct a new instance
of an existing virtual handle with the same storage type. This can be done by using the `NewInstance` method
as seen below
```cpp
vtkm::cont::ArrayHandle<vtkm::Float32> pressure;
vtkm::cont::ArrayHandleVariant v(pressure);
vtkm::cont::ArrayHandleVariant newArray = v->NewInstance();
bool isConstant = vtkm::cont::IsType< decltype(pressure) >(newArray); //will be true
```
......@@ -38,11 +38,11 @@ namespace
struct FieldMapper
{
vtkm::cont::DynamicArrayHandle& Output;
vtkm::cont::VariantArrayHandle& Output;
vtkm::worklet::Clip& Worklet;
bool IsCellField;
FieldMapper(vtkm::cont::DynamicArrayHandle& output,
FieldMapper(vtkm::cont::VariantArrayHandle& output,
vtkm::worklet::Clip& worklet,
bool isCellField)
: Output(output)
......@@ -90,7 +90,7 @@ int main(int argc, char* argv[])
bool invertClip = false;
vtkm::cont::CellSetExplicit<> outputCellSet =
clip.Run(input.GetCellSet(0),
scalarField.GetData().ResetTypeList(vtkm::TypeListTagScalarAll()),
scalarField.GetData().ResetTypes(vtkm::TypeListTagScalarAll()),
clipValue,
invertClip);
vtkm::Float64 clipTime = timer.GetElapsedTime();
......@@ -124,7 +124,7 @@ int main(int argc, char* argv[])
continue;
}
vtkm::cont::DynamicArrayHandle outField;
vtkm::cont::VariantArrayHandle outField;
FieldMapper fieldMapper(outField, clip, isCellField);
inField.GetData().CastAndCall(fieldMapper);
output.AddField(vtkm::cont::Field(inField.GetName(), inField.GetAssociation(), outField));
......
......@@ -64,12 +64,11 @@ public:
VTKM_CONT
vtkm::Range GetComputedRange() const { return this->ComputedRange; }
template <typename T, typename StorageType, typename DerivedPolicy, typename DeviceAdapter>
template <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
const DeviceAdapter& tag);
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
//@{
/// when operating on vtkm::cont::MultiBlock, we
......
......@@ -123,13 +123,12 @@ inline VTKM_CONT HistogramMPI::HistogramMPI()
}
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy, typename DeviceAdapter>
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet HistogramMPI::DoExecute(
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&,
const DeviceAdapter& device)
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
vtkm::cont::ArrayHandle<vtkm::Id> binArray;
T delta;
......@@ -142,12 +141,11 @@ inline VTKM_CONT vtkm::cont::DataSet HistogramMPI::DoExecute(
static_cast<T>(this->ComputedRange.Min),
static_cast<T>(this->ComputedRange.Max),
delta,
binArray,
device);
binArray);
}
else
{
worklet.Run(field, this->NumberOfBins, this->ComputedRange, delta, binArray, device);
worklet.Run(field, this->NumberOfBins, this->ComputedRange, delta, binArray);
}
this->BinDelta = static_cast<vtkm::Float64>(delta);
......
......@@ -47,7 +47,6 @@
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
static bool printProgress = true;
......
......@@ -58,6 +58,7 @@ set(headers
VecAxisAlignedPointCoordinates.h
VecFromPortal.h
VecFromPortalPermute.h
VecFromVirtPortal.h
VectorAnalysis.h
VecTraits.h
VecVariable.h
......
......@@ -75,10 +75,55 @@ public:
}
private:
const IndexVecType* Indices;
const IndexVecType* const Indices;
PortalType Portal;
};