From d63ad805008ef644526830bd6d0f596c8d980e70 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Sun, 20 Jan 2008 23:19:33 +0000 Subject: [PATCH] Took out vcs_seconds routine. Now relying on clockWC. --- Cantera/src/equil/Makefile.in | 2 +- Cantera/src/equil/vcs_MultiPhaseEquil.cpp | 7 ++- Cantera/src/equil/vcs_inest.cpp | 6 +- Cantera/src/equil/vcs_solve.cpp | 8 ++- Cantera/src/equil/vcs_solve_TP.cpp | 12 ++-- Cantera/src/equil/vcs_timer_generic.cpp | 67 ----------------------- 6 files changed, 21 insertions(+), 81 deletions(-) delete mode 100644 Cantera/src/equil/vcs_timer_generic.cpp diff --git a/Cantera/src/equil/Makefile.in b/Cantera/src/equil/Makefile.in index e530375c9..b63177f73 100644 --- a/Cantera/src/equil/Makefile.in +++ b/Cantera/src/equil/Makefile.in @@ -68,7 +68,7 @@ VCSNONIDEAL_OBJ = vcs_solve_TP.o vcs_VolPhase.o vcs_solve.o vcs_prob.o \ vcs_elem_rearrange.o vcs_MultiPhaseEquil.o \ vcs_nasa_poly.o vcs_nondim.o vcs_Exception.o \ vcs_funcVtot.o vcs_inest.o vcs_rearrange.o \ - vcs_root1d.o vcs_rxnadj.o vcs_timer_generic.o \ + vcs_root1d.o vcs_rxnadj.o \ vcs_SpeciesProperties.o vcs_equilibrate.o \ vcs_prep.o vcs_species_thermo.o vcs_Gibbs.o \ $(DALT_OBJ) diff --git a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp index c030cb89b..1e52acc6a 100644 --- a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp +++ b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp @@ -23,6 +23,7 @@ #include "ct_defs.h" #include "mix_defs.h" +#include "clockWC.h" #include "speciesThermoTypes.h" #ifdef WITH_IDEAL_SOLUTIONS #include "IdealSolidSolnPhase.h" @@ -567,7 +568,7 @@ namespace VCSnonideal { // Debugging level int maxit = maxsteps;; - double ts = vcs_second(); + clockWC tickTock; int nsp = m_mix->nSpecies(); int nel = m_mix->nElements(); int nph = m_mix->nPhases(); @@ -651,7 +652,7 @@ namespace VCSnonideal { m_mix->setPhaseMoles(ip, phaseMole); } - double te = vcs_second(); + double te = tickTock.secondsWC(); if (printLvl > 0) { plogf("\n Results from vcs:\n"); if (iSuccess != 0) { @@ -710,7 +711,7 @@ namespace VCSnonideal { plogf("------------------------------------------" "-------------------\n"); if (printLvl > 2) { - plogf("Total time = %12.6e seconds\n", te - ts); + plogf("Total time = %12.6e seconds\n", te); } } return iSuccess; diff --git a/Cantera/src/equil/vcs_inest.cpp b/Cantera/src/equil/vcs_inest.cpp index a1afb8601..83ee7570e 100644 --- a/Cantera/src/equil/vcs_inest.cpp +++ b/Cantera/src/equil/vcs_inest.cpp @@ -21,6 +21,8 @@ #include "vcs_internal.h" #include "vcs_VolPhase.h" +#include "clockWC.h" + namespace VCSnonideal { static char pprefix[20] = " --- vcs_inest: "; @@ -396,7 +398,7 @@ namespace VCSnonideal { { int retn = 0; double test; - double tsecond = vcs_second(); + Cantera::clockWC tickTock; test = -1.0E20; /* * Malloc temporary space for usage in this routine and in @@ -494,7 +496,7 @@ namespace VCSnonideal { /* * Free malloced memory */ - tsecond = vcs_second() - tsecond; + double tsecond = tickTock.secondsWC(); m_VCount->T_Time_inest += tsecond; (m_VCount->T_Calls_Inest)++; return retn; diff --git a/Cantera/src/equil/vcs_solve.cpp b/Cantera/src/equil/vcs_solve.cpp index 2fcd0d931..69cb28d8a 100644 --- a/Cantera/src/equil/vcs_solve.cpp +++ b/Cantera/src/equil/vcs_solve.cpp @@ -21,6 +21,8 @@ #include "vcs_SpeciesProperties.h" #include "vcs_species_thermo.h" +#include "clockWC.h" + #include #include "math.h" using namespace std; @@ -292,7 +294,7 @@ namespace VCSnonideal { int iprintTime) { int retn = 0; int iconv = 0, nspecies0, nelements0, nphase0; - double te, ts = vcs_second(); + Cantera::clockWC tickTock; if (iprintTime == -1) { iprintTime = MAX(ipr, ip1); } @@ -409,8 +411,8 @@ namespace VCSnonideal { /* * Report on the time if requested to do so */ - te = vcs_second(); - m_VCount->T_Time_vcs += te - ts; + double te = tickTock.secondsWC(); + m_VCount->T_Time_vcs += te; if (iprintTime > 0) { vcs_TCounters_report(); } diff --git a/Cantera/src/equil/vcs_solve_TP.cpp b/Cantera/src/equil/vcs_solve_TP.cpp index ca97f17c3..de9ac1c81 100644 --- a/Cantera/src/equil/vcs_solve_TP.cpp +++ b/Cantera/src/equil/vcs_solve_TP.cpp @@ -20,6 +20,8 @@ #include "vcs_VolPhase.h" #include "vcs_species_thermo.h" +#include "clockWC.h" + #ifdef WIN32 #pragma warning(disable:4996) #endif @@ -156,7 +158,7 @@ namespace VCSnonideal { double test, RT; int j, k, l, solveFail, l1, kspec, irxn, im, forced, iph; // double *ss, *sm, *sa, *aw, *wx, - double dx, xx, par, tsecond; + double dx, xx, par; int liqphase = FALSE, numSpecliquid = 0; int dofast, soldel, ll, it1; int lec, npb, iti, i, lnospec; @@ -186,7 +188,7 @@ namespace VCSnonideal { * Initialize and set up all counters */ vcs_counters_init(0); - tsecond = vcs_second(); + Cantera::clockWC ticktock; /* * Malloc temporary space for usage in this routine and in @@ -1894,7 +1896,7 @@ namespace VCSnonideal { /* * Calculate counters */ - tsecond = vcs_second() - tsecond; + double tsecond = ticktock.secondsWC(); m_VCount->Time_vcs_TP = tsecond; m_VCount->T_Time_vcs_TP += m_VCount->Time_vcs_TP; (m_VCount->T_Calls_vcs_TP)++; @@ -3276,7 +3278,7 @@ namespace VCSnonideal { int juse = -1; int jlose = -1; double *dptr, *scrxn_ptr; - double tsecond = vcs_second(); + Cantera::clockWC tickTock; #ifdef DEBUG_MODE if (vcs_debug_print_lvl >= 2) { plogf(" "); for(i=0; i<77; i++) plogf("-"); plogf("\n"); @@ -3749,7 +3751,7 @@ namespace VCSnonideal { } L_CLEANUP: ; - tsecond = vcs_second() - tsecond; + double tsecond = tickTock.secondsWC(); m_VCount->Time_basopt += tsecond; (m_VCount->Basis_Opts)++; return VCS_SUCCESS; diff --git a/Cantera/src/equil/vcs_timer_generic.cpp b/Cantera/src/equil/vcs_timer_generic.cpp deleted file mode 100644 index a0894b466..000000000 --- a/Cantera/src/equil/vcs_timer_generic.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/*==================================================================== - * ------------------------ - * | CVS File Information | - * ------------------------ - * $RCSfile$ - * $Author$ - * $Date$ - * $Revision$ - * $Name$ - *====================================================================*/ - -#include -#include "vcs_internal.h" - -#ifdef COUGAR -#define HAVE_MD_TIMER -#endif -namespace VCSnonideal { -/**************************************************************************/ -/**************************************************************************/ -/**************************************************************************/ -#ifndef HAVE_MD_TIMER -double vcs_second(void) - - /************************************************************************* - * - * vcs_second() - * - * Returns system cpu and wall clock time in seconds. This - * is a strictly Ansi C timer, since clock() is defined as an - * Ansi C function. On some machines clock() returns type - * unsigned long (HP) and on others (SUN) it returns type long. - * An attempt to recover the actual time for clocks which have - * rolled over is made also. However, it only works if this - * function is called fairly regularily during - * the solution procedure. - * - * clock() -> returns the time in microseconds. Division by - * the macro CLOCKS_PER_SEC recovers the time in seconds. - *************************************************************************/ -{ - static clock_t last_num_ticks = 0; - static double inv_clocks_per_sec = 1./(double)CLOCKS_PER_SEC; - static double clock_width = - (double)(1L<<((int)sizeof(clock_t)*8-2))*4./(double)CLOCKS_PER_SEC; - static int clock_rollovers = 0; - clock_t num_ticks = clock(); - if (num_ticks < last_num_ticks) { - clock_rollovers++; - } - double value = num_ticks * inv_clocks_per_sec; - if (clock_rollovers) { - value += clock_rollovers * clock_width; - } - last_num_ticks = num_ticks; - return(value); -} -#else -#include -double vcs_second(void) -{ - return dclock(); -} -#endif - -} -