]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add initial tests for ginkgo
authorPratik Nayak <pratik.nayak4@gmail.com>
Wed, 30 Jan 2019 11:49:36 +0000 (12:49 +0100)
committerPratik Nayak <pratik.nayak4@gmail.com>
Wed, 30 Jan 2019 11:49:36 +0000 (12:49 +0100)
tests/ginkgo/CMakeLists.txt [new file with mode: 0644]
tests/ginkgo/solver.cc [new file with mode: 0644]
tests/ginkgo/solver.output [new file with mode: 0644]

diff --git a/tests/ginkgo/CMakeLists.txt b/tests/ginkgo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f549331
--- /dev/null
@@ -0,0 +1,6 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
+INCLUDE(../setup_testsubproject.cmake)
+PROJECT(testsuite CXX)
+IF(DEAL_II_WITH_GINKGO)
+  DEAL_II_PICKUP_TESTS()
+ENDIF()
diff --git a/tests/ginkgo/solver.cc b/tests/ginkgo/solver.cc
new file mode 100644 (file)
index 0000000..560d911
--- /dev/null
@@ -0,0 +1,67 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 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.
+//
+// ---------------------------------------------------------------------
+
+// test the Ginkgo CG solver
+
+#include <deal.II/lac/ginkgo_solver.h>
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/vector_memory.h>
+
+#include <iostream>
+#include <typeinfo>
+
+#include "../testmatrix.h"
+#include "../tests.h"
+
+int
+main(int argc, char **argv)
+{
+  initlog();
+  deallog << std::setprecision(4);
+
+  {
+    SolverControl control(100, 1e-3);
+
+    const unsigned int size = 32;
+    unsigned int       dim  = (size - 1) * (size - 1);
+
+    deallog << "Size " << size << " Unknowns " << dim << std::endl;
+
+    // Make matrix
+    FDMatrix        testproblem(size, size);
+    SparsityPattern structure(dim, dim, 5);
+    testproblem.five_point_structure(structure);
+    structure.compress();
+    SparseMatrix<double> A(structure);
+    testproblem.five_point(A);
+
+    Vector<double> f(dim);
+    f = 1.;
+    Vector<double> u(dim);
+    u = 0.;
+
+    // std::shared_ptr<gko::Executor> exec = gko::CudaExecutor::create(0,
+    //                                                               gko::OmpExecutor::create());
+    // std::shared_ptr<gko::Executor> exec = gko::OmpExecutor::create();
+    std::shared_ptr<gko::Executor> exec = gko::ReferenceExecutor::create();
+    GinkgoWrappers::SolverCG<>     solver(control, exec);
+
+    check_solver_within_range(solver.solve(A, u, f),
+                              control.last_step(),
+                              35,
+                              39);
+  }
+}
diff --git a/tests/ginkgo/solver.output b/tests/ginkgo/solver.output
new file mode 100644 (file)
index 0000000..4ce62b0
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver stopped within 35 - 39 iterations

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.