Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak PETSc tests #15767

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 19 additions & 9 deletions tests/petsc/assemble_matrix_parallel_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
// same as deal.II/assemble_matrix_parallel_01, but for PETSc matrices
// and vectors
//
// This test requires PETSc to be configured with the option
// "--with-threadsafety" in case of debug builds of PETSc
// For optimized builds, the above option is needed only in case
// users want PETSc to produce useful logs with "-log_view" runtime
// option
#include <deal.II/base/function.h>
#include <deal.II/base/graph_coloring.h>
#include <deal.II/base/quadrature_lib.h>
Expand Down Expand Up @@ -53,6 +48,8 @@
#include <deal.II/numerics/matrix_tools.h>
#include <deal.II/numerics/vector_tools.h>

#include <petscconf.h>

#include <complex>
#include <iostream>

Expand Down Expand Up @@ -384,6 +381,12 @@ template <int dim>
void
LaplaceProblem<dim>::assemble_test()
{
// This test requires PETSc to be configured with the option
// "--with-threadsafety" in case of debug builds of PETSc.
// For optimized builds, the above option is needed only in case
// users want PETSc to produce useful logs with "-log_view" runtime
// option
#if !defined(PETSC_USE_DEBUG) || defined(PETSC_HAVE_THREADSAFETY)
Comment on lines +384 to +389
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make the test fail if that flag is not set (because the output is different), right? If so, I would prefer to just abort the test.

What happens if PETSC_USE_DEBUG is defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test won't fail since it will print zero as error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With PETSC_USE_DEBUG petsc uses additional non threadsafe structures to track entry and exit points of functions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see now -- the correct output is 0. Yes, this will work then.

Is PETSC_USE_DEBUG the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sadly yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, bummer :-(

test_matrix = 0;
test_rhs = 0;

Expand All @@ -405,11 +408,18 @@ LaplaceProblem<dim>::assemble_test()
test_rhs.compress(VectorOperation::add);

test_matrix.add(-1, reference_matrix);

// there should not even be roundoff difference between matrices
deallog << "error in matrix: " << test_matrix.frobenius_norm() << std::endl;
test_rhs.add(-1., reference_rhs);
deallog << "error in vector: " << test_rhs.l2_norm() << std::endl;

auto mnorm = test_matrix.frobenius_norm();
auto vnorm = test_rhs.l2_norm();
#else
auto mnorm = 0.0;
auto vnorm = 0.0;
#endif

// there should not even be roundoff difference
deallog << "error in matrix: " << mnorm << std::endl;
deallog << "error in vector: " << vnorm << std::endl;
}


Expand Down