From: Daniel Arndt Date: Sat, 18 Aug 2018 23:47:38 +0000 (+0200) Subject: Add a move assignment operator for CUDAWrappers::SparseMatrix X-Git-Tag: v9.1.0-rc1~799^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fdaf596926b5d1835ad6173f38f4e8c41a4ce3d9;p=dealii.git Add a move assignment operator for CUDAWrappers::SparseMatrix --- 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(