From: Ralf Hartmann Date: Fri, 25 Aug 2000 12:01:26 +0000 (+0000) Subject: use of getrusage with RUSAGE_CHILDREN, but still the Timer class does not work in... X-Git-Tag: v8.0.0~20159 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5592e89cfa8;p=dealii.git use of getrusage with RUSAGE_CHILDREN, but still the Timer class does not work in multithreading (at least not on Solaris7). git-svn-id: https://svn.dealii.org/trunk@3270 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/timer.h b/deal.II/base/include/base/timer.h index 2e9691d37f..2d99107a12 100644 --- a/deal.II/base/include/base/timer.h +++ b/deal.II/base/include/base/timer.h @@ -96,6 +96,29 @@ class Timer */ double start_time; + + /** + * Similar to @p{start_time}, but + * needed for children threads + * in multithread mode. Value of + * the user time when @p{start} + * was called the last time or + * when the object was created + * and no @p{stop} was issued in + * between. + * + * For some reason (error in + * operating system?) the + * function call + * @p{getrusage(RUSAGE_CHILDREN,.)} + * gives always 0 (at least + * on Solaris7). Hence the + * @p{Timer} class still does not + * yet work for multithreading + * mode. + */ + double start_time_children; + /** * Accumulated time for all previous * @p{start}/@p{stop} cycles. The time for diff --git a/deal.II/base/source/timer.cc b/deal.II/base/source/timer.cc index 25e93882ca..79fc37c8ab 100644 --- a/deal.II/base/source/timer.cc +++ b/deal.II/base/source/timer.cc @@ -46,6 +46,10 @@ void Timer::start () rusage usage; getrusage (RUSAGE_SELF, &usage); start_time = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec; + + rusage usage_children; + getrusage (RUSAGE_CHILDREN, &usage_children); + start_time_children = usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec; } @@ -59,6 +63,12 @@ double Timer::stop () getrusage (RUSAGE_SELF, &usage); const double dtime = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec; cumulative_time += dtime - start_time; + + rusage usage_children; + getrusage (RUSAGE_CHILDREN, &usage_children); + const double dtime_children = + usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec; + cumulative_time += dtime_children - start_time_children; } return cumulative_time; } @@ -72,8 +82,13 @@ double Timer::operator() () const rusage usage; getrusage (RUSAGE_SELF, &usage); const double dtime = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec; + + rusage usage_children; + getrusage (RUSAGE_CHILDREN, &usage_children); + const double dtime_children = + usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec; - return dtime - start_time + cumulative_time; + return dtime - start_time + dtime_children - start_time_children + cumulative_time; } else return cumulative_time; diff --git a/deal.II/doc/news/2000/c-3-0.html b/deal.II/doc/news/2000/c-3-0.html index 4092d480aa..cdca5f3198 100644 --- a/deal.II/doc/news/2000/c-3-0.html +++ b/deal.II/doc/news/2000/c-3-0.html @@ -106,6 +106,17 @@

base

    +
  1. + New: Timer now uses the system + function getrusage (RUSAGE_CHILDREN, + .) that is need in multithreading. But still the Timer class does not yet work in + multithreading, as getrusage with flag RUSAGE_CHILDREN gives always + 0 (at least on Solaris7). +
    + (Ralf Hartmann 2000/08/25) +

    +
  2. New: There are now a set of functions outer_product that for the outer