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