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>
40 using DevTag = 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 <
class FunctorType>
367 vtkm::exec::openmp::internal::TaskTiling1D kernel(functor);
368 ScheduleTask(kernel, numInstances);
371 template <
class FunctorType>
376 vtkm::exec::openmp::internal::TaskTiling3D kernel(functor);
377 ScheduleTask(kernel, rangeMax);
393 template <
typename WorkletType,
typename InvocationType>
394 static vtkm::exec::openmp::internal::TaskTiling1D
MakeTask(
const WorkletType& worklet,
395 const InvocationType& invocation,
398 return vtkm::exec::openmp::internal::TaskTiling1D(worklet, invocation);
401 template <
typename WorkletType,
typename InvocationType>
402 static vtkm::exec::openmp::internal::TaskTiling3D
MakeTask(
const WorkletType& worklet,
403 const InvocationType& invocation,
406 return vtkm::exec::openmp::internal::TaskTiling3D(worklet, invocation);
412 #endif //vtk_m_cont_openmp_internal_DeviceAdapterAlgorithmOpenMP_h
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT vtkm::cont::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorBegin(const PortalType &portal)
Convenience function for converting an ArrayPortal to a begin iterator.
Definition: ArrayPortalToIterators.h:178
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
static VTKM_CONT T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:254
static VTKM_CONT 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
vtkm::Id NumChunks
Definition: FunctorsOpenMP.h:191
static VTKM_CONT void Unique(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmOpenMP.h:339
Manages an array-worth of data.
Definition: ArrayHandle.h:283
Groups connected points that have the same field value.
Definition: Atomic.h:19
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmOpenMP.h:303
static vtkm::exec::openmp::internal::TaskTiling3D MakeTask(const WorkletType &worklet, const InvocationType &invocation, vtkm::Id3)
Definition: DeviceAdapterAlgorithmOpenMP.h:402
static VTKM_CONT U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: DeviceAdapterAlgorithmOpenMP.h:178
The TypeTraits class provides helpful compile-time information about the basic types used in VTKm (an...
Definition: TypeTraits.h:61
VTKM_CONT 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:465
VTKM_CONT 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:574
VTKM_CONT void DetachFromAll()
Detaches this Token from all resources to allow them to be used elsewhere or deleted.
static VTKM_CONT U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Compute a accumulated sum operation on the input ArrayHandle.
static VTKM_CONT void Schedule(FunctorType functor, vtkm::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmOpenMP.h:372
VTKM_CONT 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:593
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Unstable ascending sort of input array.
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
static VTKM_CONT void Schedule(FunctorType functor, vtkm::Id numInstances)
Definition: DeviceAdapterAlgorithmOpenMP.h:363
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.
static VTKM_CONT T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:220
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
Definition: ParallelScanOpenMP.h:56
static VTKM_CONT void Copy(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:44
Binary Predicate that takes two arguments argument x, and y and returns True if and only if x is less...
Definition: BinaryPredicates.h:45
void parallel_sort(vtkm::cont::ArrayHandle< T, Container > &, BinaryCompare)
Definition: ParallelSortOpenMP.h:75
static VTKM_CONT T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue)
Definition: DeviceAdapterAlgorithmOpenMP.h:263
void ReduceByKeyHelper(KeysInArray keysInArray, ValuesInArray valuesInArray, KeysOutArray keysOutArray, ValuesOutArray valuesOutArray, BinaryFunctor functor)
Definition: FunctorsOpenMP.h:514
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: DeviceAdapterAlgorithmOpenMP.h:75
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.
static VTKM_CONT U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmOpenMP.h:186
static VTKM_CONT void Synchronize()
Definition: DeviceAdapterAlgorithmOpenMP.h:380
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
#define VTKM_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:266
void Initialize(vtkm::Id numValues, vtkm::Id valueSize)
Definition: FunctorsOpenMP.h:197
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:41
static VTKM_CONT T U
Definition: DeviceAdapterAlgorithm.h:347
static VTKM_CONT void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Reduce an array to only the unique values it contains.
#define VTKM_OPENMP_DIRECTIVE(directive)
Definition: FunctorsOpenMP.h:37
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: DeviceAdapterAlgorithmOpenMP.h:64
Definition: FunctorsOpenMP.h:635
std::false_type OpenMPReductionSupported
Definition: FunctorsOpenMP.h:303
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.
static vtkm::exec::openmp::internal::TaskTiling1D MakeTask(const WorkletType &worklet, const InvocationType &invocation, vtkm::Id)
Definition: DeviceAdapterAlgorithmOpenMP.h:394
vtkm::Id Reduce(OutIterT data)
Definition: FunctorsOpenMP.h:236
static VTKM_CONT T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor)
Definition: DeviceAdapterAlgorithmOpenMP.h:229
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 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 func)
Definition: DeviceAdapterAlgorithmOpenMP.h:208
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Storage > &values)
Unstable ascending sort of input array.
Definition: DeviceAdapterAlgorithmOpenMP.h:295
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 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:613
static VTKM_CONT 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
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.
Definition: FunctorsOpenMP.h:185
void parallel_sort_bykey(vtkm::cont::ArrayHandle< T, StorageT > &, vtkm::cont::ArrayHandle< U, StorageU > &, BinaryCompare)
Definition: ParallelSortOpenMP.h:244
static VTKM_CONT void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmOpenMP.h:321
DeviceAdapterTagOpenMP DevTag
Definition: DeviceAdapterAlgorithmOpenMP.h:40
static VTKM_EXEC_CONT T ZeroInitialization()
Definition: TypeTraits.h:75
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
OPenMP implementation for Control Environment.
Definition: FunctorsOpenMP.h:63
static VTKM_CONT void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: DeviceAdapterAlgorithmOpenMP.h:331