]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add test 7301/head
authorbenjamin <benjamin.brands@fau.de>
Mon, 8 Oct 2018 19:37:29 +0000 (21:37 +0200)
committerbenjamin <benjamin.brands@fau.de>
Tue, 9 Oct 2018 09:16:14 +0000 (11:16 +0200)
tests/scalapack/scalapack_10_d.cc [new file with mode: 0644]
tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=1.output [new file with mode: 0644]
tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=11.output [new file with mode: 0644]
tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=4.output [new file with mode: 0644]
tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=5.output [new file with mode: 0644]

diff --git a/tests/scalapack/scalapack_10_d.cc b/tests/scalapack/scalapack_10_d.cc
new file mode 100644 (file)
index 0000000..7d27c7e
--- /dev/null
@@ -0,0 +1,103 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 - 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.
+//
+// ---------------------------------------------------------------------
+
+#include "../lapack/create_matrix.h"
+#include "../tests.h"
+
+// test loading of distributed ScaLAPACKMatrices by call to constructor
+
+#include <deal.II/base/conditional_ostream.h>
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/multithread_info.h>
+#include <deal.II/base/timer.h>
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/scalapack.h>
+
+#include <cstdio>
+#include <fstream>
+#include <iostream>
+
+
+template <typename NumberType>
+void
+test(const unsigned int size, const unsigned int block_size)
+{
+  const std::string filename("scalapack_10_d_test.h5");
+
+  MPI_Comm           mpi_communicator(MPI_COMM_WORLD);
+  const unsigned int this_mpi_process(
+    Utilities::MPI::this_mpi_process(mpi_communicator));
+  ConditionalOStream pcout(std::cout, (this_mpi_process == 0));
+
+  // create FullMatrix and fill it
+  FullMatrix<NumberType> full(size);
+  unsigned int           count = 0;
+  for (unsigned int i = 0; i < size; ++i)
+    for (unsigned int j = 0; j < size; ++j, ++count)
+      full(i, j) = count;
+
+  // create 2d process grid
+  std::shared_ptr<Utilities::MPI::ProcessGrid> grid =
+    std::make_shared<Utilities::MPI::ProcessGrid>(
+      mpi_communicator, size, size, block_size, block_size);
+
+  // create process grid with only one process
+  std::shared_ptr<Utilities::MPI::ProcessGrid> grid_1 =
+    std::make_shared<Utilities::MPI::ProcessGrid>(mpi_communicator, 1, 1);
+
+  ScaLAPACKMatrix<NumberType> scalapack_matrix_1(
+    size, size, grid_1, block_size, block_size);
+
+  scalapack_matrix_1 = full;
+  scalapack_matrix_1.save(filename.c_str());
+
+  ScaLAPACKMatrix<NumberType> scalapack_matrix(filename,
+                                               grid,
+                                               block_size,
+                                               block_size);
+
+  FullMatrix<NumberType> copy(size);
+  scalapack_matrix.copy_to(copy);
+  copy.add(-1, full);
+
+  pcout << size << " " << block_size << std::endl;
+
+  if (copy.frobenius_norm() > 1e-12)
+    pcout << "norm of difference: " << copy.frobenius_norm() << std::endl;
+
+  AssertThrow(copy.frobenius_norm() < 1e-12, ExcInternalError());
+  std::remove(filename.c_str());
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(
+    argc, argv, numbers::invalid_unsigned_int);
+
+  const std::vector<unsigned int> sizes       = {{100, 200, 300}};
+  const std::vector<unsigned int> block_sizes = {{16, 32}};
+
+  for (const auto &s : sizes)
+    for (const auto &b : block_sizes)
+      test<double>(s, b);
+
+  for (const auto &s : sizes)
+    for (const auto &b : block_sizes)
+      test<float>(s, b);
+}
diff --git a/tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=1.output b/tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=1.output
new file mode 100644 (file)
index 0000000..04301e6
--- /dev/null
@@ -0,0 +1,12 @@
+100 16
+100 32
+200 16
+200 32
+300 16
+300 32
+100 16
+100 32
+200 16
+200 32
+300 16
+300 32
diff --git a/tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=11.output b/tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=11.output
new file mode 100644 (file)
index 0000000..04301e6
--- /dev/null
@@ -0,0 +1,12 @@
+100 16
+100 32
+200 16
+200 32
+300 16
+300 32
+100 16
+100 32
+200 16
+200 32
+300 16
+300 32
diff --git a/tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=4.output b/tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=4.output
new file mode 100644 (file)
index 0000000..04301e6
--- /dev/null
@@ -0,0 +1,12 @@
+100 16
+100 32
+200 16
+200 32
+300 16
+300 32
+100 16
+100 32
+200 16
+200 32
+300 16
+300 32
diff --git a/tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=5.output b/tests/scalapack/scalapack_10_d.with_hdf5=on.mpirun=5.output
new file mode 100644 (file)
index 0000000..04301e6
--- /dev/null
@@ -0,0 +1,12 @@
+100 16
+100 32
+200 16
+200 32
+300 16
+300 32
+100 16
+100 32
+200 16
+200 32
+300 16
+300 32

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.