vtk-m/vtkm/cont/ArrayHandleUniformPointCoordinates.h
Kenneth Moreland aec75ab1a2 Suppress CUDA warning about device calling host
The destructors of some control side objects (such as CellSet and
ArrayHandle) are defined. These destructors are obviously only compiled
for the control environment (i.e. for CUDA only for the host). However,
not all of the subclasses implemented their own destructors. In CUDA,
when a default destructor is used, it is compiled for both host and
device. This caused a problem as the superclass's destructor was only
compiled for the host and therefore caused a warning.

Fixed the problem by defining an empty destructor to any subclasses that
needed one.

It's weird that I ran into this problem while chaning the List TMP
class, but the solution seems fine.
2019-12-10 09:15:40 -07:00

130 lines
4.1 KiB
C++

//============================================================================
// 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_ArrayHandleUniformPointCoordinates_h
#define vtk_m_cont_ArrayHandleUniformPointCoordinates_h
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/StorageImplicit.h>
#include <vtkm/internal/ArrayPortalUniformPointCoordinates.h>
namespace vtkm
{
namespace cont
{
/// ArrayHandleUniformPointCoordinates is a specialization of ArrayHandle. It
/// contains the information necessary to compute the point coordinates in a
/// uniform orthogonal grid (extent, origin, and spacing) and implicitly
/// computes these coordinates in its array portal.
///
class VTKM_ALWAYS_EXPORT ArrayHandleUniformPointCoordinates
: public vtkm::cont::ArrayHandle<
vtkm::Vec3f,
vtkm::cont::StorageTagImplicit<vtkm::internal::ArrayPortalUniformPointCoordinates>>
{
public:
VTKM_ARRAY_HANDLE_SUBCLASS_NT(
ArrayHandleUniformPointCoordinates,
(vtkm::cont::ArrayHandle<
vtkm::Vec3f,
vtkm::cont::StorageTagImplicit<vtkm::internal::ArrayPortalUniformPointCoordinates>>));
private:
using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
public:
VTKM_CONT
ArrayHandleUniformPointCoordinates(vtkm::Id3 dimensions,
ValueType origin = ValueType(0.0f, 0.0f, 0.0f),
ValueType spacing = ValueType(1.0f, 1.0f, 1.0f))
: Superclass(StorageType(
vtkm::internal::ArrayPortalUniformPointCoordinates(dimensions, origin, spacing)))
{
}
/// Implemented so that it is defined exclusively in the control environment.
/// If there is a separate device for the execution environment (for example,
/// with CUDA), then the automatically generated destructor could be
/// created for all devices, and it would not be valid for all devices.
///
~ArrayHandleUniformPointCoordinates() {}
};
}
} // namespace vtkm::cont
//=============================================================================
// Specializations of serialization related classes
/// @cond SERIALIZATION
namespace vtkm
{
namespace cont
{
template <>
struct SerializableTypeString<vtkm::cont::ArrayHandleUniformPointCoordinates>
{
static VTKM_CONT const std::string Get() { return "AH_UniformPointCoordinates"; }
};
template <>
struct SerializableTypeString<vtkm::cont::ArrayHandle<
vtkm::Vec3f,
vtkm::cont::StorageTagImplicit<vtkm::internal::ArrayPortalUniformPointCoordinates>>>
: SerializableTypeString<vtkm::cont::ArrayHandleUniformPointCoordinates>
{
};
}
} // vtkm::cont
namespace mangled_diy_namespace
{
template <>
struct Serialization<vtkm::cont::ArrayHandleUniformPointCoordinates>
{
private:
using Type = vtkm::cont::ArrayHandleUniformPointCoordinates;
using BaseType = vtkm::cont::ArrayHandle<typename Type::ValueType, typename Type::StorageTag>;
public:
static VTKM_CONT void save(BinaryBuffer& bb, const BaseType& obj)
{
auto portal = obj.GetPortalConstControl();
vtkmdiy::save(bb, portal.GetDimensions());
vtkmdiy::save(bb, portal.GetOrigin());
vtkmdiy::save(bb, portal.GetSpacing());
}
static VTKM_CONT void load(BinaryBuffer& bb, BaseType& obj)
{
vtkm::Id3 dims;
typename BaseType::ValueType origin, spacing;
vtkmdiy::load(bb, dims);
vtkmdiy::load(bb, origin);
vtkmdiy::load(bb, spacing);
obj = vtkm::cont::ArrayHandleUniformPointCoordinates(dims, origin, spacing);
}
};
template <>
struct Serialization<vtkm::cont::ArrayHandle<
vtkm::Vec3f,
vtkm::cont::StorageTagImplicit<vtkm::internal::ArrayPortalUniformPointCoordinates>>>
: Serialization<vtkm::cont::ArrayHandleUniformPointCoordinates>
{
};
} // diy
/// @endcond SERIALIZATION
#endif //vtk_+m_cont_ArrayHandleUniformPointCoordinates_h