diff --git a/src/utils/DeviceVector.h b/src/utils/DeviceVector.h index 4024edf34..ebe3e4db8 100644 --- a/src/utils/DeviceVector.h +++ b/src/utils/DeviceVector.h @@ -13,6 +13,7 @@ #include #include #include +#include #include // External Includes @@ -35,12 +36,16 @@ namespace cuda_utilities * `data()` method. This class works for any device side pointer, scalar or * array valued. * - * \tparam T Any serialized type where `sizeof(T)` returns correct results - * should work but non-primitive types have not been tested. + * \tparam T Any trivially copyable type where `sizeof(T)` returns correct + * results should work, but non-primitive types have not been tested. */ template class DeviceVector { + static_assert(std::is_trivially_copyable_v, + "DeviceVector can only be used with trivially_copyable types due to the internal " + "usage of functions like cudaMemcpy, cudaMemcpyPeer, cudaMemset"); + public: /*! * \brief Construct a new Device Vector object by calling the @@ -60,6 +65,15 @@ class DeviceVector */ ~DeviceVector() { _deAllocate(); } + /* The following are deleted because they currently lead to invalid state. + * (But they can all easily be implemented in the future). + */ + DeviceVector() = delete; + DeviceVector(const DeviceVector &) = delete; + DeviceVector(DeviceVector &&) = delete; + DeviceVector &operator=(const DeviceVector &other) = delete; + DeviceVector &operator=(DeviceVector &&other) = delete; + /*! * \brief Get the raw device pointer *