VTK-m  2.2
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 <>
37  : vtkm::cont::internal::DeviceAdapterAlgorithmGeneral<
38  DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>,
39  vtkm::cont::DeviceAdapterTagSerial>
40 {
41 private:
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 <typename Hints, typename FunctorType>
404  VTKM_CONT static inline void Schedule(Hints, FunctorType functor, vtkm::Id size)
405  {
407 
408  vtkm::exec::serial::internal::TaskTiling1D kernel(functor);
409  ScheduleTask(kernel, size);
410  }
411 
412  template <typename FunctorType>
413  VTKM_CONT static inline void Schedule(FunctorType&& functor, vtkm::Id size)
414  {
415  Schedule(vtkm::cont::internal::HintList<>{}, functor, size);
416  }
417 
418  template <typename Hints, typename FunctorType>
419  VTKM_CONT static inline void Schedule(Hints, FunctorType functor, vtkm::Id3 size)
420  {
422 
423  vtkm::exec::serial::internal::TaskTiling3D kernel(functor);
424  ScheduleTask(kernel, size);
425  }
426 
427  template <typename FunctorType>
428  VTKM_CONT static inline void Schedule(FunctorType&& functor, vtkm::Id3 size)
429  {
430  Schedule(vtkm::cont::internal::HintList<>{}, functor, size);
431  }
432 
433 private:
434  template <typename Vin,
435  typename I,
436  typename Vout,
437  class StorageVin,
438  class StorageI,
439  class StorageVout>
443  {
445 
446  const vtkm::Id n = values.GetNumberOfValues();
447  VTKM_ASSERT(n == index.GetNumberOfValues());
448 
449  vtkm::cont::Token token;
450 
451  auto valuesPortal = values.PrepareForInput(Device(), token);
452  auto indexPortal = index.PrepareForInput(Device(), token);
453  auto valuesOutPortal = values_out.PrepareForOutput(n, Device(), token);
454 
455  for (vtkm::Id i = 0; i < n; i++)
456  {
457  valuesOutPortal.Set(i, valuesPortal.Get(indexPortal.Get(i)));
458  }
459  }
460 
462  template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
465  BinaryCompare binary_compare)
466  {
468 
469  //combine the keys and values into a ZipArrayHandle
470  //we than need to specify a custom compare function wrapper
471  //that only checks for key side of the pair, using the custom compare
472  //functor that the user passed in
473  auto zipHandle = vtkm::cont::make_ArrayHandleZip(keys, values);
474  Sort(zipHandle, internal::KeyCompare<T, U, BinaryCompare>(binary_compare));
475  }
476 
477 public:
478  template <typename T, typename U, class StorageT, class StorageU>
481  {
483 
484  SortByKey(keys, values, std::less<T>());
485  }
486 
487  template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
490  const BinaryCompare& binary_compare)
491  {
493 
494  internal::WrappedBinaryOperator<bool, BinaryCompare> wrappedCompare(binary_compare);
495  constexpr bool larger_than_64bits = sizeof(U) > sizeof(vtkm::Int64);
496  if (larger_than_64bits)
497  {
501  vtkm::cont::ArrayHandle<U, StorageU> valuesScattered;
502 
503  Copy(ArrayHandleIndex(keys.GetNumberOfValues()), indexArray);
504  SortByKeyDirect(keys, indexArray, wrappedCompare);
505  Scatter(values, indexArray, valuesScattered);
506  Copy(valuesScattered, values);
507  }
508  else
509  {
510  SortByKeyDirect(keys, values, wrappedCompare);
511  }
512  }
513 
514  template <typename T, class Storage>
516  {
518 
519  Sort(values, std::less<T>());
520  }
521 
522  template <typename T, class Storage, class BinaryCompare>
524  BinaryCompare binary_compare)
525  {
527 
528  vtkm::cont::Token token;
529 
530  auto arrayPortal = values.PrepareForInPlace(Device(), token);
531  vtkm::cont::ArrayPortalToIterators<decltype(arrayPortal)> iterators(arrayPortal);
532 
533  internal::WrappedBinaryOperator<bool, BinaryCompare> wrappedCompare(binary_compare);
534  std::sort(iterators.GetBegin(), iterators.GetEnd(), wrappedCompare);
535  }
536 
537  template <typename T, class Storage>
539  {
541 
542  Unique(values, std::equal_to<T>());
543  }
544 
545  template <typename T, class Storage, class BinaryCompare>
547  BinaryCompare binary_compare)
548  {
550 
551  vtkm::cont::Token token;
552  auto arrayPortal = values.PrepareForInPlace(Device(), token);
553  vtkm::cont::ArrayPortalToIterators<decltype(arrayPortal)> iterators(arrayPortal);
554  internal::WrappedBinaryOperator<bool, BinaryCompare> wrappedCompare(binary_compare);
555 
556  auto end = std::unique(iterators.GetBegin(), iterators.GetEnd(), wrappedCompare);
557  vtkm::Id newSize = static_cast<vtkm::Id>(end - iterators.GetBegin());
558  token.DetachFromAll();
559  values.Allocate(newSize, vtkm::CopyFlag::On);
560  }
561 
562  VTKM_CONT static void Synchronize()
563  {
564  // Nothing to do. This device is serial and has no asynchronous operations.
565  }
566 };
567 
568 template <>
570 {
571 public:
572  template <typename Hints, typename WorkletType, typename InvocationType>
573  static vtkm::exec::serial::internal::TaskTiling1D MakeTask(WorkletType& worklet,
574  InvocationType& invocation,
575  vtkm::Id,
576  Hints = Hints{})
577  {
578  // Currently ignoring hints.
579  return vtkm::exec::serial::internal::TaskTiling1D(worklet, invocation);
580  }
581 
582  template <typename Hints, typename WorkletType, typename InvocationType>
583  static vtkm::exec::serial::internal::TaskTiling3D MakeTask(WorkletType& worklet,
584  InvocationType& invocation,
585  vtkm::Id3,
586  Hints = Hints{})
587  {
588  // Currently ignoring hints.
589  return vtkm::exec::serial::internal::TaskTiling3D(worklet, invocation);
590  }
591 
592  template <typename WorkletType, typename InvocationType, typename RangeType>
593  VTKM_CONT static auto MakeTask(WorkletType& worklet,
594  InvocationType& invocation,
595  const RangeType& range)
596  {
597  return MakeTask<vtkm::cont::internal::HintList<>>(worklet, invocation, range);
598  }
599 };
600 }
601 } // namespace vtkm::cont
602 
603 #endif //vtk_m_cont_serial_internal_DeviceAdapterAlgorithmSerial_h
vtkm::cont::DeviceAdapterAlgorithm::ScanExclusive
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.
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Sort
static void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: DeviceAdapterAlgorithmSerial.h:515
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Schedule
static void Schedule(FunctorType &&functor, vtkm::Id3 size)
Definition: DeviceAdapterAlgorithmSerial.h:428
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Unique
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: DeviceAdapterAlgorithmSerial.h:538
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:300
ArrayHandle.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::ScanInclusive
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmSerial.h:308
vtkm::TypeTraits
The TypeTraits class provides helpful compile-time information about the basic types used in VTKm (an...
Definition: TypeTraits.h:61
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::cont::DeviceAdapterAlgorithm::Schedule
static void Schedule(Functor functor, vtkm::Id numInstances)
Schedule many instances of a function to run on concurrent threads.
ArrayPortalToIterators.h
DeviceAdapterAlgorithmGeneral.h
vtkm::cont::DeviceAdapterAlgorithm::Copy
static void Copy(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Copy the contents of one ArrayHandle to another.
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Scatter
static void Scatter(vtkm::cont::ArrayHandle< Vin, StorageVin > &values, vtkm::cont::ArrayHandle< I, StorageI > &index, vtkm::cont::ArrayHandle< Vout, StorageVout > &values_out)
Definition: DeviceAdapterAlgorithmSerial.h:440
vtkm::cont::ArrayHandle::GetNumberOfValues
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
vtkm::cont::ArrayPortalToIteratorEnd
vtkm::cont::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorEnd(const PortalType &portal)
Convenience function for converting an ArrayPortal to an end iterator.
Definition: ArrayPortalToIterators.h:189
DeviceAdapterAlgorithm.h
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Unique
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmSerial.h:546
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Sort
static void Sort(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmSerial.h:523
vtkm::cont::DeviceAdapterTagSerial
Tag for a device adapter that performs all computation on the same single thread as the control envir...
Definition: DeviceAdapterTagSerial.h:22
vtkm::cont::DeviceAdapterAlgorithm::Unique
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Reduce an array to only the unique values it contains.
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::SortByKeyDirect
static 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:463
ArrayHandleZip.h
vtkm::cont::DeviceAdapterAlgorithm::VIn
static T VIn
Definition: DeviceAdapterAlgorithm.h:349
DeviceAdapterTagSerial.h
vtkm::Add
Definition: Types.h:260
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::cont::make_ArrayHandleZip
vtkm::cont::ArrayHandleZip< FirstHandleType, SecondHandleType > make_ArrayHandleZip(const FirstHandleType &first, const SecondHandleType &second)
A convenience function for creating an ArrayHandleZip.
Definition: ArrayHandleZip.h:290
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 >::Reduce
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmSerial.h:222
vtkm::cont::ArrayHandle::PrepareForInPlace
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:618
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Schedule
static void Schedule(Hints, FunctorType functor, vtkm::Id3 size)
Definition: DeviceAdapterAlgorithmSerial.h:419
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::ReduceByKey
static 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::ArrayPortalToIterators
Definition: ArrayPortalToIterators.h:27
vtkm::cont::DeviceAdapterAlgorithm::KIn
static T KIn
Definition: DeviceAdapterAlgorithm.h:348
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::ScanExclusive
static 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 >::CopySubRange
static 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::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::CopyIf
static 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::cont::DeviceAdapterAlgorithm::ScanInclusive
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.
vtkm::cont::DeviceAdapterAlgorithm::Sort
static void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Unstable ascending sort of input array.
VTKM_CONT_EXPORT
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
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::U
static T U
Definition: DeviceAdapterAlgorithm.h:347
vtkm::cont::ArrayHandle::PrepareForOutput
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:638
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 >::ScanExclusive
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmSerial.h:390
vtkm::cont::ArrayHandle::ReleaseResources
void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:584
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
VTKM_LOG_SCOPE_FUNCTION
#define VTKM_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:214
vtkm::Int64
signed long long Int64
Base type to use for 64-bit signed integer numbers.
Definition: Types.h:204
vtkm::cont::DeviceAdapterAlgorithm
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:41
vtkm::CopyFlag::On
@ On
vtkm::cont::DeviceAdapterAlgorithm::SortByKey
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Unstable ascending sort of keys and values.
vtkm::cont::Token::DetachFromAll
void DetachFromAll()
Detaches this Token from all resources to allow them to be used elsewhere or deleted.
ErrorExecution.h
BinaryOperators.h
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Synchronize
static void Synchronize()
Definition: DeviceAdapterAlgorithmSerial.h:562
vtkm::cont::DeviceAdapterAlgorithm::CopySubRange
static 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::DeviceTaskTypes< vtkm::cont::DeviceAdapterTagSerial >::MakeTask
static auto MakeTask(WorkletType &worklet, InvocationType &invocation, const RangeType &range)
Definition: DeviceAdapterAlgorithmSerial.h:593
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Reduce
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: DeviceAdapterAlgorithmSerial.h:214
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::ScanInclusive
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmSerial.h:338
vtkm::Vec< vtkm::Id, 3 >
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Schedule
static void Schedule(Hints, FunctorType functor, vtkm::Id size)
Definition: DeviceAdapterAlgorithmSerial.h:404
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::CopyIf
static 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::ArrayPortalToIteratorBegin
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::PrepareForInput
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:599
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::SortByKey
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, const BinaryCompare &binary_compare)
Definition: DeviceAdapterAlgorithmSerial.h:488
vtkm::TypeTraits::ZeroInitialization
static T ZeroInitialization()
A static function that returns 0 (or the closest equivalent to it) for the given type.
Definition: TypeTraits.h:77
vtkm::cont::DeviceAdapterAlgorithm::Reduce
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Compute a accumulated sum operation on the input ArrayHandle.
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:1208
vtkm::cont::ArrayHandle::Allocate
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:490
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::Schedule
static void Schedule(FunctorType &&functor, vtkm::Id size)
Definition: DeviceAdapterAlgorithmSerial.h:413
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 >::Copy
static 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 >::CopyIf
static 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::cont::DeviceAdapterAlgorithm::VOut
static T VOut
Definition: DeviceAdapterAlgorithm.h:350
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:55
vtkm::cont::DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagSerial >::SortByKey
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: DeviceAdapterAlgorithmSerial.h:479