]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add tests 7082/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 20 Aug 2018 16:33:50 +0000 (18:33 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 20 Aug 2018 17:59:24 +0000 (19:59 +0200)
tests/cuda/sparse_matrix_02.cu [new file with mode: 0644]
tests/cuda/sparse_matrix_02.output [new file with mode: 0644]

diff --git a/tests/cuda/sparse_matrix_02.cu b/tests/cuda/sparse_matrix_02.cu
new file mode 100644 (file)
index 0000000..bec9672
--- /dev/null
@@ -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 <deal.II/base/cuda.h>
+#include <deal.II/base/exceptions.h>
+
+#include <deal.II/lac/cuda_sparse_matrix.h>
+
+#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<double> 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<double> 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 (file)
index 0000000..fbf0f1b
--- /dev/null
@@ -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

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.