diff options
Diffstat (limited to 'Carpet')
-rw-r--r-- | Carpet/CarpetLib/src/data.cc | 1 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gdata.cc | 101 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gdata.hh | 44 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/make.code.defn | 3 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/timestat.cc | 120 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/timestat.hh | 58 |
6 files changed, 182 insertions, 145 deletions
diff --git a/Carpet/CarpetLib/src/data.cc b/Carpet/CarpetLib/src/data.cc index 2d4192e13..758bd47a1 100644 --- a/Carpet/CarpetLib/src/data.cc +++ b/Carpet/CarpetLib/src/data.cc @@ -17,6 +17,7 @@ #include "bbox.hh" #include "defs.hh" #include "dist.hh" +#include "timestat.hh" #include "vect.hh" #include "data.hh" diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc index 507ea0b44..37a78069a 100644 --- a/Carpet/CarpetLib/src/gdata.cc +++ b/Carpet/CarpetLib/src/gdata.cc @@ -1,13 +1,8 @@ -#include <algorithm> #include <cassert> -#include <cmath> #include <cstdlib> #include <iostream> -#include <mpi.h> - #include "cctk.h" -#include "cctk_Arguments.h" #include "cctk_Parameters.h" #include "util_ErrorCodes.h" @@ -109,102 +104,6 @@ static int nexttag () -timestat::timestat () : wtime(0.0), wtime2(0.0), count(0.0), running(false) -{ -} - -void timestat::addstat (double const t) -{ - wtime += t; - wtime2 += t*t; - ++count; -} - -void timestat::start () -{ - assert (! running); - running = true; - starttime = MPI_Wtime(); -} - -void timestat::stop () -{ - assert (running); - running = false; - double const endtime = MPI_Wtime(); - addstat (endtime - starttime); -} - -ostream& operator<< (ostream& os, const timestat& wt) -{ - double const avg = wt.wtime / wt.count; - double const stddev = sqrt(max(0.0, wt.wtime2 / wt.count - avg * avg)); - os << "timestat[seconds]:" - << " cnt: " << wt.count - << " sum: " << wt.wtime - << " avg: " << avg - << " stddev: " << stddev; - return os; -} - -timestat wtime_copyfrom_recv; -timestat wtime_copyfrom_send; -timestat wtime_copyfrom_wait; - -timestat wtime_copyfrom_recv_maketyped; -timestat wtime_copyfrom_recv_allocate; -timestat wtime_copyfrom_recv_changeproc_recv; -timestat wtime_copyfrom_send_copyfrom_nocomm1; -timestat wtime_copyfrom_send_copyfrom_nocomm2; -timestat wtime_copyfrom_send_changeproc_send; -timestat wtime_copyfrom_wait_changeproc_wait; -timestat wtime_copyfrom_wait_copyfrom_nocomm; -timestat wtime_copyfrom_wait_delete; - -timestat wtime_changeproc_recv; -timestat wtime_changeproc_send; -timestat wtime_changeproc_wait; - -timestat wtime_irecv; -timestat wtime_isend; -timestat wtime_isendwait; -timestat wtime_irecvwait; - -extern "C" void CarpetLib_printtimestats (CCTK_ARGUMENTS); -void CarpetLib_printtimestats (CCTK_ARGUMENTS) -{ - DECLARE_CCTK_ARGUMENTS; - DECLARE_CCTK_PARAMETERS; - if (print_timestats) { - cout << "Timing statistics from CarpetLib:" << endl - << " wtime_copyfrom_recv: " << wtime_copyfrom_recv << endl - << " wtime_copyfrom_send: " << wtime_copyfrom_send << endl - << " wtime_copyfrom_wait: " << wtime_copyfrom_wait << endl - << endl - << " wtime_copyfrom_recv_maketyped: " << wtime_copyfrom_recv_maketyped << endl - << " wtime_copyfrom_recv_allocate: " << wtime_copyfrom_recv_allocate << endl - << " wtime_copyfrom_recv_changeproc_recv: " << wtime_copyfrom_recv_changeproc_recv << endl - << " wtime_copyfrom_send_copyfrom_nocomm1: " << wtime_copyfrom_send_copyfrom_nocomm1 << endl - << " wtime_copyfrom_send_copyfrom_nocomm2: " << wtime_copyfrom_send_copyfrom_nocomm2 << endl - << " wtime_copyfrom_send_changeproc_send: " << wtime_copyfrom_send_changeproc_send << endl - << " wtime_copyfrom_wait_changeproc_wait: " << wtime_copyfrom_wait_changeproc_wait << endl - << " wtime_copyfrom_wait_copyfrom_nocomm2: " << wtime_copyfrom_wait_copyfrom_nocomm << endl - << " wtime_copyfrom_wait_delete: " << wtime_copyfrom_wait_delete << endl - << endl - << " wtime_changeproc_recv: " << wtime_changeproc_recv << endl - << " wtime_changeproc_send: " << wtime_changeproc_send << endl - << " wtime_changeproc_wait: " << wtime_changeproc_wait << endl - << endl - << " wtime_irecv: " << wtime_irecv << endl - << " wtime_isend: " << wtime_isend << endl - << " wtime_isendwait: " << wtime_isendwait << endl - << " wtime_irecvwait: " << wtime_irecvwait << endl - << endl; - } -} - - - // Constructors template<int D> gdata<D>::gdata (const int varindex_, const operator_type transport_operator_) diff --git a/Carpet/CarpetLib/src/gdata.hh b/Carpet/CarpetLib/src/gdata.hh index 9d544f9bb..9d08a5b63 100644 --- a/Carpet/CarpetLib/src/gdata.hh +++ b/Carpet/CarpetLib/src/gdata.hh @@ -14,6 +14,7 @@ #include "dist.hh" #include "bbox.hh" #include "operators.hh" +#include "timestat.hh" #include "vect.hh" using namespace std; @@ -48,49 +49,6 @@ public: -// Time (in seconds) spend during various operations -struct timestat { - double wtime; - double wtime2; - double count; - timestat (); -private: - bool running; - double starttime; -public: - void start(); - void stop(); -private: - void addstat (double const t); -}; - -ostream& operator<< (ostream& os, const timestat& wt); - -extern timestat wtime_copyfrom_recv; -extern timestat wtime_copyfrom_send; -extern timestat wtime_copyfrom_wait; - -extern timestat wtime_copyfrom_recv_maketyped; -extern timestat wtime_copyfrom_recv_allocate; -extern timestat wtime_copyfrom_recv_changeproc_recv; -extern timestat wtime_copyfrom_send_copyfrom_nocomm1; -extern timestat wtime_copyfrom_send_copyfrom_nocomm2; -extern timestat wtime_copyfrom_send_changeproc_send; -extern timestat wtime_copyfrom_wait_changeproc_wait; -extern timestat wtime_copyfrom_wait_copyfrom_nocomm; -extern timestat wtime_copyfrom_wait_delete; - -extern timestat wtime_changeproc_recv; -extern timestat wtime_changeproc_send; -extern timestat wtime_changeproc_wait; - -extern timestat wtime_irecv; -extern timestat wtime_isend; -extern timestat wtime_irecvwait; -extern timestat wtime_isendwait; - - - // A generic data storage without type information template<int D> class gdata { diff --git a/Carpet/CarpetLib/src/make.code.defn b/Carpet/CarpetLib/src/make.code.defn index b85fdc0a2..cc9ee9a22 100644 --- a/Carpet/CarpetLib/src/make.code.defn +++ b/Carpet/CarpetLib/src/make.code.defn @@ -39,7 +39,8 @@ SRCS = bbox.cc \ prolongate_3d_real8_2tl_eno.F90 \ prolongate_3d_real8_3tl_eno.F90 \ restrict_3d_real8.F77 \ - restrict_3d_real8_rf2.F77 + restrict_3d_real8_rf2.F77 \ + timestat.cc # Subdirectories containing source files SUBDIRS = diff --git a/Carpet/CarpetLib/src/timestat.cc b/Carpet/CarpetLib/src/timestat.cc new file mode 100644 index 000000000..0c43c6ed3 --- /dev/null +++ b/Carpet/CarpetLib/src/timestat.cc @@ -0,0 +1,120 @@ +#include <algorithm> +#include <cmath> +#include <iostream> + +#include <mpi.h> + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +#include "timestat.hh" + + + +using namespace std; + + + +timestat::timestat () + : wtime(0.0), wtime2(0.0), count(0.0), + running(false) +{ +} + +void timestat::addstat (double const t) +{ + wtime += t; + wtime2 += t*t; + ++count; +} + +void timestat::start () +{ + assert (! running); + running = true; + starttime = MPI_Wtime(); +} + +void timestat::stop () +{ + assert (running); + running = false; + double const endtime = MPI_Wtime(); + addstat (endtime - starttime); +} + + + +ostream& operator<< (ostream& os, const timestat& wt) +{ + double const avg = wt.wtime / wt.count; + double const stddev = sqrt(max(0.0, wt.wtime2 / wt.count - avg * avg)); + os << "timestat[seconds]:" + << " cnt: " << wt.count + << " sum: " << wt.wtime + << " avg: " << avg + << " stddev: " << stddev; + return os; +} + + + +timestat wtime_copyfrom_recv; +timestat wtime_copyfrom_send; +timestat wtime_copyfrom_wait; + +timestat wtime_copyfrom_recv_maketyped; +timestat wtime_copyfrom_recv_allocate; +timestat wtime_copyfrom_recv_changeproc_recv; +timestat wtime_copyfrom_send_copyfrom_nocomm1; +timestat wtime_copyfrom_send_copyfrom_nocomm2; +timestat wtime_copyfrom_send_changeproc_send; +timestat wtime_copyfrom_wait_changeproc_wait; +timestat wtime_copyfrom_wait_copyfrom_nocomm; +timestat wtime_copyfrom_wait_delete; + +timestat wtime_changeproc_recv; +timestat wtime_changeproc_send; +timestat wtime_changeproc_wait; + +timestat wtime_irecv; +timestat wtime_isend; +timestat wtime_isendwait; +timestat wtime_irecvwait; + + + +extern "C" void CarpetLib_printtimestats (CCTK_ARGUMENTS); + +void CarpetLib_printtimestats (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + if (print_timestats) { + cout << "Timing statistics from CarpetLib:" << endl + << " wtime_copyfrom_recv: " << wtime_copyfrom_recv << endl + << " wtime_copyfrom_send: " << wtime_copyfrom_send << endl + << " wtime_copyfrom_wait: " << wtime_copyfrom_wait << endl + << endl + << " wtime_copyfrom_recv_maketyped: " << wtime_copyfrom_recv_maketyped << endl + << " wtime_copyfrom_recv_allocate: " << wtime_copyfrom_recv_allocate << endl + << " wtime_copyfrom_recv_changeproc_recv: " << wtime_copyfrom_recv_changeproc_recv << endl + << " wtime_copyfrom_send_copyfrom_nocomm1: " << wtime_copyfrom_send_copyfrom_nocomm1 << endl + << " wtime_copyfrom_send_copyfrom_nocomm2: " << wtime_copyfrom_send_copyfrom_nocomm2 << endl + << " wtime_copyfrom_send_changeproc_send: " << wtime_copyfrom_send_changeproc_send << endl + << " wtime_copyfrom_wait_changeproc_wait: " << wtime_copyfrom_wait_changeproc_wait << endl + << " wtime_copyfrom_wait_copyfrom_nocomm2: " << wtime_copyfrom_wait_copyfrom_nocomm << endl + << " wtime_copyfrom_wait_delete: " << wtime_copyfrom_wait_delete << endl + << endl + << " wtime_changeproc_recv: " << wtime_changeproc_recv << endl + << " wtime_changeproc_send: " << wtime_changeproc_send << endl + << " wtime_changeproc_wait: " << wtime_changeproc_wait << endl + << endl + << " wtime_irecv: " << wtime_irecv << endl + << " wtime_isend: " << wtime_isend << endl + << " wtime_isendwait: " << wtime_isendwait << endl + << " wtime_irecvwait: " << wtime_irecvwait << endl + << endl; + } +} diff --git a/Carpet/CarpetLib/src/timestat.hh b/Carpet/CarpetLib/src/timestat.hh new file mode 100644 index 000000000..95cc53e00 --- /dev/null +++ b/Carpet/CarpetLib/src/timestat.hh @@ -0,0 +1,58 @@ +#ifndef TIMESTAT_HH +#define TIMESTAT_HH + + + +// Time (in seconds) spend during various operations +class timestat { + +public: + double wtime; + double wtime2; + double count; + +public: + timestat (); + +private: + void addstat (double const t); + +private: + bool running; + double starttime; + +public: + void start(); + void stop(); +}; + +ostream& operator<< (ostream& os, const timestat& wt); + + + +extern timestat wtime_copyfrom_recv; +extern timestat wtime_copyfrom_send; +extern timestat wtime_copyfrom_wait; + +extern timestat wtime_copyfrom_recv_maketyped; +extern timestat wtime_copyfrom_recv_allocate; +extern timestat wtime_copyfrom_recv_changeproc_recv; +extern timestat wtime_copyfrom_send_copyfrom_nocomm1; +extern timestat wtime_copyfrom_send_copyfrom_nocomm2; +extern timestat wtime_copyfrom_send_changeproc_send; +extern timestat wtime_copyfrom_wait_changeproc_wait; +extern timestat wtime_copyfrom_wait_copyfrom_nocomm; +extern timestat wtime_copyfrom_wait_delete; + +extern timestat wtime_changeproc_recv; +extern timestat wtime_changeproc_send; +extern timestat wtime_changeproc_wait; + +extern timestat wtime_irecv; +extern timestat wtime_isend; +extern timestat wtime_irecvwait; +extern timestat wtime_isendwait; + + + +#endif TIMESTAT_HH |