From 7dc7cbab1214364fac2cfd5466099cd3f8bd6908 Mon Sep 17 00:00:00 2001 From: Pratik Nayak Date: Wed, 30 Jan 2019 12:49:36 +0100 Subject: [PATCH] Add initial tests for ginkgo --- tests/ginkgo/CMakeLists.txt | 6 ++++ tests/ginkgo/solver.cc | 67 +++++++++++++++++++++++++++++++++++++ tests/ginkgo/solver.output | 3 ++ 3 files changed, 76 insertions(+) create mode 100644 tests/ginkgo/CMakeLists.txt create mode 100644 tests/ginkgo/solver.cc create mode 100644 tests/ginkgo/solver.output diff --git a/tests/ginkgo/CMakeLists.txt b/tests/ginkgo/CMakeLists.txt new file mode 100644 index 0000000000..f549331a05 --- /dev/null +++ b/tests/ginkgo/CMakeLists.txt @@ -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 index 0000000000..560d9117c4 --- /dev/null +++ b/tests/ginkgo/solver.cc @@ -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 +#include +#include +#include + +#include +#include + +#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 A(structure); + testproblem.five_point(A); + + Vector f(dim); + f = 1.; + Vector u(dim); + u = 0.; + + // std::shared_ptr exec = gko::CudaExecutor::create(0, + // gko::OmpExecutor::create()); + // std::shared_ptr exec = gko::OmpExecutor::create(); + std::shared_ptr 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 index 0000000000..4ce62b0ef7 --- /dev/null +++ b/tests/ginkgo/solver.output @@ -0,0 +1,3 @@ + +DEAL::Size 32 Unknowns 961 +DEAL::Solver stopped within 35 - 39 iterations -- 2.39.5