Timer_dh.h

Go to the documentation of this file.
00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2009) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
00028 */
00029 
00030 #ifndef TIMER_DH_H
00031 #define TIMER_DH_H
00032 
00033 #include "euclid_common.h"
00034 
00035 /*--------------------------------------------------------------*/
00036 /* Stuff in this block isn't really needed for multi-processor
00037  * runs, since recording CPU time probably isn't useful.
00038  * if EUCLID_TIMING is defined in $PCPACK_DIR/bmake_XXX/common,
00039  * the times() function is used;
00040  * then MPI_Wtime() is used in preference to times().
00041  *
00042  * You may need to fiddle with some of these includes, depending
00043  * on your system.  Make sure and check the logFile to ensure
00044  * that CLK_TCK was properly defined.  See Timer_dhCreate()
00045  * for additional details. 
00046  *
00047  * if "JUNK_TIMING" is defined during compilation, timing functions
00048  * either do nothing, or return -1.0; this is primarily for debugging.
00049  */
00050 
00051 #ifdef EUCLID_TIMING
00052 #include <sys/times.h>
00053 #include <sys/types.h>
00054 #if HAVE_UNISTD_H
00055 #  include <unistd.h>
00056 #endif /* HAVE_UNISTD_H */
00057 
00058 #elif !defined(JUNK_TIMING)
00059 /* #include <sys/types.h> 
00060 #include <sys/sysconfig.h>
00061 */
00062 #ifdef WIN32
00063 #  include <time.h>
00064 #endif
00065 #if HAVE_UNISTD_H
00066 #  include <unistd.h>   /* needed for sysconf(_SC_CLK_TCK) */
00067 #endif /* HAVE_UNISTD_H */
00068 #endif
00069 
00070 
00071 /* 
00072    ??? may be needed for some compilers/platforms?
00073 #include <limits.h>
00074 #include <time.h>
00075 #include <sys/resource.h>
00076 */
00077 
00078 /*--------------------------------------------------------------*/
00079 
00080 #ifdef __cplusplus
00081 extern "C"
00082 {
00083 #endif
00084 
00085   struct _timer_dh
00086   {
00087     bool isRunning;
00088     long int sc_clk_tck;
00089     double begin_wall;
00090     double end_wall;
00091 
00092 #ifdef EUCLID_TIMING
00093     struct tms begin_cpu;
00094     struct tms end_cpu;
00095 #endif
00096 
00097   };
00098 
00099   extern void Timer_dhCreate (Timer_dh * t);
00100   extern void Timer_dhDestroy (Timer_dh t);
00101   extern void Timer_dhStart (Timer_dh t);
00102   extern void Timer_dhStop (Timer_dh t);
00103   extern double Timer_dhReadCPU (Timer_dh t);
00104   extern double Timer_dhReadWall (Timer_dh t);
00105   extern double Timer_dhReadUsage (Timer_dh t);
00106 
00107 /* notes:
00108     (1)  unless compiled with EUCLID_TIMING defined, readCPU 
00109          and readUseage return -1.0.
00110     (2)  whenever start() is called, the timer is reset; you
00111          don't need to call stop() first.
00112     (3)  if stop() HAS been called, the readXX functions return
00113          timings between start() and stop(); , if start()
00114          was called but not stop(), they sample the time then
00115          return; if start() was never called, they return junk.
00116 */
00117 
00118 #ifdef __cplusplus
00119 }
00120 #endif
00121 
00122 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:05:35 2011 for Ifpack Package Browser (Single Doxygen Collection) by  doxygen 1.6.3