2015-06-15 14:20:51 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2015-06-15 14:20:51 +00:00
|
|
|
// 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_exec_ExecutionWholeArray_h
|
|
|
|
#define vtk_m_exec_ExecutionWholeArray_h
|
|
|
|
|
|
|
|
#include <vtkm/cont/ArrayHandle.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/cont/DeviceAdapter.h>
|
2015-06-15 14:20:51 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace exec
|
|
|
|
{
|
2015-06-15 14:20:51 +00:00
|
|
|
|
2017-12-22 18:25:35 +00:00
|
|
|
/// The following classes have been deprecated and are meant to be used
|
|
|
|
/// internally only. Please use the \c WholeArrayIn, \c WholeArrayOut, and
|
|
|
|
/// \c WholeArrayInOut \c ControlSignature tags instead.
|
|
|
|
|
2015-06-15 14:20:51 +00:00
|
|
|
/// \c ExecutionWholeArray is an execution object that allows an array handle
|
|
|
|
/// content to be a parameter in an execution environment
|
|
|
|
/// function. This can be used to allow worklets to have a shared search
|
2017-12-22 18:25:35 +00:00
|
|
|
/// structure.
|
2015-06-15 14:20:51 +00:00
|
|
|
///
|
2017-12-22 18:25:35 +00:00
|
|
|
template <typename T, typename StorageTag, typename DeviceAdapterTag>
|
2018-09-10 17:28:46 +00:00
|
|
|
class ExecutionWholeArray
|
2015-06-15 14:20:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-11-23 17:53:41 +00:00
|
|
|
using ValueType = T;
|
2017-05-18 14:29:41 +00:00
|
|
|
using HandleType = vtkm::cont::ArrayHandle<T, StorageTag>;
|
2016-11-23 17:53:41 +00:00
|
|
|
using PortalType = typename HandleType::template ExecutionTypes<DeviceAdapterTag>::Portal;
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ExecutionWholeArray()
|
|
|
|
: Portal()
|
2015-06-15 14:20:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ExecutionWholeArray(HandleType& handle)
|
|
|
|
: Portal(handle.PrepareForInPlace(DeviceAdapterTag()))
|
2015-08-24 18:42:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ExecutionWholeArray(HandleType& handle, vtkm::Id length)
|
|
|
|
: Portal(handle.PrepareForOutput(length, DeviceAdapterTag()))
|
2015-06-15 14:20:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC
|
2015-09-09 19:26:51 +00:00
|
|
|
vtkm::Id GetNumberOfValues() const { return this->Portal.GetNumberOfValues(); }
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC
|
2015-06-15 14:20:51 +00:00
|
|
|
T Get(vtkm::Id index) const { return this->Portal.Get(index); }
|
|
|
|
|
2017-03-14 12:56:44 +00:00
|
|
|
VTKM_EXEC
|
|
|
|
T operator[](vtkm::Id index) const { return this->Portal.Get(index); }
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC
|
2016-01-27 16:07:20 +00:00
|
|
|
void Set(vtkm::Id index, const T& t) const { this->Portal.Set(index, t); }
|
2015-06-15 14:20:51 +00:00
|
|
|
|
2016-11-25 16:39:08 +00:00
|
|
|
VTKM_EXEC
|
|
|
|
const PortalType& GetPortal() const { return this->Portal; }
|
|
|
|
|
2015-06-15 14:20:51 +00:00
|
|
|
private:
|
|
|
|
PortalType Portal;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \c ExecutionWholeArrayConst is an execution object that allows an array handle
|
|
|
|
/// content to be a parameter in an execution environment
|
|
|
|
/// function. This can be used to allow worklets to have a shared search
|
|
|
|
/// structure
|
|
|
|
///
|
2017-12-22 18:25:35 +00:00
|
|
|
template <typename T, typename StorageTag, typename DeviceAdapterTag>
|
2018-09-10 17:28:46 +00:00
|
|
|
class ExecutionWholeArrayConst
|
2015-06-15 14:20:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-11-23 17:53:41 +00:00
|
|
|
using ValueType = T;
|
2017-05-18 14:29:41 +00:00
|
|
|
using HandleType = vtkm::cont::ArrayHandle<T, StorageTag>;
|
2016-11-23 17:53:41 +00:00
|
|
|
using PortalType = typename HandleType::template ExecutionTypes<DeviceAdapterTag>::PortalConst;
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ExecutionWholeArrayConst()
|
|
|
|
: Portal()
|
2015-06-15 14:20:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ExecutionWholeArrayConst(const HandleType& handle)
|
|
|
|
: Portal(handle.PrepareForInput(DeviceAdapterTag()))
|
2015-06-15 14:20:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC
|
2015-09-09 19:26:51 +00:00
|
|
|
vtkm::Id GetNumberOfValues() const { return this->Portal.GetNumberOfValues(); }
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC
|
2015-06-15 14:20:51 +00:00
|
|
|
T Get(vtkm::Id index) const { return this->Portal.Get(index); }
|
|
|
|
|
2017-03-14 12:56:44 +00:00
|
|
|
VTKM_EXEC
|
|
|
|
T operator[](vtkm::Id index) const { return this->Portal.Get(index); }
|
|
|
|
|
2016-11-25 16:39:08 +00:00
|
|
|
VTKM_EXEC
|
|
|
|
const PortalType& GetPortal() const { return this->Portal; }
|
|
|
|
|
2015-06-15 14:20:51 +00:00
|
|
|
private:
|
|
|
|
PortalType Portal;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} // namespace vtkm::exec
|
|
|
|
|
2018-09-10 17:28:46 +00:00
|
|
|
#endif //vtk_m_exec_ExecutionWholeArray_h
|