Go to the documentation of this file.
10 #ifndef vtk_m_cont_tbb_internal_DeviceAdapterAlgorithmTBB_h
11 #define vtk_m_cont_tbb_internal_DeviceAdapterAlgorithmTBB_h
34 : vtkm::cont::internal::DeviceAdapterAlgorithmGeneral<
35 DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagTBB>,
36 vtkm::cont::DeviceAdapterTagTBB>
39 template <
typename T,
typename U,
class CIn,
class COut>
54 template <
typename T,
typename U,
class CIn,
class CStencil,
class COut>
62 CopyIf(input, stencil, output, unary_predicate);
65 template <
typename T,
typename U,
class CIn,
class CStencil,
class COut,
class UnaryPredicate>
69 UnaryPredicate unary_predicate)
86 template <
typename T,
typename U,
class CIn,
class COut>
98 if (input == output &&
99 ((outputIndex >= inputStartIndex &&
100 outputIndex < inputStartIndex + numberOfElementsToCopy) ||
101 (inputStartIndex >= outputIndex &&
102 inputStartIndex < outputIndex + numberOfElementsToCopy)))
107 if (inputStartIndex < 0 || numberOfElementsToCopy < 0 || outputIndex < 0 ||
108 inputStartIndex >= inSize)
114 if (inSize < (inputStartIndex + numberOfElementsToCopy))
116 numberOfElementsToCopy = (inSize - inputStartIndex);
120 const vtkm::Id copyOutEnd = outputIndex + numberOfElementsToCopy;
121 if (outSize < copyOutEnd)
142 inputPortal, outputPortal, inputStartIndex, outputIndex, numberOfElementsToCopy);
147 template <
typename T,
typename U,
class CIn>
156 template <
typename T,
typename U,
class CIn,
class BinaryFunctor>
159 BinaryFunctor binary_functor)
160 -> decltype(tbb::ReducePortals(input.ReadPortal(), initialValue, binary_functor))
170 template <
typename T,
181 BinaryFunctor binary_functor)
200 template <
typename T,
class CIn,
class COut>
207 return tbb::ScanInclusivePortals(
213 template <
typename T,
class CIn,
class COut,
class BinaryFunctor>
216 BinaryFunctor binary_functor)
221 return tbb::ScanInclusivePortals(
227 template <
typename T,
class CIn,
class COut>
234 return tbb::ScanExclusivePortals(
241 template <
typename T,
class CIn,
class COut,
class BinaryFunctor>
244 BinaryFunctor binary_functor,
245 const T& initialValue)
250 return tbb::ScanExclusivePortals(
257 VTKM_CONT_EXPORT static void ScheduleTask(vtkm::exec::tbb::internal::TaskTiling1D& functor,
259 VTKM_CONT_EXPORT static void ScheduleTask(vtkm::exec::tbb::internal::TaskTiling3D& functor,
262 template <
typename H
ints,
typename FunctorType>
266 "Schedule TBB 1D: '%s'",
269 vtkm::exec::tbb::internal::TaskTiling1D kernel(functor);
270 ScheduleTask(kernel, numInstances);
273 template <
typename FunctorType>
276 Schedule(vtkm::cont::internal::HintList<>{}, functor, numInstances);
279 template <
typename H
ints,
typename FunctorType>
283 "Schedule TBB 3D: '%s'",
286 vtkm::exec::tbb::internal::TaskTiling3D kernel(functor);
287 ScheduleTask(kernel, rangeMax);
290 template <
typename FunctorType>
293 Schedule(vtkm::cont::internal::HintList<>{}, functor, rangeMax);
299 template <
typename T,
class Container>
309 template <
typename T,
class Container,
class BinaryCompare>
311 BinaryCompare binary_compare)
318 template <
typename T,
typename U,
class StorageT,
class StorageU>
327 template <
typename T,
typename U,
class StorageT,
class StorageU,
class BinaryCompare>
330 BinaryCompare binary_compare)
337 template <
typename T,
class Storage>
340 Unique(values, std::equal_to<T>());
343 template <
typename T,
class Storage,
class BinaryCompare>
345 BinaryCompare binary_compare)
406 "Start() function should be called first then trying to call Stop() and"
407 " GetElapsedTime().");
411 ::tbb::tick_count startTime = this->
StartTime;
414 ::tbb::tick_count::interval_t elapsedTime = stopTime - startTime;
422 return ::tbb::tick_count::now();
436 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
437 static vtkm::exec::tbb::internal::TaskTiling1D
MakeTask(WorkletType& worklet,
438 InvocationType& invocation,
443 return vtkm::exec::tbb::internal::TaskTiling1D(worklet, invocation);
446 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
447 static vtkm::exec::tbb::internal::TaskTiling3D
MakeTask(WorkletType& worklet,
448 InvocationType& invocation,
453 return vtkm::exec::tbb::internal::TaskTiling3D(worklet, invocation);
456 template <
typename WorkletType,
typename InvocationType,
typename RangeType>
458 InvocationType& invocation,
459 const RangeType& range)
461 return MakeTask<vtkm::cont::internal::HintList<>>(worklet, invocation, range);
467 #endif //vtk_m_cont_tbb_internal_DeviceAdapterAlgorithmTBB_h
static void Sort(vtkm::cont::ArrayHandle< T, Container > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmTBB.h:310
static void Schedule(Hints, FunctorType functor, vtkm::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmTBB.h:280
std::string TypeToString(const std::type_info &t)
Use RTTI information to retrieve the name of the type T.
static auto Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor) -> decltype(tbb::ReducePortals(input.ReadPortal(), initialValue, binary_functor))
Definition: DeviceAdapterAlgorithmTBB.h:157
#define VTKM_LOG_SCOPE(level,...)
Definition: Logging.h:211
TimeStamp StopTime
Definition: DeviceAdapterAlgorithm.h:704
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)
Definition: DeviceAdapterAlgorithmTBB.h:87
Manages an array-worth of data.
Definition: ArrayHandle.h:300
void Reset()
Definition: DeviceAdapterAlgorithmTBB.h:375
bool Started() const
Definition: DeviceAdapterAlgorithmTBB.h:394
static void Copy(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:40
static void CopyIf(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:55
vtkm::Id ReduceByKeyPortals(KeysInPortalType keysInPortal, ValuesInPortalType valuesInPortal, KeysOutPortalType keysOutPortal, ValuesOutPortalType valuesOutPortal, BinaryOperationType binaryOperation)
Definition: FunctorsTBB.h:787
Groups connected points that have the same field value.
Definition: Atomic.h:19
static void Schedule(FunctorType &&functor, vtkm::Id numInstances)
Definition: DeviceAdapterAlgorithmTBB.h:274
The TypeTraits class provides helpful compile-time information about the basic types used in VTKm (an...
Definition: TypeTraits.h:61
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:201
static void Schedule(Functor functor, vtkm::Id numInstances)
Schedule many instances of a function to run on concurrent threads.
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor, const T &initialValue)
Definition: DeviceAdapterAlgorithmTBB.h:242
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmTBB.h:214
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
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: DeviceAdapterAlgorithmTBB.h:66
bool Ready() const
Definition: DeviceAdapterAlgorithmTBB.h:398
vtkm::Id UniquePortals(PortalType portal, BinaryOperationType binaryOperation)
Definition: FunctorsTBB.h:1364
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Reduce an array to only the unique values it contains.
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
DeviceAdapterTimerImplementation()
Definition: DeviceAdapterAlgorithmTBB.h:373
bool Stopped() const
Definition: DeviceAdapterAlgorithmTBB.h:396
void Stop()
Definition: DeviceAdapterAlgorithmTBB.h:388
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
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmTBB.h:328
::tbb::tick_count StopTime
Definition: DeviceAdapterAlgorithmTBB.h:429
void parallel_sort_bykey(vtkm::cont::ArrayHandle< T, StorageT > &, vtkm::cont::ArrayHandle< U, StorageU > &, BinaryCompare)
Definition: ParallelSortTBB.h:225
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
static T U
Definition: DeviceAdapterAlgorithm.h:347
bool StartReady
Definition: DeviceAdapterAlgorithm.h:701
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
bool StopReady
Definition: DeviceAdapterAlgorithm.h:702
vtkm::Float64 GetElapsedTime() const
Definition: DeviceAdapterAlgorithmTBB.h:400
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
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: DeviceAdapterAlgorithmTBB.h:319
Tag for a device adapter that uses the Intel Threading Building Blocks library to run algorithms on m...
Definition: DeviceAdapterTagTBB.h:27
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
#define VTKM_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:214
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:41
static auto Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue) -> decltype(Reduce(input, initialValue, vtkm::Add
Definition: DeviceAdapterAlgorithmTBB.h:148
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:228
void DetachFromAll()
Detaches this Token from all resources to allow them to be used elsewhere or deleted.
static void Schedule(Hints, FunctorType functor, vtkm::Id numInstances)
Definition: DeviceAdapterAlgorithmTBB.h:263
@ Error
Important but non-fatal errors, such as device fail-over.
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.
#define VTKM_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:208
Class providing a device-specific timer.
Definition: DeviceAdapterAlgorithm.h:613
static auto MakeTask(WorkletType &worklet, InvocationType &invocation, const RangeType &range)
Definition: DeviceAdapterAlgorithmTBB.h:457
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: DeviceAdapterAlgorithmTBB.h:338
vtkm::Id CopyIfPortals(InputPortalType inputPortal, StencilPortalType stencilPortal, OutputPortalType outputPortal, UnaryPredicateType unaryPredicate)
Definition: FunctorsTBB.h:347
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 void Sort(vtkm::cont::ArrayHandle< T, Container > &values)
Definition: DeviceAdapterAlgorithmTBB.h:300
static void Unique(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmTBB.h:344
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.
void Reset()
Resets the timer.
Definition: DeviceAdapterAlgorithm.h:630
bool StopReady
Definition: DeviceAdapterAlgorithmTBB.h:427
static vtkm::exec::tbb::internal::TaskTiling3D MakeTask(WorkletType &worklet, InvocationType &invocation, vtkm::Id3, Hints=Hints{})
Definition: DeviceAdapterAlgorithmTBB.h:447
::tbb::tick_count StartTime
Definition: DeviceAdapterAlgorithmTBB.h:428
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:161
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 void Synchronize()
Definition: DeviceAdapterAlgorithmTBB.h:358
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Compute a accumulated sum operation on the input ArrayHandle.
static vtkm::exec::tbb::internal::TaskTiling1D MakeTask(WorkletType &worklet, InvocationType &invocation, vtkm::Id, Hints=Hints{})
Definition: DeviceAdapterAlgorithmTBB.h:437
::tbb::tick_count GetCurrentTime() const
Definition: DeviceAdapterAlgorithmTBB.h:419
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
TimeStamp GetCurrentTime() const
Definition: DeviceAdapterAlgorithm.h:682
void Start()
Definition: DeviceAdapterAlgorithmTBB.h:381
TimeStamp StartTime
Definition: DeviceAdapterAlgorithm.h:703
bool StartReady
Definition: DeviceAdapterAlgorithmTBB.h:426
void parallel_sort(vtkm::cont::ArrayHandle< T, Container > &, BinaryCompare)
Definition: ParallelSortTBB.h:79
static void Schedule(FunctorType &&functor, vtkm::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmTBB.h:291
void CopyPortals(const InputPortalType &inPortal, const OutputPortalType &outPortal, vtkm::Id inOffset, vtkm::Id outOffset, vtkm::Id numValues)
Definition: FunctorsTBB.h:146
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
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 binary_functor)
Definition: DeviceAdapterAlgorithmTBB.h:177