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>
49 auto outputPortal = output.
PrepareForOutput(inSize, DeviceAdapterTagTBB(), token);
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)
138 auto inputPortal = input.
PrepareForInput(DeviceAdapterTagTBB(), token);
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))
165 return tbb::ReducePortals(input.PrepareForInput(vtkm::cont::DeviceAdapterTagTBB(), token),
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 <
class FunctorType>
266 "Schedule TBB 1D: '%s'",
269 vtkm::exec::tbb::internal::TaskTiling1D kernel(functor);
270 ScheduleTask(kernel, numInstances);
273 template <
class FunctorType>
277 "Schedule TBB 3D: '%s'",
280 vtkm::exec::tbb::internal::TaskTiling3D kernel(functor);
281 ScheduleTask(kernel, rangeMax);
287 template <
typename T,
class Container>
297 template <
typename T,
class Container,
class BinaryCompare>
299 BinaryCompare binary_compare)
306 template <
typename T,
typename U,
class StorageT,
class StorageU>
315 template <
typename T,
typename U,
class StorageT,
class StorageU,
class BinaryCompare>
318 BinaryCompare binary_compare)
325 template <
typename T,
class Storage>
328 Unique(values, std::equal_to<T>());
331 template <
typename T,
class Storage,
class BinaryCompare>
333 BinaryCompare binary_compare)
394 "Start() function should be called first then trying to call Stop() and"
395 " GetElapsedTime().");
399 ::tbb::tick_count startTime = this->
StartTime;
402 ::tbb::tick_count::interval_t elapsedTime = stopTime - startTime;
410 return ::tbb::tick_count::now();
424 template <
typename WorkletType,
typename InvocationType>
425 static vtkm::exec::tbb::internal::TaskTiling1D
MakeTask(WorkletType& worklet,
426 InvocationType& invocation,
429 return vtkm::exec::tbb::internal::TaskTiling1D(worklet, invocation);
432 template <
typename WorkletType,
typename InvocationType>
433 static vtkm::exec::tbb::internal::TaskTiling3D
MakeTask(WorkletType& worklet,
434 InvocationType& invocation,
437 return vtkm::exec::tbb::internal::TaskTiling3D(worklet, invocation);
443 #endif //vtk_m_cont_tbb_internal_DeviceAdapterAlgorithmTBB_h
VTKM_CONT vtkm::Id CopyIfPortals(InputPortalType inputPortal, StencilPortalType stencilPortal, OutputPortalType outputPortal, UnaryPredicateType unaryPredicate)
Definition: FunctorsTBB.h:347
#define VTKM_LOG_SCOPE(level,...)
Definition: Logging.h:265
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
TimeStamp StopTime
Definition: DeviceAdapterAlgorithm.h:704
static VTKM_CONT void Schedule(FunctorType functor, vtkm::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmTBB.h:274
Manages an array-worth of data.
Definition: ArrayHandle.h:283
VTKM_CONT::tbb::tick_count GetCurrentTime() const
Definition: DeviceAdapterAlgorithmTBB.h:407
VTKM_CONT DeviceAdapterTimerImplementation()
Definition: DeviceAdapterAlgorithmTBB.h:361
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_CONT vtkm::Float64 GetElapsedTime() const
Definition: DeviceAdapterAlgorithmTBB.h:388
VTKM_CONT void Stop()
Definition: DeviceAdapterAlgorithmTBB.h:376
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Container > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmTBB.h:298
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
VTKM_CONT void Start()
Definition: DeviceAdapterAlgorithmTBB.h:369
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
static VTKM_CONT T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:201
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 T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor)
Definition: DeviceAdapterAlgorithmTBB.h:214
VTKM_CONT vtkm::Id UniquePortals(PortalType portal, BinaryOperationType binaryOperation)
Definition: FunctorsTBB.h:1364
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)
Definition: DeviceAdapterAlgorithmTBB.h:87
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 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
static vtkm::exec::tbb::internal::TaskTiling3D MakeTask(WorkletType &worklet, InvocationType &invocation, vtkm::Id3)
Definition: DeviceAdapterAlgorithmTBB.h:433
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
VTKM_CONT bool Ready() const
Definition: DeviceAdapterAlgorithmTBB.h:386
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
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 binary_functor)
Definition: DeviceAdapterAlgorithmTBB.h:177
static VTKM_CONT void Sort(vtkm::cont::ArrayHandle< T, Container > &values)
Definition: DeviceAdapterAlgorithmTBB.h:288
static VTKM_CONT void Unique(vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: DeviceAdapterAlgorithmTBB.h:326
static VTKM_CONT void Unique(vtkm::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmTBB.h:332
::tbb::tick_count StopTime
Definition: DeviceAdapterAlgorithmTBB.h:417
void parallel_sort_bykey(vtkm::cont::ArrayHandle< T, StorageT > &, vtkm::cont::ArrayHandle< U, StorageU > &, BinaryCompare)
Definition: ParallelSortTBB.h:225
static vtkm::exec::tbb::internal::TaskTiling1D MakeTask(WorkletType &worklet, InvocationType &invocation, vtkm::Id)
Definition: DeviceAdapterAlgorithmTBB.h:425
static VTKM_CONT auto Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue) -> decltype(Reduce(input, initialValue, vtkm::Add
Definition: DeviceAdapterAlgorithmTBB.h:148
static VTKM_CONT void Synchronize()
Definition: DeviceAdapterAlgorithmTBB.h:346
static VTKM_CONT void Copy(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:40
bool StartReady
Definition: DeviceAdapterAlgorithm.h:701
bool StopReady
Definition: DeviceAdapterAlgorithm.h:702
VTKM_CONT void Reset()
Resets the timer.
Definition: DeviceAdapterAlgorithm.h:630
static VTKM_CONT 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
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
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:41
static VTKM_CONT void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmTBB.h:316
static VTKM_CONT void Schedule(FunctorType functor, vtkm::Id numInstances)
Definition: DeviceAdapterAlgorithmTBB.h:263
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.
VTKM_CONT TimeStamp GetCurrentTime() const
Definition: DeviceAdapterAlgorithm.h:682
@ Error
Important but non-fatal errors, such as device fail-over.
#define VTKM_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:261
Class providing a device-specific timer.
Definition: DeviceAdapterAlgorithm.h:613
static VTKM_CONT T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmTBB.h:228
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.
VTKM_CONT bool Stopped() const
Definition: DeviceAdapterAlgorithmTBB.h:384
Predicate that takes a single argument x, and returns True if it isn't the identity of the Type T.
Definition: UnaryPredicates.h:32
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 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.
bool StopReady
Definition: DeviceAdapterAlgorithmTBB.h:415
::tbb::tick_count StartTime
Definition: DeviceAdapterAlgorithmTBB.h:416
double Float64
Definition: Types.h:155
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: DeviceAdapterAlgorithmTBB.h:55
VTKM_CONT vtkm::Id ReduceByKeyPortals(KeysInPortalType keysInPortal, ValuesInPortalType valuesInPortal, KeysOutPortalType keysOutPortal, ValuesOutPortalType valuesOutPortal, BinaryOperationType binaryOperation)
Definition: FunctorsTBB.h:787
static VTKM_CONT 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
VTKM_CONT bool Started() const
Definition: DeviceAdapterAlgorithmTBB.h:382
TimeStamp StartTime
Definition: DeviceAdapterAlgorithm.h:703
bool StartReady
Definition: DeviceAdapterAlgorithmTBB.h:414
static VTKM_CONT void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: DeviceAdapterAlgorithmTBB.h:307
void parallel_sort(vtkm::cont::ArrayHandle< T, Container > &, BinaryCompare)
Definition: ParallelSortTBB.h:79
VTKM_CONT_EXPORT VTKM_CONT std::string TypeToString(const std::type_info &t)
Use RTTI information to retrieve the name of the type T.
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,...
VTKM_CONT void Reset()
Definition: DeviceAdapterAlgorithmTBB.h:363