]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Work around a problem where we cannot elide zero additions for certain matrices by...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 7 Jun 2004 19:55:51 +0000 (19:55 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 7 Jun 2004 19:55:51 +0000 (19:55 +0000)
git-svn-id: https://svn.dealii.org/trunk@9402 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_matrix_base.h
deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h
deal.II/lac/include/lac/petsc_sparse_matrix.h
deal.II/lac/include/lac/sparse_matrix.h

index 831ec6c407b8b5651d4678435e578d43084d52b7..b50cb2e5eb58fe6ec4dd224fce1febf2200e9e42 100644 (file)
@@ -1180,8 +1180,12 @@ BlockMatrixBase<MatrixType>::add (const unsigned int i,
                                   const unsigned int j,
                                   const value_type value)
 {
-                                   // save some cycles for zero additions
-  if (value == 0)
+                                   // save some cycles for zero additions, but
+                                   // only if it is safe for the matrix we are
+                                   // working with
+  if ((MatrixType::Traits::zero_addition_can_be_elided == true)
+      &&
+      (value == 0))
     return;
   
   const std::pair<unsigned int,unsigned int>
index ca64fc6a5540248c6d38c935e6ab0a9e7dd4b953..469cb4373fd3d478cd78660f551f5fa224a9055a 100644 (file)
@@ -75,6 +75,36 @@ namespace PETScWrappers
     class SparseMatrix : public MatrixBase
     {
       public:
+                                         /**
+                                          * A structure that describes some of
+                                          * the traits of this class in terms
+                                          * of its run-time behavior. Some
+                                          * other classes (such as the block
+                                          * matrix classes) that take one or
+                                          * other of the matrix classes as its
+                                          * template parameters can tune their
+                                          * behavior based on the variables in
+                                          * this class.
+                                          */
+        struct Traits
+        {
+                                             /**
+                                              * It is not safe to elide
+                                              * additions of zeros to
+                                              * individual elements of this
+                                              * matrix. The reason is that
+                                              * additions to the matrix may
+                                              * trigger collective operations
+                                              * synchronising buffers on
+                                              * multiple processes. If an
+                                              * addition is elided on one
+                                              * process, this may lead to
+                                              * other processes hanging in an
+                                              * infinite waiting loop.
+                                              */
+            static const bool zero_addition_can_be_elided = false;
+        };
+
                                          /**
                                           * Default constructor. Create an
                                           * empty matrix.
index 76291d259e98b3043933571f33eff4b1e39b939e..6b54011476801422e82f66b7c59eb4f795a8c7c2 100644 (file)
@@ -41,6 +41,27 @@ namespace PETScWrappers
   class SparseMatrix : public MatrixBase
   {
     public:
+                                       /**
+                                        * A structure that describes some of
+                                        * the traits of this class in terms of
+                                        * its run-time behavior. Some other
+                                        * classes (such as the block matrix
+                                        * classes) that take one or other of
+                                        * the matrix classes as its template
+                                        * parameters can tune their behavior
+                                        * based on the variables in this
+                                        * class.
+                                        */
+      struct Traits
+      {
+                                           /**
+                                            * It is safe to elide additions of
+                                            * zeros to individual elements of
+                                            * this matrix.
+                                            */
+          static const bool zero_addition_can_be_elided = true;
+      };
+
                                        /**
                                         * Default constructor. Create an empty
                                         * matrix.
index a4f1243ec8f34f76a48ddf6913ebaad9c8cc35ff..991385d3788f52a902fb65be7bb455b675c5b9cd 100644 (file)
@@ -418,6 +418,26 @@ class SparseMatrix : public virtual Subscriptor
     typedef
     internals::SparseMatrixIterators::Iterator<number,false>
     iterator;
+
+                                     /**
+                                      * A structure that describes some of the
+                                      * traits of this class in terms of its
+                                      * run-time behavior. Some other classes
+                                      * (such as the block matrix classes)
+                                      * that take one or other of the matrix
+                                      * classes as its template parameters can
+                                      * tune their behavior based on the
+                                      * variables in this class.
+                                      */
+    struct Traits
+    {
+                                         /**
+                                          * It is safe to elide additions of
+                                          * zeros to individual elements of
+                                          * this matrix.
+                                          */
+        static const bool zero_addition_can_be_elided = true;
+    };
     
                                     /**
                                      * Constructor; initializes the matrix to

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.