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.
This commit is contained in:
Kenneth Moreland 2019-12-09 17:56:08 -05:00
parent 851864d0b5
commit aec75ab1a2
5 changed files with 33 additions and 0 deletions

@ -412,6 +412,13 @@ public:
: Superclass(StorageType(firstArray, secondArray, thirdArray))
{
}
/// 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.
///
~ArrayHandleCartesianProduct() {}
};
/// A convenience function for creating an ArrayHandleCartesianProduct. It takes the two

@ -62,6 +62,13 @@ public:
this->ValidateTypeCast<typename ArrayHandleType::ValueType>();
}
/// 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.
///
~ArrayHandleCast() {}
private:
// Log warnings if type cast is valid but lossy:
template <typename SrcValueType>

@ -703,6 +703,13 @@ public:
: Superclass(StorageType(handle, functor, inverseFunctor))
{
}
/// 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.
///
~ArrayHandleTransform() {}
};
template <typename HandleType, typename FunctorType, typename InverseFunctorType>

@ -48,6 +48,13 @@ public:
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

@ -119,6 +119,11 @@ public:
void PrintSummary(std::ostream& out) const override;
// Cannot use the default implementation of the destructure because the CUDA compiler
// will attempt to create it for device, and then it will fail when it tries to call
// the destructor of the superclass.
~CellSetStructured() override {}
private:
InternalsType Structure;
};