Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
SWE
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
SWE
Commits
3af18e4a
Commit
3af18e4a
authored
Jun 27, 2013
by
Sebastian Rettenberger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for more than 2 timers
parent
2aae636f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
69 deletions
+38
-69
swe_mpi.cpp
src/examples/swe_mpi.cpp
+8
-8
swe_simple.cpp
src/examples/swe_simple.cpp
+3
-3
Logger.hh
src/tools/Logger.hh
+27
-58
No files found.
src/examples/swe_mpi.cpp
View file @
3af18e4a
...
...
@@ -433,7 +433,7 @@ int main( int argc, char** argv ) {
// do time steps until next checkpoint is reached
while
(
l_t
<
l_checkPoints
[
c
]
)
{
//reset CPU-Communication clock
tools
::
Logger
::
logger
.
resetC
puCommunicationClockToCurrentTime
(
);
tools
::
Logger
::
logger
.
resetC
lockToCurrentTime
(
"CpuCommunication"
);
// exchange ghost and copy layers
exchangeLeftRightGhostLayers
(
l_leftNeighborRank
,
l_leftInflow
,
l_leftOutflow
,
...
...
@@ -445,7 +445,7 @@ int main( int argc, char** argv ) {
l_mpiRow
);
// reset the cpu clock
tools
::
Logger
::
logger
.
resetC
puClockToCurrentTime
(
);
tools
::
Logger
::
logger
.
resetC
lockToCurrentTime
(
"Cpu"
);
// set values in ghost cells
l_wavePropgationBlock
.
setGhostLayer
();
...
...
@@ -457,7 +457,7 @@ int main( int argc, char** argv ) {
float
l_maxTimeStepWidth
=
l_wavePropgationBlock
.
getMaxTimestep
();
// update the cpu time in the logger
tools
::
Logger
::
logger
.
update
CpuTime
(
);
tools
::
Logger
::
logger
.
update
Time
(
"Cpu"
);
//! maximum allowed time steps of all blocks
float
l_maxTimeStepWidthGlobal
;
...
...
@@ -466,14 +466,14 @@ int main( int argc, char** argv ) {
MPI_Allreduce
(
&
l_maxTimeStepWidth
,
&
l_maxTimeStepWidthGlobal
,
1
,
MPI_FLOAT
,
MPI_MIN
,
MPI_COMM_WORLD
);
// reset the cpu time
tools
::
Logger
::
logger
.
resetC
puClockToCurrentTime
(
);
tools
::
Logger
::
logger
.
resetC
lockToCurrentTime
(
"Cpu"
);
// update the cell values
l_wavePropgationBlock
.
updateUnknowns
(
l_maxTimeStepWidthGlobal
);
// update the cpu and CPU-communication time in the logger
tools
::
Logger
::
logger
.
update
CpuTime
(
);
tools
::
Logger
::
logger
.
update
CpuCommunicationTime
(
);
tools
::
Logger
::
logger
.
update
Time
(
"Cpu"
);
tools
::
Logger
::
logger
.
update
Time
(
"CpuCommunication"
);
// update simulation time with time step width.
l_t
+=
l_maxTimeStepWidthGlobal
;
...
...
@@ -511,10 +511,10 @@ int main( int argc, char** argv ) {
tools
::
Logger
::
logger
.
printStatisticsMessage
();
// print the cpu time
tools
::
Logger
::
logger
.
print
CpuTime
(
"CPU time"
);
tools
::
Logger
::
logger
.
print
Time
(
"Cpu"
,
"CPU time"
);
// print CPU + Communication time
tools
::
Logger
::
logger
.
print
CpuCommunicationTime
(
);
tools
::
Logger
::
logger
.
print
Time
(
"CpuCommunication"
,
"CPU + Communication time"
);
// print the wall clock time (includes plotting)
tools
::
Logger
::
logger
.
printWallClockTime
(
time
(
NULL
));
...
...
src/examples/swe_simple.cpp
View file @
3af18e4a
...
...
@@ -235,7 +235,7 @@ int main( int argc, char** argv ) {
l_wavePropgationBlock
.
setGhostLayer
();
// reset the cpu clock
tools
::
Logger
::
logger
.
resetC
puClockToCurrentTime
(
);
tools
::
Logger
::
logger
.
resetC
lockToCurrentTime
(
"Cpu"
);
// approximate the maximum time step
// TODO: This calculation should be replaced by the usage of the wave speeds occuring during the flux computation
...
...
@@ -252,7 +252,7 @@ int main( int argc, char** argv ) {
l_wavePropgationBlock
.
updateUnknowns
(
l_maxTimeStepWidth
);
// update the cpu time in the logger
tools
::
Logger
::
logger
.
update
CpuTime
(
);
tools
::
Logger
::
logger
.
update
Time
(
"Cpu"
);
// update simulation time with time step width.
l_t
+=
l_maxTimeStepWidth
;
...
...
@@ -284,7 +284,7 @@ int main( int argc, char** argv ) {
tools
::
Logger
::
logger
.
printStatisticsMessage
();
// print the cpu time
tools
::
Logger
::
logger
.
print
CpuTime
(
);
tools
::
Logger
::
logger
.
print
Time
(
"Cpu"
,
"CPU time"
);
// print the wall clock time (includes plotting)
tools
::
Logger
::
logger
.
printWallClockTime
(
time
(
NULL
));
...
...
src/tools/Logger.hh
View file @
3af18e4a
...
...
@@ -33,6 +33,7 @@
#include <mpi.h>
#endif
#include <map>
#include <string>
#include <iostream>
#include <ctime>
...
...
@@ -88,25 +89,15 @@ class tools::Logger {
//! definition of indentation
const
std
::
string
indentation
;
//! C
PU clock
//! C
locks
#if (defined USEMPI && !defined CUDA)
double
cpuClock
;
std
::
map
<
std
::
string
,
double
>
clocks
;
#else
clock_t
cpuClock
;
std
::
map
<
std
::
string
,
clock_t
>
clocks
;
#endif
//! CPU-Communication clock
#if (defined USEMPI && !defined CUDA)
double
cpuCommClock
;
#else
clock_t
cpuCommClock
;
#endif
//! CPU time
double
cpuTime
;
//! CPU and communication time
double
cpuCommTime
;
//! Timer
std
::
map
<
std
::
string
,
double
>
timer
;
//! wall clock time: cpu, communication, IO
double
wallClockTime
;
...
...
@@ -178,8 +169,6 @@ class tools::Logger {
midDelimiter
(
i_midDelimiter
),
largeDelimiter
(
i_largeDelimiter
),
indentation
(
i_indentation
)
{
//set time to zero
cpuTime
=
cpuCommTime
=
wallClockTime
=
0.
;
#ifndef USEMPI
// Since we have one static logger, we do not know the MPI rank in this
...
...
@@ -427,40 +416,30 @@ class tools::Logger {
}
/**
* Update the CPU time.
* Update a timer
*
* @param i_name Name of timer
*/
void
updateCpuTime
()
{
void
updateTime
(
const
std
::
string
&
i_name
)
{
// If the timer does not yet exist it will be initialized with 0 by std::map
// Works only with [] no with .at()
#if (defined USEMPI && !defined CUDA)
cpuTime
+=
MPI_Wtime
()
-
cpuClock
;
timer
[
i_name
]
+=
MPI_Wtime
()
-
clocks
.
at
(
i_name
)
;
#else
cpuTime
+=
(
clock
()
-
cpuClock
)
/
(
double
)
CLOCKS_PER_SEC
;
timer
[
i_name
]
+=
(
clock
()
-
clocks
.
at
(
i_name
)
)
/
(
double
)
CLOCKS_PER_SEC
;
#endif
}
/**
* Update the CPU-Communication time.
* Reset a clock to the current time
*
* @param i_name Name of timer/clock
*/
void
updateCpuCommunicationTime
()
{
#if (defined USEMPI && !defined CUDA)
cpuCommTime
+=
MPI_Wtime
()
-
cpuCommClock
;
#else
cpuCommTime
+=
(
clock
()
-
cpuCommClock
)
/
(
double
)
CLOCKS_PER_SEC
;
#endif
}
void
resetCpuClockToCurrentTime
()
{
void
resetClockToCurrentTime
(
const
std
::
string
&
i_name
)
{
#if (defined USEMPI && !defined CUDA)
cpuClock
=
MPI_Wtime
();
clocks
[
i_name
]
=
MPI_Wtime
();
#else
cpuClock
=
clock
();
#endif
}
void
resetCpuCommunicationClockToCurrentTime
()
{
#if (defined USEMPI && !defined CUDA)
cpuCommClock
=
MPI_Wtime
();
#else
cpuCommClock
=
clock
();
clocks
[
i_name
]
=
clock
();
#endif
}
...
...
@@ -487,25 +466,15 @@ class tools::Logger {
}
/**
* Print elapsed CPU time.
*
* @param i_cpuTimeMessage cpu time message.
*/
void
printCpuTime
(
const
std
::
string
i_cpuTimeMessage
=
"CPU time"
)
{
timeCout
()
<<
indentation
<<
"process "
<<
processRank
<<
" - "
<<
i_cpuTimeMessage
<<
": "
<<
cpuTime
<<
" seconds"
<<
std
::
endl
;
}
/**
* Print elapsed CPU + communication time.
* Print elapsed time.
*
* @param i_cpuCommunicationTimeMessage CPU + communication time message.
* @param i_name Name of the timer
* @param i_message time message.
*/
void
print
CpuCommunicationTime
(
const
std
::
string
i_cpuCommunicationTimeMessage
=
"CPU + communication time"
)
{
void
print
Time
(
const
std
::
string
&
i_name
,
const
std
::
string
&
i_message
)
{
timeCout
()
<<
indentation
<<
"process "
<<
processRank
<<
" - "
<<
i_
cpuCommunicationTimeM
essage
<<
": "
<<
cpuCommTime
<<
" seconds"
<<
std
::
endl
;
<<
i_
m
essage
<<
": "
<<
timer
.
at
(
i_name
)
<<
" seconds"
<<
std
::
endl
;
}
/**
...
...
@@ -523,7 +492,7 @@ class tools::Logger {
}
public
:
/** The logger all classes shoud use */
/** The logger all classes shou
l
d use */
static
Logger
logger
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment