}
/**
- * Deleter to be used for `std::unique_ptr` pointing to device memory.
+ * Allocator to be used for `std::unique_ptr` pointing to device memory.
*/
template <typename Number>
- void
- delete_device_data(Number *device_ptr) noexcept
+ Number *
+ allocate_device_data(const std::size_t size)
{
#ifdef DEAL_II_COMPILER_CUDA_AWARE
- const cudaError_t error_code = cudaFree(device_ptr);
- (void)error_code;
- AssertNothrow(error_code == cudaSuccess,
- dealii::ExcCudaError(cudaGetErrorString(error_code)));
+ Number *device_ptr;
+ Utilities::CUDA::malloc(device_ptr, size);
+ return device_ptr;
#else
- (void)device_ptr;
+ (void)size;
+ Assert(
+ false,
+ ExcMessage(
+ "This function can only be used if deal.II is built with CUDA support!"));
#endif
}
/**
- * Allocator to be used for `std::unique_ptr` pointing to device memory.
+ * Deleter to be used for `std::unique_ptr` pointing to device memory.
*/
template <typename Number>
- Number *
- allocate_device_data(const std::size_t size)
+ void
+ delete_device_data(Number *device_ptr) noexcept
{
#ifdef DEAL_II_COMPILER_CUDA_AWARE
- Number *device_ptr;
- Utilities::CUDA::malloc(device_ptr, size);
- return device_ptr;
+ const cudaError_t error_code = cudaFree(device_ptr);
+ AssertNothrowCuda(error_code);
#else
- (void)size;
+ (void)device_ptr;
+ AssertNothrow(
+ false,
+ ExcMessage(
+ "This function can only be used if deal.II is built with CUDA support!"));
#endif
}