aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Antonio Sanchez <cantonios@google.com>2021-02-17 15:09:37 -0800
committerGravatar Antonio Sanchez <cantonios@google.com>2021-02-24 11:31:41 -0800
commit5908aeeaba8f768bcce467849d1d41be5ac96599 (patch)
treef5a6215fce2ec41fc8dded5bdd387af58ab16769 /test
parent119763cf38093ddc82ae2a9d644e3d975148d908 (diff)
Fix CUDA device new and delete, and add test.
HIP does not support new/delete on device, so test is skipped.
Diffstat (limited to 'test')
-rw-r--r--test/gpu_basic.cu21
1 files changed, 21 insertions, 0 deletions
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
@@ -234,6 +234,26 @@ struct replicate {
};
template<typename T>
+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<T> u(out + offset);
+ u = *x;
+ delete x;
+
+ offset += T::MaxSizeAtCompileTime;
+ T* y = new T[1];
+ y[0] = T(in + offset);
+ Eigen::Map<T> v(out + offset);
+ v = y[0];
+ delete[] y;
+ }
+};
+
+template<typename T>
struct redux {
EIGEN_DEVICE_FUNC
void operator()(int i, const typename T::Scalar* in, typename T::Scalar* out) const
@@ -418,4 +438,5 @@ EIGEN_DECLARE_TEST(gpu_basic)
typedef Matrix<float,6,6> Matrix6f;
CALL_SUBTEST( run_and_compare_to_gpu(eigenvalues<Matrix6f>(), nthreads, in, out) );
#endif
+ CALL_SUBTEST( run_and_compare_to_gpu(alloc_new_delete<Vector3f>(), nthreads, in, out) );
}