From: wolf Date: Mon, 17 Jan 2000 13:35:53 +0000 (+0000) Subject: Enable multithreading for end_sweep. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc77d381d5b9ae8ffa4ed41b7b00e0396d31f784;p=dealii-svn.git Enable multithreading for end_sweep. git-svn-id: https://svn.dealii.org/trunk@2230 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/numerics/time_dependent.h b/deal.II/deal.II/include/numerics/time_dependent.h index c3d0a35675..c3927a9aee 100644 --- a/deal.II/deal.II/include/numerics/time_dependent.h +++ b/deal.II/deal.II/include/numerics/time_dependent.h @@ -624,11 +624,40 @@ class TimeDependent virtual void start_sweep (const unsigned int sweep_no); /** - * Analogon to the above function, - * calling #end_sweep# of each time - * step object. + * Analogon to the above + * function, calling #end_sweep# + * of each time step object. The + * same applies with respect to + * the #virtual#ness of this + * function as for the previous + * one. + * + * This function does not + * guarantee that #end_sweep# is + * called for successive time + * steps, rather the order of + * time steps for which the + * function is called is + * arbitrary. You should + * therefore not assume that that + * function has been called for + * previous time steps + * already. If in multithread + * mode, the #end_sweep# function + * of several time steps is + * called at once, so you should + * use synchronization + * 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, + * and the value is ignored if + * not in multithread mode. */ - virtual void end_sweep (); + virtual void end_sweep (const unsigned int n_threads = 1); /** * Exception. @@ -676,7 +705,16 @@ class TimeDependent * for more information. */ const TimeSteppingData timestepping_data_postprocess; - + + private: + + /** + * Do the work of #end_sweep()# + * for some timesteps only. This + * is useful in multithread mode. + */ + void * end_sweep (const unsigned int begin_timestep, + const unsigned int end_timestep); }; diff --git a/deal.II/deal.II/source/numerics/time_dependent.cc b/deal.II/deal.II/source/numerics/time_dependent.cc index 5e0f7be822..cfb3b7a383 100644 --- a/deal.II/deal.II/source/numerics/time_dependent.cc +++ b/deal.II/deal.II/source/numerics/time_dependent.cc @@ -7,6 +7,11 @@ #include #include +#ifdef DEAL_II_USE_MT +# include +# define NTHREADS 4 +#endif + #include #include #include @@ -198,10 +203,48 @@ void TimeDependent::start_sweep (const unsigned int s) -void TimeDependent::end_sweep () +void TimeDependent::end_sweep (const unsigned int +#ifdef DEAL_II_USE_MT + n_threads +#endif +) { - for (unsigned int step=0; step MemFunData; + vector mem_fun_data (n_threads, + MemFunData(this, 0, 0, &end_sweep)); + const unsigned int stride = timesteps.size() / n_threads; + for (unsigned int i=0; iend_sweep (); + return 0; };