VTK-m  2.2
Algorithm.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_Algorithm_h
11 #define vtk_m_cont_Algorithm_h
12 
13 #include <vtkm/Types.h>
14 
15 #include <vtkm/cont/BitField.h>
18 #include <vtkm/cont/Token.h>
19 #include <vtkm/cont/TryExecute.h>
21 
22 
23 namespace vtkm
24 {
25 namespace cont
26 {
28 namespace detail
29 {
30 template <typename Device, typename T>
31 inline auto DoPrepareArgForExec(T&& object, vtkm::cont::Token& token, std::true_type) -> decltype(
32  vtkm::cont::internal::CallPrepareForExecution(std::forward<T>(object), Device{}, token))
33 {
35  return vtkm::cont::internal::CallPrepareForExecution(std::forward<T>(object), Device{}, token);
36 }
37 
38 template <typename Device, typename T>
39 inline T&& DoPrepareArgForExec(T&& object, vtkm::cont::Token&, std::false_type)
40 {
41  static_assert(!vtkm::cont::internal::IsExecutionObjectBase<T>::value,
42  "Internal error: failed to detect execution object.");
43  return std::forward<T>(object);
44 }
45 
46 template <typename Device, typename T>
47 auto PrepareArgForExec(T&& object, vtkm::cont::Token& token)
48  -> decltype(DoPrepareArgForExec<Device>(std::forward<T>(object),
49  token,
50  vtkm::cont::internal::IsExecutionObjectBase<T>{}))
51 {
52  return DoPrepareArgForExec<Device>(
53  std::forward<T>(object), token, vtkm::cont::internal::IsExecutionObjectBase<T>{});
54 }
55 
56 struct BitFieldToUnorderedSetFunctor
57 {
58  vtkm::Id Result{ 0 };
59 
60  template <typename Device, typename... Args>
61  VTKM_CONT bool operator()(Device, Args&&... args)
62  {
64  vtkm::cont::Token token;
66  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
67  return true;
68  }
69 };
70 
71 struct CopyFunctor
72 {
73  template <typename T, typename S, typename... Args>
74  VTKM_CONT bool InputArrayOnDevice(vtkm::cont::DeviceAdapterId device,
75  const vtkm::cont::ArrayHandle<T, S>& input,
76  Args&&...) const
77  {
78  return input.IsOnDevice(device);
79  }
80 
81  template <typename Device, typename... Args>
82  VTKM_CONT bool operator()(Device device, bool useExistingDevice, Args&&... args) const
83  {
85  if (!useExistingDevice || this->InputArrayOnDevice(device, std::forward<Args>(args)...))
86  {
87  vtkm::cont::Token token;
89  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
90  return true;
91  }
92  else
93  {
94  return false;
95  }
96  }
97 };
98 
99 struct CopyIfFunctor
100 {
101 
102  template <typename Device, typename... Args>
103  VTKM_CONT bool operator()(Device, Args&&... args) const
104  {
106  vtkm::cont::Token token;
108  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
109  return true;
110  }
111 };
112 
113 struct CopySubRangeFunctor
114 {
115  bool valid;
116 
117  CopySubRangeFunctor()
118  : valid(false)
119  {
120  }
121 
122  template <typename Device, typename... Args>
123  VTKM_CONT bool operator()(Device, Args&&... args)
124  {
126  vtkm::cont::Token token;
128  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
129  return true;
130  }
131 };
132 
133 struct CountSetBitsFunctor
134 {
135  vtkm::Id PopCount{ 0 };
136 
137  template <typename Device, typename... Args>
138  VTKM_CONT bool operator()(Device, Args&&... args)
139  {
141  vtkm::cont::Token token;
143  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
144  return true;
145  }
146 };
147 
148 struct FillFunctor
149 {
150  template <typename Device, typename... Args>
151  VTKM_CONT bool operator()(Device, Args&&... args)
152  {
154  vtkm::cont::Token token;
156  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
157  return true;
158  }
159 };
160 
161 struct LowerBoundsFunctor
162 {
163 
164  template <typename Device, typename... Args>
165  VTKM_CONT bool operator()(Device, Args&&... args) const
166  {
168  vtkm::cont::Token token;
170  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
171  return true;
172  }
173 };
174 
175 template <typename U>
176 struct ReduceFunctor
177 {
178  U result;
179 
180  ReduceFunctor()
182  {
183  }
184 
185  template <typename Device, typename... Args>
186  VTKM_CONT bool operator()(Device, Args&&... args)
187  {
189  vtkm::cont::Token token;
191  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
192  return true;
193  }
194 };
195 
196 struct ReduceByKeyFunctor
197 {
198  template <typename Device, typename... Args>
199  VTKM_CONT bool operator()(Device, Args&&... args) const
200  {
202  vtkm::cont::Token token;
204  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
205  return true;
206  }
207 };
208 
209 template <typename U>
210 struct ScanInclusiveResultFunctor
211 {
212  U result;
213 
214  ScanInclusiveResultFunctor()
216  {
217  }
218 
219  template <typename Device, typename... Args>
220  VTKM_CONT bool operator()(Device, Args&&... args)
221  {
223  vtkm::cont::Token token;
225  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
226  return true;
227  }
228 };
229 
230 struct ScanInclusiveByKeyFunctor
231 {
232  ScanInclusiveByKeyFunctor() {}
233 
234  template <typename Device, typename... Args>
235  VTKM_CONT bool operator()(Device, Args&&... args) const
236  {
238  vtkm::cont::Token token;
240  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
241  return true;
242  }
243 };
244 
245 template <typename T>
246 struct ScanExclusiveFunctor
247 {
248  T result;
249 
250  ScanExclusiveFunctor()
251  : result(T())
252  {
253  }
254 
255  template <typename Device, typename... Args>
256  VTKM_CONT bool operator()(Device, Args&&... args)
257  {
259  vtkm::cont::Token token;
261  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
262  return true;
263  }
264 };
265 
266 struct ScanExclusiveByKeyFunctor
267 {
268  ScanExclusiveByKeyFunctor() {}
269 
270  template <typename Device, typename... Args>
271  VTKM_CONT bool operator()(Device, Args&&... args) const
272  {
274  vtkm::cont::Token token;
276  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
277  return true;
278  }
279 };
280 
281 template <typename T>
282 struct ScanExtendedFunctor
283 {
284  template <typename Device, typename... Args>
285  VTKM_CONT bool operator()(Device, Args&&... args)
286  {
288  vtkm::cont::Token token;
290  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
291  return true;
292  }
293 };
294 
295 struct ScheduleFunctor
296 {
297  template <typename Device, typename... Args>
298  VTKM_CONT bool operator()(Device, Args&&... args)
299  {
301  vtkm::cont::Token token;
303  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
304  return true;
305  }
306 };
307 
308 struct SortFunctor
309 {
310  template <typename Device, typename... Args>
311  VTKM_CONT bool operator()(Device, Args&&... args) const
312  {
314  vtkm::cont::Token token;
316  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
317  return true;
318  }
319 };
320 
321 struct SortByKeyFunctor
322 {
323  template <typename Device, typename... Args>
324  VTKM_CONT bool operator()(Device, Args&&... args) const
325  {
327  vtkm::cont::Token token;
329  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
330  return true;
331  }
332 };
333 
334 struct SynchronizeFunctor
335 {
336  template <typename Device>
337  VTKM_CONT bool operator()(Device)
338  {
341  return true;
342  }
343 };
344 
345 struct TransformFunctor
346 {
347  template <typename Device, typename... Args>
348  VTKM_CONT bool operator()(Device, Args&&... args) const
349  {
351  vtkm::cont::Token token;
353  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
354  return true;
355  }
356 };
357 
358 struct UniqueFunctor
359 {
360  template <typename Device, typename... Args>
361  VTKM_CONT bool operator()(Device, Args&&... args) const
362  {
364  vtkm::cont::Token token;
366  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
367  return true;
368  }
369 };
370 
371 struct UpperBoundsFunctor
372 {
373  template <typename Device, typename... Args>
374  VTKM_CONT bool operator()(Device, Args&&... args) const
375  {
377  vtkm::cont::Token token;
379  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
380  return true;
381  }
382 };
383 } // namespace detail
385 
386 struct Algorithm
387 {
388 
389  template <typename IndicesStorage>
392  const vtkm::cont::BitField& bits,
394  {
395  detail::BitFieldToUnorderedSetFunctor functor;
396  vtkm::cont::TryExecuteOnDevice(devId, functor, bits, indices);
397  return functor.Result;
398  }
399 
400  template <typename IndicesStorage>
402  const vtkm::cont::BitField& bits,
404  {
405  detail::BitFieldToUnorderedSetFunctor functor;
406  vtkm::cont::TryExecute(functor, bits, indices);
407  return functor.Result;
408  }
409 
410  template <typename T, typename U, class CIn, class COut>
412  const vtkm::cont::ArrayHandle<T, CIn>& input,
414  {
415  // If we can use any device, prefer to use source's already loaded device.
416  if (devId == vtkm::cont::DeviceAdapterTagAny())
417  {
418  bool isCopied =
419  vtkm::cont::TryExecuteOnDevice(devId, detail::CopyFunctor(), true, input, output);
420  if (isCopied)
421  {
422  return true;
423  }
424  }
425  return vtkm::cont::TryExecuteOnDevice(devId, detail::CopyFunctor(), false, input, output);
426  }
427  template <typename T, typename U, class CIn, class COut>
430  {
431  Copy(vtkm::cont::DeviceAdapterTagAny(), input, output);
432  }
433 
434 
435  template <typename T, typename U, class CIn, class CStencil, class COut>
437  const vtkm::cont::ArrayHandle<T, CIn>& input,
440  {
441  vtkm::cont::TryExecuteOnDevice(devId, detail::CopyIfFunctor(), input, stencil, output);
442  }
443  template <typename T, typename U, class CIn, class CStencil, class COut>
447  {
448  CopyIf(vtkm::cont::DeviceAdapterTagAny(), input, stencil, output);
449  }
450 
451 
452  template <typename T, typename U, class CIn, class CStencil, class COut, class UnaryPredicate>
454  const vtkm::cont::ArrayHandle<T, CIn>& input,
457  UnaryPredicate unary_predicate)
458  {
460  devId, detail::CopyIfFunctor(), input, stencil, output, unary_predicate);
461  }
462  template <typename T, typename U, class CIn, class CStencil, class COut, class UnaryPredicate>
466  UnaryPredicate unary_predicate)
467  {
468  CopyIf(vtkm::cont::DeviceAdapterTagAny(), input, stencil, output, unary_predicate);
469  }
470 
471 
472  template <typename T, typename U, class CIn, class COut>
474  const vtkm::cont::ArrayHandle<T, CIn>& input,
475  vtkm::Id inputStartIndex,
476  vtkm::Id numberOfElementsToCopy,
478  vtkm::Id outputIndex = 0)
479  {
480  detail::CopySubRangeFunctor functor;
482  devId, functor, input, inputStartIndex, numberOfElementsToCopy, output, outputIndex);
483  return functor.valid;
484  }
485  template <typename T, typename U, class CIn, class COut>
487  vtkm::Id inputStartIndex,
488  vtkm::Id numberOfElementsToCopy,
490  vtkm::Id outputIndex = 0)
491  {
493  input,
494  inputStartIndex,
495  numberOfElementsToCopy,
496  output,
497  outputIndex);
498  }
499 
501  const vtkm::cont::BitField& bits)
502  {
503  detail::CountSetBitsFunctor functor;
504  vtkm::cont::TryExecuteOnDevice(devId, functor, bits);
505  return functor.PopCount;
506  }
507 
509  {
511  }
512 
514  vtkm::cont::BitField& bits,
515  bool value,
516  vtkm::Id numBits)
517  {
518  detail::FillFunctor functor;
519  vtkm::cont::TryExecuteOnDevice(devId, functor, bits, value, numBits);
520  }
521 
522  VTKM_CONT static void Fill(vtkm::cont::BitField& bits, bool value, vtkm::Id numBits)
523  {
524  Fill(vtkm::cont::DeviceAdapterTagAny{}, bits, value, numBits);
525  }
526 
528  vtkm::cont::BitField& bits,
529  bool value)
530  {
531  detail::FillFunctor functor;
532  vtkm::cont::TryExecuteOnDevice(devId, functor, bits, value);
533  }
534 
535  VTKM_CONT static void Fill(vtkm::cont::BitField& bits, bool value)
536  {
537  Fill(vtkm::cont::DeviceAdapterTagAny{}, bits, value);
538  }
539 
540  template <typename WordType>
542  vtkm::cont::BitField& bits,
543  WordType word,
544  vtkm::Id numBits)
545  {
546  detail::FillFunctor functor;
547  vtkm::cont::TryExecuteOnDevice(devId, functor, bits, word, numBits);
548  }
549 
550  template <typename WordType>
551  VTKM_CONT static void Fill(vtkm::cont::BitField& bits, WordType word, vtkm::Id numBits)
552  {
553  Fill(vtkm::cont::DeviceAdapterTagAny{}, bits, word, numBits);
554  }
555 
556  template <typename WordType>
558  vtkm::cont::BitField& bits,
559  WordType word)
560  {
561  detail::FillFunctor functor;
562  vtkm::cont::TryExecuteOnDevice(devId, functor, bits, word);
563  }
564 
565  template <typename WordType>
566  VTKM_CONT static void Fill(vtkm::cont::BitField& bits, WordType word)
567  {
568  Fill(vtkm::cont::DeviceAdapterTagAny{}, bits, word);
569  }
570 
571  template <typename T, typename S>
574  const T& value)
575  {
576  detail::FillFunctor functor;
577  vtkm::cont::TryExecuteOnDevice(devId, functor, handle, value);
578  }
579 
580  template <typename T, typename S>
581  VTKM_CONT static void Fill(vtkm::cont::ArrayHandle<T, S>& handle, const T& value)
582  {
583  Fill(vtkm::cont::DeviceAdapterTagAny{}, handle, value);
584  }
585 
586  template <typename T, typename S>
589  const T& value,
590  const vtkm::Id numValues)
591  {
592  detail::FillFunctor functor;
593  vtkm::cont::TryExecuteOnDevice(devId, functor, handle, value, numValues);
594  }
595 
596  template <typename T, typename S>
598  const T& value,
599  const vtkm::Id numValues)
600  {
601  Fill(vtkm::cont::DeviceAdapterTagAny{}, handle, value, numValues);
602  }
603 
604  template <typename T, class CIn, class CVal, class COut>
606  const vtkm::cont::ArrayHandle<T, CIn>& input,
607  const vtkm::cont::ArrayHandle<T, CVal>& values,
609  {
610  vtkm::cont::TryExecuteOnDevice(devId, detail::LowerBoundsFunctor(), input, values, output);
611  }
612  template <typename T, class CIn, class CVal, class COut>
614  const vtkm::cont::ArrayHandle<T, CVal>& values,
616  {
617  LowerBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output);
618  }
619 
620 
621  template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
623  const vtkm::cont::ArrayHandle<T, CIn>& input,
624  const vtkm::cont::ArrayHandle<T, CVal>& values,
626  BinaryCompare binary_compare)
627  {
629  devId, detail::LowerBoundsFunctor(), input, values, output, binary_compare);
630  }
631  template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
633  const vtkm::cont::ArrayHandle<T, CVal>& values,
635  BinaryCompare binary_compare)
636  {
637  LowerBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output, binary_compare);
638  }
639 
640 
641  template <class CIn, class COut>
645  {
646  vtkm::cont::TryExecuteOnDevice(devId, detail::LowerBoundsFunctor(), input, values_output);
647  }
648  template <class CIn, class COut>
651  {
652  LowerBounds(vtkm::cont::DeviceAdapterTagAny(), input, values_output);
653  }
654 
655 
656  template <typename T, typename U, class CIn>
658  const vtkm::cont::ArrayHandle<T, CIn>& input,
659  U initialValue)
660  {
661  detail::ReduceFunctor<U> functor;
662  vtkm::cont::TryExecuteOnDevice(devId, functor, input, initialValue);
663  return functor.result;
664  }
665  template <typename T, typename U, class CIn>
666  VTKM_CONT static U Reduce(const vtkm::cont::ArrayHandle<T, CIn>& input, U initialValue)
667  {
668  return Reduce(vtkm::cont::DeviceAdapterTagAny(), input, initialValue);
669  }
670 
671 
672  template <typename T, typename U, class CIn, class BinaryFunctor>
674  const vtkm::cont::ArrayHandle<T, CIn>& input,
675  U initialValue,
676  BinaryFunctor binary_functor)
677  {
678  detail::ReduceFunctor<U> functor;
679  vtkm::cont::TryExecuteOnDevice(devId, functor, input, initialValue, binary_functor);
680  return functor.result;
681  }
682  template <typename T, typename U, class CIn, class BinaryFunctor>
684  U initialValue,
685  BinaryFunctor binary_functor)
686  {
687  return Reduce(vtkm::cont::DeviceAdapterTagAny(), input, initialValue, binary_functor);
688  }
689 
690 
691  template <typename T,
692  typename U,
693  class CKeyIn,
694  class CValIn,
695  class CKeyOut,
696  class CValOut,
697  class BinaryFunctor>
703  BinaryFunctor binary_functor)
704  {
706  detail::ReduceByKeyFunctor(),
707  keys,
708  values,
709  keys_output,
710  values_output,
711  binary_functor);
712  }
713  template <typename T,
714  typename U,
715  class CKeyIn,
716  class CValIn,
717  class CKeyOut,
718  class CValOut,
719  class BinaryFunctor>
724  BinaryFunctor binary_functor)
725  {
726  ReduceByKey(
727  vtkm::cont::DeviceAdapterTagAny(), keys, values, keys_output, values_output, binary_functor);
728  }
729 
730 
731  template <typename T, class CIn, class COut>
733  const vtkm::cont::ArrayHandle<T, CIn>& input,
735  {
736  detail::ScanInclusiveResultFunctor<T> functor;
737  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output);
738  return functor.result;
739  }
740  template <typename T, class CIn, class COut>
743  {
744  return ScanInclusive(vtkm::cont::DeviceAdapterTagAny(), input, output);
745  }
746 
747 
748  template <typename T, class CIn, class COut, class BinaryFunctor>
750  const vtkm::cont::ArrayHandle<T, CIn>& input,
752  BinaryFunctor binary_functor)
753  {
754  detail::ScanInclusiveResultFunctor<T> functor;
755  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output, binary_functor);
756  return functor.result;
757  }
758  template <typename T, class CIn, class COut, class BinaryFunctor>
761  BinaryFunctor binary_functor)
762  {
763  return ScanInclusive(vtkm::cont::DeviceAdapterTagAny(), input, output, binary_functor);
764  }
765 
766 
767  template <typename T,
768  typename U,
769  typename KIn,
770  typename VIn,
771  typename VOut,
772  typename BinaryFunctor>
775  const vtkm::cont::ArrayHandle<U, VIn>& values,
776  vtkm::cont::ArrayHandle<U, VOut>& values_output,
777  BinaryFunctor binary_functor)
778  {
780  devId, detail::ScanInclusiveByKeyFunctor(), keys, values, values_output, binary_functor);
781  }
782  template <typename T,
783  typename U,
784  typename KIn,
785  typename VIn,
786  typename VOut,
787  typename BinaryFunctor>
789  const vtkm::cont::ArrayHandle<U, VIn>& values,
790  vtkm::cont::ArrayHandle<U, VOut>& values_output,
791  BinaryFunctor binary_functor)
792  {
794  vtkm::cont::DeviceAdapterTagAny(), keys, values, values_output, binary_functor);
795  }
796 
797 
798  template <typename T, typename U, typename KIn, typename VIn, typename VOut>
801  const vtkm::cont::ArrayHandle<U, VIn>& values,
802  vtkm::cont::ArrayHandle<U, VOut>& values_output)
803  {
805  devId, detail::ScanInclusiveByKeyFunctor(), keys, values, values_output);
806  }
807  template <typename T, typename U, typename KIn, typename VIn, typename VOut>
809  const vtkm::cont::ArrayHandle<U, VIn>& values,
810  vtkm::cont::ArrayHandle<U, VOut>& values_output)
811  {
812  ScanInclusiveByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values, values_output);
813  }
814 
815 
816  template <typename T, class CIn, class COut>
818  const vtkm::cont::ArrayHandle<T, CIn>& input,
820  {
821  detail::ScanExclusiveFunctor<T> functor;
822  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output);
823  return functor.result;
824  }
825  template <typename T, class CIn, class COut>
828  {
829  return ScanExclusive(vtkm::cont::DeviceAdapterTagAny(), input, output);
830  }
831 
832 
833  template <typename T, class CIn, class COut, class BinaryFunctor>
835  const vtkm::cont::ArrayHandle<T, CIn>& input,
837  BinaryFunctor binaryFunctor,
838  const T& initialValue)
839  {
840  detail::ScanExclusiveFunctor<T> functor;
841  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output, binaryFunctor, initialValue);
842  return functor.result;
843  }
844  template <typename T, class CIn, class COut, class BinaryFunctor>
847  BinaryFunctor binaryFunctor,
848  const T& initialValue)
849  {
850  return ScanExclusive(
851  vtkm::cont::DeviceAdapterTagAny(), input, output, binaryFunctor, initialValue);
852  }
853 
854 
855  template <typename T, typename U, typename KIn, typename VIn, typename VOut, class BinaryFunctor>
858  const vtkm::cont::ArrayHandle<U, VIn>& values,
860  const U& initialValue,
861  BinaryFunctor binaryFunctor)
862  {
864  detail::ScanExclusiveByKeyFunctor(),
865  keys,
866  values,
867  output,
868  initialValue,
869  binaryFunctor);
870  }
871  template <typename T, typename U, typename KIn, typename VIn, typename VOut, class BinaryFunctor>
873  const vtkm::cont::ArrayHandle<U, VIn>& values,
875  const U& initialValue,
876  BinaryFunctor binaryFunctor)
877  {
879  vtkm::cont::DeviceAdapterTagAny(), keys, values, output, initialValue, binaryFunctor);
880  }
881 
882 
883  template <typename T, typename U, class KIn, typename VIn, typename VOut>
886  const vtkm::cont::ArrayHandle<U, VIn>& values,
888  {
890  devId, detail::ScanExclusiveByKeyFunctor(), keys, values, output);
891  }
892  template <typename T, typename U, class KIn, typename VIn, typename VOut>
894  const vtkm::cont::ArrayHandle<U, VIn>& values,
896  {
897  ScanExclusiveByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values, output);
898  }
899 
900 
901  template <typename T, class CIn, class COut>
903  const vtkm::cont::ArrayHandle<T, CIn>& input,
905  {
906  detail::ScanExtendedFunctor<T> functor;
907  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output);
908  }
909  template <typename T, class CIn, class COut>
912  {
914  }
915 
916 
917  template <typename T, class CIn, class COut, class BinaryFunctor>
919  const vtkm::cont::ArrayHandle<T, CIn>& input,
921  BinaryFunctor binaryFunctor,
922  const T& initialValue)
923  {
924  detail::ScanExtendedFunctor<T> functor;
925  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output, binaryFunctor, initialValue);
926  }
927  template <typename T, class CIn, class COut, class BinaryFunctor>
930  BinaryFunctor binaryFunctor,
931  const T& initialValue)
932  {
933  ScanExtended(vtkm::cont::DeviceAdapterTagAny(), input, output, binaryFunctor, initialValue);
934  }
935 
936  // Should this be deprecated in favor of `RuntimeDeviceTracker`?
937  template <typename Functor>
939  Functor functor,
940  vtkm::Id numInstances)
941  {
942  vtkm::cont::TryExecuteOnDevice(devId, detail::ScheduleFunctor{}, functor, numInstances);
943  }
944  template <typename... Hints, typename Functor>
945  VTKM_CONT static void Schedule(vtkm::cont::internal::HintList<Hints...> hints,
946  Functor functor,
947  vtkm::Id numInstances)
948  {
949  vtkm::cont::TryExecute(detail::ScheduleFunctor{}, hints, functor, numInstances);
950  }
951  template <typename Functor>
952  VTKM_CONT static void Schedule(Functor functor, vtkm::Id numInstances)
953  {
954  Schedule(vtkm::cont::DeviceAdapterTagAny{}, functor, numInstances);
955  }
956 
957 
958  template <typename Functor>
960  Functor functor,
961  vtkm::Id3 rangeMax)
962  {
963  vtkm::cont::TryExecuteOnDevice(devId, detail::ScheduleFunctor(), functor, rangeMax);
964  }
965  template <typename... Hints, typename Functor>
966  VTKM_CONT static void Schedule(vtkm::cont::internal::HintList<Hints...> hints,
967  Functor functor,
968  vtkm::Id3 rangeMax)
969  {
970  vtkm::cont::TryExecute(detail::ScheduleFunctor{}, hints, functor, rangeMax);
971  }
972  template <typename Functor>
973  VTKM_CONT static void Schedule(Functor functor, vtkm::Id3 rangeMax)
974  {
975  Schedule(vtkm::cont::DeviceAdapterTagAny(), functor, rangeMax);
976  }
977 
978 
979  template <typename T, class Storage>
982  {
983  vtkm::cont::TryExecuteOnDevice(devId, detail::SortFunctor(), values);
984  }
985  template <typename T, class Storage>
987  {
989  }
990 
991 
992  template <typename T, class Storage, class BinaryCompare>
995  BinaryCompare binary_compare)
996  {
997  vtkm::cont::TryExecuteOnDevice(devId, detail::SortFunctor(), values, binary_compare);
998  }
999  template <typename T, class Storage, class BinaryCompare>
1001  BinaryCompare binary_compare)
1002  {
1003  Sort(vtkm::cont::DeviceAdapterTagAny(), values, binary_compare);
1004  }
1005 
1006 
1007  template <typename T, typename U, class StorageT, class StorageU>
1011  {
1012  vtkm::cont::TryExecuteOnDevice(devId, detail::SortByKeyFunctor(), keys, values);
1013  }
1014  template <typename T, typename U, class StorageT, class StorageU>
1017  {
1018  SortByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values);
1019  }
1020 
1021  template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
1025  BinaryCompare binary_compare)
1026  {
1027  vtkm::cont::TryExecuteOnDevice(devId, detail::SortByKeyFunctor(), keys, values, binary_compare);
1028  }
1029  template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
1032  BinaryCompare binary_compare)
1033  {
1034  SortByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values, binary_compare);
1035  }
1036 
1037 
1039  {
1040  vtkm::cont::TryExecuteOnDevice(devId, detail::SynchronizeFunctor());
1041  }
1043 
1044 
1045  template <typename T,
1046  typename U,
1047  typename V,
1048  typename StorageT,
1049  typename StorageU,
1050  typename StorageV,
1051  typename BinaryFunctor>
1056  BinaryFunctor binaryFunctor)
1057  {
1059  devId, detail::TransformFunctor(), input1, input2, output, binaryFunctor);
1060  }
1061  template <typename T,
1062  typename U,
1063  typename V,
1064  typename StorageT,
1065  typename StorageU,
1066  typename StorageV,
1067  typename BinaryFunctor>
1071  BinaryFunctor binaryFunctor)
1072  {
1073  Transform(vtkm::cont::DeviceAdapterTagAny(), input1, input2, output, binaryFunctor);
1074  }
1075 
1076 
1077  template <typename T, class Storage>
1080  {
1081  vtkm::cont::TryExecuteOnDevice(devId, detail::UniqueFunctor(), values);
1082  }
1083  template <typename T, class Storage>
1085  {
1087  }
1088 
1089 
1090  template <typename T, class Storage, class BinaryCompare>
1093  BinaryCompare binary_compare)
1094  {
1095  vtkm::cont::TryExecuteOnDevice(devId, detail::UniqueFunctor(), values, binary_compare);
1096  }
1097  template <typename T, class Storage, class BinaryCompare>
1099  BinaryCompare binary_compare)
1100  {
1101  Unique(vtkm::cont::DeviceAdapterTagAny(), values, binary_compare);
1102  }
1103 
1104 
1105  template <typename T, class CIn, class CVal, class COut>
1107  const vtkm::cont::ArrayHandle<T, CIn>& input,
1108  const vtkm::cont::ArrayHandle<T, CVal>& values,
1110  {
1111  vtkm::cont::TryExecuteOnDevice(devId, detail::UpperBoundsFunctor(), input, values, output);
1112  }
1113  template <typename T, class CIn, class CVal, class COut>
1115  const vtkm::cont::ArrayHandle<T, CVal>& values,
1117  {
1118  UpperBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output);
1119  }
1120 
1121 
1122  template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
1124  const vtkm::cont::ArrayHandle<T, CIn>& input,
1125  const vtkm::cont::ArrayHandle<T, CVal>& values,
1127  BinaryCompare binary_compare)
1128  {
1130  devId, detail::UpperBoundsFunctor(), input, values, output, binary_compare);
1131  }
1132  template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
1134  const vtkm::cont::ArrayHandle<T, CVal>& values,
1136  BinaryCompare binary_compare)
1137  {
1138  UpperBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output, binary_compare);
1139  }
1140 
1141 
1142  template <class CIn, class COut>
1146  {
1147  vtkm::cont::TryExecuteOnDevice(devId, detail::UpperBoundsFunctor(), input, values_output);
1148  }
1149  template <class CIn, class COut>
1152  {
1153  UpperBounds(vtkm::cont::DeviceAdapterTagAny(), input, values_output);
1154  }
1155 };
1156 }
1157 } // namespace vtkm::cont
1158 
1159 #endif //vtk_m_cont_Algorithm_h
vtkm::cont::Algorithm::LowerBounds
static void LowerBounds(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< vtkm::Id, CIn > &input, vtkm::cont::ArrayHandle< vtkm::Id, COut > &values_output)
Definition: Algorithm.h:642
vtkm::cont::Algorithm::UpperBounds
static void UpperBounds(const vtkm::cont::ArrayHandle< vtkm::Id, CIn > &input, vtkm::cont::ArrayHandle< vtkm::Id, COut > &values_output)
Definition: Algorithm.h:1150
vtkm::cont::Algorithm::UpperBounds
static void UpperBounds(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output, BinaryCompare binary_compare)
Definition: Algorithm.h:1123
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::Algorithm::LowerBounds
static void LowerBounds(const vtkm::cont::ArrayHandle< vtkm::Id, CIn > &input, vtkm::cont::ArrayHandle< vtkm::Id, COut > &values_output)
Definition: Algorithm.h:649
vtkm::cont::Algorithm::Unique
static void Unique(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:1091
vtkm::cont::TryExecuteOnDevice
bool TryExecuteOnDevice(vtkm::cont::DeviceAdapterId devId, Functor &&functor)
Try to execute a functor on a specific device selected at runtime.
Definition: TryExecute.h:178
vtkm::cont::Algorithm::Schedule
static void Schedule(Functor functor, vtkm::Id3 rangeMax)
Definition: Algorithm.h:973
vtkm::cont::Algorithm::ScanInclusiveByKey
static void ScanInclusiveByKey(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< U, VOut > &values_output)
Definition: Algorithm.h:799
vtkm::cont::Algorithm::Unique
static void Unique(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:1078
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:300
vtkm::cont::Algorithm::CopySubRange
static bool CopySubRange(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::Id inputStartIndex, vtkm::Id numberOfElementsToCopy, vtkm::cont::ArrayHandle< U, COut > &output, vtkm::Id outputIndex=0)
Definition: Algorithm.h:473
vtkm::cont::DeviceAdapterAlgorithm::Fill
static void Fill(vtkm::cont::BitField &bits, bool value, vtkm::Id numBits)
Fill the BitField with a specific pattern of bits.
vtkm::cont::Algorithm::ScanExclusive
static T ScanExclusive(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:817
vtkm::cont::Algorithm::BitFieldToUnorderedSet
static vtkm::Id BitFieldToUnorderedSet(const vtkm::cont::BitField &bits, vtkm::cont::ArrayHandle< Id, IndicesStorage > &indices)
Definition: Algorithm.h:401
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, S > &handle, const T &value, const vtkm::Id numValues)
Definition: Algorithm.h:587
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::DeviceAdapterAlgorithm::UpperBounds
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.
vtkm::TypeTraits
The TypeTraits class provides helpful compile-time information about the basic types used in VTKm (an...
Definition: TypeTraits.h:61
vtkm::cont::Algorithm::Unique
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:1084
Types.h
vtkm::cont::Algorithm::LowerBounds
static void LowerBounds(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output)
Definition: Algorithm.h:613
vtkm::cont::Algorithm::ReduceByKey
static void ReduceByKey(vtkm::cont::DeviceAdapterId devId, 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)
Definition: Algorithm.h:698
vtkm::cont::Algorithm::ScanExclusive
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue)
Definition: Algorithm.h:845
vtkm::cont::DeviceAdapterAlgorithm::Schedule
static void Schedule(Functor functor, vtkm::Id numInstances)
Schedule many instances of a function to run on concurrent threads.
vtkm::cont::Algorithm::Reduce
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: Algorithm.h:666
vtkm::cont::Algorithm::SortByKey
static void SortByKey(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: Algorithm.h:1008
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::BitField &bits, WordType word)
Definition: Algorithm.h:566
vtkm::cont::Algorithm::ScanInclusive
static T ScanInclusive(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:732
vtkm::cont::DeviceAdapterAlgorithm::ScanExtended
static void ScanExtended(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Compute an extended prefix sum operation on the input ArrayHandle.
vtkm::cont::Algorithm::Reduce
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor)
Definition: Algorithm.h:683
vtkm::cont::Algorithm::SortByKey
static void SortByKey(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:1022
BitField.h
vtkm::cont::Algorithm::LowerBounds
static void LowerBounds(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output)
Definition: Algorithm.h:605
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::Algorithm::Schedule
static void Schedule(Functor functor, vtkm::Id numInstances)
Definition: Algorithm.h:952
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, S > &handle, const T &value)
Definition: Algorithm.h:572
vtkm::cont::DeviceAdapterAlgorithm::Transform
static void Transform(const vtkm::cont::ArrayHandle< T, StorageT > &input1, const vtkm::cont::ArrayHandle< U, StorageU > &input2, vtkm::cont::ArrayHandle< V, StorageV > &output, BinaryFunctor binaryFunctor)
Apply a given binary operation function element-wise to input arrays.
vtkm::cont::Algorithm::Sort
static void Sort(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:1000
vtkm::cont::Algorithm::BitFieldToUnorderedSet
static vtkm::Id BitFieldToUnorderedSet(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::BitField &bits, vtkm::cont::ArrayHandle< Id, IndicesStorage > &indices)
Definition: Algorithm.h:390
vtkm::cont::Algorithm::SortByKey
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: Algorithm.h:1015
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::BitField &bits, bool value)
Definition: Algorithm.h:527
vtkm::cont::Algorithm::Unique
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:1098
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::BitField &bits, bool value)
Definition: Algorithm.h:535
vtkm::cont::Algorithm::ScanExtended
static void ScanExtended(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue)
Definition: Algorithm.h:918
vtkm::cont::Algorithm::CountSetBits
static vtkm::Id CountSetBits(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::BitField &bits)
Definition: Algorithm.h:500
vtkm::cont::Algorithm::LowerBounds
static void LowerBounds(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output, BinaryCompare binary_compare)
Definition: Algorithm.h:622
vtkm::cont::Algorithm::ScanInclusiveByKey
static void ScanInclusiveByKey(const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< U, VOut > &values_output, BinaryFunctor binary_functor)
Definition: Algorithm.h:788
vtkm::cont::Algorithm::Transform
static void Transform(const vtkm::cont::ArrayHandle< T, StorageT > &input1, const vtkm::cont::ArrayHandle< U, StorageU > &input2, vtkm::cont::ArrayHandle< V, StorageV > &output, BinaryFunctor binaryFunctor)
Definition: Algorithm.h:1068
vtkm::cont::Algorithm::Reduce
static U Reduce(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: Algorithm.h:657
vtkm::cont::Algorithm::ScanExclusive
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:826
vtkm::cont::DeviceAdapterAlgorithm::ScanInclusiveByKey
static void ScanInclusiveByKey(const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< U, VOut > &values_output, BinaryFunctor binary_functor)
Compute a segmented inclusive prefix sum operation on the input key value pairs.
vtkm::cont::Algorithm::Schedule
static void Schedule(vtkm::cont::internal::HintList< Hints... > hints, Functor functor, vtkm::Id numInstances)
Definition: Algorithm.h:945
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::BitField &bits, WordType word)
Definition: Algorithm.h:557
Hints.h
vtkm::cont::DeviceAdapterAlgorithm::CountSetBits
static vtkm::Id CountSetBits(const vtkm::cont::BitField &bits)
Returns the total number of "1" bits in BitField.
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::BitField &bits, WordType word, vtkm::Id numBits)
Definition: Algorithm.h:551
vtkm::cont::DeviceAdapterAlgorithm::Unique
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Reduce an array to only the unique values it contains.
DeviceAdapter.h
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::cont::Algorithm::CopyIf
static void CopyIf(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output, UnaryPredicate unary_predicate)
Definition: Algorithm.h:453
vtkm::cont::DeviceAdapterAlgorithm::ScanExclusiveByKey
static T class BinaryFunctor static void ScanExclusiveByKey(const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< U, VOut > &output, const U &initialValue, BinaryFunctor binaryFunctor)
vtkm::cont::Algorithm::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: Algorithm.h:444
vtkm::cont::Algorithm::UpperBounds
static void UpperBounds(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output)
Definition: Algorithm.h:1114
vtkm::cont::Algorithm::SortByKey
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:1030
vtkm::cont::Algorithm::ScanExclusiveByKey
static void ScanExclusiveByKey(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< U, VOut > &output)
Definition: Algorithm.h:884
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.
TryExecute.h
vtkm::cont::DeviceAdapterAlgorithm::Sort
static void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Unstable ascending sort of input array.
vtkm::cont::Algorithm::ScanExclusiveByKey
static void ScanExclusiveByKey(const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< U, VOut > &output, const U &initialValue, BinaryFunctor binaryFunctor)
Definition: Algorithm.h:872
vtkm::cont::Algorithm::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 unary_predicate)
Definition: Algorithm.h:463
VTKM_IS_EXECUTION_OBJECT
#define VTKM_IS_EXECUTION_OBJECT(execObject)
Checks that the argument is a proper execution object.
Definition: ExecutionObjectBase.h:66
vtkm::cont::TryExecute
bool TryExecute(Functor &&functor, Args &&... args)
Try to execute a functor on a set of devices until one succeeds.
Definition: TryExecute.h:244
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::BitField &bits, WordType word, vtkm::Id numBits)
Definition: Algorithm.h:541
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::cont::Algorithm::ScanExclusiveByKey
static void ScanExclusiveByKey(const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< U, VOut > &output)
Definition: Algorithm.h:893
vtkm::cont::Algorithm::Copy
static void Copy(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:428
vtkm::cont::DeviceAdapterTagAny
Tag for a device adapter used to specify that any device may be used for an operation.
Definition: DeviceAdapterTag.h:180
vtkm::cont::DeviceAdapterAlgorithm
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:41
vtkm::cont::Algorithm::UpperBounds
static void UpperBounds(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output, BinaryCompare binary_compare)
Definition: Algorithm.h:1133
vtkm::cont::Algorithm::ScanInclusiveByKey
static void ScanInclusiveByKey(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< U, VOut > &values_output, BinaryFunctor binary_functor)
Definition: Algorithm.h:773
vtkm::cont::Algorithm::Sort
static void Sort(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:980
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::Algorithm::Schedule
static void Schedule(vtkm::cont::DeviceAdapterId devId, Functor functor, vtkm::Id3 rangeMax)
Definition: Algorithm.h:959
vtkm::cont::Algorithm::Copy
static bool Copy(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:411
vtkm::cont::DeviceAdapterAlgorithm::ReduceByKey
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.
vtkm::cont::Algorithm::Sort
static void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:986
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::BitField &bits, bool value, vtkm::Id numBits)
Definition: Algorithm.h:522
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::Algorithm
Definition: Algorithm.h:386
vtkm::cont::Algorithm::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: Algorithm.h:486
vtkm::cont::Algorithm::Schedule
static void Schedule(vtkm::cont::internal::HintList< Hints... > hints, Functor functor, vtkm::Id3 rangeMax)
Definition: Algorithm.h:966
vtkm::cont::ArrayHandle::IsOnDevice
bool IsOnDevice(vtkm::cont::DeviceAdapterId device) const
Returns true if the ArrayHandle's data is on the given device.
Definition: ArrayHandle.h:649
vtkm::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
vtkm::cont::Algorithm::UpperBounds
static void UpperBounds(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< vtkm::Id, CIn > &input, vtkm::cont::ArrayHandle< vtkm::Id, COut > &values_output)
Definition: Algorithm.h:1143
vtkm::Vec< vtkm::Id, 3 >
vtkm::cont::DeviceAdapterAlgorithm::LowerBounds
static void LowerBounds(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output)
Output is the first index in input for each item in values that wouldn't alter the ordering of input.
vtkm::cont::BitField
Definition: BitField.h:497
vtkm::cont::Algorithm::Synchronize
static void Synchronize()
Definition: Algorithm.h:1042
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::ArrayHandle< T, S > &handle, const T &value, const vtkm::Id numValues)
Definition: Algorithm.h:597
vtkm::cont::Algorithm::ScanExtended
static void ScanExtended(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue)
Definition: Algorithm.h:928
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::Algorithm::Transform
static void Transform(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, StorageT > &input1, const vtkm::cont::ArrayHandle< U, StorageU > &input2, vtkm::cont::ArrayHandle< V, StorageV > &output, BinaryFunctor binaryFunctor)
Definition: Algorithm.h:1052
vtkm::cont::Algorithm::Synchronize
static void Synchronize(vtkm::cont::DeviceAdapterId devId)
Definition: Algorithm.h:1038
vtkm::cont::Algorithm::ScanExclusiveByKey
static void ScanExclusiveByKey(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< U, VOut > &output, const U &initialValue, BinaryFunctor binaryFunctor)
Definition: Algorithm.h:856
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::BitField &bits, bool value, vtkm::Id numBits)
Definition: Algorithm.h:513
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::Algorithm::ScanExtended
static void ScanExtended(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:902
vtkm::cont::Algorithm::ScanExtended
static void ScanExtended(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:910
vtkm::cont::Algorithm::ScanInclusiveByKey
static void ScanInclusiveByKey(const vtkm::cont::ArrayHandle< T, KIn > &keys, const vtkm::cont::ArrayHandle< U, VIn > &values, vtkm::cont::ArrayHandle< U, VOut > &values_output)
Definition: Algorithm.h:808
vtkm::cont::Algorithm::Fill
static void Fill(vtkm::cont::ArrayHandle< T, S > &handle, const T &value)
Definition: Algorithm.h:581
vtkm::cont::Algorithm::ScanInclusive
static T ScanInclusive(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor)
Definition: Algorithm.h:749
vtkm::cont::Algorithm::CopyIf
static void CopyIf(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:436
vtkm::cont::Algorithm::Schedule
static void Schedule(vtkm::cont::DeviceAdapterId devId, Functor functor, vtkm::Id numInstances)
Definition: Algorithm.h:938
vtkm::cont::Algorithm::ReduceByKey
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)
Definition: Algorithm.h:720
vtkm::cont::Algorithm::ScanInclusive
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor)
Definition: Algorithm.h:759
vtkm::cont::Algorithm::Reduce
static U Reduce(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor)
Definition: Algorithm.h:673
vtkm::cont::DeviceAdapterAlgorithm::BitFieldToUnorderedSet
static vtkm::Id BitFieldToUnorderedSet(const vtkm::cont::BitField &bits, vtkm::cont::ArrayHandle< Id, IndicesStorage > &indices)
Create a unique, unsorted list of indices denoting which bits are set in a bitfield.
ExecutionObjectBase.h
Token.h
vtkm::cont::Algorithm::ScanInclusive
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:741
vtkm::cont::Algorithm::ScanExclusive
static T ScanExclusive(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue)
Definition: Algorithm.h:834
vtkm::cont::Algorithm::LowerBounds
static void LowerBounds(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output, BinaryCompare binary_compare)
Definition: Algorithm.h:632
vtkm::cont::Algorithm::UpperBounds
static void UpperBounds(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output)
Definition: Algorithm.h:1106
vtkm::cont::Algorithm::Sort
static void Sort(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:993
vtkm::cont::Algorithm::CountSetBits
static vtkm::Id CountSetBits(const vtkm::cont::BitField &bits)
Definition: Algorithm.h:508
VTKM_IS_DEVICE_ADAPTER_TAG
#define VTKM_IS_DEVICE_ADAPTER_TAG(tag)
Checks that the argument is a proper device adapter tag.
Definition: DeviceAdapterTag.h:194