From: bangerth
Date: Sun, 17 Mar 2013 17:55:59 +0000 (+0000)
Subject: Deprecate the function TimeDependent::end_sweep with an argument indicating the numbe...
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79878440f2fcc09bc5104b33f5ef0f505d9be387;p=dealii-svn.git
Deprecate the function TimeDependent::end_sweep with an argument indicating the number of threads. Introduce a function without an argument and use TBB facilities to make it parallel as the old one was. Actually introduce a first test for the entire TimeDependent stuff.
git-svn-id: https://svn.dealii.org/trunk@28928 0785d39b-7218-0410-832d-ea1e28bc413d
---
diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h
index 275a9b8629..0a0277e0ac 100644
--- a/deal.II/doc/news/changes.h
+++ b/deal.II/doc/news/changes.h
@@ -24,11 +24,13 @@ inconvenience this causes.
-
+(Wolfgang Bangerth, 2013/03/17)
diff --git a/deal.II/include/deal.II/numerics/time_dependent.h b/deal.II/include/deal.II/numerics/time_dependent.h
index cf7a73cec9..5b34cc9ac1 100644
--- a/deal.II/include/deal.II/numerics/time_dependent.h
+++ b/deal.II/include/deal.II/numerics/time_dependent.h
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------
// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012, 2013 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
@@ -649,11 +649,11 @@ public:
* function as for the previous
* one.
*
- * This function does not
+ * @note This function does not
* guarantee that @p end_sweep is
* called for successive time
- * steps, rather the order of
- * time steps for which the
+ * steps successively, rather the order of
+ * time step objects for which the
* function is called is
* arbitrary. You should
* therefore not assume that that
@@ -661,22 +661,19 @@ public:
* previous time steps
* already. If in multithread
* mode, the @p end_sweep function
- * of several time steps is
+ * of several time steps may be
* called at once, so you should
* use synchronization
- * mechanisms, if your program
+ * mechanisms if your program
* requires so.
- *
- * The parameter denotes the
- * number of threads that shall
- * be spawned in parallel. It
- * defaults to only one thread to
- * avoid hidden synchronisation
- * problems, and the value is
- * ignored if not in multithread
- * mode.
- */
- virtual void end_sweep (const unsigned int n_threads = 1);
+ */
+ virtual void end_sweep ();
+
+ /**
+ * @deprecated Use the function without an argument.
+ * @arg n_threads This argument is ignored.
+ */
+ virtual void end_sweep (const unsigned int n_threads) DEAL_II_DEPRECATED;
/**
* Determine an estimate for the
diff --git a/deal.II/source/numerics/time_dependent.cc b/deal.II/source/numerics/time_dependent.cc
index 52d8d4f726..8944ad436c 100644
--- a/deal.II/source/numerics/time_dependent.cc
+++ b/deal.II/source/numerics/time_dependent.cc
@@ -2,7 +2,7 @@
// $Id$
// Version: $Name$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
@@ -16,6 +16,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -203,30 +204,19 @@ void TimeDependent::start_sweep (const unsigned int s)
-void TimeDependent::end_sweep (const unsigned int n_threads)
+void TimeDependent::end_sweep (const unsigned int)
{
-#ifdef DEAL_II_WITH_THREADS
- if (n_threads > 1)
- {
- const unsigned int stride = timesteps.size() / n_threads;
- Threads::ThreadGroup<> threads;
- void (TimeDependent::*p) (const unsigned int, const unsigned int)
- = &TimeDependent::end_sweep;
- for (unsigned int i=0; i
+
+#include
+#include
+#include
+
+
+std::ofstream logfile("time_dependent_01/output");
+
+
+std::vector end_sweep_flags;
+
+
+class TimeStep : public TimeStepBase
+{
+public:
+ TimeStep (const unsigned int time_step_number)
+ :
+ TimeStepBase(0),
+ time_step_number (time_step_number)
+ {}
+
+ virtual void end_sweep ()
+ {
+ static Threads::Mutex mutex;
+ Threads::Mutex::ScopedLock lock(mutex);
+ end_sweep_flags[time_step_number] = true;
+ }
+
+ virtual void solve_primal_problem () {}
+
+private:
+ const unsigned int time_step_number;
+};
+
+
+void test ()
+{
+ // create time steps, more than there are likely threads on current machines
+ TimeDependent td (TimeDependent::TimeSteppingData(0,0),
+ TimeDependent::TimeSteppingData(0,0),
+ TimeDependent::TimeSteppingData(0,0));
+ const unsigned int n_time_steps = 10000;
+ for (unsigned int i=0; i (n_time_steps, false);
+ td.end_sweep ();
+
+ // make sure we have called TimeStep::end_sweep once for every time step object
+ Assert (end_sweep_flags == std::vector (n_time_steps, true),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+int main ()
+{
+ deallog << std::setprecision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ test ();
+
+ return 0;
+}
diff --git a/tests/deal.II/time_dependent_01/cmp/generic b/tests/deal.II/time_dependent_01/cmp/generic
new file mode 100644
index 0000000000..0fd8fc12f0
--- /dev/null
+++ b/tests/deal.II/time_dependent_01/cmp/generic
@@ -0,0 +1,2 @@
+
+DEAL::OK