From fdaf596926b5d1835ad6173f38f4e8c41a4ce3d9 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sun, 19 Aug 2018 01:47:38 +0200 Subject: [PATCH] Add a move assignment operator for CUDAWrappers::SparseMatrix --- include/deal.II/lac/cuda_sparse_matrix.h | 12 +++++++++++ source/lac/cuda_sparse_matrix.cu | 26 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/deal.II/lac/cuda_sparse_matrix.h b/include/deal.II/lac/cuda_sparse_matrix.h index f8a1bb11e2..4599622de6 100644 --- a/include/deal.II/lac/cuda_sparse_matrix.h +++ b/include/deal.II/lac/cuda_sparse_matrix.h @@ -103,6 +103,18 @@ namespace CUDAWrappers */ ~SparseMatrix(); + /** + * Move assignment operator. + */ + SparseMatrix & + operator=(CUDAWrappers::SparseMatrix &&); + + /** + * Copy assignment is deleted. + */ + SparseMatrix & + operator=(const CUDAWrappers::SparseMatrix &) = delete; + /** * Reinitialize the sparse matrix. The sparse matrix on the host is copied * to the device and the elementes are reordered according to the format diff --git a/source/lac/cuda_sparse_matrix.cu b/source/lac/cuda_sparse_matrix.cu index dfd9d7956b..455af2aae4 100644 --- a/source/lac/cuda_sparse_matrix.cu +++ b/source/lac/cuda_sparse_matrix.cu @@ -250,6 +250,32 @@ namespace CUDAWrappers + template + SparseMatrix & + SparseMatrix::operator=(SparseMatrix &&other) + { + cusparse_handle = other.cusparse_handle; + nnz = other.nnz; + n_rows = other.n_rows; + n_cols = other.n_cols; + val_dev = other.val_dev; + column_index_dev = other.column_index_dev; + row_ptr_dev = other.row_ptr_dev; + descr = other.descr; + + other.nnz = 0; + other.n_rows = 0; + other.n_cols = 0; + other.val_dev = nullptr; + other.column_index_dev = nullptr; + other.row_ptr_dev = nullptr; + other.descr = nullptr; + + return *this; + } + + + template void SparseMatrix::reinit( -- 2.39.5