Carmen Code
 All Classes Files Functions Variables Macros Pages
Functions
CPUTimeRef.cpp File Reference

Compute the reference CPU time with the finite volume solver. The output is the CPU time for 1 iteration. More...

#include "Carmen.h"
Include dependency graph for CPUTimeRef.cpp:

Functions

double CPUTimeRef (int iterations, int scales)
 Returns the time required by a finite volume computation using iterations iterations and scales scales. It is use to estimate the CPU time compression. More...
 

Detailed Description

Compute the reference CPU time with the finite volume solver. The output is the CPU time for 1 iteration.

Function Documentation

double CPUTimeRef ( int  iterations,
int  scales 
)

Returns the time required by a finite volume computation using iterations iterations and scales scales. It is use to estimate the CPU time compression.

Parameters
iterationsNumber of iterations.
scalesScales
Returns
double
24 {
25  // --- Local variables ---------------------------------------------------
26 
27  int OldIterationNb=0;
28  int OldScaleNb=0;
29  real OldTimeStep=0.;
30  bool ConstantTimeStepOld=ConstantTimeStep;
31 
32  double result=0.;
33 
34  Timer CPURef;
35  FineMesh* MeshRef;
36 
37  // --- Execution ---------------------------------------------------------
38 
39  // Toggle on : Compute reference CPU time
40 
41  ComputeCPUTimeRef = true;
42 
43  // Toggle off : Constant time step
44 
45  ConstantTimeStep = true;
46 
47  // backup values of IterationNb and ScaleNb
48 
49  OldIterationNb = IterationNb;
50  OldScaleNb = ScaleNb;
51  OldTimeStep = TimeStep;
52 
53  // use reference values
54  IterationNb = iterations;
55  ScaleNb = scales;
56  TimeStep = 0.;
57 
58  one_D=1; two_D=1;
59  if (Dimension >= 2) one_D=1<<ScaleNb;
60  if (Dimension == 3) two_D=1<<ScaleNb;
61 
62  // init mesh
63  MeshRef = new FineMesh;
64 
65  // Iterate on time
66 
68  {
69  // start timer
70  CPURef.start();
71 
72  // Compute time evolution
73  TimeEvolution(MeshRef);
74 
75  // check CPU Time
76  CPURef.check();
77 
78  // stop timer
79  CPURef.stop();
80  }
81 
82  // Compute CPUTimeRef
83  result = CPURef.CPUTime();
84  result *= 1./IterationNb;
85  result *= 1<<(Dimension*(OldScaleNb-ScaleNb));
86 
87  // delete MeshRef
88  delete MeshRef;
89 
90  // restore values of IterationNb and ScaleNb
91  IterationNb = OldIterationNb;
92  ScaleNb = OldScaleNb;
93  TimeStep = OldTimeStep;
94  IterationNo = 0;
95 
96  one_D=1; two_D=1;
97  if (Dimension >= 2) one_D=1<<ScaleNb;
98  if (Dimension == 3) two_D=1<<ScaleNb;
99 
100  // Toggle off : Compute reference CPU time
101 
102  ComputeCPUTimeRef = false;
103 
104  // Restore the value of ConstantTimeStep
105 
106  ConstantTimeStep = ConstantTimeStepOld;
107 
108  return result;
109 }
int one_D
Definition: Parameters.cpp:236
int IterationNb
Definition: Parameters.cpp:37
int ScaleNb
Definition: Parameters.cpp:87
double CPUTime()
Returns CPU time from previous start in seconds.
Definition: Timer.cpp:124
bool ComputeCPUTimeRef
Definition: Parameters.cpp:62
An object FineMesh is a regular fine mesh, used for finite volume computations. It is not used for mu...
Definition: FineMesh.h:40
double stop()
Stop timer and, if asked, returns CPU time from previous start in seconds.
Definition: Timer.cpp:77
void TimeEvolution(FineMesh *Root)
Computes a time evolution on the regular fine mesh Root. Only for finite volume computations.
Definition: TimeEvolution.cpp:77
int Dimension
Definition: Parameters.cpp:74
int IterationNo
Definition: Parameters.cpp:168
void start()
Starts timer.
Definition: Timer.cpp:62
real TimeStep
Definition: Parameters.cpp:40
int two_D
Definition: Parameters.cpp:236
bool ConstantTimeStep
Definition: Parameters.cpp:94
void check()
Adds CPU time and real time to their buffers and resets. For long computations, it is recommended to ...
Definition: Timer.cpp:103
An object Timer gives information on the CPU time of long-time computations.
Definition: Timer.h:31
#define real
Definition: PreProcessor.h:31

Here is the caller graph for this function: