]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Switch the tests to atomic operations and add a test for graph coloring
authorBruno Turcksin <bruno.turcksin@gmail.com>
Thu, 8 Aug 2019 21:28:22 +0000 (21:28 +0000)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Sun, 11 Aug 2019 00:32:43 +0000 (00:32 +0000)
tests/cuda/matrix_free_matrix_vector_03b.cu [new file with mode: 0644]
tests/cuda/matrix_free_matrix_vector_03b.output [new file with mode: 0644]
tests/cuda/matrix_vector_common.h

diff --git a/tests/cuda/matrix_free_matrix_vector_03b.cu b/tests/cuda/matrix_free_matrix_vector_03b.cu
new file mode 100644 (file)
index 0000000..772bcba
--- /dev/null
@@ -0,0 +1,77 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+
+// this function tests the correctness of the implementation of matrix free
+// matrix-vector products by comparing with the result of deal.II sparse
+// matrix. The mesh uses a hypercube mesh with hanging nodes (created by
+// randomly refining some cells) and zero Dirichlet conditions. Same as test
+// matrix_free_matrix_vector_03b but use coloring instead of atomics
+
+#include <deal.II/base/function.h>
+
+#include "../tests.h"
+
+std::ofstream logfile("output");
+
+#include "matrix_vector_common.h"
+
+template <int dim, int fe_degree>
+void
+test()
+{
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria);
+  typename Triangulation<dim>::active_cell_iterator cell = tria.begin_active(),
+                                                    endc = tria.end();
+  if (dim < 3 || fe_degree < 2)
+    tria.refine_global(2);
+  else
+    tria.refine_global(1);
+  tria.begin(tria.n_levels() - 1)->set_refine_flag();
+  tria.last()->set_refine_flag();
+  tria.execute_coarsening_and_refinement();
+  cell = tria.begin_active();
+  for (unsigned int i = 0; i < 10 - 3 * dim; ++i)
+    {
+      cell                 = tria.begin_active();
+      unsigned int counter = 0;
+      for (; cell != endc; ++cell, ++counter)
+        if (counter % (7 - i) == 0)
+          cell->set_refine_flag();
+      tria.execute_coarsening_and_refinement();
+    }
+
+  FE_Q<dim>       fe(fe_degree);
+  DoFHandler<dim> dof(tria);
+  dof.distribute_dofs(fe);
+  AffineConstraints<double> constraints;
+  DoFTools::make_hanging_node_constraints(dof, constraints);
+
+  VectorTools::interpolate_boundary_values(dof,
+                                           0,
+                                           Functions::ZeroFunction<dim>(),
+                                           constraints);
+  constraints.close();
+
+  // Skip 2D tests with even fe_degree
+  if ((dim == 3) || ((fe_degree % 2) == 1))
+    do_test<dim,
+            fe_degree,
+            double,
+            LinearAlgebra::CUDAWrappers::Vector<double>,
+            fe_degree + 1>(dof, constraints, tria.n_active_cells(), true, true);
+}
diff --git a/tests/cuda/matrix_free_matrix_vector_03b.output b/tests/cuda/matrix_free_matrix_vector_03b.output
new file mode 100644 (file)
index 0000000..ab11bfe
--- /dev/null
@@ -0,0 +1,16 @@
+
+DEAL:2d::Testing FE_Q<2>(1)
+DEAL:2d::Norm of difference: 0.
+DEAL:2d::
+DEAL:2d::Testing FE_Q<2>(3)
+DEAL:2d::Norm of difference: 0.
+DEAL:2d::
+DEAL:3d::Testing FE_Q<3>(1)
+DEAL:3d::Norm of difference: 0.
+DEAL:3d::
+DEAL:3d::Testing FE_Q<3>(2)
+DEAL:3d::Norm of difference: 0.
+DEAL:3d::
+DEAL:3d::Testing FE_Q<3>(3)
+DEAL:3d::Norm of difference: 0.
+DEAL:3d::
index 80dbb8aec586cb0c73f8d72e277e80b3806e9da1..2c3586b2d9de0b6082a9ef49f3957c3b12ea2f6f 100644 (file)
@@ -78,7 +78,8 @@ void
 do_test(const DoFHandler<dim> &          dof,
         const AffineConstraints<double> &constraints,
         const unsigned int               n_locally_owned_cells,
-        const bool                       constant_coefficient = true)
+        const bool                       constant_coefficient = true,
+        const bool                       coloring             = false)
 {
   deallog << "Testing " << dof.get_fe().get_name() << std::endl;
 
@@ -89,6 +90,7 @@ do_test(const DoFHandler<dim> &          dof,
   additional_data.mapping_update_flags = update_values | update_gradients |
                                          update_JxW_values |
                                          update_quadrature_points;
+  additional_data.use_coloring = coloring;
   const QGauss<1> quad(n_q_points_1d);
   mf_data.reinit(mapping, dof, constraints, quad, additional_data);
 

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.