VTK-m  2.0
DeviceAdapterAlgorithmSerial.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_cont_serial_internal_DeviceAdapterAlgorithmSerial_h
11 #define vtk_m_cont_serial_internal_DeviceAdapterAlgorithmSerial_h
12 
13 #include <vtkm/cont/ArrayHandle.h>
20 
21 #include <vtkm/BinaryOperators.h>
22 
24 
25 #include <algorithm>
26 #include <iterator>
27 #include <numeric>
28 #include <type_traits>
29 
30 namespace vtkm
31 {
32 namespace cont
33 {
34 
35 template <>
36 struct DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>
37  : vtkm::cont::internal::DeviceAdapterAlgorithmGeneral<
38  DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>,
39  vtkm::cont::DeviceAdapterTagSerial>
40 {
41 private:
42  using Device = vtkm::cont::DeviceAdapterTagSerial;
43 
44  // MSVC likes complain about narrowing type conversions in std::copy and
45  // provides no reasonable way to disable the warning. As a work-around, this
46  // template calls std::copy if and only if the types match, otherwise falls
47  // back to a iterative casting approach. Since std::copy can only really
48  // optimize same-type copies, this shouldn't affect performance.
49  template <typename InPortal, typename OutPortal>
50  static void DoCopy(InPortal src,
51  OutPortal dst,
52  std::false_type,
53  vtkm::Id startIndex,
54  vtkm::Id numToCopy,
55  vtkm::Id outIndex)
56  {
57  using OutputType = typename OutPortal::ValueType;
58  for (vtkm::Id index = 0; index < numToCopy; ++index)
59  {
60  dst.Set(index + startIndex, static_cast<OutputType>(src.Get(index + outIndex)));
61  }
62  }
63 
64  template <typename InPortal, typename OutPortal>
65  static void DoCopy(InPortal src,
66  OutPortal dst,
67  std::true_type,
68  vtkm::Id startIndex,
69  vtkm::Id numToCopy,
70  vtkm::Id outIndex)
71  {
72  std::copy(vtkm::cont::ArrayPortalToIteratorBegin(src) + startIndex,
73  vtkm::cont::ArrayPortalToIteratorBegin(src) + startIndex + numToCopy,
75  }
76 
77 public:
78  template <typename T, typename U, class CIn, class COut>
81  {
83 
84  vtkm::cont::Token token;
85 
86  const vtkm::Id inSize = input.GetNumberOfValues();
87  auto inputPortal = input.PrepareForInput(DeviceAdapterTagSerial(), token);
88  auto outputPortal = output.PrepareForOutput(inSize, DeviceAdapterTagSerial(), token);
89 
90  if (inSize <= 0)
91  {
92  return;
93  }
94 
95  using InputType = decltype(inputPortal.Get(0));
96  using OutputType = decltype(outputPortal.Get(0));
97 
98  DoCopy(inputPortal, outputPortal, std::is_same<InputType, OutputType>{}, 0, inSize, 0);
99  }
100 
101  template <typename T, typename U, class CIn, class CStencil, class COut>
105  {
107 
108  ::vtkm::NotZeroInitialized unary_predicate;
109  CopyIf(input, stencil, output, unary_predicate);
110  }
111 
112  template <typename T, typename U, class CIn, class CStencil, class COut, class UnaryPredicate>
116  UnaryPredicate predicate)
117  {
119 
120  vtkm::Id writePos = 0;
121 
122  {
123  vtkm::cont::Token token;
124 
125  vtkm::Id inputSize = input.GetNumberOfValues();
126  VTKM_ASSERT(inputSize == stencil.GetNumberOfValues());
127 
128  auto inputPortal = input.PrepareForInput(DeviceAdapterTagSerial(), token);
129  auto stencilPortal = stencil.PrepareForInput(DeviceAdapterTagSerial(), token);
130  auto outputPortal = output.PrepareForOutput(inputSize, DeviceAdapterTagSerial(), token);
131 
132  for (vtkm::Id readPos = 0; readPos < inputSize; ++readPos)
133  {
134  if (predicate(stencilPortal.Get(readPos)))
135  {
136  outputPortal.Set(writePos, inputPortal.Get(readPos));
137  ++writePos;
138  }
139  }
140  }
141 
142  output.Allocate(writePos, vtkm::CopyFlag::On);
143  }
144 
145  template <typename T, typename U, class CIn, class COut>
147  vtkm::Id inputStartIndex,
148  vtkm::Id numberOfElementsToCopy,
150  vtkm::Id outputIndex = 0)
151  {
153 
154  const vtkm::Id inSize = input.GetNumberOfValues();
155 
156  // Check if the ranges overlap and fail if they do.
157  if (input == output &&
158  ((outputIndex >= inputStartIndex &&
159  outputIndex < inputStartIndex + numberOfElementsToCopy) ||
160  (inputStartIndex >= outputIndex &&
161  inputStartIndex < outputIndex + numberOfElementsToCopy)))
162  {
163  return false;
164  }
165 
166  if (inputStartIndex < 0 || numberOfElementsToCopy < 0 || outputIndex < 0 ||
167  inputStartIndex >= inSize)
168  { //invalid parameters
169  return false;
170  }
171 
172  //determine if the numberOfElementsToCopy needs to be reduced
173  if (inSize < (inputStartIndex + numberOfElementsToCopy))
174  { //adjust the size
175  numberOfElementsToCopy = (inSize - inputStartIndex);
176  }
177 
178  const vtkm::Id outSize = output.GetNumberOfValues();
179  const vtkm::Id copyOutEnd = outputIndex + numberOfElementsToCopy;
180  if (outSize < copyOutEnd)
181  { //output is not large enough
182  if (outSize == 0)
183  { //since output has nothing, just need to allocate to correct length
184  output.Allocate(copyOutEnd);
185  }
186  else
187  { //we currently have data in this array, so preserve it in the new
188  //resized array
190  temp.Allocate(copyOutEnd);
191  CopySubRange(output, 0, outSize, temp);
192  output = temp;
193  }
194  }
195 
196  vtkm::cont::Token token;
197  auto inputPortal = input.PrepareForInput(DeviceAdapterTagSerial(), token);
198  auto outputPortal = output.PrepareForInPlace(DeviceAdapterTagSerial(), token);
199 
200  using InputType = decltype(inputPortal.Get(0));
201  using OutputType = decltype(outputPortal.Get(0));
202 
203  DoCopy(inputPortal,
204  outputPortal,
205  std::is_same<InputType, OutputType>(),
206  inputStartIndex,
207  numberOfElementsToCopy,
208  outputIndex);
209 
210  return true;
211  }
212 
213  template <typename T, typename U, class CIn>
214  VTKM_CONT static U Reduce(const vtkm::cont::ArrayHandle<T, CIn>& input, U initialValue)
215  {
217 
218  return Reduce(input, initialValue, vtkm::Add());
219  }
220 
221  template <typename T, typename U, class CIn, class BinaryFunctor>
223  U initialValue,
224  BinaryFunctor binary_functor)
225  {
227 
228  vtkm::cont::Token token;
229 
230  internal::WrappedBinaryOperator<U, BinaryFunctor> wrappedOp(binary_functor);
231  auto inputPortal = input.PrepareForInput(Device(), token);
232  return std::accumulate(vtkm::cont::ArrayPortalToIteratorBegin(inputPortal),
234  initialValue,
235  wrappedOp);
236  }
237 
238  template <typename T,
239  typename U,
240  class KIn,
241  class VIn,
242  class KOut,
243  class VOut,
244  class BinaryFunctor>
246  const vtkm::cont::ArrayHandle<U, VIn>& values,
248  vtkm::cont::ArrayHandle<U, VOut>& values_output,
249  BinaryFunctor binary_functor)
250  {
252 
253  vtkm::Id writePos = 0;
254  vtkm::Id readPos = 0;
255 
256  {
257  vtkm::cont::Token token;
258 
259  auto keysPortalIn = keys.PrepareForInput(Device(), token);
260  auto valuesPortalIn = values.PrepareForInput(Device(), token);
261  const vtkm::Id numberOfKeys = keys.GetNumberOfValues();
262 
263  VTKM_ASSERT(numberOfKeys == values.GetNumberOfValues());
264  if (numberOfKeys == 0)
265  {
266  keys_output.ReleaseResources();
267  values_output.ReleaseResources();
268  return;
269  }
270 
271  auto keysPortalOut = keys_output.PrepareForOutput(numberOfKeys, Device(), token);
272  auto valuesPortalOut = values_output.PrepareForOutput(numberOfKeys, Device(), token);
273 
274  T currentKey = keysPortalIn.Get(readPos);
275  U currentValue = valuesPortalIn.Get(readPos);
276 
277  for (++readPos; readPos < numberOfKeys; ++readPos)
278  {
279  while (readPos < numberOfKeys && currentKey == keysPortalIn.Get(readPos))
280  {
281  currentValue = binary_functor(currentValue, valuesPortalIn.Get(readPos));
282  ++readPos;
283  }
284 
285  if (readPos < numberOfKeys)
286  {
287  keysPortalOut.Set(writePos, currentKey);
288  valuesPortalOut.Set(writePos, currentValue);
289  ++writePos;
290 
291  currentKey = keysPortalIn.Get(readPos);
292  currentValue = valuesPortalIn.Get(readPos);
293  }
294  }
295 
296  //now write out the last set of values
297  keysPortalOut.Set(writePos, currentKey);
298  valuesPortalOut.Set(writePos, currentValue);
299  }
300 
301  //now we need to shrink to the correct number of keys/values
302  //writePos is zero-based so add 1 to get correct length
303  keys_output.Allocate(writePos + 1, vtkm::CopyFlag::On);
304  values_output.Allocate(writePos + 1, vtkm::CopyFlag::On);
305  }
306 
307  template <typename T, class CIn, class COut, class BinaryFunctor>
310  BinaryFunctor binary_functor)
311  {
313 
314  internal::WrappedBinaryOperator<T, BinaryFunctor> wrappedBinaryOp(binary_functor);
315 
316  vtkm::Id numberOfValues = input.GetNumberOfValues();
317 
318  vtkm::cont::Token token;
319 
320  auto inputPortal = input.PrepareForInput(Device(), token);
321  auto outputPortal = output.PrepareForOutput(numberOfValues, Device(), token);
322 
323  if (numberOfValues <= 0)
324  {
326  }
327 
328  std::partial_sum(vtkm::cont::ArrayPortalToIteratorBegin(inputPortal),
331  wrappedBinaryOp);
332 
333  // Return the value at the last index in the array, which is the full sum.
334  return outputPortal.Get(numberOfValues - 1);
335  }
336 
337  template <typename T, class CIn, class COut>
340  {
342 
343  return ScanInclusive(input, output, vtkm::Sum());
344  }
345 
346  template <typename T, class CIn, class COut, class BinaryFunctor>
349  BinaryFunctor binaryFunctor,
350  const T& initialValue)
351  {
353 
354  internal::WrappedBinaryOperator<T, BinaryFunctor> wrappedBinaryOp(binaryFunctor);
355 
356  vtkm::Id numberOfValues = input.GetNumberOfValues();
357 
358  vtkm::cont::Token token;
359  auto inputPortal = input.PrepareForInput(Device(), token);
360  auto outputPortal = output.PrepareForOutput(numberOfValues, Device(), token);
361 
362  if (numberOfValues <= 0)
363  {
364  return initialValue;
365  }
366 
367  // Shift right by one, by iterating backwards. We are required to iterate
368  //backwards so that the algorithm works correctly when the input and output
369  //are the same array, otherwise you just propagate the first element
370  //to all elements
371  //Note: We explicitly do not use std::copy_backwards for good reason.
372  //The ICC compiler has been found to improperly optimize the copy_backwards
373  //into a standard copy, causing the above issue.
374  T lastValue = inputPortal.Get(numberOfValues - 1);
375  for (vtkm::Id i = (numberOfValues - 1); i >= 1; --i)
376  {
377  outputPortal.Set(i, inputPortal.Get(i - 1));
378  }
379  outputPortal.Set(0, initialValue);
380 
381  std::partial_sum(vtkm::cont::ArrayPortalToIteratorBegin(outputPortal),
384  wrappedBinaryOp);
385 
386  return wrappedBinaryOp(outputPortal.Get(numberOfValues - 1), lastValue);
387  }
388 
389  template <typename T, class CIn, class COut>
392  {
394 
396  }
397 
398  VTKM_CONT_EXPORT static void ScheduleTask(vtkm::exec::serial::internal::TaskTiling1D& functor,
399  vtkm::Id size);
400  VTKM_CONT_EXPORT static void ScheduleTask(vtkm::exec::serial::internal::TaskTiling3D& functor,
401  vtkm::Id3 size);
402 
403  template <class FunctorType>
404  VTKM_CONT static inline void Schedule(FunctorType functor, vtkm::Id size)
405  {
407 
408  vtkm::exec::serial::internal::TaskTiling1D kernel(functor);
409  ScheduleTask(kernel, size);
410  }
411 
412  template <class FunctorType>
413  VTKM_CONT static inline void Schedule(FunctorType functor, vtkm::Id3 size)
414  {
416 
417  vtkm::exec::serial::internal::TaskTiling3D kernel(functor);
418  ScheduleTask(kernel, size);
419  }
420 
421 private:
422  template <typename Vin,
423  typename I,
424  typename Vout,
425  class StorageVin,
426  class StorageI,
427  class StorageVout>
431  {
433 
434  const vtkm::Id n = values.GetNumberOfValues();
435  VTKM_ASSERT(n == index.GetNumberOfValues());
436 
437  vtkm::cont::Token token;
438 
439  auto valuesPortal = values.PrepareForInput(Device(), token);
440  auto indexPortal = index.PrepareForInput(Device(), token);
441  auto valuesOutPortal = values_out.PrepareForOutput(n, Device(), token);
442 
443  for (vtkm::Id i = 0; i < n; i++)
444  {
445  valuesOutPortal.Set(i, valuesPortal.Get(indexPortal.Get(i)));
446  }
447  }
448 
449 private:
451  template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
454  BinaryCompare binary_compare)
455  {
457 
458  //combine the keys and values into a ZipArrayHandle
459  //we than need to specify a custom compare function wrapper
460  //that only checks for key side of the pair, using the custom compare
461  //functor that the user passed in
462  auto zipHandle = vtkm::cont::make_ArrayHandleZip(keys, values);
463  Sort(zipHandle, internal::KeyCompare<T, U, BinaryCompare>(binary_compare));
464  }
465 
466 public:
467  template <typename T, typename U, class StorageT, class StorageU>
470  {
472 
473  SortByKey(keys, values, std::less<T>());
474  }
475 
476  template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
479  const BinaryCompare& binary_compare)
480  {
482 
483  internal::WrappedBinaryOperator<bool, BinaryCompare> wrappedCompare(binary_compare);
484  constexpr bool larger_than_64bits = sizeof(U) > sizeof(vtkm::Int64);
485  if (larger_than_64bits)
486  {
490  vtkm::cont::ArrayHandle<U, StorageU> valuesScattered;
491 
492  Copy(ArrayHandleIndex(keys.GetNumberOfValues()), indexArray);
493  SortByKeyDirect(keys, indexArray, wrappedCompare);
494  Scatter(values, indexArray, valuesScattered);
495  Copy(valuesScattered, values);
496  }
497  else
498  {
499  SortByKeyDirect(keys, values, wrappedCompare);
500  }
501  }
502 
503  template <typename T, class Storage>
505  {
507 
508  Sort(values, std::less<T>());
509  }
510 
511  template <typename T, class Storage, class BinaryCompare>
513  BinaryCompare binary_compare)
514  {
516 
517  vtkm::cont::Token token;
518 
519  auto arrayPortal = values.PrepareForInPlace(Device(), token);
520  vtkm::cont::ArrayPortalToIterators<decltype(arrayPortal)> iterators(arrayPortal);
521 
522  internal::WrappedBinaryOperator<bool, BinaryCompare> wrappedCompare(binary_compare);
523  std::sort(iterators.GetBegin(), iterators.GetEnd(), wrappedCompare);
524  }
525 
526  template <typename T, class Storage>
528  {
530 
531  Unique(values, std::equal_to<T>());
532  }
533 
534  template <typename T, class Storage, class BinaryCompare>
536  BinaryCompare binary_compare)
537  {
539 
540  vtkm::cont::Token token;
541  auto arrayPortal = values.PrepareForInPlace(Device(), token);
542  vtkm::cont::ArrayPortalToIterators<decltype(arrayPortal)> iterators(arrayPortal);
543  internal::WrappedBinaryOperator<bool, BinaryCompare> wrappedCompare(binary_compare);
544 
545  auto end = std::unique(iterators.GetBegin(), iterators.GetEnd(), wrappedCompare);
546  vtkm::Id newSize = static_cast<vtkm::Id>(end - iterators.GetBegin());
547  token.DetachFromAll();
548  values.Allocate(newSize, vtkm::CopyFlag::On);
549  }
550 
551  VTKM_CONT static void Synchronize()
552  {
553  // Nothing to do. This device is serial and has no asynchronous operations.
554  }
555 };
556 
557 template <>
558 class DeviceTaskTypes<vtkm::cont::DeviceAdapterTagSerial>
559 {
560 public:
561  template <typename WorkletType, typename InvocationType>
562  static vtkm::exec::serial::internal::TaskTiling1D MakeTask(WorkletType& worklet,
563  InvocationType& invocation,
564  vtkm::Id)
565  {
566  return vtkm::exec::serial::internal::TaskTiling1D(worklet, invocation);
567  }
568 
569  template <typename WorkletType, typename InvocationType>
570  static vtkm::exec::serial::internal::TaskTiling3D MakeTask(WorkletType& worklet,
571  InvocationType& invocation,
572  vtkm::Id3)
573  {
574  return vtkm::exec::serial::internal::TaskTiling3D(worklet, invocation);
575  }
576 };
577 }
578 } // namespace vtkm::cont
579 
580 #endif //vtk_m_cont_serial_internal_DeviceAdapterAlgorithmSerial_h
vtkm::cont::ArrayPortalToIteratorBegin
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::cont::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorBegin(const PortalType &portal)
Convenience function for converting an ArrayPortal to a begin iterator.
Definition: ArrayPortalToIterators.h:178
vtkm::cont::ArrayHandle::GetNumberOfValues
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::CopySubRange
static VTKM_CONT bool CopySubRange(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::Id inputStartIndex, vtkm::Id numberOfElementsToCopy, vtkm::cont::ArrayHandle< U, COut > &output, vtkm::Id outputIndex=0)
Definition: DeviceAdapterAlgorithmSerial.h:146
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
ArrayHandle.h
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::SortByKey
static VTKM_CONT void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, const BinaryCompare &binary_compare)
Definition: DeviceAdapterAlgorithmSerial.h:477
vtkm::cont::DeviceAdapterAlgorithm::Copy
static VTKM_CONT void Copy(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Copy the contents of one ArrayHandle to another.
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::TypeTraits
The TypeTraits class provides helpful compile-time information about the basic types used in VTKm (an...
Definition: TypeTraits.h:61
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Device
vtkm::cont::DeviceAdapterTagSerial Device
Definition: DeviceAdapterAlgorithmSerial.h:42
vtkm::cont::DeviceAdapterAlgorithm::VIn
static VTKM_CONT T VIn
Definition: DeviceAdapterAlgorithm.h:349
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::cont::ArrayHandle::Allocate
VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:465
vtkm::cont::ArrayPortalToIteratorEnd
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::cont::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorEnd(const PortalType &portal)
Convenience function for converting an ArrayPortal to an end iterator.
Definition: ArrayPortalToIterators.h:189
vtkm::cont::ArrayHandle::PrepareForInput
VTKM_CONT ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used as an input to an operation in the execution environment.
Definition: ArrayHandle.h:574
vtkm::cont::Token::DetachFromAll
VTKM_CONT void DetachFromAll()
Detaches this Token from all resources to allow them to be used elsewhere or deleted.
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Schedule
static VTKM_CONT void Schedule(FunctorType functor, vtkm::Id size)
Definition: DeviceAdapterAlgorithmSerial.h:404
vtkm::cont::DeviceAdapterAlgorithm::Reduce
static VTKM_CONT U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Compute a accumulated sum operation on the input ArrayHandle.
ArrayPortalToIterators.h
DeviceAdapterAlgorithmGeneral.h
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Sort
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmSerial.h:512
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Copy
static VTKM_CONT void Copy(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: DeviceAdapterAlgorithmSerial.h:79
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::SortByKey
static VTKM_CONT void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: DeviceAdapterAlgorithmSerial.h:468
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::ScanExclusive
static VTKM_CONT T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmSerial.h:390
vtkm::cont::ArrayHandle::PrepareForInPlace
VTKM_CONT WritePortalType PrepareForInPlace(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used in an in-place operation (both as input and output) in the execution e...
Definition: ArrayHandle.h:593
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::ScanInclusive
static VTKM_CONT T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmSerial.h:338
vtkm::cont::DeviceAdapterAlgorithm::KIn
static VTKM_CONT T KIn
Definition: DeviceAdapterAlgorithm.h:348
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Unique
static VTKM_CONT void Unique(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmSerial.h:535
vtkm::cont::DeviceAdapterAlgorithm::Sort
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Unstable ascending sort of input array.
DeviceAdapterAlgorithm.h
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Scatter
static VTKM_CONT void Scatter(vtkm::cont::ArrayHandle< Vin, StorageVin > &values, vtkm::cont::ArrayHandle< I, StorageI > &index, vtkm::cont::ArrayHandle< Vout, StorageVout > &values_out)
Definition: DeviceAdapterAlgorithmSerial.h:428
vtkm::cont::DeviceAdapterAlgorithm::ScanExclusive
static VTKM_CONT 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.
ArrayHandleZip.h
DeviceAdapterTagSerial.h
vtkm::Add
Definition: Types.h:222
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::ScanInclusive
static VTKM_CONT T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmSerial.h:308
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::Sum
Binary Predicate that takes two arguments argument x, and y and returns sum (addition) of the two val...
Definition: BinaryOperators.h:33
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Synchronize
static VTKM_CONT void Synchronize()
Definition: DeviceAdapterAlgorithmSerial.h:551
vtkm::cont::ArrayPortalToIterators
Definition: ArrayPortalToIterators.h:27
vtkm::cont::make_ArrayHandleZip
VTKM_CONT vtkm::cont::ArrayHandleZip< FirstHandleType, SecondHandleType > make_ArrayHandleZip(const FirstHandleType &first, const SecondHandleType &second)
A convenience function for creating an ArrayHandleZip.
Definition: ArrayHandleZip.h:288
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::ScanExclusive
static VTKM_CONT T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue)
Definition: DeviceAdapterAlgorithmSerial.h:347
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::DoCopy
static void DoCopy(InPortal src, OutPortal dst, std::true_type, vtkm::Id startIndex, vtkm::Id numToCopy, vtkm::Id outIndex)
Definition: DeviceAdapterAlgorithmSerial.h:65
vtkm::cont::DeviceAdapterAlgorithm::ScanInclusive
static VTKM_CONT 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.
vtkm::cont::DeviceTaskTypes
Class providing a device-specific support for selecting the optimal Task type for a given worklet.
Definition: DeviceAdapterAlgorithm.h:744
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Schedule
static VTKM_CONT void Schedule(FunctorType functor, vtkm::Id3 size)
Definition: DeviceAdapterAlgorithmSerial.h:413
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::CopyIf
static VTKM_CONT void CopyIf(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output, UnaryPredicate predicate)
Definition: DeviceAdapterAlgorithmSerial.h:113
VTKM_LOG_SCOPE_FUNCTION
#define VTKM_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:266
vtkm::cont::DeviceAdapterAlgorithm
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:41
vtkm::CopyFlag::On
@ On
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Reduce
static VTKM_CONT U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: DeviceAdapterAlgorithmSerial.h:214
vtkm::cont::DeviceAdapterAlgorithm::VOut
static VTKM_CONT T VOut
Definition: DeviceAdapterAlgorithm.h:350
ErrorExecution.h
vtkm::cont::DeviceAdapterAlgorithm::U
static VTKM_CONT T U
Definition: DeviceAdapterAlgorithm.h:347
vtkm::cont::DeviceAdapterAlgorithm::Unique
static VTKM_CONT void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Reduce an array to only the unique values it contains.
BinaryOperators.h
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Unique
static VTKM_CONT void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: DeviceAdapterAlgorithmSerial.h:527
vtkm::Vec< vtkm::Id, 3 >
vtkm::cont::DeviceAdapterAlgorithm::CopySubRange
static VTKM_CONT bool CopySubRange(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::Id inputStartIndex, vtkm::Id numberOfElementsToCopy, vtkm::cont::ArrayHandle< U, COut > &output, vtkm::Id outputIndex=0)
Copy the contents of a section of one ArrayHandle to another.
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::CopyIf
static VTKM_CONT void CopyIf(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmSerial.h:102
vtkm::NotZeroInitialized
Predicate that takes a single argument x, and returns True if it isn't the identity of the Type T.
Definition: UnaryPredicates.h:32
vtkm::cont::DeviceAdapterAlgorithm::SortByKey
static VTKM_CONT void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Unstable ascending sort of keys and values.
vtkm::cont::ArrayHandle::PrepareForOutput
VTKM_CONT WritePortalType PrepareForOutput(vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares (allocates) this array to be used as an output from an operation in the execution environmen...
Definition: ArrayHandle.h:613
vtkm::cont::DeviceAdapterAlgorithm::CopyIf
static VTKM_CONT void CopyIf(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output)
Conditionally copy elements in the input array to the output array.
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Reduce
static VTKM_CONT U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmSerial.h:222
vtkm::cont::DeviceTaskTypes::MakeTask
static vtkm::exec::internal::TaskSingular< WorkletType, InvocationType > MakeTask(WorkletType &worklet, InvocationType &invocation, vtkm::Id, vtkm::Id globalIndexOffset=0)
Definition: DeviceAdapterAlgorithmGeneral.h:1195
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::ReduceByKey
static VTKM_CONT void ReduceByKey(const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< T, KOut > &keys_output, vtkm::cont::ArrayHandle< U, VOut > &values_output, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmSerial.h:245
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::DoCopy
static void DoCopy(InPortal src, OutPortal dst, std::false_type, vtkm::Id startIndex, vtkm::Id numToCopy, vtkm::Id outIndex)
Definition: DeviceAdapterAlgorithmSerial.h:50
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Sort
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: DeviceAdapterAlgorithmSerial.h:504
vtkm::cont::ArrayHandle::ReleaseResources
VTKM_CONT void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:559
vtkm::TypeTraits::ZeroInitialization
static VTKM_EXEC_CONT T ZeroInitialization()
Definition: TypeTraits.h:75
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::SortByKeyDirect
static VTKM_CONT void SortByKeyDirect(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Reorder the value array along with the sorting algorithm.
Definition: DeviceAdapterAlgorithmSerial.h:452
TaskTiling.h
vtkm::cont::LogLevel::Perf
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
vtkm::cont::ArrayHandleIndex
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54