]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a move assignment operator for CUDAWrappers::SparseMatrix
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 18 Aug 2018 23:47:38 +0000 (01:47 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 20 Aug 2018 17:28:28 +0000 (19:28 +0200)
include/deal.II/lac/cuda_sparse_matrix.h
source/lac/cuda_sparse_matrix.cu

index f8a1bb11e26587f4adbf4647c0d1ea42ef25d4b9..4599622de6d2a339ae0d0e5eb9987bbdb0ad2db3 100644 (file)
@@ -103,6 +103,18 @@ namespace CUDAWrappers
      */
     ~SparseMatrix();
 
+    /**
+     * Move assignment operator.
+     */
+    SparseMatrix &
+    operator=(CUDAWrappers::SparseMatrix<Number> &&);
+
+    /**
+     * Copy assignment is deleted.
+     */
+    SparseMatrix &
+    operator=(const CUDAWrappers::SparseMatrix<Number> &) = 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
index dfd9d7956bf72cbbbb37e0174dc7052bdfd21871..455af2aae4e5f725c60847cae8a36b6ec595e9b1 100644 (file)
@@ -250,6 +250,32 @@ namespace CUDAWrappers
 
 
 
+  template <typename Number>
+  SparseMatrix<Number> &
+  SparseMatrix<Number>::operator=(SparseMatrix<Number> &&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 <typename Number>
   void
   SparseMatrix<Number>::reinit(

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.