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
|
|
|
|
2021-02-10 00:59:25 +00:00
|
|
|
#include <vtkm/Deprecated.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace exec
|
|
|
|
{
|
2015-06-15 14:20:51 +00:00
|
|
|
|
2021-02-10 00:59:25 +00:00
|
|
|
/// The following classes have been sort of deprecated and are meant to be used
|
2017-12-22 18:25:35 +00:00
|
|
|
/// 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
|
|
|
///
|
2021-02-10 00:59:25 +00:00
|
|
|
template <typename T, typename StorageTag, typename... MaybeDevice>
|
|
|
|
class ExecutionWholeArray;
|
|
|
|
|
|
|
|
template <typename T, typename StorageTag>
|
|
|
|
class ExecutionWholeArray<T, StorageTag>
|
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>;
|
2021-02-01 15:03:11 +00:00
|
|
|
using PortalType = typename HandleType::WritePortalType;
|
2016-11-23 17:53:41 +00:00
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-01-19 06:36:14 +00:00
|
|
|
VTKM_CONT
|
2021-02-10 00:59:25 +00:00
|
|
|
ExecutionWholeArray(HandleType& handle,
|
|
|
|
vtkm::cont::DeviceAdapterId device,
|
|
|
|
vtkm::cont::Token& token)
|
|
|
|
: Portal(handle.PrepareForInPlace(device, token))
|
2020-01-19 06:36:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
2021-02-10 00:59:25 +00:00
|
|
|
ExecutionWholeArray(HandleType& handle,
|
|
|
|
vtkm::Id length,
|
|
|
|
vtkm::cont::DeviceAdapterId device,
|
|
|
|
vtkm::cont::Token& token)
|
|
|
|
: Portal(handle.PrepareForOutput(length, device, token))
|
2020-01-19 06:36:14 +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;
|
|
|
|
};
|
|
|
|
|
2021-02-10 00:59:25 +00:00
|
|
|
template <typename T, typename StorageTag, typename Device>
|
|
|
|
class VTKM_DEPRECATED(1.6, "ExecutionWholeArray no longer uses Device template parameter.")
|
|
|
|
ExecutionWholeArray<T, StorageTag, Device> : public ExecutionWholeArray<T, StorageTag>
|
|
|
|
{
|
|
|
|
using Superclass = ExecutionWholeArray<T, StorageTag>;
|
|
|
|
using HandleType = typename Superclass::HandleType;
|
|
|
|
|
|
|
|
public:
|
|
|
|
using Superclass::Superclass;
|
|
|
|
|
|
|
|
VTKM_CONT ExecutionWholeArray(HandleType& handle)
|
|
|
|
: Superclass(handle, Device{}, vtkm::cont::Token{})
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
ExecutionWholeArray(HandleType& handle, vtkm::Id length)
|
|
|
|
: Superclass(handle, length, Device{}, vtkm::cont::Token{})
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
ExecutionWholeArray(HandleType& handle, vtkm::cont::Token& token)
|
|
|
|
: Superclass(handle, Device{}, token)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
ExecutionWholeArray(HandleType& handle, vtkm::Id length, vtkm::cont::Token& token)
|
|
|
|
: Superclass(handle, length, Device{}, token)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-06-15 14:20:51 +00:00
|
|
|
/// \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
|
|
|
|
///
|
2021-02-10 00:59:25 +00:00
|
|
|
template <typename T, typename StorageTag, typename... MaybeDevice>
|
|
|
|
class ExecutionWholeArrayConst;
|
|
|
|
|
|
|
|
template <typename T, typename StorageTag>
|
|
|
|
class ExecutionWholeArrayConst<T, StorageTag>
|
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>;
|
2021-02-01 15:03:11 +00:00
|
|
|
using PortalType = typename HandleType::ReadPortalType;
|
2016-11-23 17:53:41 +00:00
|
|
|
|
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
|
2021-02-10 00:59:25 +00:00
|
|
|
ExecutionWholeArrayConst(const HandleType& handle,
|
|
|
|
vtkm::cont::DeviceAdapterId device,
|
|
|
|
vtkm::cont::Token& token)
|
|
|
|
: Portal(handle.PrepareForInput(device, token))
|
2020-01-19 06:36:14 +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;
|
|
|
|
};
|
2021-02-10 00:59:25 +00:00
|
|
|
|
|
|
|
template <typename T, typename StorageTag, typename Device>
|
|
|
|
class VTKM_DEPRECATED(1.6, "ExecutionWholeArray no longer uses Device template parameter.")
|
|
|
|
ExecutionWholeArrayConst<T, StorageTag, Device> : public ExecutionWholeArrayConst<T, StorageTag>
|
|
|
|
{
|
|
|
|
using Superclass = ExecutionWholeArrayConst<T, StorageTag>;
|
|
|
|
using HandleType = typename Superclass::HandleType;
|
|
|
|
|
|
|
|
public:
|
|
|
|
using Superclass::Superclass;
|
|
|
|
|
|
|
|
VTKM_CONT ExecutionWholeArrayConst(HandleType& handle)
|
|
|
|
: Superclass(handle, Device{}, vtkm::cont::Token{})
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
ExecutionWholeArrayConst(HandleType& handle, vtkm::cont::Token& token)
|
|
|
|
: Superclass(handle, Device{}, token)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-06-15 14:20:51 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::exec
|
|
|
|
|
2018-09-10 17:28:46 +00:00
|
|
|
#endif //vtk_m_exec_ExecutionWholeArray_h
|