Go to the documentation of this file.
10 #ifndef vtk_m_worklet_KernelSplatter_h
11 #define vtk_m_worklet_KernelSplatter_h
28 #include <vtkm/worklet/splatkernels/Gaussian.h>
29 #include <vtkm/worklet/splatkernels/KernelBase.h>
30 #include <vtkm/worklet/splatkernels/Spline3rdOrder.h>
37 #if defined(__VTKM_GAUSSIAN_SPLATTER_BENCHMARK) && !defined(START_TIMER_BLOCK)
39 #define START_TIMER_BLOCK(name) \
40 vtkm::cont::Timer timer_##name{ DeviceAdapter() }; \
44 #define END_TIMER_BLOCK(name) \
45 std::cout << #name " : elapsed : " << timer_##name.GetElapsedTime() << "\n";
47 #if !defined(START_TIMER_BLOCK)
48 #define START_TIMER_BLOCK(name)
49 #define END_TIMER_BLOCK(name)
64 template <
typename T,
typename S = VTKM_DEFAULT_STORAGE_TAG>
68 using StorageType = vtkm::cont::internal::Storage<T, S>;
69 using PortalConstType =
typename StorageType::PortalConstType;
70 PortalConstType readPortal = outputArray.
ReadPortal();
72 std::vector<ValueType> result(readPortal.GetNumberOfValues());
73 std::copy(iterators.GetBegin(), iterators.GetEnd(), result.begin());
75 std::copy(result.begin(), result.end(), std::ostream_iterator<ValueType>(std::cout,
" "));
76 std::cout << std::endl;
80 template <
typename T,
int S>
82 const std::string& name)
86 PortalConstType readPortal = outputArray.
ReadPortal();
92 std::cout << portal.Get(i);
94 std::cout << std::endl;
97 template <
typename I,
typename T,
int S>
101 const std::string& name)
103 using PortalConstType =
typename vtkm::cont::
104 ArrayHandlePermutation<I, vtkm::cont::ArrayHandle<vtkm::Vec<T, S>>>::ReadPortalType;
105 PortalConstType readPortal = outputArray.
ReadPortal();
111 std::cout << outputPortal.Get(i);
113 std::cout << std::endl;
117 template <
typename T,
typename S>
123 template <
typename T,
int S>
129 template <
typename I,
typename T,
int S>
139 template <
typename Kernel,
typename DeviceAdapter>
170 template <
typename T>
173 T& voxel_value)
const
202 const Kernel& kernel)
210 template <
typename T,
typename T2>
223 double cutoff =
kernel_.maxDistance(h);
224 for (
int i = 0; i < 3; i++)
226 splat[i] = (sample[i] - this->origin_[i]) / this->spacing_[i];
227 min[i] =
static_cast<vtkm::Id>(ceil(
static_cast<double>(splat[i]) - cutoff));
228 max[i] =
static_cast<vtkm::Id>(floor(
static_cast<double>(splat[i]) + cutoff));
233 if (max[i] >= this->VolumeDimensions[i])
235 max[i] = this->VolumeDimensions[i] - 1;
237 size =
static_cast<vtkm::Id>(size * (1 + max[i] - min[i]));
242 footprintSize = size;
260 template <
typename T>
266 localId = (index - offset) % modulus;
302 template <
typename T,
typename T2,
typename P>
312 vtkm::Id yRange = 1 + maxBound[1] - minBound[1];
313 vtkm::Id xRange = 1 + maxBound[0] - minBound[0];
315 vtkm::Id i = localNeighborId / divisor;
316 vtkm::Id remainder = localNeighborId % divisor;
322 (splatPoint[1] - voxel[1]) *
spacing_[0],
323 (splatPoint[2] - voxel[2]) *
spacing_[0]);
327 splatValue = scale *
kernel.w2(kernel_H, dist2);
331 if (neighborVoxelId < 0)
332 neighborVoxelId = -1;
351 template <
typename ExecArgPortalType>
354 ExecArgPortalType& execArg)
const
356 execArg.Set(voxelIndex,
static_cast<vtkm::Float32>(splatValue));
370 const Kernel& kernel)
392 template <
typename StorageT>
416 footprintDispatcher.SetDevice(DeviceAdapter());
419 footprintDispatcher.Invoke(
420 xValues, yValues, zValues, rValues, splatPoints, footprintMin, footprintMax, numNeighbors);
439 numNeighborsPrefixSum);
442 std::cout <<
"totalSplatSize " << totalSplatSize <<
"\n";
449 numNeighborsExclusiveSum);
463 numNeighborsPrefixSum, countingArray, neighbor2SplatId);
473 IdPermType modulii(neighbor2SplatId, numNeighbors);
476 IdPermType offsets(neighbor2SplatId, numNeighborsExclusiveSum);
480 idDispatcher.SetDevice(DeviceAdapter());
482 idDispatcher.Invoke(modulii, offsets, localNeighborIds);
495 VecPermType ptFootprintMins(neighbor2SplatId, footprintMin);
496 VecPermType ptFootprintMaxs(neighbor2SplatId, footprintMax);
514 splatterDispatcher.SetDevice(DeviceAdapter());
517 splatterDispatcher.Invoke(ptSplatPoints,
553 neighborVoxelIds, splatValues, uniqueVoxelIds, voxelSplatSums,
vtkm::Add());
568 zeroDispatcher.SetDevice(DeviceAdapter());
569 zeroDispatcher.Invoke(indexArray, scalarSplatOutput);
578 scatterDispatcher.SetDevice(DeviceAdapter());
581 scatterDispatcher.Invoke(uniqueVoxelIds, voxelSplatSums, scalarSplatOutput);
593 #endif //vtk_m_worklet_KernelSplatter_h
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Compute an exclusive prefix sum operation on the input ArrayHandle.
Manages an array-worth of data.
Definition: ArrayHandle.h:300
Groups connected points that have the same field value.
Definition: Atomic.h:19
static void UpperBounds(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output)
Output is the last index in input for each item in values that wouldn't alter the ordering of input.
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
A control signature tag for output fields.
Definition: WorkletMapField.h:80
constexpr vtkm::Vec< T, vtkm::IdComponent(sizeof...(Ts)+1)> make_Vec(T value0, Ts &&... args)
Initializes and returns a Vec containing all the arguments.
Definition: Types.h:1250
Contains and manages the geometric data structures that VTK-m operates on.
Definition: DataSet.h:57
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
vtkm::Vec< vtkm::Float32, 3 > Vec3f_32
Vec3f_32 corresponds to a 3-dimensional vector of 32-bit floating point values.
Definition: Types.h:1058
#define END_TIMER_BLOCK(name)
Definition: KernelSplatter.h:49
vtkm::Vec< vtkm::Float64, 3 > Vec3f_64
Vec3f_64 corresponds to a 3-dimensional vector of 64-bit floating point values.
Definition: Types.h:1064
Definition: ArrayPortalToIterators.h:27
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
#define START_TIMER_BLOCK(name)
Definition: KernelSplatter.h:48
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Compute an inclusive prefix sum operation on the input ArrayHandle.
A control signature tag for input fields.
Definition: WorkletMapField.h:60
Implicitly permutes the values in an array.
Definition: ArrayHandlePermutation.h:233
ArrayHandleCounting is a specialization of ArrayHandle.
Definition: ArrayHandleCounting.h:130
#define VTKM_CONT
Definition: ExportMacros.h:57
void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:584
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Unstable ascending sort of keys and values.
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
static void ReduceByKey(const vtkm::cont::ArrayHandle< T, CKeyIn > &keys, const vtkm::cont::ArrayHandle< U, CValIn > &values, vtkm::cont::ArrayHandle< T, CKeyOut > &keys_output, vtkm::cont::ArrayHandle< U, CValOut > &values_output, BinaryFunctor binary_functor)
Compute a accumulated sum operation on the input key value pairs.
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:433
A short fixed-length array.
Definition: Types.h:357
void OutputArrayDebug(const vtkm::cont::ArrayHandle< T, S > &, const std::string &)
Definition: KernelSplatter.h:118
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:157
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:161
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:39
The ExecutionSignature tag to use to get the work index.
Definition: WorkIndex.h:39