1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
|
/*
* -- High Performance Computing Linpack Benchmark (HPL)
* HPL - 2.0 - September 10, 2008
* Antoine P. Petitet
* University of Tennessee, Knoxville
* Innovative Computing Laboratory
* (C) Copyright 2000-2008 All Rights Reserved
*
* -- Copyright notice and Licensing terms:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions, and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgement:
* This product includes software developed at the University of
* Tennessee, Knoxville, Innovative Computing Laboratory.
*
* 4. The name of the University, the name of the Laboratory, or the
* names of its contributors may not be used to endorse or promote
* products derived from this software without specific written
* permission.
*
* -- Disclaimer:
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ---------------------------------------------------------------------
*/
/*
* Include files
*/
#include "hpl.h"
/*
* ---------------------------------------------------------------------
* Static variables
* ---------------------------------------------------------------------
*/
static int HPL_timer_disabled;
static double HPL_timer_cpusec [HPL_NTIMER],
HPL_timer_cpustart [HPL_NTIMER],
HPL_timer_wallsec [HPL_NTIMER],
HPL_timer_wallstart[HPL_NTIMER];
/*
* ---------------------------------------------------------------------
* User callable functions
* ---------------------------------------------------------------------
*/
#ifdef HPL_STDC_HEADERS
void HPL_timer_boot( void )
#else
void HPL_timer_boot()
#endif
{
/*
* HPL_timer_boot (re)sets all timers to 0, and enables HPL_timer.
*/
/*
* .. Local Variables ..
*/
int i;
/* ..
* .. Executable Statements ..
*/
HPL_timer_disabled = 0;
for( i = 0; i < HPL_NTIMER; i++ )
{
HPL_timer_cpusec [i] = HPL_timer_wallsec [i] = HPL_rzero;
HPL_timer_cpustart[i] = HPL_timer_wallstart[i] = HPL_TIMER_STARTFLAG;
}
/*
* End of HPL_timer_boot
*/
}
#ifdef HPL_STDC_HEADERS
void HPL_timer( const int I )
#else
void HPL_timer( I )
const int I;
#endif
{
/*
* Purpose
* =======
*
* HPL_timer provides a "stopwatch" functionality cpu/wall timer in
* seconds. Up to 64 separate timers can be functioning at once. The
* first call starts the timer, and the second stops it. This routine
* can be disenabled by calling HPL_timer_disable(), so that calls to
* the timer are ignored. This feature can be used to make sure certain
* sections of code do not affect timings, even if they call routines
* which have HPL_timer calls in them. HPL_timer_enable() will re-enable
* the timer functionality. One can retrieve the current value of a
* timer by calling
*
* t0 = HPL_timer_inquire( HPL_WALL_TIME | HPL_CPU_TIME, I )
*
* where I is the timer index in [0..64). To initialize the timer
* functionality, one must have called HPL_timer_boot() prior to any of
* the functions mentioned above.
*
* Arguments
* =========
*
* I (global input) const int
* On entry, I specifies the timer to stop/start.
*
* ---------------------------------------------------------------------
*/
/* ..
* .. Executable Statements ..
*/
if( HPL_timer_disabled ) return;
/*
* If timer has not been started, start it. Otherwise, stop it and add
* interval to count
*/
if( HPL_timer_wallstart[I] == HPL_TIMER_STARTFLAG )
{
HPL_timer_wallstart[I] = HPL_timer_walltime();
HPL_timer_cpustart [I] = HPL_timer_cputime ();
}
else
{
HPL_timer_cpusec [I] += HPL_timer_cputime () - HPL_timer_cpustart [I];
HPL_timer_wallsec [I] += HPL_timer_walltime() - HPL_timer_wallstart[I];
HPL_timer_wallstart[I] = HPL_TIMER_STARTFLAG;
}
/*
* End of HPL_timer
*/
}
#ifdef HPL_STDC_HEADERS
void HPL_timer_enable( void )
#else
void HPL_timer_enable()
#endif
{
/*
* HPL_timer_enable sets it so calls to HPL_timer are not ignored.
*/
/* ..
* .. Executable Statements ..
*/
HPL_timer_disabled = 0;
return;
/*
* End of HPL_timer_enable
*/
}
#ifdef HPL_STDC_HEADERS
void HPL_timer_disable( void )
#else
void HPL_timer_disable()
#endif
{
/*
* HPL_timer_disable sets it so calls to HPL_timer are ignored.
*/
/* ..
* .. Executable Statements ..
*/
HPL_timer_disabled = 1;
return;
/*
* End of HPL_timer_disable
*/
}
#ifdef HPL_STDC_HEADERS
double HPL_timer_inquire
(
const HPL_T_TIME TMTYPE,
const int I
)
#else
double HPL_timer_inquire( TMTYPE, I )
const int I;
const HPL_T_TIME TMTYPE;
#endif
{
/*
* Purpose
* =======
*
* HPL_timer_inquire returns wall- or cpu- time that has accumulated in
* timer I.
*
* Arguments
* =========
*
* TMTYPE (global input) const HPL_T_TIME
* On entry, TMTYPE specifies what time will be returned as fol-
* lows
* = HPL_WALL_TIME : wall clock time is returned,
* = HPL_CPU_TIME : CPU time is returned (default).
*
* I (global input) const int
* On entry, I specifies the timer to return.
*
* ---------------------------------------------------------------------
*/
/*
* .. Local Variables ..
*/
double time;
/* ..
* .. Executable Statements ..
*/
/*
* If wall- or cpu-time are not available on this machine, return
* HPL_TIMER_ERROR
*/
if( TMTYPE == HPL_WALL_TIME )
{
if( HPL_timer_walltime() == HPL_TIMER_ERROR )
time = HPL_TIMER_ERROR;
else
time = HPL_timer_wallsec[I];
}
else
{
if( HPL_timer_cputime() == HPL_TIMER_ERROR )
time = HPL_TIMER_ERROR;
else
time = HPL_timer_cpusec [I];
}
return( time );
/*
* End of HPL_timer_inquire
*/
}
|