Go to the documentation of this file.
18 #ifndef viskores_cont_tbb_internal_DeviceAdapterAlgorithmTBB_h
19 #define viskores_cont_tbb_internal_DeviceAdapterAlgorithmTBB_h
42 : viskores::cont::internal::DeviceAdapterAlgorithmGeneral<
43 DeviceAdapterAlgorithm<viskores::cont::DeviceAdapterTagTBB>,
44 viskores::cont::DeviceAdapterTagTBB>
47 template <
typename T,
typename U,
class CIn,
class COut>
62 template <
typename T,
typename U,
class CIn,
class CStencil,
class COut>
70 CopyIf(input, stencil, output, unary_predicate);
73 template <
typename T,
typename U,
class CIn,
class CStencil,
class COut,
class UnaryPredicate>
77 UnaryPredicate unary_predicate)
94 template <
typename T,
typename U,
class CIn,
class COut>
106 if (input == output &&
107 ((outputIndex >= inputStartIndex &&
108 outputIndex < inputStartIndex + numberOfElementsToCopy) ||
109 (inputStartIndex >= outputIndex &&
110 inputStartIndex < outputIndex + numberOfElementsToCopy)))
115 if (inputStartIndex < 0 || numberOfElementsToCopy < 0 || outputIndex < 0 ||
116 inputStartIndex >= inSize)
122 if (inSize < (inputStartIndex + numberOfElementsToCopy))
124 numberOfElementsToCopy = (inSize - inputStartIndex);
128 const viskores::Id copyOutEnd = outputIndex + numberOfElementsToCopy;
129 if (outSize < copyOutEnd)
150 inputPortal, outputPortal, inputStartIndex, outputIndex, numberOfElementsToCopy);
155 template <
typename T,
typename U,
class CIn>
164 template <
typename T,
typename U,
class CIn,
class BinaryFunctor>
167 BinaryFunctor binary_functor)
168 -> decltype(tbb::ReducePortals(input.ReadPortal(), initialValue, binary_functor))
178 template <
typename T,
189 BinaryFunctor binary_functor)
208 template <
typename T,
class CIn,
class COut>
215 return tbb::ScanInclusivePortals(
222 template <
typename T,
class CIn,
class COut,
class BinaryFunctor>
225 BinaryFunctor binary_functor)
230 return tbb::ScanInclusivePortals(
237 template <
typename T,
class CIn,
class COut>
244 return tbb::ScanExclusivePortals(
252 template <
typename T,
class CIn,
class COut,
class BinaryFunctor>
255 BinaryFunctor binary_functor,
256 const T& initialValue)
261 return tbb::ScanExclusivePortals(
269 VISKORES_CONT_EXPORT
static void ScheduleTask(
270 viskores::exec::tbb::internal::TaskTiling1D& functor,
272 VISKORES_CONT_EXPORT
static void ScheduleTask(
273 viskores::exec::tbb::internal::TaskTiling3D& functor,
276 template <
typename H
ints,
typename FunctorType>
280 "Schedule TBB 1D: '%s'",
283 viskores::exec::tbb::internal::TaskTiling1D kernel(functor);
284 ScheduleTask(kernel, numInstances);
287 template <
typename FunctorType>
290 Schedule(viskores::cont::internal::HintList<>{}, functor, numInstances);
293 template <
typename H
ints,
typename FunctorType>
297 "Schedule TBB 3D: '%s'",
300 viskores::exec::tbb::internal::TaskTiling3D kernel(functor);
301 ScheduleTask(kernel, rangeMax);
304 template <
typename FunctorType>
307 Schedule(viskores::cont::internal::HintList<>{}, functor, rangeMax);
313 template <
typename T,
class Container>
323 template <
typename T,
class Container,
class BinaryCompare>
325 BinaryCompare binary_compare)
332 template <
typename T,
typename U,
class StorageT,
class StorageU>
341 template <
typename T,
typename U,
class StorageT,
class StorageU,
class BinaryCompare>
344 BinaryCompare binary_compare)
351 template <
typename T,
class Storage>
354 Unique(values, std::equal_to<T>());
357 template <
typename T,
class Storage,
class BinaryCompare>
359 BinaryCompare binary_compare)
420 "Start() function should be called first then trying to call Stop() and"
421 " GetElapsedTime().");
425 ::tbb::tick_count startTime = this->
StartTime;
428 ::tbb::tick_count::interval_t elapsedTime = stopTime - startTime;
436 return ::tbb::tick_count::now();
450 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
451 static viskores::exec::tbb::internal::TaskTiling1D
MakeTask(WorkletType& worklet,
452 InvocationType& invocation,
457 return viskores::exec::tbb::internal::TaskTiling1D(worklet, invocation);
460 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
461 static viskores::exec::tbb::internal::TaskTiling3D
MakeTask(WorkletType& worklet,
462 InvocationType& invocation,
467 return viskores::exec::tbb::internal::TaskTiling3D(worklet, invocation);
470 template <
typename WorkletType,
typename InvocationType,
typename RangeType>
472 InvocationType& invocation,
473 const RangeType& range)
475 return MakeTask<viskores::cont::internal::HintList<>>(worklet, invocation, range);
481 #endif //viskores_cont_tbb_internal_DeviceAdapterAlgorithmTBB_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
@ Error
Important but non-fatal errors, such as device fail-over.
viskores::Id CopyIfPortals(InputPortalType inputPortal, StencilPortalType stencilPortal, OutputPortalType outputPortal, UnaryPredicateType unaryPredicate)
Definition: FunctorsTBB.h:358
bool Started() const
Definition: DeviceAdapterAlgorithmTBB.h:408
bool Ready() const
Definition: DeviceAdapterAlgorithmTBB.h:412
static T ScanInclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:209
#define VISKORES_LOG_SCOPE(level,...)
Definition: Logging.h:219
bool StartReady
Definition: DeviceAdapterAlgorithmTBB.h:440
TimeStamp GetCurrentTime() const
Definition: DeviceAdapterAlgorithm.h:695
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
bool StartReady
Definition: DeviceAdapterAlgorithm.h:714
bool Stopped() const
Definition: DeviceAdapterAlgorithmTBB.h:410
Manages an array-worth of data.
Definition: ArrayHandle.h:313
static void Schedule(FunctorType &&functor, viskores::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmTBB.h:305
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: DeviceAdapterAlgorithmTBB.h:95
void parallel_sort(viskores::cont::ArrayHandle< T, Container > &, BinaryCompare)
Definition: ParallelSortTBB.h:87
static void Unique(viskores::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmTBB.h:358
void Stop()
Definition: DeviceAdapterAlgorithmTBB.h:402
static T U
Definition: DeviceAdapterAlgorithm.h:358
void Reset()
Resets the timer.
Definition: DeviceAdapterAlgorithm.h:642
::tbb::tick_count GetCurrentTime() const
Definition: DeviceAdapterAlgorithmTBB.h:433
static U Reduce(const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue)
Compute a accumulated sum operation on the input ArrayHandle.
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: DeviceAdapterAlgorithmTBB.h:74
static void Schedule(Hints, FunctorType functor, viskores::Id numInstances)
Definition: DeviceAdapterAlgorithmTBB.h:277
static void SortByKey(viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmTBB.h:342
static void Sort(viskores::cont::ArrayHandle< T, Container > &values)
Definition: DeviceAdapterAlgorithmTBB.h:314
The TypeTraits class provides helpful compile-time information about the basic types used in Viskores...
Definition: TypeTraits.h:69
static viskores::exec::tbb::internal::TaskTiling3D MakeTask(WorkletType &worklet, InvocationType &invocation, viskores::Id3, Hints=Hints{})
Definition: DeviceAdapterAlgorithmTBB.h:461
static void Copy(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< U, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:48
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
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.
#define VISKORES_CONT
Definition: ExportMacros.h:65
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 binary_functor)
Definition: DeviceAdapterAlgorithmTBB.h:185
static T ScanInclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmTBB.h:223
Groups connected points that have the same field value.
Definition: Atomic.h:27
Predicate that takes a single argument x, and returns True if it isn't the identity of the Type T.
Definition: UnaryPredicates.h:40
void CopyPortals(const InputPortalType &inPortal, const OutputPortalType &outPortal, viskores::Id inOffset, viskores::Id outOffset, viskores::Id numValues)
Definition: FunctorsTBB.h:154
void DetachFromAll()
Detaches this Token from all resources to allow them to be used elsewhere or deleted.
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
TimeStamp StopTime
Definition: DeviceAdapterAlgorithm.h:717
::tbb::tick_count StartTime
Definition: DeviceAdapterAlgorithmTBB.h:442
static void Unique(viskores::cont::ArrayHandle< T, Storage > &values)
Reduce an array to only the unique values it contains.
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
void parallel_sort_bykey(viskores::cont::ArrayHandle< T, StorageT > &, viskores::cont::ArrayHandle< U, StorageU > &, BinaryCompare)
Definition: ParallelSortTBB.h:236
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
void Start()
Definition: DeviceAdapterAlgorithmTBB.h:395
static void Schedule(Hints, FunctorType functor, viskores::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmTBB.h:294
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
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
static T ScanExclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:238
Class providing a device-specific timer.
Definition: DeviceAdapterAlgorithm.h:625
void Reset()
Definition: DeviceAdapterAlgorithmTBB.h:389
viskores::Id ReduceByKeyPortals(KeysInPortalType keysInPortal, ValuesInPortalType valuesInPortal, KeysOutPortalType keysOutPortal, ValuesOutPortalType valuesOutPortal, BinaryOperationType binaryOperation)
Definition: FunctorsTBB.h:801
static void CopyIf(const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< U, CStencil > &stencil, viskores::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:63
static auto Reduce(const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor) -> decltype(tbb::ReducePortals(input.ReadPortal(), initialValue, binary_functor))
Definition: DeviceAdapterAlgorithmTBB.h:165
static viskores::exec::tbb::internal::TaskTiling1D MakeTask(WorkletType &worklet, InvocationType &invocation, viskores::Id, Hints=Hints{})
Definition: DeviceAdapterAlgorithmTBB.h:451
DeviceAdapterTimerImplementation()
Definition: DeviceAdapterAlgorithmTBB.h:387
static auto Reduce(const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue) -> decltype(Reduce(input, initialValue, viskores::Add
Definition: DeviceAdapterAlgorithmTBB.h:156
static void Unique(viskores::cont::ArrayHandle< T, Storage > &values)
Definition: DeviceAdapterAlgorithmTBB.h:352
#define VISKORES_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:216
Tag for a device adapter that uses the Intel Threading Building Blocks library to run algorithms on m...
Definition: DeviceAdapterTagTBB.h:37
TimeStamp StartTime
Definition: DeviceAdapterAlgorithm.h:716
#define VISKORES_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:225
static void Sort(viskores::cont::ArrayHandle< T, Container > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmTBB.h:324
bool StopReady
Definition: DeviceAdapterAlgorithmTBB.h:441
@ 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 Synchronize()
Definition: DeviceAdapterAlgorithmTBB.h:372
static auto MakeTask(WorkletType &worklet, InvocationType &invocation, const RangeType &range)
Definition: DeviceAdapterAlgorithmTBB.h:471
static T ScanExclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor, const T &initialValue)
Definition: DeviceAdapterAlgorithmTBB.h:253
::tbb::tick_count StopTime
Definition: DeviceAdapterAlgorithmTBB.h:443
static void SortByKey(viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values)
Definition: DeviceAdapterAlgorithmTBB.h:333
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:169
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
static void Schedule(FunctorType &&functor, viskores::Id numInstances)
Definition: DeviceAdapterAlgorithmTBB.h:288
viskores::Id UniquePortals(PortalType portal, BinaryOperationType binaryOperation)
Definition: FunctorsTBB.h:1381
std::string TypeToString(const std::type_info &t)
Use RTTI information to retrieve the name of the type T.
static void Schedule(Functor functor, viskores::Id numInstances)
Schedule many instances of a function to run on concurrent threads.
viskores::Float64 GetElapsedTime() const
Definition: DeviceAdapterAlgorithmTBB.h:414
bool StopReady
Definition: DeviceAdapterAlgorithm.h:715