Go to the documentation of this file.
10 #ifndef vtk_m_cont_openmp_internal_DeviceAdapterAlgorithmOpenMP_h
11 #define vtk_m_cont_openmp_internal_DeviceAdapterAlgorithmOpenMP_h
27 #include <type_traits>
36 : vtkm::cont::internal::DeviceAdapterAlgorithmGeneral<
37 DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagOpenMP>,
38 vtkm::cont::DeviceAdapterTagOpenMP>
43 template <
typename T,
typename U,
class CIn,
class COut>
60 CopyHelper(inputPortal, outputPortal, 0, 0, inSize);
63 template <
typename T,
typename U,
class CIn,
class CStencil,
class COut>
71 CopyIf(input, stencil, output, unary_predicate);
74 template <
typename T,
typename U,
class CIn,
class CStencil,
class COut,
class UnaryPredicate>
78 UnaryPredicate unary_predicate)
107 helper.
CopyIf(inIter, stencilIter, outIter, unary_predicate, i);
117 template <
typename T,
typename U,
class CIn,
class COut>
131 if (input == output &&
132 ((outputIndex >= inputStartIndex && outputIndex < inputStartIndex + numberOfValuesToCopy) ||
133 (inputStartIndex >= outputIndex && inputStartIndex < outputIndex + numberOfValuesToCopy)))
138 if (inputStartIndex < 0 || numberOfValuesToCopy < 0 || outputIndex < 0 ||
139 inputStartIndex >= inSize)
145 if (inSize < (inputStartIndex + numberOfValuesToCopy))
147 numberOfValuesToCopy = (inSize - inputStartIndex);
151 const vtkm::Id copyOutEnd = outputIndex + numberOfValuesToCopy;
152 if (outSize < copyOutEnd)
172 CopyHelper(inputPortal, outputPortal, inputStartIndex, outputIndex, numberOfValuesToCopy);
177 template <
typename T,
typename U,
class CIn>
185 template <
typename T,
typename U,
class CIn,
class BinaryFunctor>
188 BinaryFunctor binary_functor)
198 return ReduceHelper::Execute(portal, initialValue, binary_functor, fastPath);
201 template <
typename T,
219 template <
typename T,
class CIn,
class COut>
228 template <
typename T,
class CIn,
class COut,
class BinaryFunctor>
231 BinaryFunctor binaryFunctor)
250 return impl.Execute(
vtkm::Id2(0, numVals));
253 template <
typename T,
class CIn,
class COut>
262 template <
typename T,
class CIn,
class COut,
class BinaryFunctor>
265 BinaryFunctor binaryFunctor,
266 const T& initialValue)
286 return impl.Execute(
vtkm::Id2(0, numVals));
294 template <
typename T,
class Storage>
302 template <
typename T,
class Storage,
class BinaryCompare>
304 BinaryCompare binary_compare)
311 template <
typename T,
typename U,
class StorageT,
class StorageU>
320 template <
typename T,
typename U,
class StorageT,
class StorageU,
class BinaryCompare>
323 BinaryCompare binary_compare)
330 template <
typename T,
class Storage>
335 Unique(values, std::equal_to<T>());
338 template <
typename T,
class Storage,
class BinaryCompare>
340 BinaryCompare binary_compare)
348 using IterT =
typename std::decay<decltype(iter)>::type;
351 Uniqifier uniquifier(iter, portal.GetNumberOfValues(), binary_compare);
352 vtkm::Id outSize = uniquifier.Execute();
357 VTKM_CONT_EXPORT static void ScheduleTask(vtkm::exec::openmp::internal::TaskTiling1D& functor,
359 VTKM_CONT_EXPORT static void ScheduleTask(vtkm::exec::openmp::internal::TaskTiling3D& functor,
362 template <
typename H
ints,
typename FunctorType>
367 vtkm::exec::openmp::internal::TaskTiling1D kernel(functor);
368 ScheduleTask(kernel, numInstances);
371 template <
typename FunctorType>
374 Schedule(vtkm::cont::internal::HintList<>{}, functor, numInstances);
377 template <
typename H
ints,
typename FunctorType>
382 vtkm::exec::openmp::internal::TaskTiling3D kernel(functor);
383 ScheduleTask(kernel, rangeMax);
386 template <
typename FunctorType>
389 Schedule(vtkm::cont::internal::HintList<>{}, functor, rangeMax);
405 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
406 static vtkm::exec::openmp::internal::TaskTiling1D
MakeTask(
const WorkletType& worklet,
407 const InvocationType& invocation,
412 return vtkm::exec::openmp::internal::TaskTiling1D(worklet, invocation);
415 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
416 static vtkm::exec::openmp::internal::TaskTiling3D
MakeTask(
const WorkletType& worklet,
417 const InvocationType& invocation,
422 return vtkm::exec::openmp::internal::TaskTiling3D(worklet, invocation);
425 template <
typename WorkletType,
typename InvocationType,
typename RangeType>
427 InvocationType& invocation,
428 const RangeType& range)
430 return MakeTask<vtkm::cont::internal::HintList<>>(worklet, invocation, range);
436 #endif //vtk_m_cont_openmp_internal_DeviceAdapterAlgorithmOpenMP_h
static void Synchronize()
Definition: DeviceAdapterAlgorithmOpenMP.h:392
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: DeviceAdapterAlgorithmOpenMP.h:178
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.
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: DeviceAdapterAlgorithmOpenMP.h:312
void CopyIf(InIterT inIter, StencilIterT stencilIter, OutIterT outIter, PredicateT pred, vtkm::Id chunk)
Definition: FunctorsOpenMP.h:214
static vtkm::exec::openmp::internal::TaskTiling1D MakeTask(const WorkletType &worklet, const InvocationType &invocation, vtkm::Id, Hints=Hints{})
Definition: DeviceAdapterAlgorithmOpenMP.h:406
static bool CopySubRange(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::Id inputStartIndex, vtkm::Id numberOfValuesToCopy, vtkm::cont::ArrayHandle< U, COut > &output, vtkm::Id outputIndex=0)
Definition: DeviceAdapterAlgorithmOpenMP.h:118
vtkm::Id NumChunks
Definition: FunctorsOpenMP.h:191
Manages an array-worth of data.
Definition: ArrayHandle.h:300
Groups connected points that have the same field value.
Definition: Atomic.h:19
Tag for a device adapter that uses OpenMP compiler extensions to run algorithms on multiple threads.
Definition: DeviceAdapterTagOpenMP.h:25
The TypeTraits class provides helpful compile-time information about the basic types used in VTKm (an...
Definition: TypeTraits.h:61
static void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Unstable ascending sort of input array.
Definition: DeviceAdapterAlgorithmOpenMP.h:295
static void Schedule(Functor functor, vtkm::Id numInstances)
Schedule many instances of a function to run on concurrent threads.
static void Schedule(Hints, FunctorType functor, vtkm::Id numInstances)
Definition: DeviceAdapterAlgorithmOpenMP.h:363
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmOpenMP.h:321
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmOpenMP.h:339
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Reduce an array to only the unique values it contains.
static void Copy(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:44
static vtkm::exec::openmp::internal::TaskTiling3D MakeTask(const WorkletType &worklet, const InvocationType &invocation, vtkm::Id3, Hints=Hints{})
Definition: DeviceAdapterAlgorithmOpenMP.h:416
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
Definition: ParallelScanOpenMP.h:56
static void Schedule(Hints, FunctorType functor, vtkm::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmOpenMP.h:378
Binary Predicate that takes two arguments argument x, and y and returns True if and only if x is less...
Definition: BinaryPredicates.h:45
WritePortalType PrepareForInPlace(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used in an in-place operation (both as input and output) in the execution e...
Definition: ArrayHandle.h:618
void parallel_sort(vtkm::cont::ArrayHandle< T, Container > &, BinaryCompare)
Definition: ParallelSortOpenMP.h:75
void ReduceByKeyHelper(KeysInArray keysInArray, ValuesInArray valuesInArray, KeysOutArray keysOutArray, ValuesOutArray valuesOutArray, BinaryFunctor functor)
Definition: FunctorsOpenMP.h:514
static void Schedule(FunctorType &&functor, vtkm::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmOpenMP.h:387
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.
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 func)
Definition: DeviceAdapterAlgorithmOpenMP.h:208
static void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Unstable ascending sort of input array.
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor)
Definition: DeviceAdapterAlgorithmOpenMP.h:229
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
static T U
Definition: DeviceAdapterAlgorithm.h:347
WritePortalType PrepareForOutput(vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares (allocates) this array to be used as an output from an operation in the execution environmen...
Definition: ArrayHandle.h:638
static void CopyIf(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:64
static auto MakeTask(WorkletType &worklet, InvocationType &invocation, const RangeType &range)
Definition: DeviceAdapterAlgorithmOpenMP.h:426
Class providing a device-specific support for selecting the optimal Task type for a given worklet.
Definition: DeviceAdapterAlgorithm.h:744
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
#define VTKM_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:214
void Initialize(vtkm::Id numValues, vtkm::Id valueSize)
Definition: FunctorsOpenMP.h:197
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:41
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Unstable ascending sort of keys and values.
void DetachFromAll()
Detaches this Token from all resources to allow them to be used elsewhere or deleted.
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmOpenMP.h:186
#define VTKM_OPENMP_DIRECTIVE(directive)
Definition: FunctorsOpenMP.h:37
static void Sort(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmOpenMP.h:303
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.
Definition: FunctorsOpenMP.h:635
std::false_type OpenMPReductionSupported
Definition: FunctorsOpenMP.h:303
vtkm::Id Reduce(OutIterT data)
Definition: FunctorsOpenMP.h:236
Predicate that takes a single argument x, and returns True if it isn't the identity of the Type T.
Definition: UnaryPredicates.h:32
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:220
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::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorBegin(const PortalType &portal)
Convenience function for converting an ArrayPortal to a begin iterator.
Definition: ArrayPortalToIterators.h:178
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:254
ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used as an input to an operation in the execution environment.
Definition: ArrayHandle.h:599
static T ZeroInitialization()
A static function that returns 0 (or the closest equivalent to it) for the given type.
Definition: TypeTraits.h:77
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Compute a accumulated sum operation on the input ArrayHandle.
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: DeviceAdapterAlgorithmOpenMP.h:331
void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:490
Definition: FunctorsOpenMP.h:185
void parallel_sort_bykey(vtkm::cont::ArrayHandle< T, StorageT > &, vtkm::cont::ArrayHandle< U, StorageU > &, BinaryCompare)
Definition: ParallelSortOpenMP.h:244
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue)
Definition: DeviceAdapterAlgorithmOpenMP.h:263
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: DeviceAdapterAlgorithmOpenMP.h:75
static void Schedule(FunctorType &&functor, vtkm::Id numInstances)
Definition: DeviceAdapterAlgorithmOpenMP.h:372
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
OPenMP implementation for Control Environment.
Definition: FunctorsOpenMP.h:63