From: Daniel Arndt Date: Mon, 20 Aug 2018 16:33:50 +0000 (+0200) Subject: Add tests X-Git-Tag: v9.1.0-rc1~799^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7082%2Fhead;p=dealii.git Add tests --- 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