From a024cda1935d17ed4b443527d60f25f953406b15 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 20 Aug 2018 18:33:50 +0200 Subject: [PATCH] Add tests --- tests/cuda/sparse_matrix_02.cu | 62 ++++++++++++++++++++++++++++++ tests/cuda/sparse_matrix_02.output | 34 ++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tests/cuda/sparse_matrix_02.cu create mode 100644 tests/cuda/sparse_matrix_02.output diff --git a/tests/cuda/sparse_matrix_02.cu b/tests/cuda/sparse_matrix_02.cu new file mode 100644 index 0000000000..bec9672194 --- /dev/null +++ b/tests/cuda/sparse_matrix_02.cu @@ -0,0 +1,62 @@ +// --------------------------------------------------------------------- +// +// 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. +// +// --------------------------------------------------------------------- + +// Check print and print_format + +#include +#include + +#include + +#include "../testmatrix.h" +#include "../tests.h" + + +void +test(Utilities::CUDA::Handle &cuda_handle) +{ + // Build the sparse matrix on the host + const unsigned int size = 3; + unsigned int dim = (size - 1) * (size - 1); + + FDMatrix testproblem(size, size); + SparsityPattern structure(dim, dim, 5); + testproblem.five_point_structure(structure); + structure.compress(); + SparseMatrix A(structure); + testproblem.upwind(A, true); + A.print(deallog.get_file_stream()); + A.print_formatted(deallog.get_file_stream()); + + // Create the sparse matrix on the device + CUDAWrappers::SparseMatrix A_dev(cuda_handle, A); + A_dev.print(deallog.get_file_stream()); + A_dev.print_formatted(deallog.get_file_stream()); +} + +int +main() +{ + initlog(); + deallog.depth_console(0); + + Utilities::CUDA::Handle cuda_handle; + + test(cuda_handle); + + deallog << "OK" << std::endl; + + return 0; +} diff --git a/tests/cuda/sparse_matrix_02.output b/tests/cuda/sparse_matrix_02.output new file mode 100644 index 0000000000..fbf0f1b3af --- /dev/null +++ b/tests/cuda/sparse_matrix_02.output @@ -0,0 +1,34 @@ + +(0,0) 3.00000 +(0,1) -1.00000 +(0,2) 0.00000 +(1,1) 3.00000 +(1,0) 0.00000 +(1,3) 0.00000 +(2,2) 3.00000 +(2,0) 0.00000 +(2,3) -1.00000 +(3,3) 3.00000 +(3,1) 0.00000 +(3,2) 0.00000 +3.000e+00 -1.000e+00 0.000e+00 +0.000e+00 3.000e+00 0.000e+00 +0.000e+00 3.000e+00 -1.000e+00 + 0.000e+00 0.000e+00 3.000e+00 +(0,0) 3.00000 +(0,1) -1.00000 +(0,2) 0.00000 +(1,1) 3.00000 +(1,0) 0.00000 +(1,3) 0.00000 +(2,2) 3.00000 +(2,0) 0.00000 +(2,3) -1.00000 +(3,3) 3.00000 +(3,1) 0.00000 +(3,2) 0.00000 +3.000e+00 -1.000e+00 0.000e+00 +0.000e+00 3.000e+00 0.000e+00 +0.000e+00 3.000e+00 -1.000e+00 + 0.000e+00 0.000e+00 3.000e+00 +DEAL::OK -- 2.39.5