]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add tests.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 29 Jul 2021 00:23:46 +0000 (18:23 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 4 Aug 2021 15:21:50 +0000 (09:21 -0600)
tests/base/aligned_vector_replicate_05.cc [new file with mode: 0644]
tests/base/aligned_vector_replicate_05.mpirun=3.output [new file with mode: 0644]
tests/base/aligned_vector_replicate_06.cc [new file with mode: 0644]
tests/base/aligned_vector_replicate_06.mpirun=3.output [new file with mode: 0644]
tests/base/aligned_vector_replicate_07.cc [new file with mode: 0644]
tests/base/aligned_vector_replicate_07.mpirun=3.output [new file with mode: 0644]

diff --git a/tests/base/aligned_vector_replicate_05.cc b/tests/base/aligned_vector_replicate_05.cc
new file mode 100644 (file)
index 0000000..4b45c74
--- /dev/null
@@ -0,0 +1,73 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2012 - 2021 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 AlignedVector::replicate_across_communicator(). This variation
+// of the _03 test checks that we can move a replicated object and
+// that the moved-to object inherits the shared memory window and all
+// other information. This tests uses move-construction.
+
+#include <deal.II/base/aligned_vector.h>
+
+#include "../tests.h"
+
+
+void
+test(const unsigned int root)
+{
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    deallog << root << " of " << Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD)
+            << ": ";
+
+  AlignedVector<int> avec(1000);
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    {
+      unsigned int counter = 0;
+      for (auto &i : avec)
+        i = counter++;
+    }
+
+  avec.replicate_across_communicator(MPI_COMM_WORLD, root);
+
+  // Move avec
+  AlignedVector<int> xvec(std::move(avec));
+  {
+    unsigned int counter = 0;
+
+    for (auto &i : xvec)
+      {
+        AssertDimension(i, counter);
+        ++counter;
+      }
+  }
+
+  MPI_Barrier(MPI_COMM_WORLD);
+
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    deallog << "OK!" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll                    all;
+
+  for (unsigned int i = 0; i < Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD);
+       ++i)
+    test(i);
+}
diff --git a/tests/base/aligned_vector_replicate_05.mpirun=3.output b/tests/base/aligned_vector_replicate_05.mpirun=3.output
new file mode 100644 (file)
index 0000000..db547dd
--- /dev/null
@@ -0,0 +1,8 @@
+
+DEAL:0::0 of 3: OK!
+
+DEAL:1::1 of 3: OK!
+
+
+DEAL:2::2 of 3: OK!
+
diff --git a/tests/base/aligned_vector_replicate_06.cc b/tests/base/aligned_vector_replicate_06.cc
new file mode 100644 (file)
index 0000000..93224e9
--- /dev/null
@@ -0,0 +1,74 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2012 - 2021 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 AlignedVector::replicate_across_communicator(). This variation
+// of the _03 test checks that we can move a replicated object and
+// that the moved-to object inherits the shared memory window and all
+// other information. This tests uses move-assignment.
+
+#include <deal.II/base/aligned_vector.h>
+
+#include "../tests.h"
+
+
+void
+test(const unsigned int root)
+{
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    deallog << root << " of " << Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD)
+            << ": ";
+
+  AlignedVector<int> avec(1000);
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    {
+      unsigned int counter = 0;
+      for (auto &i : avec)
+        i = counter++;
+    }
+
+  avec.replicate_across_communicator(MPI_COMM_WORLD, root);
+
+  // Move avec
+  AlignedVector<int> xvec;
+  xvec = std::move(avec);
+  {
+    unsigned int counter = 0;
+
+    for (auto &i : xvec)
+      {
+        AssertDimension(i, counter);
+        ++counter;
+      }
+  }
+
+  MPI_Barrier(MPI_COMM_WORLD);
+
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    deallog << "OK!" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll                    all;
+
+  for (unsigned int i = 0; i < Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD);
+       ++i)
+    test(i);
+}
diff --git a/tests/base/aligned_vector_replicate_06.mpirun=3.output b/tests/base/aligned_vector_replicate_06.mpirun=3.output
new file mode 100644 (file)
index 0000000..db547dd
--- /dev/null
@@ -0,0 +1,8 @@
+
+DEAL:0::0 of 3: OK!
+
+DEAL:1::1 of 3: OK!
+
+
+DEAL:2::2 of 3: OK!
+
diff --git a/tests/base/aligned_vector_replicate_07.cc b/tests/base/aligned_vector_replicate_07.cc
new file mode 100644 (file)
index 0000000..d54b6d0
--- /dev/null
@@ -0,0 +1,74 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2012 - 2021 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 AlignedVector::replicate_across_communicator(). This variation
+// of the _03 test checks that we can swap a replicated object and
+// that the swapped-to object inherits the shared memory window and all
+// other information.
+
+#include <deal.II/base/aligned_vector.h>
+
+#include "../tests.h"
+
+
+void
+test(const unsigned int root)
+{
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    deallog << root << " of " << Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD)
+            << ": ";
+
+  AlignedVector<int> avec(1000);
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    {
+      unsigned int counter = 0;
+      for (auto &i : avec)
+        i = counter++;
+    }
+
+  avec.replicate_across_communicator(MPI_COMM_WORLD, root);
+
+  // Move avec
+  AlignedVector<int> xvec;
+  xvec.swap(avec);
+  {
+    unsigned int counter = 0;
+
+    for (auto &i : xvec)
+      {
+        AssertDimension(i, counter);
+        ++counter;
+      }
+  }
+
+  MPI_Barrier(MPI_COMM_WORLD);
+
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    deallog << "OK!" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll                    all;
+
+  for (unsigned int i = 0; i < Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD);
+       ++i)
+    test(i);
+}
diff --git a/tests/base/aligned_vector_replicate_07.mpirun=3.output b/tests/base/aligned_vector_replicate_07.mpirun=3.output
new file mode 100644 (file)
index 0000000..db547dd
--- /dev/null
@@ -0,0 +1,8 @@
+
+DEAL:0::0 of 3: OK!
+
+DEAL:1::1 of 3: OK!
+
+
+DEAL:2::2 of 3: 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.