From cd1db3591ef38160e365297355d42788952f2b49 Mon Sep 17 00:00:00 2001 From: hartmann Date: Fri, 25 Aug 2000 12:01:26 +0000 Subject: [PATCH] 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 --- deal.II/base/include/base/timer.h | 23 +++++++++++++++++++++++ deal.II/base/source/timer.cc | 17 ++++++++++++++++- deal.II/doc/news/2000/c-3-0.html | 11 +++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) 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 -- 2.39.5