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
f5054b7f
Commit
f5054b7f
authored
Nov 05, 2012
by
Sebastian Rettenberger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix logger in mpi parallization
parent
90e18ec5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
33 deletions
+32
-33
swe_mpi.cpp
src/examples/swe_mpi.cpp
+26
-26
Logger.hpp
src/tools/Logger.hpp
+6
-7
No files found.
src/examples/swe_mpi.cpp
View file @
f5054b7f
...
@@ -109,15 +109,15 @@ int main( int argc, char** argv ) {
...
@@ -109,15 +109,15 @@ int main( int argc, char** argv ) {
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
l_numberOfProcesses
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
l_numberOfProcesses
);
// initialize a logger for every MPI process
// initialize a logger for every MPI process
tools
::
Logger
l_sweLogger
(
l_mpiRank
);
tools
::
Logger
::
logger
.
setProcessRank
(
l_mpiRank
);
// print the welcome message
// print the welcome message
l_sweL
ogger
.
printWelcomeMessage
();
tools
::
Logger
::
l
ogger
.
printWelcomeMessage
();
// set current wall clock time within the solver
// set current wall clock time within the solver
l_sweL
ogger
.
initWallClockTime
(
MPI_Wtime
()
);
tools
::
Logger
::
l
ogger
.
initWallClockTime
(
MPI_Wtime
()
);
//print the number of processes
//print the number of processes
l_sweL
ogger
.
printNumberOfProcesses
(
l_numberOfProcesses
);
tools
::
Logger
::
l
ogger
.
printNumberOfProcesses
(
l_numberOfProcesses
);
// check if the necessary command line input parameters are given
// check if the necessary command line input parameters are given
#ifndef READXML
#ifndef READXML
...
@@ -172,8 +172,8 @@ int main( int argc, char** argv ) {
...
@@ -172,8 +172,8 @@ int main( int argc, char** argv ) {
l_blocksX
=
l_numberOfProcesses
/
l_blocksY
;
l_blocksX
=
l_numberOfProcesses
/
l_blocksY
;
// print information about the grid
// print information about the grid
l_sweL
ogger
.
printNumberOfCells
(
l_nX
,
l_nY
);
tools
::
Logger
::
l
ogger
.
printNumberOfCells
(
l_nX
,
l_nY
);
l_sweL
ogger
.
printNumberOfBlocks
(
l_blocksX
,
l_blocksY
);
tools
::
Logger
::
l
ogger
.
printNumberOfBlocks
(
l_blocksX
,
l_blocksY
);
//! local position of each MPI process in x- and y-direction.
//! local position of each MPI process in x- and y-direction.
...
@@ -228,8 +228,8 @@ int main( int argc, char** argv ) {
...
@@ -228,8 +228,8 @@ int main( int argc, char** argv ) {
l_dY
=
(
l_scenario
.
getBoundaryPos
(
BND_TOP
)
-
l_scenario
.
getBoundaryPos
(
BND_BOTTOM
)
)
/
l_nY
;
l_dY
=
(
l_scenario
.
getBoundaryPos
(
BND_TOP
)
-
l_scenario
.
getBoundaryPos
(
BND_BOTTOM
)
)
/
l_nY
;
// print information about the cell size and local number of cells
// print information about the cell size and local number of cells
l_sweL
ogger
.
printCellSize
(
l_dX
,
l_dY
);
tools
::
Logger
::
l
ogger
.
printCellSize
(
l_dX
,
l_dY
);
l_sweL
ogger
.
printNumberOfCellsPerProcess
(
l_nXLocal
,
l_nYLocal
);
tools
::
Logger
::
l
ogger
.
printNumberOfCellsPerProcess
(
l_nXLocal
,
l_nYLocal
);
// initialize the grid data and the corresponding static variables
// initialize the grid data and the corresponding static variables
SWE_Block
::
initGridData
(
l_nXLocal
,
l_nYLocal
,
l_dX
,
l_dY
);
SWE_Block
::
initGridData
(
l_nXLocal
,
l_nYLocal
,
l_dX
,
l_dY
);
...
@@ -272,26 +272,26 @@ int main( int argc, char** argv ) {
...
@@ -272,26 +272,26 @@ int main( int argc, char** argv ) {
* Connect SWE blocks at boundaries
* Connect SWE blocks at boundaries
*/
*/
// left and right boundaries
// left and right boundaries
l_sweL
ogger
.
printString
(
"Connecting SWE blocks at left boundaries."
);
tools
::
Logger
::
l
ogger
.
printString
(
"Connecting SWE blocks at left boundaries."
);
SWE_Block1D
*
l_leftInflow
=
l_wavePropgationBlock
.
grabGhostLayer
(
BND_LEFT
);
SWE_Block1D
*
l_leftInflow
=
l_wavePropgationBlock
.
grabGhostLayer
(
BND_LEFT
);
SWE_Block1D
*
l_leftOutflow
=
l_wavePropgationBlock
.
registerCopyLayer
(
BND_LEFT
);
SWE_Block1D
*
l_leftOutflow
=
l_wavePropgationBlock
.
registerCopyLayer
(
BND_LEFT
);
if
(
l_blockPositionX
==
0
)
if
(
l_blockPositionX
==
0
)
l_wavePropgationBlock
.
setBoundaryType
(
BND_LEFT
,
OUTFLOW
);
l_wavePropgationBlock
.
setBoundaryType
(
BND_LEFT
,
OUTFLOW
);
l_sweL
ogger
.
printString
(
"Connecting SWE blocks at right boundaries."
);
tools
::
Logger
::
l
ogger
.
printString
(
"Connecting SWE blocks at right boundaries."
);
SWE_Block1D
*
l_rightInflow
=
l_wavePropgationBlock
.
grabGhostLayer
(
BND_RIGHT
);
SWE_Block1D
*
l_rightInflow
=
l_wavePropgationBlock
.
grabGhostLayer
(
BND_RIGHT
);
SWE_Block1D
*
l_rightOutflow
=
l_wavePropgationBlock
.
registerCopyLayer
(
BND_RIGHT
);
SWE_Block1D
*
l_rightOutflow
=
l_wavePropgationBlock
.
registerCopyLayer
(
BND_RIGHT
);
if
(
l_blockPositionX
==
l_blocksX
-
1
)
if
(
l_blockPositionX
==
l_blocksX
-
1
)
l_wavePropgationBlock
.
setBoundaryType
(
BND_RIGHT
,
OUTFLOW
);
l_wavePropgationBlock
.
setBoundaryType
(
BND_RIGHT
,
OUTFLOW
);
// bottom and top boundaries
// bottom and top boundaries
l_sweL
ogger
.
printString
(
"Connecting SWE blocks at bottom boundaries."
);
tools
::
Logger
::
l
ogger
.
printString
(
"Connecting SWE blocks at bottom boundaries."
);
SWE_Block1D
*
l_bottomInflow
=
l_wavePropgationBlock
.
grabGhostLayer
(
BND_BOTTOM
);
SWE_Block1D
*
l_bottomInflow
=
l_wavePropgationBlock
.
grabGhostLayer
(
BND_BOTTOM
);
SWE_Block1D
*
l_bottomOutflow
=
l_wavePropgationBlock
.
registerCopyLayer
(
BND_BOTTOM
);
SWE_Block1D
*
l_bottomOutflow
=
l_wavePropgationBlock
.
registerCopyLayer
(
BND_BOTTOM
);
if
(
l_blockPositionY
==
0
)
if
(
l_blockPositionY
==
0
)
l_wavePropgationBlock
.
setBoundaryType
(
BND_BOTTOM
,
OUTFLOW
);
l_wavePropgationBlock
.
setBoundaryType
(
BND_BOTTOM
,
OUTFLOW
);
l_sweL
ogger
.
printString
(
"Connecting SWE blocks at top boundaries."
);
tools
::
Logger
::
l
ogger
.
printString
(
"Connecting SWE blocks at top boundaries."
);
SWE_Block1D
*
l_topInflow
=
l_wavePropgationBlock
.
grabGhostLayer
(
BND_TOP
);
SWE_Block1D
*
l_topInflow
=
l_wavePropgationBlock
.
grabGhostLayer
(
BND_TOP
);
SWE_Block1D
*
l_topOutflow
=
l_wavePropgationBlock
.
registerCopyLayer
(
BND_TOP
);
SWE_Block1D
*
l_topOutflow
=
l_wavePropgationBlock
.
registerCopyLayer
(
BND_TOP
);
if
(
l_blockPositionY
==
l_blocksY
-
1
)
if
(
l_blockPositionY
==
l_blocksY
-
1
)
...
@@ -350,7 +350,7 @@ int main( int argc, char** argv ) {
...
@@ -350,7 +350,7 @@ int main( int argc, char** argv ) {
l_topNeighborRank
=
(
l_blockPositionY
<
l_blocksY
-
1
)
?
l_mpiRank
+
1
:
MPI_PROC_NULL
;
l_topNeighborRank
=
(
l_blockPositionY
<
l_blocksY
-
1
)
?
l_mpiRank
+
1
:
MPI_PROC_NULL
;
// print the MPI grid
// print the MPI grid
l_sweL
ogger
.
cout
()
<<
"neighbors: "
tools
::
Logger
::
l
ogger
.
cout
()
<<
"neighbors: "
<<
l_leftNeighborRank
<<
" (left), "
<<
l_leftNeighborRank
<<
" (left), "
<<
l_rightNeighborRank
<<
" (right), "
<<
l_rightNeighborRank
<<
" (right), "
<<
l_bottomNeighborRank
<<
" (bottom), "
<<
l_bottomNeighborRank
<<
" (bottom), "
...
@@ -366,7 +366,7 @@ int main( int argc, char** argv ) {
...
@@ -366,7 +366,7 @@ int main( int argc, char** argv ) {
l_mpiRow
);
l_mpiRow
);
// write the output at time zero
// write the output at time zero
l_sweL
ogger
.
printOutputTime
(
0
);
tools
::
Logger
::
l
ogger
.
printOutputTime
(
0
);
#ifdef WRITENETCDF
#ifdef WRITENETCDF
//boundary size of the ghost layers
//boundary size of the ghost layers
int
l_boundarySize
[
4
];
int
l_boundarySize
[
4
];
...
@@ -394,8 +394,8 @@ int main( int argc, char** argv ) {
...
@@ -394,8 +394,8 @@ int main( int argc, char** argv ) {
* Simulation.
* Simulation.
*/
*/
// print the start message and reset the wall clock time
// print the start message and reset the wall clock time
l_sweL
ogger
.
printStartMessage
();
tools
::
Logger
::
l
ogger
.
printStartMessage
();
l_sweL
ogger
.
initWallClockTime
(
time
(
NULL
));
tools
::
Logger
::
l
ogger
.
initWallClockTime
(
time
(
NULL
));
//! simulation time.
//! simulation time.
float
l_t
=
0.0
;
float
l_t
=
0.0
;
...
@@ -403,7 +403,7 @@ int main( int argc, char** argv ) {
...
@@ -403,7 +403,7 @@ int main( int argc, char** argv ) {
// loop over checkpoints
// loop over checkpoints
for
(
int
c
=
1
;
c
<=
l_numberOfCheckPoints
;
c
++
)
{
for
(
int
c
=
1
;
c
<=
l_numberOfCheckPoints
;
c
++
)
{
//reset CPU-Communication clock
//reset CPU-Communication clock
l_sweL
ogger
.
resetCpuCommunicationClockToCurrentTime
();
tools
::
Logger
::
l
ogger
.
resetCpuCommunicationClockToCurrentTime
();
// do time steps until next checkpoint is reached
// do time steps until next checkpoint is reached
while
(
l_t
<
l_checkPoints
[
c
]
)
{
while
(
l_t
<
l_checkPoints
[
c
]
)
{
...
@@ -417,7 +417,7 @@ int main( int argc, char** argv ) {
...
@@ -417,7 +417,7 @@ int main( int argc, char** argv ) {
l_mpiRow
);
l_mpiRow
);
// reset the cpu clock
// reset the cpu clock
l_sweL
ogger
.
resetCpuClockToCurrentTime
();
tools
::
Logger
::
l
ogger
.
resetCpuClockToCurrentTime
();
// set values in ghost cells
// set values in ghost cells
l_wavePropgationBlock
.
setGhostLayer
();
l_wavePropgationBlock
.
setGhostLayer
();
...
@@ -441,15 +441,15 @@ int main( int argc, char** argv ) {
...
@@ -441,15 +441,15 @@ int main( int argc, char** argv ) {
l_t
+=
l_maxTimeStepWidthGlobal
;
l_t
+=
l_maxTimeStepWidthGlobal
;
// print the current simulation time
// print the current simulation time
l_sweL
ogger
.
printSimulationTime
(
l_t
);
tools
::
Logger
::
l
ogger
.
printSimulationTime
(
l_t
);
}
}
// update and reset the cpu time in the logger
// update and reset the cpu time in the logger
l_sweL
ogger
.
updateCpuTime
();
tools
::
Logger
::
l
ogger
.
updateCpuTime
();
l_sweL
ogger
.
resetCpuClockToCurrentTime
();
tools
::
Logger
::
l
ogger
.
resetCpuClockToCurrentTime
();
// print current simulation time
// print current simulation time
l_sweL
ogger
.
printOutputTime
(
l_t
);
tools
::
Logger
::
l
ogger
.
printOutputTime
(
l_t
);
// write output
// write output
#ifdef WRITENETCDF
#ifdef WRITENETCDF
...
@@ -467,16 +467,16 @@ int main( int argc, char** argv ) {
...
@@ -467,16 +467,16 @@ int main( int argc, char** argv ) {
* Finalize.
* Finalize.
*/
*/
// write the statistics message
// write the statistics message
l_sweL
ogger
.
printStatisticsMessage
();
tools
::
Logger
::
l
ogger
.
printStatisticsMessage
();
// print the cpu time
// print the cpu time
l_sweL
ogger
.
printCpuTime
(
"CPU time"
);
tools
::
Logger
::
l
ogger
.
printCpuTime
(
"CPU time"
);
// print the wall clock time (includes plotting)
// print the wall clock time (includes plotting)
l_sweL
ogger
.
printWallClockTime
(
time
(
NULL
));
tools
::
Logger
::
l
ogger
.
printWallClockTime
(
time
(
NULL
));
// print the finish message
// print the finish message
l_sweL
ogger
.
printFinishMessage
();
tools
::
Logger
::
l
ogger
.
printFinishMessage
();
// finalize MPI execution
// finalize MPI execution
MPI_Finalize
();
MPI_Finalize
();
...
...
src/tools/Logger.hpp
View file @
f5054b7f
...
@@ -153,7 +153,7 @@ class tools::Logger {
...
@@ -153,7 +153,7 @@ class tools::Logger {
* @param i_largeDelimiter definition of the large delimiter.
* @param i_largeDelimiter definition of the large delimiter.
* @param i_indentation definition of the indentation (used in all messages, except welcome, start and finish).
* @param i_indentation definition of the indentation (used in all messages, except welcome, start and finish).
*/
*/
Logger
(
const
int
i_processRank
=
-
1
,
Logger
(
const
int
i_processRank
=
0
,
const
std
::
string
i_programName
=
"SWE"
,
const
std
::
string
i_programName
=
"SWE"
,
const
std
::
string
i_welcomeMessage
=
"Welcome to"
,
const
std
::
string
i_welcomeMessage
=
"Welcome to"
,
const
std
::
string
i_copyRights
=
"
\n\n
SWE Copyright (C) 2012
\n
"
const
std
::
string
i_copyRights
=
"
\n\n
SWE Copyright (C) 2012
\n
"
...
@@ -181,12 +181,11 @@ class tools::Logger {
...
@@ -181,12 +181,11 @@ class tools::Logger {
//set time to zero
//set time to zero
cpuTime
=
cpuCommTime
=
wallClockTime
=
0.
;
cpuTime
=
cpuCommTime
=
wallClockTime
=
0.
;
#ifdef USEMPI
#ifndef USEMPI
// determine local MPI rank
// Since we have one static logger, we do not know the MPI rank in this
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
processRank
);
// constructor. When using MPI, the process rank has to be set first,
#else
// before printing the welcome message.
processRank
=
0
;
printWelcomeMessage
();
printWelcomeMessage
();
#endif
#endif
}
}
...
...
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