Go to the documentation of this file.
18 #ifndef viskores_cont_openmp_internal_DeviceAdapterAlgorithmOpenMP_h
19 #define viskores_cont_openmp_internal_DeviceAdapterAlgorithmOpenMP_h
35 #include <type_traits>
44 : viskores::cont::internal::DeviceAdapterAlgorithmGeneral<
45 DeviceAdapterAlgorithm<viskores::cont::DeviceAdapterTagOpenMP>,
46 viskores::cont::DeviceAdapterTagOpenMP>
51 template <
typename T,
typename U,
class CIn,
class COut>
68 CopyHelper(inputPortal, outputPortal, 0, 0, inSize);
71 template <
typename T,
typename U,
class CIn,
class CStencil,
class COut>
79 CopyIf(input, stencil, output, unary_predicate);
82 template <
typename T,
typename U,
class CIn,
class CStencil,
class COut,
class UnaryPredicate>
86 UnaryPredicate unary_predicate)
115 helper.
CopyIf(inIter, stencilIter, outIter, unary_predicate, i);
125 template <
typename T,
typename U,
class CIn,
class COut>
139 if (input == output &&
140 ((outputIndex >= inputStartIndex && outputIndex < inputStartIndex + numberOfValuesToCopy) ||
141 (inputStartIndex >= outputIndex && inputStartIndex < outputIndex + numberOfValuesToCopy)))
146 if (inputStartIndex < 0 || numberOfValuesToCopy < 0 || outputIndex < 0 ||
147 inputStartIndex >= inSize)
153 if (inSize < (inputStartIndex + numberOfValuesToCopy))
155 numberOfValuesToCopy = (inSize - inputStartIndex);
159 const viskores::Id copyOutEnd = outputIndex + numberOfValuesToCopy;
160 if (outSize < copyOutEnd)
180 CopyHelper(inputPortal, outputPortal, inputStartIndex, outputIndex, numberOfValuesToCopy);
185 template <
typename T,
typename U,
class CIn>
193 template <
typename T,
typename U,
class CIn,
class BinaryFunctor>
196 BinaryFunctor binary_functor)
206 return ReduceHelper::Execute(portal, initialValue, binary_functor, fastPath);
209 template <
typename T,
227 template <
typename T,
class CIn,
class COut>
236 template <
typename T,
class CIn,
class COut,
class BinaryFunctor>
239 BinaryFunctor binaryFunctor)
261 template <
typename T,
class CIn,
class COut>
271 template <
typename T,
class CIn,
class COut,
class BinaryFunctor>
274 BinaryFunctor binaryFunctor,
275 const T& initialValue)
303 template <
typename T,
class Storage>
311 template <
typename T,
class Storage,
class BinaryCompare>
313 BinaryCompare binary_compare)
320 template <
typename T,
typename U,
class StorageT,
class StorageU>
329 template <
typename T,
typename U,
class StorageT,
class StorageU,
class BinaryCompare>
332 BinaryCompare binary_compare)
339 template <
typename T,
class Storage>
344 Unique(values, std::equal_to<T>());
347 template <
typename T,
class Storage,
class BinaryCompare>
349 BinaryCompare binary_compare)
357 using IterT =
typename std::decay<decltype(iter)>::type;
360 Uniqifier uniquifier(iter, portal.GetNumberOfValues(), binary_compare);
366 VISKORES_CONT_EXPORT
static void ScheduleTask(
367 viskores::exec::openmp::internal::TaskTiling1D& functor,
369 VISKORES_CONT_EXPORT
static void ScheduleTask(
370 viskores::exec::openmp::internal::TaskTiling3D& functor,
373 template <
typename H
ints,
typename FunctorType>
378 viskores::exec::openmp::internal::TaskTiling1D kernel(functor);
379 ScheduleTask(kernel, numInstances);
382 template <
typename FunctorType>
385 Schedule(viskores::cont::internal::HintList<>{}, functor, numInstances);
388 template <
typename H
ints,
typename FunctorType>
393 viskores::exec::openmp::internal::TaskTiling3D kernel(functor);
394 ScheduleTask(kernel, rangeMax);
397 template <
typename FunctorType>
400 Schedule(viskores::cont::internal::HintList<>{}, functor, rangeMax);
416 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
417 static viskores::exec::openmp::internal::TaskTiling1D
MakeTask(
const WorkletType& worklet,
418 const InvocationType& invocation,
423 return viskores::exec::openmp::internal::TaskTiling1D(worklet, invocation);
426 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
427 static viskores::exec::openmp::internal::TaskTiling3D
MakeTask(
const WorkletType& worklet,
428 const InvocationType& invocation,
433 return viskores::exec::openmp::internal::TaskTiling3D(worklet, invocation);
436 template <
typename WorkletType,
typename InvocationType,
typename RangeType>
438 InvocationType& invocation,
439 const RangeType& range)
441 return MakeTask<viskores::cont::internal::HintList<>>(worklet, invocation, range);
447 #endif //viskores_cont_openmp_internal_DeviceAdapterAlgorithmOpenMP_h
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.
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:49
static T ScanExclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue)
Definition: DeviceAdapterAlgorithmOpenMP.h:272
void parallel_sort_bykey(viskores::cont::ArrayHandle< T, StorageT > &, viskores::cont::ArrayHandle< U, StorageU > &, BinaryCompare)
Definition: ParallelSortOpenMP.h:255
static void Schedule(Hints, FunctorType functor, viskores::Id numInstances)
Definition: DeviceAdapterAlgorithmOpenMP.h:374
Binary Predicate that takes two arguments argument x, and y and returns True if and only if x is less...
Definition: BinaryPredicates.h:53
static void Synchronize()
Definition: DeviceAdapterAlgorithmOpenMP.h:403
static void SortByKey(viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmOpenMP.h:330
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
static viskores::exec::openmp::internal::TaskTiling3D MakeTask(const WorkletType &worklet, const InvocationType &invocation, viskores::Id3, Hints=Hints{})
Definition: DeviceAdapterAlgorithmOpenMP.h:427
static T ZeroInitialization()
A static function that returns 0 (or the closest equivalent to it) for the given type.
Definition: TypeTraits.h:85
static U Reduce(const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmOpenMP.h:194
static void Unique(viskores::cont::ArrayHandle< T, Storage > &values)
Definition: DeviceAdapterAlgorithmOpenMP.h:340
static viskores::exec::openmp::internal::TaskTiling1D MakeTask(const WorkletType &worklet, const InvocationType &invocation, viskores::Id, Hints=Hints{})
Definition: DeviceAdapterAlgorithmOpenMP.h:417
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::Id Reduce(OutIterT data)
Definition: FunctorsOpenMP.h:244
static T U
Definition: DeviceAdapterAlgorithm.h:358
#define VISKORES_OPENMP_DIRECTIVE(directive)
Definition: FunctorsOpenMP.h:45
OPenMP implementation for Control Environment.
Definition: FunctorsOpenMP.h:71
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.
static U Reduce(const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue)
Compute a accumulated sum operation on the input ArrayHandle.
static void Sort(viskores::cont::ArrayHandle< T, Storage > &values)
Unstable ascending sort of input array.
static void Sort(viskores::cont::ArrayHandle< T, Storage > &values)
Unstable ascending sort of input array.
Definition: DeviceAdapterAlgorithmOpenMP.h:304
static auto MakeTask(WorkletType &worklet, InvocationType &invocation, const RangeType &range)
Definition: DeviceAdapterAlgorithmOpenMP.h:437
Tag for a device adapter that uses OpenMP compiler extensions to run algorithms on multiple threads.
Definition: DeviceAdapterTagOpenMP.h:35
void CopyIf(InIterT inIter, StencilIterT stencilIter, OutIterT outIter, PredicateT pred, viskores::Id chunk)
Definition: FunctorsOpenMP.h:222
static void Copy(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< U, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:52
static void Unique(viskores::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmOpenMP.h:348
static void CopyIf(const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< U, CStencil > &stencil, viskores::cont::ArrayHandle< T, COut > &output, UnaryPredicate unary_predicate)
Definition: DeviceAdapterAlgorithmOpenMP.h:83
The TypeTraits class provides helpful compile-time information about the basic types used in Viskores...
Definition: TypeTraits.h:69
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
void parallel_sort(viskores::cont::ArrayHandle< T, Container > &, BinaryCompare)
Definition: ParallelSortOpenMP.h:83
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.
static T ScanInclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor)
Definition: DeviceAdapterAlgorithmOpenMP.h:237
static void SortByKey(viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values)
Unstable ascending sort of keys and values.
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
static bool CopySubRange(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::Id inputStartIndex, viskores::Id numberOfValuesToCopy, viskores::cont::ArrayHandle< U, COut > &output, viskores::Id outputIndex=0)
Definition: DeviceAdapterAlgorithmOpenMP.h:126
Predicate that takes a single argument x, and returns True if it isn't the identity of the Type T.
Definition: UnaryPredicates.h:40
static void CopyIf(const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< U, CStencil > &stencil, viskores::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:72
void DetachFromAll()
Detaches this Token from all resources to allow them to be used elsewhere or deleted.
viskores::Id NumChunks
Definition: FunctorsOpenMP.h:199
Definition: FunctorsOpenMP.h:644
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::cont::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorBegin(const PortalType &portal)
Convenience function for converting an ArrayPortal to a begin iterator.
Definition: ArrayPortalToIterators.h:189
static T ScanExclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:262
void ReduceByKeyHelper(KeysInArray keysInArray, ValuesInArray valuesInArray, KeysOutArray keysOutArray, ValuesOutArray valuesOutArray, BinaryFunctor functor)
Definition: FunctorsOpenMP.h:522
static void Unique(viskores::cont::ArrayHandle< T, Storage > &values)
Reduce an array to only the unique values it contains.
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.
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::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
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
Definition: ParallelScanOpenMP.h:64
static void Schedule(Hints, FunctorType functor, viskores::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmOpenMP.h:389
static void Schedule(FunctorType &&functor, viskores::Id numInstances)
Definition: DeviceAdapterAlgorithmOpenMP.h:383
static void SortByKey(viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values)
Definition: DeviceAdapterAlgorithmOpenMP.h:321
#define VISKORES_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:225
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
Class providing a device-specific support for selecting the optimal Task type for a given worklet.
Definition: DeviceAdapterAlgorithm.h:757
static void ReduceByKey(const viskores::cont::ArrayHandle< T, CKeyIn > &keys, const viskores::cont::ArrayHandle< U, CValIn > &values, viskores::cont::ArrayHandle< T, CKeyOut > &keys_output, viskores::cont::ArrayHandle< U, CValOut > &values_output, BinaryFunctor func)
Definition: DeviceAdapterAlgorithmOpenMP.h:216
Definition: FunctorsOpenMP.h:193
static T ScanInclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmOpenMP.h:228
std::false_type OpenMPReductionSupported
Definition: FunctorsOpenMP.h:311
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
static U Reduce(const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: DeviceAdapterAlgorithmOpenMP.h:186
void Initialize(viskores::Id numValues, viskores::Id valueSize)
Definition: FunctorsOpenMP.h:205
static void Sort(viskores::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmOpenMP.h:312
static void Schedule(FunctorType &&functor, viskores::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmOpenMP.h:398
static void Schedule(Functor functor, viskores::Id numInstances)
Schedule many instances of a function to run on concurrent threads.