From 5908aeeaba8f768bcce467849d1d41be5ac96599 Mon Sep 17 00:00:00 2001 From: Antonio Sanchez Date: Wed, 17 Feb 2021 15:09:37 -0800 Subject: Fix CUDA device new and delete, and add test. HIP does not support new/delete on device, so test is skipped. --- test/gpu_basic.cu | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test') diff --git a/test/gpu_basic.cu b/test/gpu_basic.cu index 46e4a436f..1935f0bc6 100644 --- a/test/gpu_basic.cu +++ b/test/gpu_basic.cu @@ -233,6 +233,26 @@ struct replicate { } }; +template +struct alloc_new_delete { + EIGEN_DEVICE_FUNC + void operator()(int i, const typename T::Scalar* in, typename T::Scalar* out) const + { + int offset = 2*i*T::MaxSizeAtCompileTime; + T* x = new T(in + offset); + Eigen::Map u(out + offset); + u = *x; + delete x; + + offset += T::MaxSizeAtCompileTime; + T* y = new T[1]; + y[0] = T(in + offset); + Eigen::Map v(out + offset); + v = y[0]; + delete[] y; + } +}; + template struct redux { EIGEN_DEVICE_FUNC @@ -418,4 +438,5 @@ EIGEN_DECLARE_TEST(gpu_basic) typedef Matrix Matrix6f; CALL_SUBTEST( run_and_compare_to_gpu(eigenvalues(), nthreads, in, out) ); #endif + CALL_SUBTEST( run_and_compare_to_gpu(alloc_new_delete(), nthreads, in, out) ); } -- cgit v1.2.3