Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HPC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexandru Dura
HPC
Commits
26c9df1a
Commit
26c9df1a
authored
Apr 14, 2020
by
Alexandru Dura
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the checkpoint restart feature
parent
eb257440
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
12 deletions
+50
-12
project/src/Main.cpp
project/src/Main.cpp
+43
-6
project/src/Problem.cpp
project/src/Problem.cpp
+2
-4
project/src/Problem.h
project/src/Problem.h
+5
-2
No files found.
project/src/Main.cpp
View file @
26c9df1a
...
...
@@ -74,13 +74,26 @@ void exchangeHalos(int rank, int nsize, Problem &p) {
int
main
(
int
argc
,
char
**
argv
)
{
MPI_Init
(
nullptr
,
nullptr
);
// Process arguments for checkpoint facility
const
char
*
pauseFile
=
nullptr
;
const
char
*
restartFile
=
nullptr
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
!
strncmp
(
argv
[
i
],
"-p="
,
3
))
{
pauseFile
=
argv
[
i
]
+
3
;
}
else
if
(
!
strncmp
(
argv
[
i
],
"-r="
,
3
))
{
restartFile
=
argv
[
i
]
+
3
;
}
}
// Initialize the MPI machinery
MPI_Init
(
nullptr
,
nullptr
);
int
nsize
,
rank
;
MPI_Comm_size
(
DEFAULT_COMM
,
&
nsize
);
MPI_Comm_rank
(
DEFAULT_COMM
,
&
rank
);
// Distribute the problem parameters
GlobalProblemConfig
config
;
MPI_Datatype
GlobalProblemConfig_t
;
MPI_Type_create_struct
(
5
,
GlobalProblemConfig
::
block_lengths
(),
GlobalProblemConfig
::
displacements
(),
...
...
@@ -92,26 +105,50 @@ int main(int argc, char **argv) {
}
MPI_Bcast
(
&
config
,
1
,
GlobalProblemConfig_t
,
0
,
DEFAULT_COMM
);
printf
(
"%d: %d, %d
\n
"
,
rank
,
config
.
xdim
,
config
.
ydim
);
// Set up the local problem
unsigned
localXdim
=
config
.
xdim
;
unsigned
localYdim
=
config
.
ydim
/
nsize
;
assert
(
config
.
ydim
%
nsize
==
0
);
int
upNeighbour
=
rank
+
1
;
int
dnNeighbour
=
rank
-
1
;
// Hardcoded parameters
double
gateVal
=
100
;
unsigned
nGates
=
2
;
Problem
p
(
nsize
,
rank
,
localXdim
,
localYdim
,
nGates
,
nGates
,
gateVal
);
if
(
restartFile
)
{
printf
(
"%d: Restarting from file %s
\n
"
,
rank
,
restartFile
);
MPI_File
fh
;
int
dataSize
=
p
.
getField
().
numCols
()
*
localYdim
;
double
*
data
=
p
.
getField
().
firstRow
().
raw
();
MPI_File_open
(
DEFAULT_COMM
,
restartFile
,
MPI_MODE_RDONLY
,
MPI_INFO_NULL
,
&
fh
);
MPI_File_set_view
(
fh
,
rank
*
dataSize
*
sizeof
(
double
),
MPI_DOUBLE
,
MPI_DOUBLE
,
"native"
,
MPI_INFO_NULL
);
MPI_File_read
(
fh
,
data
,
dataSize
,
MPI_DOUBLE
,
MPI_STATUS_IGNORE
);
MPI_File_close
(
&
fh
);
}
// Simulate
for
(
int
i
=
0
;
i
<
config
.
maxiter
;
++
i
)
{
exchangeHalos
(
rank
,
nsize
,
p
);
p
.
step
(
config
.
cx
,
config
.
cy
);
}
if
(
pauseFile
)
{
// Write the problem out, for later restart
MPI_File
fh
;
int
dataSize
=
p
.
getField
().
numCols
()
*
localYdim
;
double
*
data
=
p
.
getField
().
firstRow
().
raw
();
MPI_File_open
(
DEFAULT_COMM
,
pauseFile
,
MPI_MODE_WRONLY
|
MPI_MODE_CREATE
,
MPI_INFO_NULL
,
&
fh
);
MPI_File_set_view
(
fh
,
rank
*
dataSize
*
sizeof
(
double
),
MPI_DOUBLE
,
MPI_DOUBLE
,
"native"
,
MPI_INFO_NULL
);
MPI_File_write
(
fh
,
data
,
dataSize
,
MPI_DOUBLE
,
MPI_STATUS_IGNORE
);
MPI_File_close
(
&
fh
);
printf
(
"%d: Problem written out to file %s
\n
"
,
rank
,
pauseFile
);
}
// Compute the global min and max
double
localMin
,
localMax
;
...
...
project/src/Problem.cpp
View file @
26c9df1a
...
...
@@ -35,10 +35,8 @@ void Problem::addGates(Field &f, unsigned xGates, unsigned yGates, double value)
unsigned
gateStart
=
gateCentre
-
0.5
*
GATE_WIDTH
*
nFields
*
ydim
;
unsigned
gateEnd
=
gateCentre
+
0.5
*
GATE_WIDTH
*
nFields
*
ydim
;
if
(
gateStart
>=
starty
&&
gateStart
<
endy
)
{
for
(
unsigned
j
=
gateStart
;
j
<
std
::
min
(
gateEnd
,
endy
);
j
++
)
{
f
[
j
-
starty
+
1
][
xdim
+
1
]
=
value
;
}
for
(
unsigned
j
=
std
::
max
(
gateStart
,
starty
);
j
<
std
::
min
(
gateEnd
,
endy
);
j
++
)
{
f
[
j
-
starty
+
1
][
xdim
+
1
]
=
value
;
}
}
}
...
...
project/src/Problem.h
View file @
26c9df1a
...
...
@@ -15,6 +15,10 @@ class Problem {
Field
*
currentf
;
Field
*
nextf
;
unsigned
xgates
;
unsigned
ygates
;
double
gateVal
;
void
initField
(
Field
&
f
);
void
addGates
(
Field
&
f
,
unsigned
xgates
,
unsigned
ygates
,
double
value
);
...
...
@@ -28,13 +32,12 @@ public:
f0
(
xdim
,
ydim
),
f1
(
xdim
,
ydim
),
currentf
(
&
f0
),
nextf
(
&
f1
)
{
nextf
(
&
f1
)
,
xgates
(
xgates
),
ygates
(
ygates
),
gateVal
(
gateVal
)
{
initField
(
f0
);
initField
(
f1
);
addGates
(
f0
,
xgates
,
ygates
,
gateVal
);
addGates
(
f1
,
xgates
,
ygates
,
gateVal
);
}
void
step
(
double
cx
,
double
cy
);
...
...
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