From f7bd3de7139ed8ed8080ba94ce6d4dc37cf19076 Mon Sep 17 00:00:00 2001 From: heister Date: Tue, 26 Mar 2013 20:17:22 +0000 Subject: [PATCH] Check at runtime that we do not use multiple threads when using PETSc vectors git-svn-id: https://svn.dealii.org/trunk@29046 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/lac/petsc_parallel_vector.cc | 1 - deal.II/source/lac/petsc_vector_base.cc | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/deal.II/source/lac/petsc_parallel_vector.cc b/deal.II/source/lac/petsc_parallel_vector.cc index 9d36ee6304..70196a4add 100644 --- a/deal.II/source/lac/petsc_parallel_vector.cc +++ b/deal.II/source/lac/petsc_parallel_vector.cc @@ -243,7 +243,6 @@ namespace PETScWrappers //64bit indices won't work yet: Assert (sizeof(unsigned int)==sizeof(PetscInt), ExcInternalError()); - std::vector ghostindices; ghostnodes.fill_index_vector(ghostindices); diff --git a/deal.II/source/lac/petsc_vector_base.cc b/deal.II/source/lac/petsc_vector_base.cc index 8de2a942bb..2deb0cc26f 100644 --- a/deal.II/source/lac/petsc_vector_base.cc +++ b/deal.II/source/lac/petsc_vector_base.cc @@ -20,6 +20,7 @@ # include # include # include +# include DEAL_II_NAMESPACE_OPEN @@ -149,7 +150,11 @@ namespace PETScWrappers ghosted(false), last_action (::dealii::VectorOperation::unknown), attained_ownership(true) - {} + { + Assert( multithread_info.is_running_single_threaded(), + ExcMessage("PETSc does not support multi-threaded access, set " + "the thread limit to 1 in MPI_InitFinalize().")); + } @@ -161,6 +166,10 @@ namespace PETScWrappers last_action (::dealii::VectorOperation::unknown), attained_ownership(true) { + Assert( multithread_info.is_running_single_threaded(), + ExcMessage("PETSc does not support multi-threaded access, set " + "the thread limit to 1 in MPI_InitFinalize().")); + int ierr = VecDuplicate (v.vector, &vector); AssertThrow (ierr == 0, ExcPETScError(ierr)); @@ -177,7 +186,11 @@ namespace PETScWrappers ghosted(false), last_action (::dealii::VectorOperation::unknown), attained_ownership(false) - {} + { + Assert( multithread_info.is_running_single_threaded(), + ExcMessage("PETSc does not support multi-threaded access, set " + "the thread limit to 1 in MPI_InitFinalize().")); + } -- 2.39.5