VTK-m  2.0
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>
20 
21 
22 namespace vtkm
23 {
24 namespace cont
25 {
27 namespace detail
28 {
29 template <typename Device, typename T>
30 inline auto DoPrepareArgForExec(T&& object, vtkm::cont::Token& token, std::true_type) -> decltype(
31  vtkm::cont::internal::CallPrepareForExecution(std::forward<T>(object), Device{}, token))
32 {
34  return vtkm::cont::internal::CallPrepareForExecution(std::forward<T>(object), Device{}, token);
35 }
36 
37 template <typename Device, typename T>
38 inline T&& DoPrepareArgForExec(T&& object, vtkm::cont::Token&, std::false_type)
39 {
40  static_assert(!vtkm::cont::internal::IsExecutionObjectBase<T>::value,
41  "Internal error: failed to detect execution object.");
42  return std::forward<T>(object);
43 }
44 
45 template <typename Device, typename T>
46 auto PrepareArgForExec(T&& object, vtkm::cont::Token& token)
47  -> decltype(DoPrepareArgForExec<Device>(std::forward<T>(object),
48  token,
49  vtkm::cont::internal::IsExecutionObjectBase<T>{}))
50 {
51  return DoPrepareArgForExec<Device>(
52  std::forward<T>(object), token, vtkm::cont::internal::IsExecutionObjectBase<T>{});
53 }
54 
55 struct BitFieldToUnorderedSetFunctor
56 {
57  vtkm::Id Result{ 0 };
58 
59  template <typename Device, typename... Args>
60  VTKM_CONT bool operator()(Device, Args&&... args)
61  {
63  vtkm::cont::Token token;
65  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
66  return true;
67  }
68 };
69 
70 struct CopyFunctor
71 {
72  template <typename T, typename S, typename... Args>
73  VTKM_CONT bool InputArrayOnDevice(vtkm::cont::DeviceAdapterId device,
74  const vtkm::cont::ArrayHandle<T, S>& input,
75  Args&&...) const
76  {
77  return input.IsOnDevice(device);
78  }
79 
80  template <typename Device, typename... Args>
81  VTKM_CONT bool operator()(Device device, bool useExistingDevice, Args&&... args) const
82  {
84  if (!useExistingDevice || this->InputArrayOnDevice(device, std::forward<Args>(args)...))
85  {
86  vtkm::cont::Token token;
88  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
89  return true;
90  }
91  else
92  {
93  return false;
94  }
95  }
96 };
97 
98 struct CopyIfFunctor
99 {
100 
101  template <typename Device, typename... Args>
102  VTKM_CONT bool operator()(Device, Args&&... args) const
103  {
105  vtkm::cont::Token token;
107  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
108  return true;
109  }
110 };
111 
112 struct CopySubRangeFunctor
113 {
114  bool valid;
115 
116  CopySubRangeFunctor()
117  : valid(false)
118  {
119  }
120 
121  template <typename Device, typename... Args>
122  VTKM_CONT bool operator()(Device, Args&&... args)
123  {
125  vtkm::cont::Token token;
127  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
128  return true;
129  }
130 };
131 
132 struct CountSetBitsFunctor
133 {
134  vtkm::Id PopCount{ 0 };
135 
136  template <typename Device, typename... Args>
137  VTKM_CONT bool operator()(Device, Args&&... args)
138  {
140  vtkm::cont::Token token;
142  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
143  return true;
144  }
145 };
146 
147 struct FillFunctor
148 {
149  template <typename Device, typename... Args>
150  VTKM_CONT bool operator()(Device, Args&&... args)
151  {
153  vtkm::cont::Token token;
155  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
156  return true;
157  }
158 };
159 
160 struct LowerBoundsFunctor
161 {
162 
163  template <typename Device, typename... Args>
164  VTKM_CONT bool operator()(Device, Args&&... args) const
165  {
167  vtkm::cont::Token token;
169  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
170  return true;
171  }
172 };
173 
174 template <typename U>
175 struct ReduceFunctor
176 {
177  U result;
178 
179  ReduceFunctor()
181  {
182  }
183 
184  template <typename Device, typename... Args>
185  VTKM_CONT bool operator()(Device, Args&&... args)
186  {
188  vtkm::cont::Token token;
190  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
191  return true;
192  }
193 };
194 
195 struct ReduceByKeyFunctor
196 {
197  template <typename Device, typename... Args>
198  VTKM_CONT bool operator()(Device, Args&&... args) const
199  {
201  vtkm::cont::Token token;
203  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
204  return true;
205  }
206 };
207 
208 template <typename U>
209 struct ScanInclusiveResultFunctor
210 {
211  U result;
212 
213  ScanInclusiveResultFunctor()
215  {
216  }
217 
218  template <typename Device, typename... Args>
219  VTKM_CONT bool operator()(Device, Args&&... args)
220  {
222  vtkm::cont::Token token;
224  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
225  return true;
226  }
227 };
228 
229 struct ScanInclusiveByKeyFunctor
230 {
231  ScanInclusiveByKeyFunctor() {}
232 
233  template <typename Device, typename... Args>
234  VTKM_CONT bool operator()(Device, Args&&... args) const
235  {
237  vtkm::cont::Token token;
239  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
240  return true;
241  }
242 };
243 
244 template <typename T>
245 struct ScanExclusiveFunctor
246 {
247  T result;
248 
249  ScanExclusiveFunctor()
250  : result(T())
251  {
252  }
253 
254  template <typename Device, typename... Args>
255  VTKM_CONT bool operator()(Device, Args&&... args)
256  {
258  vtkm::cont::Token token;
260  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
261  return true;
262  }
263 };
264 
265 struct ScanExclusiveByKeyFunctor
266 {
267  ScanExclusiveByKeyFunctor() {}
268 
269  template <typename Device, typename... Args>
270  VTKM_CONT bool operator()(Device, Args&&... args) const
271  {
273  vtkm::cont::Token token;
275  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
276  return true;
277  }
278 };
279 
280 template <typename T>
281 struct ScanExtendedFunctor
282 {
283  template <typename Device, typename... Args>
284  VTKM_CONT bool operator()(Device, Args&&... args)
285  {
287  vtkm::cont::Token token;
289  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
290  return true;
291  }
292 };
293 
294 struct ScheduleFunctor
295 {
296  template <typename Device, typename... Args>
297  VTKM_CONT bool operator()(Device, Args&&... args)
298  {
300  vtkm::cont::Token token;
302  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
303  return true;
304  }
305 };
306 
307 struct SortFunctor
308 {
309  template <typename Device, typename... Args>
310  VTKM_CONT bool operator()(Device, Args&&... args) const
311  {
313  vtkm::cont::Token token;
315  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
316  return true;
317  }
318 };
319 
320 struct SortByKeyFunctor
321 {
322  template <typename Device, typename... Args>
323  VTKM_CONT bool operator()(Device, Args&&... args) const
324  {
326  vtkm::cont::Token token;
328  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
329  return true;
330  }
331 };
332 
333 struct SynchronizeFunctor
334 {
335  template <typename Device>
336  VTKM_CONT bool operator()(Device)
337  {
340  return true;
341  }
342 };
343 
344 struct TransformFunctor
345 {
346  template <typename Device, typename... Args>
347  VTKM_CONT bool operator()(Device, Args&&... args) const
348  {
350  vtkm::cont::Token token;
352  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
353  return true;
354  }
355 };
356 
357 struct UniqueFunctor
358 {
359  template <typename Device, typename... Args>
360  VTKM_CONT bool operator()(Device, Args&&... args) const
361  {
363  vtkm::cont::Token token;
365  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
366  return true;
367  }
368 };
369 
370 struct UpperBoundsFunctor
371 {
372  template <typename Device, typename... Args>
373  VTKM_CONT bool operator()(Device, Args&&... args) const
374  {
376  vtkm::cont::Token token;
378  PrepareArgForExec<Device>(std::forward<Args>(args), token)...);
379  return true;
380  }
381 };
382 } // namespace detail
384 
385 struct Algorithm
386 {
387 
388  template <typename IndicesStorage>
391  const vtkm::cont::BitField& bits,
393  {
394  detail::BitFieldToUnorderedSetFunctor functor;
395  vtkm::cont::TryExecuteOnDevice(devId, functor, bits, indices);
396  return functor.Result;
397  }
398 
399  template <typename IndicesStorage>
401  const vtkm::cont::BitField& bits,
403  {
404  detail::BitFieldToUnorderedSetFunctor functor;
405  vtkm::cont::TryExecute(functor, bits, indices);
406  return functor.Result;
407  }
408 
409  template <typename T, typename U, class CIn, class COut>
411  const vtkm::cont::ArrayHandle<T, CIn>& input,
413  {
414  // If we can use any device, prefer to use source's already loaded device.
415  if (devId == vtkm::cont::DeviceAdapterTagAny())
416  {
417  bool isCopied =
418  vtkm::cont::TryExecuteOnDevice(devId, detail::CopyFunctor(), true, input, output);
419  if (isCopied)
420  {
421  return true;
422  }
423  }
424  return vtkm::cont::TryExecuteOnDevice(devId, detail::CopyFunctor(), false, input, output);
425  }
426  template <typename T, typename U, class CIn, class COut>
429  {
430  Copy(vtkm::cont::DeviceAdapterTagAny(), input, output);
431  }
432 
433 
434  template <typename T, typename U, class CIn, class CStencil, class COut>
436  const vtkm::cont::ArrayHandle<T, CIn>& input,
439  {
440  vtkm::cont::TryExecuteOnDevice(devId, detail::CopyIfFunctor(), input, stencil, output);
441  }
442  template <typename T, typename U, class CIn, class CStencil, class COut>
446  {
447  CopyIf(vtkm::cont::DeviceAdapterTagAny(), input, stencil, output);
448  }
449 
450 
451  template <typename T, typename U, class CIn, class CStencil, class COut, class UnaryPredicate>
453  const vtkm::cont::ArrayHandle<T, CIn>& input,
456  UnaryPredicate unary_predicate)
457  {
459  devId, detail::CopyIfFunctor(), input, stencil, output, unary_predicate);
460  }
461  template <typename T, typename U, class CIn, class CStencil, class COut, class UnaryPredicate>
465  UnaryPredicate unary_predicate)
466  {
467  CopyIf(vtkm::cont::DeviceAdapterTagAny(), input, stencil, output, unary_predicate);
468  }
469 
470 
471  template <typename T, typename U, class CIn, class COut>
473  const vtkm::cont::ArrayHandle<T, CIn>& input,
474  vtkm::Id inputStartIndex,
475  vtkm::Id numberOfElementsToCopy,
477  vtkm::Id outputIndex = 0)
478  {
479  detail::CopySubRangeFunctor functor;
481  devId, functor, input, inputStartIndex, numberOfElementsToCopy, output, outputIndex);
482  return functor.valid;
483  }
484  template <typename T, typename U, class CIn, class COut>
486  vtkm::Id inputStartIndex,
487  vtkm::Id numberOfElementsToCopy,
489  vtkm::Id outputIndex = 0)
490  {
491  return CopySubRange(vtkm::cont::DeviceAdapterTagAny(),
492  input,
493  inputStartIndex,
494  numberOfElementsToCopy,
495  output,
496  outputIndex);
497  }
498 
500  const vtkm::cont::BitField& bits)
501  {
502  detail::CountSetBitsFunctor functor;
503  vtkm::cont::TryExecuteOnDevice(devId, functor, bits);
504  return functor.PopCount;
505  }
506 
508  {
509  return CountSetBits(vtkm::cont::DeviceAdapterTagAny{}, bits);
510  }
511 
513  vtkm::cont::BitField& bits,
514  bool value,
515  vtkm::Id numBits)
516  {
517  detail::FillFunctor functor;
518  vtkm::cont::TryExecuteOnDevice(devId, functor, bits, value, numBits);
519  }
520 
521  VTKM_CONT static void Fill(vtkm::cont::BitField& bits, bool value, vtkm::Id numBits)
522  {
523  Fill(vtkm::cont::DeviceAdapterTagAny{}, bits, value, numBits);
524  }
525 
527  vtkm::cont::BitField& bits,
528  bool value)
529  {
530  detail::FillFunctor functor;
531  vtkm::cont::TryExecuteOnDevice(devId, functor, bits, value);
532  }
533 
534  VTKM_CONT static void Fill(vtkm::cont::BitField& bits, bool value)
535  {
536  Fill(vtkm::cont::DeviceAdapterTagAny{}, bits, value);
537  }
538 
539  template <typename WordType>
541  vtkm::cont::BitField& bits,
542  WordType word,
543  vtkm::Id numBits)
544  {
545  detail::FillFunctor functor;
546  vtkm::cont::TryExecuteOnDevice(devId, functor, bits, word, numBits);
547  }
548 
549  template <typename WordType>
550  VTKM_CONT static void Fill(vtkm::cont::BitField& bits, WordType word, vtkm::Id numBits)
551  {
552  Fill(vtkm::cont::DeviceAdapterTagAny{}, bits, word, numBits);
553  }
554 
555  template <typename WordType>
557  vtkm::cont::BitField& bits,
558  WordType word)
559  {
560  detail::FillFunctor functor;
561  vtkm::cont::TryExecuteOnDevice(devId, functor, bits, word);
562  }
563 
564  template <typename WordType>
565  VTKM_CONT static void Fill(vtkm::cont::BitField& bits, WordType word)
566  {
567  Fill(vtkm::cont::DeviceAdapterTagAny{}, bits, word);
568  }
569 
570  template <typename T, typename S>
573  const T& value)
574  {
575  detail::FillFunctor functor;
576  vtkm::cont::TryExecuteOnDevice(devId, functor, handle, value);
577  }
578 
579  template <typename T, typename S>
580  VTKM_CONT static void Fill(vtkm::cont::ArrayHandle<T, S>& handle, const T& value)
581  {
582  Fill(vtkm::cont::DeviceAdapterTagAny{}, handle, value);
583  }
584 
585  template <typename T, typename S>
588  const T& value,
589  const vtkm::Id numValues)
590  {
591  detail::FillFunctor functor;
592  vtkm::cont::TryExecuteOnDevice(devId, functor, handle, value, numValues);
593  }
594 
595  template <typename T, typename S>
597  const T& value,
598  const vtkm::Id numValues)
599  {
600  Fill(vtkm::cont::DeviceAdapterTagAny{}, handle, value, numValues);
601  }
602 
603  template <typename T, class CIn, class CVal, class COut>
605  const vtkm::cont::ArrayHandle<T, CIn>& input,
606  const vtkm::cont::ArrayHandle<T, CVal>& values,
608  {
609  vtkm::cont::TryExecuteOnDevice(devId, detail::LowerBoundsFunctor(), input, values, output);
610  }
611  template <typename T, class CIn, class CVal, class COut>
613  const vtkm::cont::ArrayHandle<T, CVal>& values,
615  {
616  LowerBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output);
617  }
618 
619 
620  template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
622  const vtkm::cont::ArrayHandle<T, CIn>& input,
623  const vtkm::cont::ArrayHandle<T, CVal>& values,
625  BinaryCompare binary_compare)
626  {
628  devId, detail::LowerBoundsFunctor(), input, values, output, binary_compare);
629  }
630  template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
632  const vtkm::cont::ArrayHandle<T, CVal>& values,
634  BinaryCompare binary_compare)
635  {
636  LowerBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output, binary_compare);
637  }
638 
639 
640  template <class CIn, class COut>
644  {
645  vtkm::cont::TryExecuteOnDevice(devId, detail::LowerBoundsFunctor(), input, values_output);
646  }
647  template <class CIn, class COut>
650  {
651  LowerBounds(vtkm::cont::DeviceAdapterTagAny(), input, values_output);
652  }
653 
654 
655  template <typename T, typename U, class CIn>
657  const vtkm::cont::ArrayHandle<T, CIn>& input,
658  U initialValue)
659  {
660  detail::ReduceFunctor<U> functor;
661  vtkm::cont::TryExecuteOnDevice(devId, functor, input, initialValue);
662  return functor.result;
663  }
664  template <typename T, typename U, class CIn>
665  VTKM_CONT static U Reduce(const vtkm::cont::ArrayHandle<T, CIn>& input, U initialValue)
666  {
667  return Reduce(vtkm::cont::DeviceAdapterTagAny(), input, initialValue);
668  }
669 
670 
671  template <typename T, typename U, class CIn, class BinaryFunctor>
673  const vtkm::cont::ArrayHandle<T, CIn>& input,
674  U initialValue,
675  BinaryFunctor binary_functor)
676  {
677  detail::ReduceFunctor<U> functor;
678  vtkm::cont::TryExecuteOnDevice(devId, functor, input, initialValue, binary_functor);
679  return functor.result;
680  }
681  template <typename T, typename U, class CIn, class BinaryFunctor>
683  U initialValue,
684  BinaryFunctor binary_functor)
685  {
686  return Reduce(vtkm::cont::DeviceAdapterTagAny(), input, initialValue, binary_functor);
687  }
688 
689 
690  template <typename T,
691  typename U,
692  class CKeyIn,
693  class CValIn,
694  class CKeyOut,
695  class CValOut,
696  class BinaryFunctor>
702  BinaryFunctor binary_functor)
703  {
705  detail::ReduceByKeyFunctor(),
706  keys,
707  values,
708  keys_output,
709  values_output,
710  binary_functor);
711  }
712  template <typename T,
713  typename U,
714  class CKeyIn,
715  class CValIn,
716  class CKeyOut,
717  class CValOut,
718  class BinaryFunctor>
723  BinaryFunctor binary_functor)
724  {
725  ReduceByKey(
726  vtkm::cont::DeviceAdapterTagAny(), keys, values, keys_output, values_output, binary_functor);
727  }
728 
729 
730  template <typename T, class CIn, class COut>
732  const vtkm::cont::ArrayHandle<T, CIn>& input,
734  {
735  detail::ScanInclusiveResultFunctor<T> functor;
736  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output);
737  return functor.result;
738  }
739  template <typename T, class CIn, class COut>
742  {
743  return ScanInclusive(vtkm::cont::DeviceAdapterTagAny(), input, output);
744  }
745 
746 
747  template <typename T, class CIn, class COut, class BinaryFunctor>
749  const vtkm::cont::ArrayHandle<T, CIn>& input,
751  BinaryFunctor binary_functor)
752  {
753  detail::ScanInclusiveResultFunctor<T> functor;
754  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output, binary_functor);
755  return functor.result;
756  }
757  template <typename T, class CIn, class COut, class BinaryFunctor>
760  BinaryFunctor binary_functor)
761  {
762  return ScanInclusive(vtkm::cont::DeviceAdapterTagAny(), input, output, binary_functor);
763  }
764 
765 
766  template <typename T,
767  typename U,
768  typename KIn,
769  typename VIn,
770  typename VOut,
771  typename BinaryFunctor>
774  const vtkm::cont::ArrayHandle<U, VIn>& values,
775  vtkm::cont::ArrayHandle<U, VOut>& values_output,
776  BinaryFunctor binary_functor)
777  {
779  devId, detail::ScanInclusiveByKeyFunctor(), keys, values, values_output, binary_functor);
780  }
781  template <typename T,
782  typename U,
783  typename KIn,
784  typename VIn,
785  typename VOut,
786  typename BinaryFunctor>
788  const vtkm::cont::ArrayHandle<U, VIn>& values,
789  vtkm::cont::ArrayHandle<U, VOut>& values_output,
790  BinaryFunctor binary_functor)
791  {
793  vtkm::cont::DeviceAdapterTagAny(), keys, values, values_output, binary_functor);
794  }
795 
796 
797  template <typename T, typename U, typename KIn, typename VIn, typename VOut>
800  const vtkm::cont::ArrayHandle<U, VIn>& values,
801  vtkm::cont::ArrayHandle<U, VOut>& values_output)
802  {
804  devId, detail::ScanInclusiveByKeyFunctor(), keys, values, values_output);
805  }
806  template <typename T, typename U, typename KIn, typename VIn, typename VOut>
808  const vtkm::cont::ArrayHandle<U, VIn>& values,
809  vtkm::cont::ArrayHandle<U, VOut>& values_output)
810  {
811  ScanInclusiveByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values, values_output);
812  }
813 
814 
815  template <typename T, class CIn, class COut>
817  const vtkm::cont::ArrayHandle<T, CIn>& input,
819  {
820  detail::ScanExclusiveFunctor<T> functor;
821  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output);
822  return functor.result;
823  }
824  template <typename T, class CIn, class COut>
827  {
828  return ScanExclusive(vtkm::cont::DeviceAdapterTagAny(), input, output);
829  }
830 
831 
832  template <typename T, class CIn, class COut, class BinaryFunctor>
834  const vtkm::cont::ArrayHandle<T, CIn>& input,
836  BinaryFunctor binaryFunctor,
837  const T& initialValue)
838  {
839  detail::ScanExclusiveFunctor<T> functor;
840  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output, binaryFunctor, initialValue);
841  return functor.result;
842  }
843  template <typename T, class CIn, class COut, class BinaryFunctor>
846  BinaryFunctor binaryFunctor,
847  const T& initialValue)
848  {
849  return ScanExclusive(
850  vtkm::cont::DeviceAdapterTagAny(), input, output, binaryFunctor, initialValue);
851  }
852 
853 
854  template <typename T, typename U, typename KIn, typename VIn, typename VOut, class BinaryFunctor>
857  const vtkm::cont::ArrayHandle<U, VIn>& values,
859  const U& initialValue,
860  BinaryFunctor binaryFunctor)
861  {
863  detail::ScanExclusiveByKeyFunctor(),
864  keys,
865  values,
866  output,
867  initialValue,
868  binaryFunctor);
869  }
870  template <typename T, typename U, typename KIn, typename VIn, typename VOut, class BinaryFunctor>
872  const vtkm::cont::ArrayHandle<U, VIn>& values,
874  const U& initialValue,
875  BinaryFunctor binaryFunctor)
876  {
878  vtkm::cont::DeviceAdapterTagAny(), keys, values, output, initialValue, binaryFunctor);
879  }
880 
881 
882  template <typename T, typename U, class KIn, typename VIn, typename VOut>
885  const vtkm::cont::ArrayHandle<U, VIn>& values,
887  {
889  devId, detail::ScanExclusiveByKeyFunctor(), keys, values, output);
890  }
891  template <typename T, typename U, class KIn, typename VIn, typename VOut>
893  const vtkm::cont::ArrayHandle<U, VIn>& values,
895  {
896  ScanExclusiveByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values, output);
897  }
898 
899 
900  template <typename T, class CIn, class COut>
902  const vtkm::cont::ArrayHandle<T, CIn>& input,
904  {
905  detail::ScanExtendedFunctor<T> functor;
906  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output);
907  }
908  template <typename T, class CIn, class COut>
911  {
912  ScanExtended(vtkm::cont::DeviceAdapterTagAny(), input, output);
913  }
914 
915 
916  template <typename T, class CIn, class COut, class BinaryFunctor>
918  const vtkm::cont::ArrayHandle<T, CIn>& input,
920  BinaryFunctor binaryFunctor,
921  const T& initialValue)
922  {
923  detail::ScanExtendedFunctor<T> functor;
924  vtkm::cont::TryExecuteOnDevice(devId, functor, input, output, binaryFunctor, initialValue);
925  }
926  template <typename T, class CIn, class COut, class BinaryFunctor>
929  BinaryFunctor binaryFunctor,
930  const T& initialValue)
931  {
932  ScanExtended(vtkm::cont::DeviceAdapterTagAny(), input, output, binaryFunctor, initialValue);
933  }
934 
935 
936  template <class Functor>
938  Functor functor,
939  vtkm::Id numInstances)
940  {
941  vtkm::cont::TryExecuteOnDevice(devId, detail::ScheduleFunctor(), functor, numInstances);
942  }
943  template <class Functor>
944  VTKM_CONT static void Schedule(Functor functor, vtkm::Id numInstances)
945  {
946  Schedule(vtkm::cont::DeviceAdapterTagAny(), functor, numInstances);
947  }
948 
949 
950  template <class Functor>
952  Functor functor,
953  vtkm::Id3 rangeMax)
954  {
955  vtkm::cont::TryExecuteOnDevice(devId, detail::ScheduleFunctor(), functor, rangeMax);
956  }
957  template <class Functor>
958  VTKM_CONT static void Schedule(Functor functor, vtkm::Id3 rangeMax)
959  {
960  Schedule(vtkm::cont::DeviceAdapterTagAny(), functor, rangeMax);
961  }
962 
963 
964  template <typename T, class Storage>
967  {
968  vtkm::cont::TryExecuteOnDevice(devId, detail::SortFunctor(), values);
969  }
970  template <typename T, class Storage>
972  {
973  Sort(vtkm::cont::DeviceAdapterTagAny(), values);
974  }
975 
976 
977  template <typename T, class Storage, class BinaryCompare>
980  BinaryCompare binary_compare)
981  {
982  vtkm::cont::TryExecuteOnDevice(devId, detail::SortFunctor(), values, binary_compare);
983  }
984  template <typename T, class Storage, class BinaryCompare>
986  BinaryCompare binary_compare)
987  {
988  Sort(vtkm::cont::DeviceAdapterTagAny(), values, binary_compare);
989  }
990 
991 
992  template <typename T, typename U, class StorageT, class StorageU>
996  {
997  vtkm::cont::TryExecuteOnDevice(devId, detail::SortByKeyFunctor(), keys, values);
998  }
999  template <typename T, typename U, class StorageT, class StorageU>
1002  {
1003  SortByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values);
1004  }
1005 
1006  template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
1010  BinaryCompare binary_compare)
1011  {
1012  vtkm::cont::TryExecuteOnDevice(devId, detail::SortByKeyFunctor(), keys, values, binary_compare);
1013  }
1014  template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
1017  BinaryCompare binary_compare)
1018  {
1019  SortByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values, binary_compare);
1020  }
1021 
1022 
1024  {
1025  vtkm::cont::TryExecuteOnDevice(devId, detail::SynchronizeFunctor());
1026  }
1027  VTKM_CONT static void Synchronize() { Synchronize(vtkm::cont::DeviceAdapterTagAny()); }
1028 
1029 
1030  template <typename T,
1031  typename U,
1032  typename V,
1033  typename StorageT,
1034  typename StorageU,
1035  typename StorageV,
1036  typename BinaryFunctor>
1041  BinaryFunctor binaryFunctor)
1042  {
1044  devId, detail::TransformFunctor(), input1, input2, output, binaryFunctor);
1045  }
1046  template <typename T,
1047  typename U,
1048  typename V,
1049  typename StorageT,
1050  typename StorageU,
1051  typename StorageV,
1052  typename BinaryFunctor>
1056  BinaryFunctor binaryFunctor)
1057  {
1058  Transform(vtkm::cont::DeviceAdapterTagAny(), input1, input2, output, binaryFunctor);
1059  }
1060 
1061 
1062  template <typename T, class Storage>
1065  {
1066  vtkm::cont::TryExecuteOnDevice(devId, detail::UniqueFunctor(), values);
1067  }
1068  template <typename T, class Storage>
1070  {
1071  Unique(vtkm::cont::DeviceAdapterTagAny(), values);
1072  }
1073 
1074 
1075  template <typename T, class Storage, class BinaryCompare>
1078  BinaryCompare binary_compare)
1079  {
1080  vtkm::cont::TryExecuteOnDevice(devId, detail::UniqueFunctor(), values, binary_compare);
1081  }
1082  template <typename T, class Storage, class BinaryCompare>
1084  BinaryCompare binary_compare)
1085  {
1086  Unique(vtkm::cont::DeviceAdapterTagAny(), values, binary_compare);
1087  }
1088 
1089 
1090  template <typename T, class CIn, class CVal, class COut>
1092  const vtkm::cont::ArrayHandle<T, CIn>& input,
1093  const vtkm::cont::ArrayHandle<T, CVal>& values,
1095  {
1096  vtkm::cont::TryExecuteOnDevice(devId, detail::UpperBoundsFunctor(), input, values, output);
1097  }
1098  template <typename T, class CIn, class CVal, class COut>
1100  const vtkm::cont::ArrayHandle<T, CVal>& values,
1102  {
1103  UpperBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output);
1104  }
1105 
1106 
1107  template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
1109  const vtkm::cont::ArrayHandle<T, CIn>& input,
1110  const vtkm::cont::ArrayHandle<T, CVal>& values,
1112  BinaryCompare binary_compare)
1113  {
1115  devId, detail::UpperBoundsFunctor(), input, values, output, binary_compare);
1116  }
1117  template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
1119  const vtkm::cont::ArrayHandle<T, CVal>& values,
1121  BinaryCompare binary_compare)
1122  {
1123  UpperBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output, binary_compare);
1124  }
1125 
1126 
1127  template <class CIn, class COut>
1131  {
1132  vtkm::cont::TryExecuteOnDevice(devId, detail::UpperBoundsFunctor(), input, values_output);
1133  }
1134  template <class CIn, class COut>
1137  {
1138  UpperBounds(vtkm::cont::DeviceAdapterTagAny(), input, values_output);
1139  }
1140 };
1141 }
1142 } // namespace vtkm::cont
1143 
1144 #endif //vtk_m_cont_Algorithm_h
vtkm::cont::Algorithm::ScanExtended
static VTKM_CONT void ScanExtended(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:909
vtkm::cont::Algorithm::SortByKey
static VTKM_CONT void SortByKey(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: Algorithm.h:993
vtkm::cont::ArrayHandle< T, S >
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::cont::Algorithm::ScanExclusiveByKey
static VTKM_CONT 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:892
vtkm::cont::Algorithm::ScanInclusive
static VTKM_CONT T ScanInclusive(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:731
vtkm::cont::DeviceAdapterAlgorithm::ScanExtended
static VTKM_CONT 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
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::Algorithm::BitFieldToUnorderedSet
static VTKM_CONT vtkm::Id BitFieldToUnorderedSet(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::BitField &bits, vtkm::cont::ArrayHandle< Id, IndicesStorage > &indices)
Definition: Algorithm.h:389
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::ScanExclusiveByKey
static VTKM_CONT 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:883
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::BitField &bits, WordType word, vtkm::Id numBits)
Definition: Algorithm.h:540
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::ArrayHandle< T, S > &handle, const T &value)
Definition: Algorithm.h:580
Types.h
vtkm::cont::Algorithm::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: Algorithm.h:443
vtkm::cont::Algorithm::ScanExtended
static VTKM_CONT void ScanExtended(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue)
Definition: Algorithm.h:927
vtkm::cont::DeviceAdapterAlgorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::BitField &bits, bool value, vtkm::Id numBits)
Fill the BitField with a specific pattern of bits.
vtkm::cont::Algorithm::ScanInclusiveByKey
static VTKM_CONT 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:807
vtkm::cont::Algorithm::UpperBounds
static VTKM_CONT 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:1091
vtkm::cont::Algorithm::Sort
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:985
vtkm::cont::Algorithm::Sort
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:971
vtkm::cont::Algorithm::UpperBounds
static VTKM_CONT void UpperBounds(const vtkm::cont::ArrayHandle< vtkm::Id, CIn > &input, vtkm::cont::ArrayHandle< vtkm::Id, COut > &values_output)
Definition: Algorithm.h:1135
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.
BitField.h
vtkm::cont::Algorithm::ScanInclusive
static VTKM_CONT 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:748
vtkm::cont::Algorithm::ScanInclusiveByKey
static VTKM_CONT 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:772
vtkm::cont::Algorithm::Unique
static VTKM_CONT void Unique(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:1076
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::ArrayHandle< T, S > &handle, const T &value, const vtkm::Id numValues)
Definition: Algorithm.h:596
vtkm::cont::Algorithm::LowerBounds
static VTKM_CONT 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:604
vtkm::cont::Algorithm::SortByKey
static VTKM_CONT void SortByKey(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:1007
vtkm::cont::Algorithm::CopySubRange
static VTKM_CONT 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:472
vtkm::cont::Algorithm::Schedule
static VTKM_CONT void Schedule(Functor functor, vtkm::Id numInstances)
Definition: Algorithm.h:944
vtkm::cont::Algorithm::Sort
static VTKM_CONT void Sort(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:965
vtkm::cont::Algorithm::ScanExtended
static VTKM_CONT 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:917
vtkm::cont::Algorithm::Copy
static VTKM_CONT bool Copy(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:410
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::BitField &bits, bool value, vtkm::Id numBits)
Definition: Algorithm.h:521
vtkm::cont::DeviceAdapterAlgorithm::LowerBounds
static VTKM_CONT 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::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::BitField &bits, WordType word)
Definition: Algorithm.h:565
vtkm::cont::DeviceAdapterAlgorithm::Sort
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Unstable ascending sort of input array.
vtkm::cont::Algorithm::ScanInclusiveByKey
static VTKM_CONT 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:798
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::Algorithm::CountSetBits
static VTKM_CONT vtkm::Id CountSetBits(const vtkm::cont::BitField &bits)
Definition: Algorithm.h:507
vtkm::cont::DeviceAdapterAlgorithm::BitFieldToUnorderedSet
static VTKM_CONT 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.
vtkm::cont::Algorithm::CopyIf
static VTKM_CONT 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:452
vtkm::cont::Algorithm::ScanExclusive
static VTKM_CONT 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:833
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.
vtkm::cont::Algorithm::SortByKey
static VTKM_CONT void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:1015
vtkm::cont::Algorithm::Synchronize
static VTKM_CONT void Synchronize(vtkm::cont::DeviceAdapterId devId)
Definition: Algorithm.h:1023
DeviceAdapter.h
vtkm::cont::TryExecuteOnDevice
VTKM_CONT 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::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::cont::Algorithm::Transform
static VTKM_CONT 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:1053
vtkm::cont::Algorithm::ReduceByKey
static VTKM_CONT 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:719
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::BitField &bits, bool value)
Definition: Algorithm.h:534
vtkm::cont::Algorithm::Schedule
static VTKM_CONT void Schedule(vtkm::cont::DeviceAdapterId devId, Functor functor, vtkm::Id numInstances)
Definition: Algorithm.h:937
vtkm::cont::Algorithm::Unique
static VTKM_CONT void Unique(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:1063
vtkm::cont::Algorithm::LowerBounds
static VTKM_CONT 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:621
vtkm::cont::DeviceAdapterAlgorithm::Transform
static VTKM_CONT 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::Reduce
static VTKM_CONT U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor)
Definition: Algorithm.h:682
vtkm::cont::Algorithm::UpperBounds
static VTKM_CONT 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:1128
vtkm::cont::Algorithm::Reduce
static VTKM_CONT U Reduce(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor)
Definition: Algorithm.h:672
TryExecute.h
vtkm::cont::Algorithm::ScanExclusiveByKey
static VTKM_CONT 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:871
vtkm::cont::Algorithm::ScanExclusive
static VTKM_CONT T ScanExclusive(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:816
vtkm::cont::Algorithm::Schedule
static VTKM_CONT void Schedule(vtkm::cont::DeviceAdapterId devId, Functor functor, vtkm::Id3 rangeMax)
Definition: Algorithm.h:951
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, S > &handle, const T &value)
Definition: Algorithm.h:571
vtkm::cont::Algorithm::UpperBounds
static VTKM_CONT 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:1118
vtkm::cont::Algorithm::UpperBounds
static VTKM_CONT 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:1099
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, S > &handle, const T &value, const vtkm::Id numValues)
Definition: Algorithm.h:586
vtkm::cont::Algorithm::ScanInclusive
static VTKM_CONT T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:740
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::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::Algorithm::CopyIf
static VTKM_CONT 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:435
vtkm::cont::Algorithm::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: Algorithm.h:485
vtkm::cont::Algorithm::UpperBounds
static VTKM_CONT 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:1108
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::Algorithm::LowerBounds
static VTKM_CONT 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:641
vtkm::cont::Algorithm::ScanExclusive
static VTKM_CONT T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:825
vtkm::cont::DeviceAdapterAlgorithm
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:41
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::BitField &bits, WordType word, vtkm::Id numBits)
Definition: Algorithm.h:550
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::BitField &bits, bool value, vtkm::Id numBits)
Definition: Algorithm.h:512
vtkm::cont::Algorithm::BitFieldToUnorderedSet
static VTKM_CONT vtkm::Id BitFieldToUnorderedSet(const vtkm::cont::BitField &bits, vtkm::cont::ArrayHandle< Id, IndicesStorage > &indices)
Definition: Algorithm.h:400
vtkm::cont::Algorithm::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 unary_predicate)
Definition: Algorithm.h:462
vtkm::cont::Algorithm::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: Algorithm.h:844
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.
vtkm::cont::Algorithm::Reduce
static VTKM_CONT U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: Algorithm.h:665
vtkm::cont::Algorithm
Definition: Algorithm.h:385
vtkm::cont::Algorithm::CountSetBits
static VTKM_CONT vtkm::Id CountSetBits(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::BitField &bits)
Definition: Algorithm.h:499
vtkm::cont::Algorithm::LowerBounds
static VTKM_CONT void LowerBounds(const vtkm::cont::ArrayHandle< vtkm::Id, CIn > &input, vtkm::cont::ArrayHandle< vtkm::Id, COut > &values_output)
Definition: Algorithm.h:648
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::Vec< vtkm::Id, 3 >
vtkm::cont::DeviceAdapterAlgorithm::CountSetBits
static VTKM_CONT vtkm::Id CountSetBits(const vtkm::cont::BitField &bits)
Returns the total number of "1" bits in BitField.
vtkm::cont::Algorithm::Transform
static VTKM_CONT 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:1037
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::BitField
Definition: BitField.h:497
vtkm::cont::Algorithm::ReduceByKey
static VTKM_CONT 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:697
vtkm::cont::Algorithm::Reduce
static VTKM_CONT U Reduce(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: Algorithm.h:656
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::Algorithm::ScanExtended
static VTKM_CONT void ScanExtended(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:901
vtkm::cont::Algorithm::Unique
static VTKM_CONT void Unique(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:1083
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::Schedule
static VTKM_CONT void Schedule(Functor functor, vtkm::Id numInstances)
Schedule many instances of a function to run on concurrent threads.
vtkm::cont::Algorithm::ScanExclusiveByKey
static VTKM_CONT 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:855
vtkm::cont::DeviceAdapterAlgorithm::UpperBounds
static VTKM_CONT 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::cont::Algorithm::LowerBounds
static VTKM_CONT 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:612
vtkm::cont::DeviceAdapterAlgorithm::ReduceByKey
static VTKM_CONT 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::LowerBounds
static VTKM_CONT 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:631
vtkm::cont::ArrayHandle::IsOnDevice
VTKM_CONT bool IsOnDevice(vtkm::cont::DeviceAdapterId device) const
Returns true if the ArrayHandle's data is on the given device.
Definition: ArrayHandle.h:624
vtkm::cont::Algorithm::Sort
static VTKM_CONT void Sort(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: Algorithm.h:978
vtkm::cont::DeviceAdapterAlgorithm::ScanInclusiveByKey
static VTKM_CONT 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::Unique
static VTKM_CONT void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:1069
vtkm::cont::Algorithm::Synchronize
static VTKM_CONT void Synchronize()
Definition: Algorithm.h:1027
vtkm::cont::Algorithm::ScanInclusive
static VTKM_CONT T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor)
Definition: Algorithm.h:758
vtkm::cont::Algorithm::Schedule
static VTKM_CONT void Schedule(Functor functor, vtkm::Id3 rangeMax)
Definition: Algorithm.h:958
ExecutionObjectBase.h
Token.h
vtkm::cont::Algorithm::SortByKey
static VTKM_CONT void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: Algorithm.h:1000
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::BitField &bits, bool value)
Definition: Algorithm.h:526
vtkm::cont::Algorithm::ScanInclusiveByKey
static VTKM_CONT 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:787
vtkm::cont::Algorithm::Fill
static VTKM_CONT void Fill(vtkm::cont::DeviceAdapterId devId, vtkm::cont::BitField &bits, WordType word)
Definition: Algorithm.h:556
vtkm::cont::Algorithm::Copy
static VTKM_CONT void Copy(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:427
vtkm::cont::TryExecute
VTKM_CONT 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::DeviceAdapterAlgorithm::ScanExclusiveByKey
static VTKM_CONT T class BinaryFunctor VTKM_CONT 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_IS_DEVICE_ADAPTER_TAG
#define VTKM_IS_DEVICE_ADAPTER_TAG(tag)
Checks that the argument is a proper device adapter tag.
Definition: DeviceAdapterTag.h:164