mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Remove ArrayHandleStreaming capabilities
The `ArrayHandleStreaming` class stems from an old research project experimenting with bringing data from an `ArrayHandle` in parts and overlapping device transfer and execution. It works, but only in very limited contexts. Thus, it is not actually used today. Plus, the feature requires global indexing to be permutated throughout the worklet dispatching classes of VTK-m for no further reason. Because it is not really used, there are other more promising approaches on the horizon, and it makes further scheduling improvements difficult, we are removing this functionality.
This commit is contained in:
parent
4fef71c646
commit
4f9fa08fa1
@ -211,76 +211,6 @@ struct ScanInclusiveResultFunctor
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct StreamingScanExclusiveFunctor
|
||||
{
|
||||
T result;
|
||||
StreamingScanExclusiveFunctor()
|
||||
: result(T(0))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Device, class CIn, class COut>
|
||||
VTKM_CONT bool operator()(Device,
|
||||
const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||
result =
|
||||
vtkm::cont::DeviceAdapterAlgorithm<Device>::StreamingScanExclusive(numBlocks, input, output);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Device, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT bool operator()(Device,
|
||||
const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binary_functor,
|
||||
const T& initialValue)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||
result = vtkm::cont::DeviceAdapterAlgorithm<Device>::StreamingScanExclusive(
|
||||
numBlocks, input, output, binary_functor, initialValue);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename U>
|
||||
struct StreamingReduceFunctor
|
||||
{
|
||||
U result;
|
||||
StreamingReduceFunctor()
|
||||
: result(U(0))
|
||||
{
|
||||
}
|
||||
template <typename Device, typename T, class CIn>
|
||||
VTKM_CONT bool operator()(Device,
|
||||
const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
U initialValue)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||
result =
|
||||
vtkm::cont::DeviceAdapterAlgorithm<Device>::StreamingReduce(numBlocks, input, initialValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Device, typename T, class CIn, class BinaryFunctor>
|
||||
VTKM_CONT bool operator()(Device,
|
||||
const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
U InitialValue,
|
||||
BinaryFunctor binaryFunctor)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||
result = vtkm::cont::DeviceAdapterAlgorithm<Device>::StreamingReduce(
|
||||
numBlocks, input, InitialValue, binaryFunctor);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct ScanInclusiveByKeyFunctor
|
||||
{
|
||||
ScanInclusiveByKeyFunctor() {}
|
||||
@ -798,66 +728,6 @@ struct Algorithm
|
||||
}
|
||||
|
||||
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static T StreamingScanExclusive(vtkm::cont::DeviceAdapterId devId,
|
||||
const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||
{
|
||||
detail::StreamingScanExclusiveFunctor<T> functor;
|
||||
vtkm::cont::TryExecuteOnDevice(devId, functor, numBlocks, input, output);
|
||||
return functor.result;
|
||||
}
|
||||
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static T StreamingScanExclusive(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||
{
|
||||
return StreamingScanExclusive(vtkm::cont::DeviceAdapterTagAny(), numBlocks, input, output);
|
||||
}
|
||||
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static T StreamingScanExclusive(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binary_functor,
|
||||
const T& initialValue)
|
||||
{
|
||||
detail::StreamingScanExclusiveFunctor<T> functor;
|
||||
vtkm::cont::TryExecuteOnDevice(vtkm::cont::DeviceAdapterTagAny(),
|
||||
functor,
|
||||
numBlocks,
|
||||
input,
|
||||
output,
|
||||
binary_functor,
|
||||
initialValue);
|
||||
return functor.result;
|
||||
}
|
||||
|
||||
template <typename T, typename U, class CIn>
|
||||
VTKM_CONT static U StreamingReduce(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
U initialValue)
|
||||
{
|
||||
detail::StreamingReduceFunctor<U> functor;
|
||||
vtkm::cont::TryExecuteOnDevice(
|
||||
vtkm::cont::DeviceAdapterTagAny(), functor, numBlocks, input, initialValue);
|
||||
return functor.result;
|
||||
}
|
||||
|
||||
template <typename T, typename U, class CIn, class BinaryFunctor>
|
||||
VTKM_CONT static U StreamingReduce(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
U initialValue,
|
||||
BinaryFunctor binaryFunctor)
|
||||
{
|
||||
detail::StreamingReduceFunctor<U> functor;
|
||||
vtkm::cont::TryExecuteOnDevice(
|
||||
vtkm::cont::DeviceAdapterTagAny(), functor, numBlocks, input, initialValue, binaryFunctor);
|
||||
return functor.result;
|
||||
}
|
||||
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static T ScanInclusive(vtkm::cont::DeviceAdapterId devId,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
|
@ -604,8 +604,7 @@ public:
|
||||
this->SyncControlArray(lock);
|
||||
}
|
||||
|
||||
// Probably should make this private, but ArrayHandleStreaming needs access.
|
||||
protected:
|
||||
private:
|
||||
/// Acquires a lock on the internals of this `ArrayHandle`. The calling
|
||||
/// function should keep the returned lock and let it go out of scope
|
||||
/// when the lock is no longer needed.
|
||||
|
@ -1,310 +0,0 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_ArrayHandleStreaming_h
|
||||
#define vtk_m_cont_ArrayHandleStreaming_h
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayPortal.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename P>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalStreaming
|
||||
{
|
||||
using Writable = vtkm::internal::PortalSupportsSets<P>;
|
||||
|
||||
public:
|
||||
using PortalType = P;
|
||||
using ValueType = typename PortalType::ValueType;
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalStreaming()
|
||||
: InputPortal()
|
||||
, BlockIndex(0)
|
||||
, BlockSize(0)
|
||||
, CurBlockSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalStreaming(const PortalType& inputPortal,
|
||||
vtkm::Id blockIndex,
|
||||
vtkm::Id blockSize,
|
||||
vtkm::Id curBlockSize)
|
||||
: InputPortal(inputPortal)
|
||||
, BlockIndex(blockIndex)
|
||||
, BlockSize(blockSize)
|
||||
, CurBlockSize(curBlockSize)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <typename OtherP>
|
||||
VTKM_EXEC_CONT ArrayPortalStreaming(const ArrayPortalStreaming<OtherP>& src)
|
||||
: InputPortal(src.GetPortal())
|
||||
, BlockIndex(src.GetBlockIndex())
|
||||
, BlockSize(src.GetBlockSize())
|
||||
, CurBlockSize(src.GetCurBlockSize())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalStreaming(const ArrayPortalStreaming& src)
|
||||
: InputPortal(src.InputPortal)
|
||||
, BlockIndex(src.BlockIndex)
|
||||
, BlockSize(src.BlockSize)
|
||||
, CurBlockSize(src.CurBlockSize)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalStreaming(const ArrayPortalStreaming&& rhs)
|
||||
: InputPortal(std::move(rhs.InputPortal))
|
||||
, BlockIndex(std::move(rhs.BlockIndex))
|
||||
, BlockSize(std::move(rhs.BlockSize))
|
||||
, CurBlockSize(std::move(rhs.CurBlockSize))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
~ArrayPortalStreaming() {}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalStreaming& operator=(const ArrayPortalStreaming& src)
|
||||
{
|
||||
this->InputPortal = src.InputPortal;
|
||||
this->BlockIndex = src.BlockIndex;
|
||||
this->BlockSize = src.BlockSize;
|
||||
this->CurBlockSize = src.CurBlockSize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalStreaming& operator=(const ArrayPortalStreaming&& rhs)
|
||||
{
|
||||
this->InputPortal = std::move(rhs.InputPortal);
|
||||
this->BlockIndex = std::move(rhs.BlockIndex);
|
||||
this->BlockSize = std::move(rhs.BlockSize);
|
||||
this->CurBlockSize = std::move(rhs.CurBlockSize);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const { return this->CurBlockSize; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ValueType Get(vtkm::Id index) const
|
||||
{
|
||||
return this->InputPortal.Get(this->BlockIndex * this->BlockSize + index);
|
||||
}
|
||||
|
||||
template <typename Writable_ = Writable,
|
||||
typename = typename std::enable_if<Writable_::value>::type>
|
||||
VTKM_EXEC_CONT void Set(vtkm::Id index, const ValueType& value) const
|
||||
{
|
||||
this->InputPortal.Set(this->BlockIndex * this->BlockSize + index, value);
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
const PortalType& GetPortal() const { return this->InputPortal; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
void SetBlockSize(vtkm::Id blockSize) { this->BlockSize = blockSize; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
void SetBlockIndex(vtkm::Id blockIndex) { this->BlockIndex = blockIndex; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
void SetCurBlockSize(vtkm::Id curBlockSize) { this->CurBlockSize = curBlockSize; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetBlockSize() { return this->BlockSize; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetBlockIndex() { return this->BlockIndex; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetCurBlockSize() { return this->CurBlockSize; }
|
||||
|
||||
private:
|
||||
PortalType InputPortal;
|
||||
vtkm::Id BlockIndex;
|
||||
vtkm::Id BlockSize;
|
||||
vtkm::Id CurBlockSize;
|
||||
};
|
||||
|
||||
} // internal
|
||||
|
||||
template <typename ArrayHandleInputType>
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagStreaming
|
||||
{
|
||||
};
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename ArrayHandleInputType>
|
||||
class Storage<typename ArrayHandleInputType::ValueType, StorageTagStreaming<ArrayHandleInputType>>
|
||||
{
|
||||
public:
|
||||
using ValueType = typename ArrayHandleInputType::ValueType;
|
||||
|
||||
using PortalType = vtkm::cont::internal::ArrayPortalStreaming<
|
||||
typename vtkm::cont::internal::Storage<typename ArrayHandleInputType::ValueType,
|
||||
typename ArrayHandleInputType::StorageTag>::PortalType>;
|
||||
using PortalConstType =
|
||||
vtkm::cont::internal::ArrayPortalStreaming<typename vtkm::cont::internal::Storage<
|
||||
typename ArrayHandleInputType::ValueType,
|
||||
typename ArrayHandleInputType::StorageTag>::PortalConstType>;
|
||||
|
||||
VTKM_CONT
|
||||
Storage()
|
||||
: Valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const ArrayHandleInputType inputArray,
|
||||
vtkm::Id blockSize,
|
||||
vtkm::Id blockIndex,
|
||||
vtkm::Id curBlockSize)
|
||||
: InputArray(inputArray)
|
||||
, BlockSize(blockSize)
|
||||
, BlockIndex(blockIndex)
|
||||
, CurBlockSize(curBlockSize)
|
||||
, Valid(true)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal()
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalType(this->InputArray.WritePortal(), BlockSize, BlockIndex, CurBlockSize);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalConstType(this->InputArray.ReadPortal(), BlockSize, BlockIndex, CurBlockSize);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return CurBlockSize;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id numberOfValues) const
|
||||
{
|
||||
(void)numberOfValues;
|
||||
// Do nothing, since we only allocate a streaming array once at the beginning
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AllocateFullArray(vtkm::Id numberOfValues)
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
this->InputArray.Allocate(numberOfValues);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id numberOfValues)
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
this->InputArray.Shrink(numberOfValues);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources()
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
this->InputArray.ReleaseResources();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const ArrayHandleInputType& GetArray() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return this->InputArray;
|
||||
}
|
||||
|
||||
private:
|
||||
ArrayHandleInputType InputArray;
|
||||
vtkm::Id BlockSize;
|
||||
vtkm::Id BlockIndex;
|
||||
vtkm::Id CurBlockSize;
|
||||
bool Valid;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template <typename ArrayHandleInputType>
|
||||
class ArrayHandleStreaming
|
||||
: public vtkm::cont::ArrayHandle<typename ArrayHandleInputType::ValueType,
|
||||
StorageTagStreaming<ArrayHandleInputType>>
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleStreaming,
|
||||
(ArrayHandleStreaming<ArrayHandleInputType>),
|
||||
(vtkm::cont::ArrayHandle<typename ArrayHandleInputType::ValueType,
|
||||
StorageTagStreaming<ArrayHandleInputType>>));
|
||||
|
||||
private:
|
||||
using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
ArrayHandleStreaming(const ArrayHandleInputType& inputArray,
|
||||
const vtkm::Id blockIndex,
|
||||
const vtkm::Id blockSize,
|
||||
const vtkm::Id curBlockSize)
|
||||
: Superclass(StorageType(inputArray, blockIndex, blockSize, curBlockSize))
|
||||
{
|
||||
this->ReadPortal().SetBlockIndex(blockIndex);
|
||||
this->ReadPortal().SetBlockSize(blockSize);
|
||||
this->ReadPortal().SetCurBlockSize(curBlockSize);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AllocateFullArray(vtkm::Id numberOfValues)
|
||||
{
|
||||
auto lock = this->GetLock();
|
||||
|
||||
this->ReleaseResourcesExecutionInternal(lock);
|
||||
this->Internals->GetControlArray(lock)->AllocateFullArray(numberOfValues);
|
||||
this->Internals->SetControlArrayValid(lock, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //vtk_m_cont_ArrayHandleStreaming_h
|
@ -33,7 +33,6 @@ set(headers
|
||||
ArrayHandlePermutation.h
|
||||
ArrayHandleReverse.h
|
||||
ArrayHandleSOA.h
|
||||
ArrayHandleStreaming.h
|
||||
ArrayHandleSwizzle.h
|
||||
ArrayHandleTransform.h
|
||||
ArrayHandleUniformPointCoordinates.h
|
||||
|
@ -368,17 +368,6 @@ struct DeviceAdapterAlgorithm
|
||||
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||
vtkm::cont::ArrayHandle<U, VOut>& output);
|
||||
|
||||
/// \brief Streaming version of scan exclusive
|
||||
///
|
||||
/// Computes a scan one block at a time.
|
||||
///
|
||||
/// \return The total sum.
|
||||
///
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static T StreamingScanExclusive(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output);
|
||||
|
||||
/// \brief Compute an extended prefix sum operation on the input ArrayHandle.
|
||||
///
|
||||
/// Computes an extended prefix sum operation on the \c input ArrayHandle,
|
||||
|
@ -1862,25 +1862,19 @@ class DeviceTaskTypes<vtkm::cont::DeviceAdapterTagCuda>
|
||||
{
|
||||
public:
|
||||
template <typename WorkletType, typename InvocationType>
|
||||
static vtkm::exec::cuda::internal::TaskStrided1D<WorkletType, InvocationType> MakeTask(
|
||||
WorkletType& worklet,
|
||||
InvocationType& invocation,
|
||||
vtkm::Id,
|
||||
vtkm::Id globalIndexOffset = 0)
|
||||
static vtkm::exec::cuda::internal::TaskStrided1D<WorkletType, InvocationType>
|
||||
MakeTask(WorkletType& worklet, InvocationType& invocation, vtkm::Id)
|
||||
{
|
||||
using Task = vtkm::exec::cuda::internal::TaskStrided1D<WorkletType, InvocationType>;
|
||||
return Task(worklet, invocation, globalIndexOffset);
|
||||
return Task(worklet, invocation);
|
||||
}
|
||||
|
||||
template <typename WorkletType, typename InvocationType>
|
||||
static vtkm::exec::cuda::internal::TaskStrided3D<WorkletType, InvocationType> MakeTask(
|
||||
WorkletType& worklet,
|
||||
InvocationType& invocation,
|
||||
vtkm::Id3,
|
||||
vtkm::Id globalIndexOffset = 0)
|
||||
static vtkm::exec::cuda::internal::TaskStrided3D<WorkletType, InvocationType>
|
||||
MakeTask(WorkletType& worklet, InvocationType& invocation, vtkm::Id3)
|
||||
{
|
||||
using Task = vtkm::exec::cuda::internal::TaskStrided3D<WorkletType, InvocationType>;
|
||||
return Task(worklet, invocation, globalIndexOffset);
|
||||
return Task(worklet, invocation);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <vtkm/cont/ArrayHandleDiscard.h>
|
||||
#include <vtkm/cont/ArrayHandleImplicit.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/ArrayHandleStreaming.h>
|
||||
#include <vtkm/cont/ArrayHandleView.h>
|
||||
#include <vtkm/cont/ArrayHandleZip.h>
|
||||
#include <vtkm/cont/BitField.h>
|
||||
@ -569,49 +568,6 @@ public:
|
||||
return scanResult;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Streaming Reduce
|
||||
template <typename T, typename U, class CIn>
|
||||
VTKM_CONT static U StreamingReduce(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
U initialValue)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
return DerivedAlgorithm::StreamingReduce(numBlocks, input, initialValue, vtkm::Add());
|
||||
}
|
||||
|
||||
template <typename T, typename U, class CIn, class BinaryFunctor>
|
||||
VTKM_CONT static U StreamingReduce(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
U initialValue,
|
||||
BinaryFunctor binary_functor)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
vtkm::Id fullSize = input.GetNumberOfValues();
|
||||
vtkm::Id blockSize = fullSize / numBlocks;
|
||||
if (fullSize % numBlocks != 0)
|
||||
blockSize += 1;
|
||||
|
||||
U lastResult = vtkm::TypeTraits<U>::ZeroInitialization();
|
||||
for (vtkm::Id block = 0; block < numBlocks; block++)
|
||||
{
|
||||
vtkm::Id numberOfInstances = blockSize;
|
||||
if (block == numBlocks - 1)
|
||||
numberOfInstances = fullSize - blockSize * block;
|
||||
|
||||
vtkm::cont::ArrayHandleStreaming<vtkm::cont::ArrayHandle<T, CIn>> streamIn(
|
||||
input, block, blockSize, numberOfInstances);
|
||||
|
||||
if (block == 0)
|
||||
lastResult = DerivedAlgorithm::Reduce(streamIn, initialValue, binary_functor);
|
||||
else
|
||||
lastResult = DerivedAlgorithm::Reduce(streamIn, lastResult, binary_functor);
|
||||
}
|
||||
return lastResult;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Reduce By Key
|
||||
template <typename T,
|
||||
@ -857,63 +813,6 @@ public:
|
||||
keys, values, output, vtkm::TypeTraits<ValueT>::ZeroInitialization(), vtkm::Sum());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Streaming exclusive scan
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static T StreamingScanExclusive(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
return DerivedAlgorithm::StreamingScanExclusive(
|
||||
numBlocks, input, output, vtkm::Sum(), vtkm::TypeTraits<T>::ZeroInitialization());
|
||||
}
|
||||
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static T StreamingScanExclusive(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binary_functor,
|
||||
const T& initialValue)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
vtkm::Id fullSize = input.GetNumberOfValues();
|
||||
vtkm::Id blockSize = fullSize / numBlocks;
|
||||
if (fullSize % numBlocks != 0)
|
||||
blockSize += 1;
|
||||
|
||||
T lastResult = vtkm::TypeTraits<T>::ZeroInitialization();
|
||||
for (vtkm::Id block = 0; block < numBlocks; block++)
|
||||
{
|
||||
vtkm::Id numberOfInstances = blockSize;
|
||||
if (block == numBlocks - 1)
|
||||
numberOfInstances = fullSize - blockSize * block;
|
||||
|
||||
vtkm::cont::ArrayHandleStreaming<vtkm::cont::ArrayHandle<T, CIn>> streamIn(
|
||||
input, block, blockSize, numberOfInstances);
|
||||
|
||||
vtkm::cont::ArrayHandleStreaming<vtkm::cont::ArrayHandle<T, COut>> streamOut(
|
||||
output, block, blockSize, numberOfInstances);
|
||||
|
||||
if (block == 0)
|
||||
{
|
||||
streamOut.AllocateFullArray(fullSize);
|
||||
lastResult =
|
||||
DerivedAlgorithm::ScanExclusive(streamIn, streamOut, binary_functor, initialValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
lastResult =
|
||||
DerivedAlgorithm::ScanExclusive(streamIn, streamOut, binary_functor, lastResult);
|
||||
}
|
||||
|
||||
streamOut.SyncControlArray();
|
||||
}
|
||||
return lastResult;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Scan Inclusive
|
||||
template <typename T, class CIn, class COut>
|
||||
|
@ -399,19 +399,17 @@ public:
|
||||
template <typename WorkletType, typename InvocationType>
|
||||
static vtkm::exec::openmp::internal::TaskTiling1D MakeTask(const WorkletType& worklet,
|
||||
const InvocationType& invocation,
|
||||
vtkm::Id,
|
||||
vtkm::Id globalIndexOffset = 0)
|
||||
vtkm::Id)
|
||||
{
|
||||
return vtkm::exec::openmp::internal::TaskTiling1D(worklet, invocation, globalIndexOffset);
|
||||
return vtkm::exec::openmp::internal::TaskTiling1D(worklet, invocation);
|
||||
}
|
||||
|
||||
template <typename WorkletType, typename InvocationType>
|
||||
static vtkm::exec::openmp::internal::TaskTiling3D MakeTask(const WorkletType& worklet,
|
||||
const InvocationType& invocation,
|
||||
vtkm::Id3,
|
||||
vtkm::Id globalIndexOffset = 0)
|
||||
vtkm::Id3)
|
||||
{
|
||||
return vtkm::exec::openmp::internal::TaskTiling3D(worklet, invocation, globalIndexOffset);
|
||||
return vtkm::exec::openmp::internal::TaskTiling3D(worklet, invocation);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -553,19 +553,17 @@ public:
|
||||
template <typename WorkletType, typename InvocationType>
|
||||
static vtkm::exec::serial::internal::TaskTiling1D MakeTask(WorkletType& worklet,
|
||||
InvocationType& invocation,
|
||||
vtkm::Id,
|
||||
vtkm::Id globalIndexOffset = 0)
|
||||
vtkm::Id)
|
||||
{
|
||||
return vtkm::exec::serial::internal::TaskTiling1D(worklet, invocation, globalIndexOffset);
|
||||
return vtkm::exec::serial::internal::TaskTiling1D(worklet, invocation);
|
||||
}
|
||||
|
||||
template <typename WorkletType, typename InvocationType>
|
||||
static vtkm::exec::serial::internal::TaskTiling3D MakeTask(WorkletType& worklet,
|
||||
InvocationType& invocation,
|
||||
vtkm::Id3,
|
||||
vtkm::Id globalIndexOffset = 0)
|
||||
vtkm::Id3)
|
||||
{
|
||||
return vtkm::exec::serial::internal::TaskTiling3D(worklet, invocation, globalIndexOffset);
|
||||
return vtkm::exec::serial::internal::TaskTiling3D(worklet, invocation);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -412,19 +412,17 @@ public:
|
||||
template <typename WorkletType, typename InvocationType>
|
||||
static vtkm::exec::tbb::internal::TaskTiling1D MakeTask(WorkletType& worklet,
|
||||
InvocationType& invocation,
|
||||
vtkm::Id,
|
||||
vtkm::Id globalIndexOffset = 0)
|
||||
vtkm::Id)
|
||||
{
|
||||
return vtkm::exec::tbb::internal::TaskTiling1D(worklet, invocation, globalIndexOffset);
|
||||
return vtkm::exec::tbb::internal::TaskTiling1D(worklet, invocation);
|
||||
}
|
||||
|
||||
template <typename WorkletType, typename InvocationType>
|
||||
static vtkm::exec::tbb::internal::TaskTiling3D MakeTask(WorkletType& worklet,
|
||||
InvocationType& invocation,
|
||||
vtkm::Id3,
|
||||
vtkm::Id globalIndexOffset = 0)
|
||||
vtkm::Id3)
|
||||
{
|
||||
return vtkm::exec::tbb::internal::TaskTiling3D(worklet, invocation, globalIndexOffset);
|
||||
return vtkm::exec::tbb::internal::TaskTiling3D(worklet, invocation);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -109,7 +109,6 @@ void ScanTest()
|
||||
vtkm::Id out;
|
||||
out = vtkm::cont::Algorithm::ScanInclusive(input, output);
|
||||
out = vtkm::cont::Algorithm::ScanInclusive(input, output, vtkm::Maximum());
|
||||
out = vtkm::cont::Algorithm::StreamingScanExclusive(1, input, output);
|
||||
vtkm::cont::Algorithm::ScanInclusiveByKey(keys, input, output, vtkm::Maximum());
|
||||
vtkm::cont::Algorithm::ScanInclusiveByKey(keys, input, output);
|
||||
out = vtkm::cont::Algorithm::ScanExclusive(input, output, vtkm::Maximum(), vtkm::Id(0));
|
||||
|
@ -39,13 +39,11 @@ public:
|
||||
ThreadIndicesBasic(vtkm::Id threadIndex,
|
||||
vtkm::Id inIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outIndex,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
vtkm::Id outIndex)
|
||||
: ThreadIndex(threadIndex)
|
||||
, InputIndex(inIndex)
|
||||
, OutputIndex(outIndex)
|
||||
, VisitIndex(visitIndex)
|
||||
, GlobalThreadIndexOffset(globalThreadIndexOffset)
|
||||
{
|
||||
}
|
||||
|
||||
@ -95,18 +93,11 @@ public:
|
||||
VTKM_EXEC
|
||||
vtkm::IdComponent GetVisitIndex() const { return this->VisitIndex; }
|
||||
|
||||
/// \brief The global index (for streaming).
|
||||
///
|
||||
/// Global index (for streaming)
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetGlobalIndex() const { return (this->GlobalThreadIndexOffset + this->ThreadIndex); }
|
||||
|
||||
private:
|
||||
vtkm::Id ThreadIndex;
|
||||
vtkm::Id InputIndex;
|
||||
vtkm::Id OutputIndex;
|
||||
vtkm::IdComponent VisitIndex;
|
||||
vtkm::Id GlobalThreadIndexOffset;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,8 @@ public:
|
||||
vtkm::Id threadIndex1D,
|
||||
vtkm::Id inIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outIndex,
|
||||
vtkm::Id globalThreadIndexOffset)
|
||||
: ThreadIndicesBasic(threadIndex1D, inIndex, visitIndex, outIndex, globalThreadIndexOffset)
|
||||
vtkm::Id outIndex)
|
||||
: ThreadIndicesBasic(threadIndex1D, inIndex, visitIndex, outIndex)
|
||||
, ThreadIndex3D(threadIndex3D)
|
||||
{
|
||||
}
|
||||
|
@ -38,8 +38,7 @@ public:
|
||||
vtkm::Id vtkmNotUsed(inputIndex),
|
||||
vtkm::IdComponent vtkmNotUsed(visitIndex),
|
||||
vtkm::Id vtkmNotUsed(outputIndex),
|
||||
const ConnectivityType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
const ConnectivityType& connectivity)
|
||||
{
|
||||
const LogicalIndexType logicalIndex = detail::Deflate(threadIndex, LogicalIndexType());
|
||||
const vtkm::Id index = connectivity.LogicalToFlatToIndex(logicalIndex);
|
||||
@ -51,15 +50,13 @@ public:
|
||||
this->LogicalIndex = logicalIndex;
|
||||
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
|
||||
//this->CellShape = connectivity.GetCellShape(index);
|
||||
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC
|
||||
ThreadIndicesTopologyMap(const vtkm::Id3& threadIndex3D,
|
||||
vtkm::Id threadIndex1D,
|
||||
const ConnectivityType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
const ConnectivityType& connectivity)
|
||||
{
|
||||
// This constructor handles multidimensional indices on one-to-one input-to-output
|
||||
auto logicalIndex = detail::Deflate(threadIndex3D, LogicalIndexType());
|
||||
@ -71,7 +68,6 @@ public:
|
||||
this->LogicalIndex = logicalIndex;
|
||||
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
|
||||
//this->CellShape = connectivity.GetCellShape(index);
|
||||
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
@ -81,8 +77,7 @@ public:
|
||||
vtkm::Id inputIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outputIndex,
|
||||
const ConnectivityType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
const ConnectivityType& connectivity)
|
||||
{
|
||||
// This constructor handles multidimensional indices on many-to-many input-to-output
|
||||
auto logicalIndex = detail::Deflate(threadIndex3D, LogicalIndexType());
|
||||
@ -94,7 +89,6 @@ public:
|
||||
this->LogicalIndex = logicalIndex;
|
||||
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
|
||||
//this->CellShape = connectivity.GetCellShape(index);
|
||||
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
|
||||
}
|
||||
|
||||
/// \brief The logical index into the input domain.
|
||||
@ -139,9 +133,6 @@ public:
|
||||
VTKM_EXEC
|
||||
vtkm::IdComponent GetVisitIndex() const { return this->VisitIndex; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetGlobalIndex() const { return (this->GlobalThreadIndexOffset + this->OutputIndex); }
|
||||
|
||||
/// \brief The input indices of the "from" elements.
|
||||
///
|
||||
/// A topology map has "from" and "to" elements (for example from points to
|
||||
@ -181,7 +172,6 @@ private:
|
||||
vtkm::Id OutputIndex;
|
||||
LogicalIndexType LogicalIndex;
|
||||
IndicesIncidentType IndicesIncident;
|
||||
vtkm::Id GlobalThreadIndexOffset;
|
||||
};
|
||||
|
||||
// Specialization for extrude types.
|
||||
@ -201,8 +191,7 @@ public:
|
||||
vtkm::Id vtkmNotUsed(inputIndex),
|
||||
vtkm::IdComponent vtkmNotUsed(visitIndex),
|
||||
vtkm::Id vtkmNotUsed(outputIndex),
|
||||
const ConnectivityType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
const ConnectivityType& connectivity)
|
||||
{
|
||||
const LogicalIndexType logicalIndex = detail::Deflate(threadIndex, LogicalIndexType());
|
||||
const vtkm::Id index = connectivity.LogicalToFlatToIndex(logicalIndex);
|
||||
@ -213,13 +202,11 @@ public:
|
||||
this->VisitIndex = 0;
|
||||
this->LogicalIndex = logicalIndex;
|
||||
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
|
||||
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
|
||||
}
|
||||
|
||||
ThreadIndicesTopologyMap(const vtkm::Id3& threadIndex3D,
|
||||
vtkm::Id threadIndex1D,
|
||||
const ConnectivityType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
const ConnectivityType& connectivity)
|
||||
{
|
||||
|
||||
const LogicalIndexType logicalIndex = detail::Deflate(threadIndex3D, LogicalIndexType());
|
||||
@ -230,7 +217,6 @@ public:
|
||||
this->VisitIndex = 0;
|
||||
this->LogicalIndex = logicalIndex;
|
||||
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
|
||||
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
|
||||
}
|
||||
|
||||
ThreadIndicesTopologyMap(const vtkm::Id3& threadIndex3D,
|
||||
@ -238,8 +224,7 @@ public:
|
||||
vtkm::Id inputIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outputIndex,
|
||||
const ConnectivityType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
const ConnectivityType& connectivity)
|
||||
{
|
||||
|
||||
const LogicalIndexType logicalIndex = detail::Deflate(threadIndex3D, LogicalIndexType());
|
||||
@ -250,7 +235,6 @@ public:
|
||||
this->VisitIndex = visitIndex;
|
||||
this->LogicalIndex = logicalIndex;
|
||||
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
|
||||
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
|
||||
}
|
||||
|
||||
/// \brief The logical index into the input domain.
|
||||
@ -295,9 +279,6 @@ public:
|
||||
VTKM_EXEC
|
||||
vtkm::IdComponent GetVisitIndex() const { return this->VisitIndex; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetGlobalIndex() const { return (this->GlobalThreadIndexOffset + this->OutputIndex); }
|
||||
|
||||
/// \brief The input indices of the "from" elements.
|
||||
///
|
||||
/// A topology map has "from" and "to" elements (for example from points to
|
||||
@ -337,7 +318,6 @@ private:
|
||||
vtkm::Id OutputIndex;
|
||||
LogicalIndexType LogicalIndex;
|
||||
IndicesIncidentType IndicesIncident;
|
||||
vtkm::Id GlobalThreadIndexOffset;
|
||||
};
|
||||
|
||||
} //namespace arg
|
||||
|
@ -61,14 +61,12 @@ public:
|
||||
vtkm::Id threadIndex1D,
|
||||
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension>& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
Dimension>& connectivity)
|
||||
: State(threadIndex3D, detail::To3D(connectivity.GetPointDimensions()))
|
||||
, ThreadIndex(threadIndex1D)
|
||||
, InputIndex(threadIndex1D)
|
||||
, OutputIndex(threadIndex1D)
|
||||
, VisitIndex(0)
|
||||
, GlobalThreadIndexOffset(globalThreadIndexOffset)
|
||||
{
|
||||
}
|
||||
|
||||
@ -81,14 +79,12 @@ public:
|
||||
vtkm::Id outputIndex,
|
||||
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension>& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
Dimension>& connectivity)
|
||||
: State(threadIndex3D, detail::To3D(connectivity.GetPointDimensions()))
|
||||
, ThreadIndex(threadIndex1D)
|
||||
, InputIndex(inputIndex)
|
||||
, OutputIndex(outputIndex)
|
||||
, VisitIndex(visitIndex)
|
||||
, GlobalThreadIndexOffset(globalThreadIndexOffset)
|
||||
{
|
||||
}
|
||||
|
||||
@ -100,15 +96,13 @@ public:
|
||||
vtkm::Id outputIndex,
|
||||
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension>& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
Dimension>& connectivity)
|
||||
: State(detail::To3D(connectivity.FlatToLogicalToIndex(inputIndex)),
|
||||
detail::To3D(connectivity.GetPointDimensions()))
|
||||
, ThreadIndex(threadIndex)
|
||||
, InputIndex(inputIndex)
|
||||
, OutputIndex(outputIndex)
|
||||
, VisitIndex(visitIndex)
|
||||
, GlobalThreadIndexOffset(globalThreadIndexOffset)
|
||||
{
|
||||
}
|
||||
|
||||
@ -130,19 +124,12 @@ public:
|
||||
VTKM_EXEC
|
||||
vtkm::IdComponent GetVisitIndex() const { return this->VisitIndex; }
|
||||
|
||||
/// \brief The global index (for streaming).
|
||||
///
|
||||
/// Global index (for streaming)
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetGlobalIndex() const { return (this->GlobalThreadIndexOffset + this->OutputIndex); }
|
||||
|
||||
private:
|
||||
vtkm::exec::BoundaryState State;
|
||||
vtkm::Id ThreadIndex;
|
||||
vtkm::Id InputIndex;
|
||||
vtkm::Id OutputIndex;
|
||||
vtkm::IdComponent VisitIndex;
|
||||
vtkm::Id GlobalThreadIndexOffset;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -39,9 +39,8 @@ public:
|
||||
vtkm::Id inIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outIndex,
|
||||
const vtkm::exec::internal::ReduceByKeyLookup<P1, P2, P3>& keyLookup,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
: Superclass(threadIndex, inIndex, visitIndex, outIndex, globalThreadIndexOffset)
|
||||
const vtkm::exec::internal::ReduceByKeyLookup<P1, P2, P3>& keyLookup)
|
||||
: Superclass(threadIndex, inIndex, visitIndex, outIndex)
|
||||
, ValueOffset(keyLookup.Offsets.Get(inIndex))
|
||||
, NumberOfValues(keyLookup.Counts.Get(inIndex))
|
||||
{
|
||||
|
@ -94,9 +94,8 @@ public:
|
||||
vtkm::Id inputIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outputIndex,
|
||||
const ConnectivityType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
: Superclass(threadIndex, inputIndex, visitIndex, outputIndex, globalThreadIndexOffset)
|
||||
const ConnectivityType& connectivity)
|
||||
: Superclass(threadIndex, inputIndex, visitIndex, outputIndex)
|
||||
// The connectivity is stored in the invocation parameter at the given
|
||||
// input domain index. If this class is being used correctly, the type
|
||||
// of the domain will match the connectivity type used here. If there is
|
||||
@ -161,8 +160,7 @@ public:
|
||||
vtkm::Id inIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outIndex,
|
||||
const ConnectivityType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
const ConnectivityType& connectivity)
|
||||
{
|
||||
this->ThreadIndex = threadIndex;
|
||||
this->InputIndex = inIndex;
|
||||
@ -171,13 +169,11 @@ public:
|
||||
this->LogicalIndex = connectivity.FlatToLogicalToIndex(this->InputIndex);
|
||||
this->IndicesIncident = connectivity.GetIndices(this->LogicalIndex);
|
||||
this->CellShape = connectivity.GetCellShape(this->InputIndex);
|
||||
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
|
||||
}
|
||||
|
||||
VTKM_EXEC ThreadIndicesTopologyMap(const vtkm::Id3& threadIndex3D,
|
||||
vtkm::Id threadIndex1D,
|
||||
const ConnectivityType& connectivity,
|
||||
const vtkm::Id globalThreadIndexOffset = 0)
|
||||
const ConnectivityType& connectivity)
|
||||
{
|
||||
// This constructor handles multidimensional indices on one-to-one input-to-output
|
||||
auto logicalIndex = detail::Deflate(threadIndex3D, LogicalIndexType());
|
||||
@ -188,7 +184,6 @@ public:
|
||||
this->LogicalIndex = logicalIndex;
|
||||
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
|
||||
this->CellShape = connectivity.GetCellShape(threadIndex1D);
|
||||
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
|
||||
}
|
||||
|
||||
VTKM_EXEC ThreadIndicesTopologyMap(const vtkm::Id3& threadIndex3D,
|
||||
@ -196,8 +191,7 @@ public:
|
||||
vtkm::Id inIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outIndex,
|
||||
const ConnectivityType& connectivity,
|
||||
const vtkm::Id globalThreadIndexOffset = 0)
|
||||
const ConnectivityType& connectivity)
|
||||
{
|
||||
// This constructor handles multidimensional indices on many-to-many input-to-output
|
||||
auto logicalIndex = detail::Deflate(threadIndex3D, LogicalIndexType());
|
||||
@ -208,7 +202,6 @@ public:
|
||||
this->LogicalIndex = logicalIndex;
|
||||
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
|
||||
this->CellShape = connectivity.GetCellShape(threadIndex1D);
|
||||
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
|
||||
}
|
||||
|
||||
/// \brief The index of the thread or work invocation.
|
||||
@ -262,9 +255,6 @@ public:
|
||||
VTKM_EXEC
|
||||
vtkm::IdComponent GetVisitIndex() const { return this->VisitIndex; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetGlobalIndex() const { return (this->GlobalThreadIndexOffset + this->OutputIndex); }
|
||||
|
||||
/// \brief The indices of the incident elements.
|
||||
///
|
||||
/// A topology map has "visited" and "incident" elements (e.g. points, cells,
|
||||
@ -305,7 +295,6 @@ private:
|
||||
LogicalIndexType LogicalIndex;
|
||||
IndicesIncidentType IndicesIncident;
|
||||
CellShapeTag CellShape;
|
||||
vtkm::Id GlobalThreadIndexOffset;
|
||||
};
|
||||
|
||||
// Specialization for permuted structured connectivity types.
|
||||
@ -333,8 +322,7 @@ public:
|
||||
vtkm::Id inputIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outputIndex,
|
||||
const PermutedConnectivityType& permutation,
|
||||
vtkm::Id globalThreadIndexOffset = 0)
|
||||
const PermutedConnectivityType& permutation)
|
||||
{
|
||||
this->ThreadIndex = threadIndex;
|
||||
this->InputIndex = inputIndex;
|
||||
@ -345,7 +333,6 @@ public:
|
||||
this->LogicalIndex = permutation.Connectivity.FlatToLogicalToIndex(permutedIndex);
|
||||
this->IndicesIncident = permutation.Connectivity.GetIndices(this->LogicalIndex);
|
||||
this->CellShape = permutation.Connectivity.GetCellShape(permutedIndex);
|
||||
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
|
||||
}
|
||||
|
||||
/// \brief The index of the thread or work invocation.
|
||||
@ -399,9 +386,6 @@ public:
|
||||
VTKM_EXEC
|
||||
vtkm::IdComponent GetVisitIndex() const { return this->VisitIndex; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetGlobalIndex() const { return (this->GlobalThreadIndexOffset + this->OutputIndex); }
|
||||
|
||||
/// \brief The indices of the incident elements.
|
||||
///
|
||||
/// A topology map has "visited" and "incident" elements (e.g. points, cells,
|
||||
@ -442,7 +426,6 @@ private:
|
||||
LogicalIndexType LogicalIndex;
|
||||
IndicesIncidentType IndicesIncident;
|
||||
CellShapeTag CellShape;
|
||||
vtkm::Id GlobalThreadIndexOffset;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ struct Fetch<FetchTag, vtkm::exec::arg::AspectTagWorkIndex, ThreadIndicesType, E
|
||||
VTKM_EXEC
|
||||
vtkm::Id Load(const ThreadIndicesType& indices, const ExecObjectType&) const
|
||||
{
|
||||
return indices.GetGlobalIndex();
|
||||
return indices.GetThreadIndex();
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
vtkm::IdComponent GetVisitIndex() const { return this->VisitIndex; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetGlobalIndex() const { return this->OutputIndex; }
|
||||
vtkm::Id GetThreadIndex() const { return this->OutputIndex; }
|
||||
|
||||
private:
|
||||
vtkm::Id InputIndex;
|
||||
|
@ -102,7 +102,7 @@ struct FetchArrayDirectIn3DTests
|
||||
for (vtkm::Id i = 0; i < ARRAY_SIZE[0]; i++, index1d++)
|
||||
{
|
||||
index3d[0] = i;
|
||||
vtkm::exec::arg::ThreadIndicesBasic3D indices(index3d, index1d, index1d, 0, index1d, 0);
|
||||
vtkm::exec::arg::ThreadIndicesBasic3D indices(index3d, index1d, index1d, 0, index1d);
|
||||
T value = fetch.Load(indices, execObject);
|
||||
VTKM_TEST_ASSERT(test_equal(value, TestValue(index1d, T())),
|
||||
"Got invalid value from Load.");
|
||||
|
@ -54,11 +54,10 @@ template <typename WType, typename IType>
|
||||
class TaskStrided1D : public TaskStrided
|
||||
{
|
||||
public:
|
||||
TaskStrided1D(const WType& worklet, const IType& invocation, vtkm::Id globalIndexOffset = 0)
|
||||
TaskStrided1D(const WType& worklet, const IType& invocation)
|
||||
: TaskStrided()
|
||||
, Worklet(worklet)
|
||||
, Invocation(invocation)
|
||||
, GlobalIndexOffset(globalIndexOffset)
|
||||
{
|
||||
this->SetErrorBufferFunction = &TaskStridedSetErrorBuffer<WType>;
|
||||
//Bind the Worklet to void*
|
||||
@ -78,8 +77,7 @@ public:
|
||||
this->Invocation.OutputToInputMap,
|
||||
this->Invocation.VisitArray,
|
||||
this->Invocation.ThreadToOutputMap,
|
||||
this->Invocation.GetInputDomain(),
|
||||
this->GlobalIndexOffset));
|
||||
this->Invocation.GetInputDomain()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +88,6 @@ private:
|
||||
// hold by reference to reduce the number of copies, it is not possible
|
||||
// currently.
|
||||
const IType Invocation;
|
||||
const vtkm::Id GlobalIndexOffset;
|
||||
};
|
||||
|
||||
template <typename WType>
|
||||
@ -123,11 +120,10 @@ template <typename WType, typename IType>
|
||||
class TaskStrided3D : public TaskStrided
|
||||
{
|
||||
public:
|
||||
TaskStrided3D(const WType& worklet, const IType& invocation, vtkm::Id globalIndexOffset = 0)
|
||||
TaskStrided3D(const WType& worklet, const IType& invocation)
|
||||
: TaskStrided()
|
||||
, Worklet(worklet)
|
||||
, Invocation(invocation)
|
||||
, GlobalIndexOffset(globalIndexOffset)
|
||||
{
|
||||
this->SetErrorBufferFunction = &TaskStridedSetErrorBuffer<WType>;
|
||||
//Bind the Worklet to void*
|
||||
@ -156,8 +152,7 @@ public:
|
||||
this->Invocation.OutputToInputMap,
|
||||
this->Invocation.VisitArray,
|
||||
this->Invocation.ThreadToOutputMap,
|
||||
this->Invocation.GetInputDomain(),
|
||||
this->GlobalIndexOffset));
|
||||
this->Invocation.GetInputDomain()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +163,6 @@ private:
|
||||
// hold by reference to reduce the number of copies, it is not possible
|
||||
// currently.
|
||||
const IType Invocation;
|
||||
const vtkm::Id GlobalIndexOffset;
|
||||
};
|
||||
|
||||
template <typename WType>
|
||||
|
@ -201,19 +201,17 @@ struct TestWorkletProxy : vtkm::exec::FunctorBase
|
||||
typename OutToInArrayType,
|
||||
typename VisitArrayType,
|
||||
typename ThreadToOutArrayType,
|
||||
typename InputDomainType,
|
||||
typename G>
|
||||
typename InputDomainType>
|
||||
VTKM_EXEC vtkm::exec::arg::ThreadIndicesBasic GetThreadIndices(
|
||||
const T& threadIndex,
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType&,
|
||||
const G& globalThreadIndexOffset) const
|
||||
const InputDomainType&) const
|
||||
{
|
||||
vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, globalThreadIndexOffset);
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex);
|
||||
}
|
||||
};
|
||||
|
||||
@ -229,19 +227,17 @@ struct TestWorkletErrorProxy : vtkm::exec::FunctorBase
|
||||
typename OutToInArrayType,
|
||||
typename VisitArrayType,
|
||||
typename ThreadToOutArrayType,
|
||||
typename InputDomainType,
|
||||
typename G>
|
||||
typename InputDomainType>
|
||||
VTKM_EXEC vtkm::exec::arg::ThreadIndicesBasic GetThreadIndices(
|
||||
const T& threadIndex,
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType&,
|
||||
const G& globalThreadIndexOffset) const
|
||||
const InputDomainType&) const
|
||||
{
|
||||
vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, globalThreadIndexOffset);
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -36,12 +36,9 @@ class TaskSingular : public vtkm::exec::TaskBase
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
TaskSingular(const WorkletType& worklet,
|
||||
const InvocationType& invocation,
|
||||
vtkm::Id globalIndexOffset = 0)
|
||||
TaskSingular(const WorkletType& worklet, const InvocationType& invocation)
|
||||
: Worklet(worklet)
|
||||
, Invocation(invocation)
|
||||
, GlobalIndexOffset(globalIndexOffset)
|
||||
{
|
||||
}
|
||||
|
||||
@ -62,8 +59,7 @@ public:
|
||||
this->Invocation.OutputToInputMap,
|
||||
this->Invocation.VisitArray,
|
||||
this->Invocation.ThreadToOutputMap,
|
||||
this->Invocation.GetInputDomain(),
|
||||
GlobalIndexOffset));
|
||||
this->Invocation.GetInputDomain()));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -73,7 +69,6 @@ private:
|
||||
// hold by reference to reduce the number of copies, it is not possible
|
||||
// currently.
|
||||
const InvocationType Invocation;
|
||||
const vtkm::Id GlobalIndexOffset;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -201,42 +201,35 @@ struct TestWorkletProxy : vtkm::exec::FunctorBase
|
||||
template <typename OutToInArrayType,
|
||||
typename VisitArrayType,
|
||||
typename ThreadToOutputArrayType,
|
||||
typename InputDomainType,
|
||||
typename G>
|
||||
typename InputDomainType>
|
||||
VTKM_EXEC vtkm::exec::arg::ThreadIndicesBasic GetThreadIndices(
|
||||
const vtkm::Id& threadIndex,
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutputArrayType& threadToOut,
|
||||
const InputDomainType&,
|
||||
const G& globalThreadIndexOffset) const
|
||||
const InputDomainType&) const
|
||||
{
|
||||
const vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, globalThreadIndexOffset);
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex);
|
||||
}
|
||||
|
||||
template <typename OutToInArrayType,
|
||||
typename VisitArrayType,
|
||||
typename ThreadToOutArrayType,
|
||||
typename InputDomainType,
|
||||
typename G>
|
||||
typename InputDomainType>
|
||||
VTKM_EXEC vtkm::exec::arg::ThreadIndicesBasic GetThreadIndices(
|
||||
const vtkm::Id3& vtkmNotUsed(iterationSpace),
|
||||
const vtkm::Id3& threadIndex,
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType&,
|
||||
const G& globalThreadIndexOffset) const
|
||||
const InputDomainType&) const
|
||||
{
|
||||
const vtkm::Id flatThreadIndex = vtkm::Dot(threadIndex, vtkm::Id3(1, 8, 64));
|
||||
const vtkm::Id outIndex = threadToOut.Get(flatThreadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(flatThreadIndex,
|
||||
outToIn.Get(outIndex),
|
||||
visit.Get(outIndex),
|
||||
outIndex,
|
||||
globalThreadIndexOffset);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(
|
||||
flatThreadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex);
|
||||
}
|
||||
};
|
||||
|
||||
@ -251,42 +244,35 @@ struct TestWorkletErrorProxy : vtkm::exec::FunctorBase
|
||||
template <typename OutToInArrayType,
|
||||
typename VisitArrayType,
|
||||
typename ThreadToOutArrayType,
|
||||
typename InputDomainType,
|
||||
typename G>
|
||||
typename InputDomainType>
|
||||
VTKM_EXEC vtkm::exec::arg::ThreadIndicesBasic GetThreadIndices(
|
||||
const vtkm::Id& threadIndex,
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType&,
|
||||
const G& globalThreadIndexOffset) const
|
||||
const InputDomainType&) const
|
||||
{
|
||||
const vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, globalThreadIndexOffset);
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex);
|
||||
}
|
||||
|
||||
template <typename OutToInArrayType,
|
||||
typename VisitArrayType,
|
||||
typename ThreadToOutputArrayType,
|
||||
typename InputDomainType,
|
||||
typename G>
|
||||
typename InputDomainType>
|
||||
VTKM_EXEC vtkm::exec::arg::ThreadIndicesBasic GetThreadIndices(
|
||||
const vtkm::Id3& vtkmNotUsed(iterationSpace),
|
||||
const vtkm::Id3& threadIndex,
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutputArrayType& threadToOutput,
|
||||
const InputDomainType&,
|
||||
const G& globalThreadIndexOffset) const
|
||||
const InputDomainType&) const
|
||||
{
|
||||
const vtkm::Id index = vtkm::Dot(threadIndex, vtkm::Id3(1, 8, 64));
|
||||
const vtkm::Id outputIndex = threadToOutput.Get(index);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(index,
|
||||
outToIn.Get(outputIndex),
|
||||
visit.Get(outputIndex),
|
||||
outputIndex,
|
||||
globalThreadIndexOffset);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(
|
||||
index, outToIn.Get(outputIndex), visit.Get(outputIndex), outputIndex);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -179,19 +179,17 @@ struct TestWorkletProxy : vtkm::exec::FunctorBase
|
||||
typename OutToInArrayType,
|
||||
typename VisitArrayType,
|
||||
typename ThreadToOutArrayType,
|
||||
typename InputDomainType,
|
||||
typename G>
|
||||
typename InputDomainType>
|
||||
VTKM_EXEC vtkm::exec::arg::ThreadIndicesBasic GetThreadIndices(
|
||||
const T& threadIndex,
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType&,
|
||||
const G& globalThreadIndexOffset) const
|
||||
const InputDomainType&) const
|
||||
{
|
||||
const vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, globalThreadIndexOffset);
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex);
|
||||
}
|
||||
};
|
||||
|
||||
@ -207,19 +205,17 @@ struct TestWorkletErrorProxy : vtkm::exec::FunctorBase
|
||||
typename OutToInArrayType,
|
||||
typename VisitArrayType,
|
||||
typename ThreadToOutArrayType,
|
||||
typename InputDomainType,
|
||||
typename G>
|
||||
typename InputDomainType>
|
||||
VTKM_EXEC vtkm::exec::arg::ThreadIndicesBasic GetThreadIndices(
|
||||
const T& threadIndex,
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType&,
|
||||
const G& globalThreadIndexOffset) const
|
||||
const InputDomainType&) const
|
||||
{
|
||||
const vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, globalThreadIndexOffset);
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -36,11 +36,7 @@ VTKM_NEVER_EXPORT void TaskTilingSetErrorBuffer(
|
||||
}
|
||||
|
||||
template <typename WType, typename IType>
|
||||
VTKM_NEVER_EXPORT void TaskTiling1DExecute(void* w,
|
||||
void* const v,
|
||||
vtkm::Id globalIndexOffset,
|
||||
vtkm::Id start,
|
||||
vtkm::Id end)
|
||||
VTKM_NEVER_EXPORT void TaskTiling1DExecute(void* w, void* const v, vtkm::Id start, vtkm::Id end)
|
||||
{
|
||||
using WorkletType = typename std::remove_cv<WType>::type;
|
||||
using InvocationType = typename std::remove_cv<IType>::type;
|
||||
@ -58,17 +54,12 @@ VTKM_NEVER_EXPORT void TaskTiling1DExecute(void* w,
|
||||
invocation->OutputToInputMap,
|
||||
invocation->VisitArray,
|
||||
invocation->ThreadToOutputMap,
|
||||
invocation->GetInputDomain(),
|
||||
globalIndexOffset));
|
||||
invocation->GetInputDomain()));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FType>
|
||||
VTKM_NEVER_EXPORT void FunctorTiling1DExecute(void* f,
|
||||
void* const,
|
||||
vtkm::Id,
|
||||
vtkm::Id start,
|
||||
vtkm::Id end)
|
||||
VTKM_NEVER_EXPORT void FunctorTiling1DExecute(void* f, void* const, vtkm::Id start, vtkm::Id end)
|
||||
{
|
||||
using FunctorType = typename std::remove_cv<FType>::type;
|
||||
FunctorType const* const functor = static_cast<FunctorType*>(f);
|
||||
@ -82,7 +73,6 @@ VTKM_NEVER_EXPORT void FunctorTiling1DExecute(void* f,
|
||||
template <typename WType, typename IType>
|
||||
VTKM_NEVER_EXPORT void TaskTiling3DExecute(void* w,
|
||||
void* const v,
|
||||
vtkm::Id globalIndexOffset,
|
||||
const vtkm::Id3& maxSize,
|
||||
vtkm::Id istart,
|
||||
vtkm::Id iend,
|
||||
@ -109,15 +99,13 @@ VTKM_NEVER_EXPORT void TaskTiling3DExecute(void* w,
|
||||
invocation->OutputToInputMap,
|
||||
invocation->VisitArray,
|
||||
invocation->ThreadToOutputMap,
|
||||
invocation->GetInputDomain(),
|
||||
globalIndexOffset));
|
||||
invocation->GetInputDomain()));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FType>
|
||||
VTKM_NEVER_EXPORT void FunctorTiling3DExecute(void* f,
|
||||
void* const,
|
||||
vtkm::Id vtkmNotUsed(globalIndexOffset),
|
||||
const vtkm::Id3& vtkmNotUsed(maxSize),
|
||||
vtkm::Id istart,
|
||||
vtkm::Id iend,
|
||||
@ -148,7 +136,6 @@ public:
|
||||
TaskTiling1D()
|
||||
: Worklet(nullptr)
|
||||
, Invocation(nullptr)
|
||||
, GlobalIndexOffset(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -161,7 +148,6 @@ public:
|
||||
, Invocation(nullptr)
|
||||
, ExecuteFunction(nullptr)
|
||||
, SetErrorBufferFunction(nullptr)
|
||||
, GlobalIndexOffset(0)
|
||||
{
|
||||
//Setup the execute and set error buffer function pointers
|
||||
this->ExecuteFunction = &FunctorTiling1DExecute<FunctorType>;
|
||||
@ -174,12 +160,11 @@ public:
|
||||
/// This constructor supports any vtkm worklet and the associated invocation
|
||||
/// parameters that go along with it
|
||||
template <typename WorkletType, typename InvocationType>
|
||||
TaskTiling1D(WorkletType& worklet, InvocationType& invocation, vtkm::Id globalIndexOffset)
|
||||
TaskTiling1D(WorkletType& worklet, InvocationType& invocation)
|
||||
: Worklet(nullptr)
|
||||
, Invocation(nullptr)
|
||||
, ExecuteFunction(nullptr)
|
||||
, SetErrorBufferFunction(nullptr)
|
||||
, GlobalIndexOffset(globalIndexOffset)
|
||||
{
|
||||
//Setup the execute and set error buffer function pointers
|
||||
this->ExecuteFunction = &TaskTiling1DExecute<WorkletType, InvocationType>;
|
||||
@ -198,7 +183,6 @@ public:
|
||||
, Invocation(task.Invocation)
|
||||
, ExecuteFunction(task.ExecuteFunction)
|
||||
, SetErrorBufferFunction(task.SetErrorBufferFunction)
|
||||
, GlobalIndexOffset(task.GlobalIndexOffset)
|
||||
{
|
||||
}
|
||||
|
||||
@ -211,20 +195,18 @@ public:
|
||||
|
||||
void operator()(vtkm::Id start, vtkm::Id end) const
|
||||
{
|
||||
this->ExecuteFunction(this->Worklet, this->Invocation, this->GlobalIndexOffset, start, end);
|
||||
this->ExecuteFunction(this->Worklet, this->Invocation, start, end);
|
||||
}
|
||||
|
||||
protected:
|
||||
void* Worklet;
|
||||
void* Invocation;
|
||||
|
||||
using ExecuteSignature = void (*)(void*, void* const, vtkm::Id, vtkm::Id, vtkm::Id);
|
||||
using ExecuteSignature = void (*)(void*, void* const, vtkm::Id, vtkm::Id);
|
||||
ExecuteSignature ExecuteFunction;
|
||||
|
||||
using SetErrorBufferSignature = void (*)(void*, const vtkm::exec::internal::ErrorMessageBuffer&);
|
||||
SetErrorBufferSignature SetErrorBufferFunction;
|
||||
|
||||
const vtkm::Id GlobalIndexOffset;
|
||||
};
|
||||
|
||||
// TaskTiling3D represents an execution pattern for a worklet
|
||||
@ -240,7 +222,6 @@ public:
|
||||
TaskTiling3D()
|
||||
: Worklet(nullptr)
|
||||
, Invocation(nullptr)
|
||||
, GlobalIndexOffset(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -253,7 +234,6 @@ public:
|
||||
, Invocation(nullptr)
|
||||
, ExecuteFunction(nullptr)
|
||||
, SetErrorBufferFunction(nullptr)
|
||||
, GlobalIndexOffset(0)
|
||||
{
|
||||
//Setup the execute and set error buffer function pointers
|
||||
this->ExecuteFunction = &FunctorTiling3DExecute<FunctorType>;
|
||||
@ -264,12 +244,11 @@ public:
|
||||
}
|
||||
|
||||
template <typename WorkletType, typename InvocationType>
|
||||
TaskTiling3D(WorkletType& worklet, InvocationType& invocation, vtkm::Id globalIndexOffset = 0)
|
||||
TaskTiling3D(WorkletType& worklet, InvocationType& invocation)
|
||||
: Worklet(nullptr)
|
||||
, Invocation(nullptr)
|
||||
, ExecuteFunction(nullptr)
|
||||
, SetErrorBufferFunction(nullptr)
|
||||
, GlobalIndexOffset(globalIndexOffset)
|
||||
{
|
||||
// Setup the execute and set error buffer function pointers
|
||||
this->ExecuteFunction = &TaskTiling3DExecute<WorkletType, InvocationType>;
|
||||
@ -288,7 +267,6 @@ public:
|
||||
, Invocation(task.Invocation)
|
||||
, ExecuteFunction(task.ExecuteFunction)
|
||||
, SetErrorBufferFunction(task.SetErrorBufferFunction)
|
||||
, GlobalIndexOffset(task.GlobalIndexOffset)
|
||||
{
|
||||
}
|
||||
|
||||
@ -305,28 +283,19 @@ public:
|
||||
vtkm::Id j,
|
||||
vtkm::Id k) const
|
||||
{
|
||||
this->ExecuteFunction(
|
||||
this->Worklet, this->Invocation, this->GlobalIndexOffset, maxSize, istart, iend, j, k);
|
||||
this->ExecuteFunction(this->Worklet, this->Invocation, maxSize, istart, iend, j, k);
|
||||
}
|
||||
|
||||
protected:
|
||||
void* Worklet;
|
||||
void* Invocation;
|
||||
|
||||
using ExecuteSignature = void (*)(void*,
|
||||
void* const,
|
||||
vtkm::Id,
|
||||
const vtkm::Id3&,
|
||||
vtkm::Id,
|
||||
vtkm::Id,
|
||||
vtkm::Id,
|
||||
vtkm::Id);
|
||||
using ExecuteSignature =
|
||||
void (*)(void*, void* const, const vtkm::Id3&, vtkm::Id, vtkm::Id, vtkm::Id, vtkm::Id);
|
||||
ExecuteSignature ExecuteFunction;
|
||||
|
||||
using SetErrorBufferSignature = void (*)(void*, const vtkm::exec::internal::ErrorMessageBuffer&);
|
||||
SetErrorBufferSignature SetErrorBufferFunction;
|
||||
|
||||
const vtkm::Id GlobalIndexOffset;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ set(headers
|
||||
DispatcherMapTopology.h
|
||||
DispatcherPointNeighborhood.h
|
||||
DispatcherReduceByKey.h
|
||||
DispatcherStreamingMapField.h
|
||||
DotProduct.h
|
||||
ExternalFaces.h
|
||||
ExtractGeometry.h
|
||||
|
@ -1,338 +0,0 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_worklet_Dispatcher_Streaming_MapField_h
|
||||
#define vtk_m_worklet_Dispatcher_Streaming_MapField_h
|
||||
|
||||
#include <vtkm/cont/ArrayHandleStreaming.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/internal/DispatcherBase.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace worklet
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct DispatcherStreamingTryExecuteFunctor
|
||||
{
|
||||
template <typename Device, typename DispatcherBaseType, typename Invocation, typename RangeType>
|
||||
VTKM_CONT bool operator()(Device device,
|
||||
const DispatcherBaseType* self,
|
||||
Invocation& invocation,
|
||||
const RangeType& dimensions,
|
||||
const RangeType& globalIndexOffset)
|
||||
{
|
||||
self->InvokeTransportParameters(
|
||||
invocation, dimensions, globalIndexOffset, self->Scatter.GetOutputRange(dimensions), device);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ControlInterface>
|
||||
struct DispatcherStreamingMapFieldTransformFunctor
|
||||
{
|
||||
vtkm::Id BlockIndex;
|
||||
vtkm::Id BlockSize;
|
||||
vtkm::Id CurBlockSize;
|
||||
vtkm::Id FullSize;
|
||||
|
||||
VTKM_CONT
|
||||
DispatcherStreamingMapFieldTransformFunctor(vtkm::Id blockIndex,
|
||||
vtkm::Id blockSize,
|
||||
vtkm::Id curBlockSize,
|
||||
vtkm::Id fullSize)
|
||||
: BlockIndex(blockIndex)
|
||||
, BlockSize(blockSize)
|
||||
, CurBlockSize(curBlockSize)
|
||||
, FullSize(fullSize)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename ParameterType, bool IsArrayHandle>
|
||||
struct DetermineReturnType;
|
||||
|
||||
template <typename ArrayHandleType>
|
||||
struct DetermineReturnType<ArrayHandleType, true>
|
||||
{
|
||||
using type = vtkm::cont::ArrayHandleStreaming<ArrayHandleType>;
|
||||
};
|
||||
|
||||
template <typename NotArrayHandleType>
|
||||
struct DetermineReturnType<NotArrayHandleType, false>
|
||||
{
|
||||
using type = NotArrayHandleType;
|
||||
};
|
||||
|
||||
template <typename ParameterType, vtkm::IdComponent Index>
|
||||
struct ReturnType
|
||||
{
|
||||
using type = typename DetermineReturnType<
|
||||
ParameterType,
|
||||
vtkm::cont::internal::ArrayHandleCheck<ParameterType>::type::value>::type;
|
||||
};
|
||||
|
||||
template <typename ParameterType, bool IsArrayHandle>
|
||||
struct TransformImpl;
|
||||
|
||||
template <typename ArrayHandleType>
|
||||
struct TransformImpl<ArrayHandleType, true>
|
||||
{
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleStreaming<ArrayHandleType> operator()(const ArrayHandleType& array,
|
||||
vtkm::Id blockIndex,
|
||||
vtkm::Id blockSize,
|
||||
vtkm::Id curBlockSize,
|
||||
vtkm::Id fullSize) const
|
||||
{
|
||||
vtkm::cont::ArrayHandleStreaming<ArrayHandleType> result =
|
||||
vtkm::cont::ArrayHandleStreaming<ArrayHandleType>(
|
||||
array, blockIndex, blockSize, curBlockSize);
|
||||
if (blockIndex == 0)
|
||||
result.AllocateFullArray(fullSize);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename NotArrayHandleType>
|
||||
struct TransformImpl<NotArrayHandleType, false>
|
||||
{
|
||||
VTKM_CONT
|
||||
NotArrayHandleType operator()(const NotArrayHandleType& notArray) const { return notArray; }
|
||||
};
|
||||
|
||||
template <typename ParameterType, vtkm::IdComponent Index>
|
||||
VTKM_CONT typename ReturnType<ParameterType, Index>::type operator()(
|
||||
const ParameterType& invokeData,
|
||||
vtkm::internal::IndexTag<Index>) const
|
||||
{
|
||||
return TransformImpl<ParameterType,
|
||||
vtkm::cont::internal::ArrayHandleCheck<ParameterType>::type::value>()(
|
||||
invokeData, this->BlockIndex, this->BlockSize, this->CurBlockSize, this->FullSize);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ControlInterface>
|
||||
struct DispatcherStreamingMapFieldTransferFunctor
|
||||
{
|
||||
VTKM_CONT
|
||||
DispatcherStreamingMapFieldTransferFunctor() {}
|
||||
|
||||
template <typename ParameterType, vtkm::IdComponent Index>
|
||||
struct ReturnType
|
||||
{
|
||||
using type = ParameterType;
|
||||
};
|
||||
|
||||
template <typename ParameterType, bool IsArrayHandle>
|
||||
struct TransformImpl;
|
||||
|
||||
template <typename ArrayHandleType>
|
||||
struct TransformImpl<ArrayHandleType, true>
|
||||
{
|
||||
VTKM_CONT
|
||||
ArrayHandleType operator()(const ArrayHandleType& array) const
|
||||
{
|
||||
array.SyncControlArray();
|
||||
return array;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename NotArrayHandleType>
|
||||
struct TransformImpl<NotArrayHandleType, false>
|
||||
{
|
||||
VTKM_CONT
|
||||
NotArrayHandleType operator()(const NotArrayHandleType& notArray) const { return notArray; }
|
||||
};
|
||||
|
||||
template <typename ParameterType, vtkm::IdComponent Index>
|
||||
VTKM_CONT typename ReturnType<ParameterType, Index>::type operator()(
|
||||
const ParameterType& invokeData,
|
||||
vtkm::internal::IndexTag<Index>) const
|
||||
{
|
||||
return TransformImpl<ParameterType,
|
||||
vtkm::cont::internal::ArrayHandleCheck<ParameterType>::type::value>()(
|
||||
invokeData);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// \brief Dispatcher for worklets that inherit from \c WorkletMapField.
|
||||
///
|
||||
template <typename WorkletType>
|
||||
class DispatcherStreamingMapField
|
||||
: public vtkm::worklet::internal::DispatcherBase<DispatcherStreamingMapField<WorkletType>,
|
||||
WorkletType,
|
||||
vtkm::worklet::WorkletMapField>
|
||||
{
|
||||
using Superclass =
|
||||
vtkm::worklet::internal::DispatcherBase<DispatcherStreamingMapField<WorkletType>,
|
||||
WorkletType,
|
||||
vtkm::worklet::WorkletMapField>;
|
||||
using ScatterType = typename Superclass::ScatterType;
|
||||
using MaskType = typename WorkletType::MaskType;
|
||||
|
||||
public:
|
||||
template <typename... T>
|
||||
VTKM_CONT DispatcherStreamingMapField(T&&... args)
|
||||
: Superclass(std::forward<T>(args)...)
|
||||
, NumberOfBlocks(1)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void SetNumberOfBlocks(vtkm::Id numberOfBlocks) { NumberOfBlocks = numberOfBlocks; }
|
||||
|
||||
friend struct detail::DispatcherStreamingTryExecuteFunctor;
|
||||
|
||||
template <typename Invocation>
|
||||
VTKM_CONT void BasicInvoke(Invocation& invocation,
|
||||
vtkm::Id numInstances,
|
||||
vtkm::Id globalIndexOffset) const
|
||||
{
|
||||
bool success = vtkm::cont::TryExecuteOnDevice(this->GetDevice(),
|
||||
detail::DispatcherStreamingTryExecuteFunctor(),
|
||||
this,
|
||||
invocation,
|
||||
numInstances,
|
||||
globalIndexOffset);
|
||||
if (!success)
|
||||
{
|
||||
throw vtkm::cont::ErrorExecution("Failed to execute worklet on any device.");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Invocation>
|
||||
VTKM_CONT void DoInvoke(Invocation& invocation) const
|
||||
{
|
||||
using namespace vtkm::worklet::internal;
|
||||
|
||||
// This is the type for the input domain
|
||||
using InputDomainType = typename Invocation::InputDomainType;
|
||||
|
||||
// We can pull the input domain parameter (the data specifying the input
|
||||
// domain) from the invocation object.
|
||||
const InputDomainType& inputDomain = invocation.GetInputDomain();
|
||||
|
||||
// For a DispatcherStreamingMapField, the inputDomain must be an ArrayHandle (or
|
||||
// an VariantArrayHandle that gets cast to one). The size of the domain
|
||||
// (number of threads/worklet instances) is equal to the size of the
|
||||
// array.
|
||||
vtkm::Id fullSize = SchedulingRange(inputDomain);
|
||||
vtkm::Id blockSize = fullSize / NumberOfBlocks;
|
||||
if (fullSize % NumberOfBlocks != 0)
|
||||
blockSize += 1;
|
||||
|
||||
using TransformFunctorType = vtkm::worklet::detail::DispatcherStreamingMapFieldTransformFunctor<
|
||||
typename Invocation::ControlInterface>;
|
||||
using TransferFunctorType = vtkm::worklet::detail::DispatcherStreamingMapFieldTransferFunctor<
|
||||
typename Invocation::ControlInterface>;
|
||||
|
||||
for (vtkm::Id block = 0; block < NumberOfBlocks; block++)
|
||||
{
|
||||
// Account for domain sizes not evenly divisable by the number of blocks
|
||||
vtkm::Id numberOfInstances = blockSize;
|
||||
if (block == NumberOfBlocks - 1)
|
||||
numberOfInstances = fullSize - blockSize * block;
|
||||
vtkm::Id globalIndexOffset = blockSize * block;
|
||||
|
||||
using ParameterInterfaceType = typename Invocation::ParameterInterface;
|
||||
using ReportedType =
|
||||
typename ParameterInterfaceType::template StaticTransformType<TransformFunctorType>::type;
|
||||
ReportedType newParams = invocation.Parameters.StaticTransformCont(
|
||||
TransformFunctorType(block, blockSize, numberOfInstances, fullSize));
|
||||
|
||||
using ChangedType = typename Invocation::template ChangeParametersType<ReportedType>::type;
|
||||
ChangedType changedParams = invocation.ChangeParameters(newParams);
|
||||
|
||||
this->BasicInvoke(changedParams, numberOfInstances, globalIndexOffset);
|
||||
|
||||
// Loop over parameters again to sync results for this block into control array
|
||||
using ParameterInterfaceType2 = typename ChangedType::ParameterInterface;
|
||||
ParameterInterfaceType2& parameters2 = changedParams.Parameters;
|
||||
parameters2.StaticTransformCont(TransferFunctorType());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Invocation,
|
||||
typename InputRangeType,
|
||||
typename OutputRangeType,
|
||||
typename DeviceAdapter>
|
||||
VTKM_CONT void InvokeTransportParameters(Invocation& invocation,
|
||||
const InputRangeType& inputRange,
|
||||
const InputRangeType& globalIndexOffset,
|
||||
const OutputRangeType& outputRange,
|
||||
DeviceAdapter device) const
|
||||
{
|
||||
using ParameterInterfaceType = typename Invocation::ParameterInterface;
|
||||
ParameterInterfaceType& parameters = invocation.Parameters;
|
||||
|
||||
using TransportFunctorType = vtkm::worklet::internal::detail::DispatcherBaseTransportFunctor<
|
||||
typename Invocation::ControlInterface,
|
||||
typename Invocation::InputDomainType,
|
||||
DeviceAdapter>;
|
||||
using ExecObjectParameters =
|
||||
typename ParameterInterfaceType::template StaticTransformType<TransportFunctorType>::type;
|
||||
|
||||
vtkm::cont::Token token;
|
||||
|
||||
ExecObjectParameters execObjectParameters = parameters.StaticTransformCont(
|
||||
TransportFunctorType(invocation.GetInputDomain(), inputRange, outputRange, token));
|
||||
|
||||
// Get the arrays used for scattering input to output.
|
||||
typename ScatterType::OutputToInputMapType outputToInputMap =
|
||||
this->Scatter.GetOutputToInputMap(inputRange);
|
||||
typename ScatterType::VisitArrayType visitArray = this->Scatter.GetVisitArray(inputRange);
|
||||
|
||||
// Get the arrays used for masking output elements.
|
||||
typename MaskType::ThreadToOutputMapType threadToOutputMap =
|
||||
this->Mask.GetThreadToOutputMap(inputRange);
|
||||
|
||||
// Replace the parameters in the invocation with the execution object and
|
||||
// pass to next step of Invoke. Also add the scatter information.
|
||||
this->InvokeSchedule(
|
||||
invocation.ChangeParameters(execObjectParameters)
|
||||
.ChangeOutputToInputMap(outputToInputMap.PrepareForInput(device, token))
|
||||
.ChangeVisitArray(visitArray.PrepareForInput(device, token))
|
||||
.ChangeThreadToOutputMap(threadToOutputMap.PrepareForInput(device, token)),
|
||||
outputRange,
|
||||
globalIndexOffset,
|
||||
device);
|
||||
}
|
||||
|
||||
template <typename Invocation, typename RangeType, typename DeviceAdapter>
|
||||
VTKM_CONT void InvokeSchedule(const Invocation& invocation,
|
||||
RangeType range,
|
||||
RangeType globalIndexOffset,
|
||||
DeviceAdapter) const
|
||||
{
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using TaskTypes = typename vtkm::cont::DeviceTaskTypes<DeviceAdapter>;
|
||||
|
||||
// The TaskType class handles the magic of fetching values
|
||||
// for each instance and calling the worklet's function.
|
||||
// The TaskType will evaluate to one of the following classes:
|
||||
//
|
||||
// vtkm::exec::internal::TaskSingular
|
||||
// vtkm::exec::internal::TaskTiling1D
|
||||
// vtkm::exec::internal::TaskTiling3D
|
||||
auto task = TaskTypes::MakeTask(this->Worklet, invocation, range, globalIndexOffset);
|
||||
Algorithm::ScheduleTask(task, range);
|
||||
}
|
||||
|
||||
vtkm::Id NumberOfBlocks;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::worklet
|
||||
|
||||
#endif //vtk_m_worklet_Dispatcher_Streaming_MapField_h
|
@ -167,16 +167,11 @@ public:
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset) const
|
||||
const InputDomainType& connectivity) const
|
||||
{
|
||||
const vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType>(threadIndex,
|
||||
outToIn.Get(outIndex),
|
||||
visit.Get(outIndex),
|
||||
outIndex,
|
||||
connectivity,
|
||||
globalThreadIndexOffset);
|
||||
return vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType>(
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, connectivity);
|
||||
}
|
||||
|
||||
/// In the remaining methods and `constexpr` we determine at compilation time
|
||||
@ -208,11 +203,10 @@ public:
|
||||
const OutToInArrayType& vtkmNotUsed(outToIn),
|
||||
const VisitArrayType& vtkmNotUsed(visit),
|
||||
const ThreadToOutArrayType& vtkmNotUsed(threadToOut),
|
||||
const InputDomainType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0) const
|
||||
const InputDomainType& connectivity) const
|
||||
{
|
||||
return vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType>(
|
||||
threadIndex3D, threadIndex1D, connectivity, globalThreadIndexOffset);
|
||||
threadIndex3D, threadIndex1D, connectivity);
|
||||
}
|
||||
|
||||
/// Default version
|
||||
@ -229,8 +223,7 @@ public:
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0) const
|
||||
const InputDomainType& connectivity) const
|
||||
{
|
||||
const vtkm::Id outIndex = threadToOut.Get(threadIndex1D);
|
||||
return vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType>(threadIndex3D,
|
||||
@ -238,8 +231,7 @@ public:
|
||||
outToIn.Get(outIndex),
|
||||
visit.Get(outIndex),
|
||||
outIndex,
|
||||
connectivity,
|
||||
globalThreadIndexOffset);
|
||||
connectivity);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -185,16 +185,12 @@ public:
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension>& inputDomain, //this should be explicitly
|
||||
vtkm::Id globalThreadIndexOffset = 0) const
|
||||
Dimension>& inputDomain //this should be explicit
|
||||
) const
|
||||
{
|
||||
const vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesPointNeighborhood(threadIndex,
|
||||
outToIn.Get(outIndex),
|
||||
visit.Get(outIndex),
|
||||
outIndex,
|
||||
inputDomain,
|
||||
globalThreadIndexOffset);
|
||||
return vtkm::exec::arg::ThreadIndicesPointNeighborhood(
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, inputDomain);
|
||||
}
|
||||
|
||||
|
||||
@ -226,11 +222,10 @@ public:
|
||||
const OutToInArrayType& vtkmNotUsed(outToIn),
|
||||
const VisitArrayType& vtkmNotUsed(visit),
|
||||
const ThreadToOutArrayType& vtkmNotUsed(threadToOut),
|
||||
const InputDomainType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0) const
|
||||
const InputDomainType& connectivity) const
|
||||
{
|
||||
return vtkm::exec::arg::ThreadIndicesPointNeighborhood(
|
||||
threadIndex3D, threadIndex1D, connectivity, globalThreadIndexOffset);
|
||||
threadIndex3D, threadIndex1D, connectivity);
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
@ -246,8 +241,7 @@ public:
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType& connectivity,
|
||||
vtkm::Id globalThreadIndexOffset = 0) const
|
||||
const InputDomainType& connectivity) const
|
||||
{
|
||||
const vtkm::Id outIndex = threadToOut.Get(threadIndex1D);
|
||||
return vtkm::exec::arg::ThreadIndicesPointNeighborhood(threadIndex3D,
|
||||
@ -255,8 +249,7 @@ public:
|
||||
outToIn.Get(outIndex),
|
||||
visit.Get(outIndex),
|
||||
outIndex,
|
||||
connectivity,
|
||||
globalThreadIndexOffset);
|
||||
connectivity);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -177,16 +177,11 @@ public:
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType& inputDomain,
|
||||
vtkm::Id globalThreadIndexOffset = 0) const
|
||||
const InputDomainType& inputDomain) const
|
||||
{
|
||||
const vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesReduceByKey(threadIndex,
|
||||
outToIn.Get(outIndex),
|
||||
visit.Get(outIndex),
|
||||
outIndex,
|
||||
inputDomain,
|
||||
globalThreadIndexOffset);
|
||||
return vtkm::exec::arg::ThreadIndicesReduceByKey(
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, inputDomain);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ public:
|
||||
//Optimization for structured cellsets so we can call StructuredPointGradient
|
||||
//and have way faster gradients
|
||||
vtkm::exec::ConnectivityStructured<Point, Cell, 3> pointGeom(geometry);
|
||||
vtkm::exec::arg::ThreadIndicesPointNeighborhood tpn(pointId, pointId, 0, pointId, pointGeom, 0);
|
||||
vtkm::exec::arg::ThreadIndicesPointNeighborhood tpn(pointId, pointId, 0, pointId, pointGeom);
|
||||
|
||||
const auto& boundary = tpn.GetBoundaryState();
|
||||
auto pointPortal = pointCoordinates.GetPortal();
|
||||
@ -535,7 +535,7 @@ public:
|
||||
//Optimization for structured cellsets so we can call StructuredPointGradient
|
||||
//and have way faster gradients
|
||||
vtkm::exec::ConnectivityStructured<Point, Cell, 3> pointGeom(geometry);
|
||||
vtkm::exec::arg::ThreadIndicesPointNeighborhood tpn(pointId, pointId, 0, pointId, pointGeom, 0);
|
||||
vtkm::exec::arg::ThreadIndicesPointNeighborhood tpn(pointId, pointId, 0, pointId, pointGeom);
|
||||
|
||||
const auto& boundary = tpn.GetBoundaryState();
|
||||
auto pointPortal = pointCoordinates.GetPortal();
|
||||
|
@ -266,12 +266,11 @@ public:
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType&,
|
||||
const vtkm::Id& globalThreadIndexOffset = 0) const
|
||||
const InputDomainType&) const
|
||||
{
|
||||
vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic(
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex, globalThreadIndexOffset);
|
||||
threadIndex, outToIn.Get(outIndex), visit.Get(outIndex), outIndex);
|
||||
}
|
||||
|
||||
/// \brief Creates a \c ThreadIndices object.
|
||||
@ -290,16 +289,11 @@ public:
|
||||
const OutToInArrayType& outToIn,
|
||||
const VisitArrayType& visit,
|
||||
const ThreadToOutArrayType& threadToOut,
|
||||
const InputDomainType&,
|
||||
const vtkm::Id& globalThreadIndexOffset = 0) const
|
||||
const InputDomainType&) const
|
||||
{
|
||||
vtkm::Id outIndex = threadToOut.Get(threadIndex1D);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic3D(threadIndex3D,
|
||||
threadIndex1D,
|
||||
outToIn.Get(outIndex),
|
||||
visit.Get(outIndex),
|
||||
outIndex,
|
||||
globalThreadIndexOffset);
|
||||
return vtkm::exec::arg::ThreadIndicesBasic3D(
|
||||
threadIndex3D, threadIndex1D, outToIn.Get(outIndex), visit.Get(outIndex), outIndex);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -59,7 +59,6 @@ set(unit_tests
|
||||
UnitTestSplatKernels.cxx
|
||||
UnitTestSplitSharpEdges.cxx
|
||||
UnitTestScatterAndMaskWithTopology.cxx
|
||||
UnitTestStreamingSine.cxx
|
||||
UnitTestStreamLineUniformGrid.cxx
|
||||
UnitTestStreamSurface.cxx
|
||||
UnitTestSurfaceNormals.cxx
|
||||
|
@ -1,118 +0,0 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayHandleStreaming.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/DispatcherStreamingMapField.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace worklet
|
||||
{
|
||||
class SineWorklet : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
using ControlSignature = void(FieldIn, FieldOut);
|
||||
using ExecutionSignature = _2(_1, WorkIndex);
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC T operator()(T x, vtkm::Id& index) const
|
||||
{
|
||||
return (static_cast<T>(index) + vtkm::Sin(x));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Utility method to print input, output, and reference arrays
|
||||
template <class T1, class T2, class T3>
|
||||
void compareArrays(T1& a1, T2& a2, T3& a3, char const* text)
|
||||
{
|
||||
for (vtkm::Id i = 0; i < a1.GetNumberOfValues(); ++i)
|
||||
{
|
||||
std::cout << a1.ReadPortal().Get(i) << " " << a2.ReadPortal().Get(i) << " "
|
||||
<< a3.ReadPortal().Get(i) << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(a2.ReadPortal().Get(i), a3.ReadPortal().Get(i), 0.01f), text);
|
||||
}
|
||||
}
|
||||
|
||||
void TestStreamingSine()
|
||||
{
|
||||
// Test the streaming worklet
|
||||
std::cout << "Testing streaming worklet:" << std::endl;
|
||||
|
||||
const vtkm::Id N = 25;
|
||||
const vtkm::Id NBlocks = 4;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> input, output, reference, summation;
|
||||
std::vector<vtkm::Float32> data(N), test(N);
|
||||
vtkm::Float32 testSum = 0.0f;
|
||||
for (vtkm::UInt32 i = 0; i < N; i++)
|
||||
{
|
||||
data[i] = static_cast<vtkm::Float32>(i);
|
||||
test[i] = static_cast<vtkm::Float32>(i) + static_cast<vtkm::Float32>(vtkm::Sin(data[i]));
|
||||
testSum += test[i];
|
||||
}
|
||||
input = vtkm::cont::make_ArrayHandle(data);
|
||||
|
||||
using DeviceAlgorithms = vtkm::cont::Algorithm;
|
||||
vtkm::worklet::SineWorklet sineWorklet;
|
||||
vtkm::worklet::DispatcherStreamingMapField<vtkm::worklet::SineWorklet> dispatcher(sineWorklet);
|
||||
dispatcher.SetNumberOfBlocks(NBlocks);
|
||||
dispatcher.Invoke(input, output);
|
||||
|
||||
reference = vtkm::cont::make_ArrayHandle(test);
|
||||
compareArrays(input, output, reference, "Wrong result for streaming sine worklet");
|
||||
|
||||
vtkm::Float32 referenceSum, streamSum;
|
||||
|
||||
// Test the streaming exclusive scan
|
||||
std::cout << "Testing streaming exclusive scan: " << std::endl;
|
||||
referenceSum = DeviceAlgorithms::ScanExclusive(input, summation);
|
||||
streamSum = DeviceAlgorithms::StreamingScanExclusive(4, input, output);
|
||||
VTKM_TEST_ASSERT(test_equal(streamSum, referenceSum, 0.01f),
|
||||
"Wrong sum for streaming exclusive scan");
|
||||
compareArrays(input, output, summation, "Wrong result for streaming exclusive scan");
|
||||
|
||||
// Test the streaming exclusive scan with binary operator
|
||||
std::cout << "Testing streaming exnclusive scan with binary operator: " << std::endl;
|
||||
vtkm::Float32 initValue = 0.0;
|
||||
referenceSum = DeviceAlgorithms::ScanExclusive(input, summation, vtkm::Maximum(), initValue);
|
||||
streamSum =
|
||||
DeviceAlgorithms::StreamingScanExclusive(4, input, output, vtkm::Maximum(), initValue);
|
||||
VTKM_TEST_ASSERT(test_equal(streamSum, referenceSum, 0.01f),
|
||||
"Wrong sum for streaming exclusive scan with binary operator");
|
||||
compareArrays(
|
||||
input, output, summation, "Wrong result for streaming exclusive scan with binary operator");
|
||||
|
||||
// Test the streaming reduce
|
||||
std::cout << "Testing streaming reduce: " << std::endl;
|
||||
referenceSum = DeviceAlgorithms::Reduce(input, 0.0f);
|
||||
streamSum = DeviceAlgorithms::StreamingReduce(4, input, 0.0f);
|
||||
std::cout << "Result: " << streamSum << " " << referenceSum << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(streamSum, referenceSum, 0.01f), "Wrong sum for streaming reduce");
|
||||
|
||||
// Test the streaming reduce with binary operator
|
||||
std::cout << "Testing streaming reduce with binary operator: " << std::endl;
|
||||
referenceSum = DeviceAlgorithms::Reduce(input, 0.0f, vtkm::Maximum());
|
||||
streamSum = DeviceAlgorithms::StreamingReduce(4, input, 0.0f, vtkm::Maximum());
|
||||
std::cout << "Result: " << streamSum << " " << referenceSum << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(streamSum, referenceSum, 0.01f),
|
||||
"Wrong sum for streaming reduce with binary operator");
|
||||
}
|
||||
|
||||
int UnitTestStreamingSine(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestStreamingSine, argc, argv);
|
||||
}
|
Loading…
Reference in New Issue
Block a user