Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Timer_dh.h
Go to the documentation of this file.
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack: Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2002) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
43 #ifndef TIMER_DH_H
44 #define TIMER_DH_H
45 
46 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
47 #ifdef __GNUC__
48 #warning "The Ifpack package is deprecated"
49 #endif
50 #endif
51 
52 #include "euclid_common.h"
53 
54 /*--------------------------------------------------------------*/
55 /* Stuff in this block isn't really needed for multi-processor
56  * runs, since recording CPU time probably isn't useful.
57  * if EUCLID_TIMING is defined in $PCPACK_DIR/bmake_XXX/common,
58  * the times() function is used;
59  * then MPI_Wtime() is used in preference to times().
60  *
61  * You may need to fiddle with some of these includes, depending
62  * on your system. Make sure and check the logFile to ensure
63  * that CLK_TCK was properly defined. See Timer_dhCreate()
64  * for additional details.
65  *
66  * if "JUNK_TIMING" is defined during compilation, timing functions
67  * either do nothing, or return -1.0; this is primarily for debugging.
68  */
69 
70 #ifdef EUCLID_TIMING
71 #include <sys/times.h>
72 #include <sys/types.h>
73 #if HAVE_UNISTD_H
74 # include <unistd.h>
75 #endif /* HAVE_UNISTD_H */
76 
77 #elif !defined(JUNK_TIMING)
78 /* #include <sys/types.h>
79 #include <sys/sysconfig.h>
80 */
81 #ifdef WIN32
82 # include <time.h>
83 #endif
84 #if HAVE_UNISTD_H
85 # include <unistd.h> /* needed for sysconf(_SC_CLK_TCK) */
86 #endif /* HAVE_UNISTD_H */
87 #endif
88 
89 
90 /*
91  ??? may be needed for some compilers/platforms?
92 #include <limits.h>
93 #include <time.h>
94 #include <sys/resource.h>
95 */
96 
97 /*--------------------------------------------------------------*/
98 
99 #ifdef __cplusplus
100 extern "C"
101 {
102 #endif
103 
104  struct _timer_dh
105  {
106  bool isRunning;
107  long int sc_clk_tck;
108  double begin_wall;
109  double end_wall;
110 
111 #ifdef EUCLID_TIMING
112  struct tms begin_cpu;
113  struct tms end_cpu;
114 #endif
115 
116  };
117 
118  extern void Timer_dhCreate (Timer_dh * t);
119  extern void Timer_dhDestroy (Timer_dh t);
120  extern void Timer_dhStart (Timer_dh t);
121  extern void Timer_dhStop (Timer_dh t);
122  extern double Timer_dhReadCPU (Timer_dh t);
123  extern double Timer_dhReadWall (Timer_dh t);
124  extern double Timer_dhReadUsage (Timer_dh t);
125 
126 /* notes:
127  (1) unless compiled with EUCLID_TIMING defined, readCPU
128  and readUseage return -1.0.
129  (2) whenever start() is called, the timer is reset; you
130  don't need to call stop() first.
131  (3) if stop() HAS been called, the readXX functions return
132  timings between start() and stop(); , if start()
133  was called but not stop(), they sample the time then
134  return; if start() was never called, they return junk.
135 */
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif
bool isRunning
Definition: Timer_dh.h:106
double Timer_dhReadWall(Timer_dh t)
Definition: Timer_dh.c:224
double begin_wall
Definition: Timer_dh.h:108
void Timer_dhDestroy(Timer_dh t)
Definition: Timer_dh.c:80
void Timer_dhStop(Timer_dh t)
Definition: Timer_dh.c:217
void Timer_dhCreate(Timer_dh *t)
Definition: Timer_dh.c:49
double end_wall
Definition: Timer_dh.h:109
double Timer_dhReadUsage(Timer_dh t)
Definition: Timer_dh.c:238
void Timer_dhStart(Timer_dh t)
Definition: Timer_dh.c:210
long int sc_clk_tck
Definition: Timer_dh.h:107
double Timer_dhReadCPU(Timer_dh t)
Definition: Timer_dh.c:231