From 324894cc3d64f724fb1e060ffc49df9b6bc6a17d Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 12 Sep 2022 09:06:14 +0200 Subject: [PATCH] Provide inlined fast code path for Vector::reinit(Vector&) --- include/deal.II/lac/vector.h | 17 +++++++++++++++++ include/deal.II/lac/vector.templates.h | 12 ------------ source/lac/vector.cc | 3 --- source/lac/vector.inst.in | 3 --- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/include/deal.II/lac/vector.h b/include/deal.II/lac/vector.h index 2e43459f2a..c049ce3898 100644 --- a/include/deal.II/lac/vector.h +++ b/include/deal.II/lac/vector.h @@ -1354,6 +1354,23 @@ Vector::update_ghost_values() const +template +template +inline void +Vector::reinit(const Vector &v, + const bool omit_zeroing_entries) +{ + // go to actual reinit functions in case we need to change something with + // the vector, else there is nothing to be done + if (!omit_zeroing_entries || size() != v.size()) + { + do_reinit(v.size(), omit_zeroing_entries, false); + thread_loop_partitioner = v.thread_loop_partitioner; + } +} + + + // Moved from vector.templates.h as an inline function by Luca Heltai // on 2009/04/12 to prevent strange compiling errors, after making // swap virtual. diff --git a/include/deal.II/lac/vector.templates.h b/include/deal.II/lac/vector.templates.h index 98b24bd7d0..850603b317 100644 --- a/include/deal.II/lac/vector.templates.h +++ b/include/deal.II/lac/vector.templates.h @@ -242,18 +242,6 @@ Vector::grow_or_shrink(const size_type n) -template -template -void -Vector::reinit(const Vector &v, - const bool omit_zeroing_entries) -{ - do_reinit(v.size(), omit_zeroing_entries, false); - thread_loop_partitioner = v.thread_loop_partitioner; -} - - - template bool Vector::all_zero() const diff --git a/source/lac/vector.cc b/source/lac/vector.cc index 09eb1facd9..fe893dcba4 100644 --- a/source/lac/vector.cc +++ b/source/lac/vector.cc @@ -33,9 +33,6 @@ Vector::operator=(const dealii::Vector &); template bool Vector::operator==(dealii::Vector const &) const; -template void -Vector::reinit(const Vector &, const bool); - // instantiate for long double manually because we use it in a few places: template class Vector; template long double diff --git a/source/lac/vector.inst.in b/source/lac/vector.inst.in index 173d5f5ade..23e5b47fac 100644 --- a/source/lac/vector.inst.in +++ b/source/lac/vector.inst.in @@ -24,18 +24,15 @@ for (S1, S2 : REAL_SCALARS) { template bool Vector::operator==(const Vector &) const; template S1 Vector::operator*(const Vector &) const; - template void Vector::reinit(const Vector &, const bool); } for (S1, S2 : COMPLEX_SCALARS) { template bool Vector::operator==(const Vector &) const; template S1 Vector::operator*(const Vector &) const; - template void Vector::reinit(const Vector &, const bool); } for (S1 : COMPLEX_SCALARS; S2 : REAL_SCALARS) { template Vector &Vector::operator=(const Vector &); - template void Vector::reinit(const Vector &, const bool); } -- 2.39.5