861
by dion
Release2009: Updated the copyright headers in all files to 2009 version |
1 |
/////////////////////////////////////////////////////////////
|
2 |
// //
|
|
1121
by Vince Boros
Copyright, Centre name, Centre address updates |
3 |
// Copyright (c) 2003-2014 by The University of Queensland //
|
4 |
// Centre for Geoscience Computing //
|
|
5 |
// http://earth.uq.edu.au/centre-geoscience-computing //
|
|
861
by dion
Release2009: Updated the copyright headers in all files to 2009 version |
6 |
// //
|
7 |
// Primary Business: Brisbane, Queensland, Australia //
|
|
8 |
// Licensed under the Open Software License version 3.0 //
|
|
9 |
// http://www.opensource.org/licenses/osl-3.0.php //
|
|
10 |
// //
|
|
11 |
/////////////////////////////////////////////////////////////
|
|
795
by dion
DW added copyright headers to most c++ files...still a few to go in subdirs. |
12 |
|
125
by slatham
Beginnings of check-pointing functionality. |
13 |
|
14 |
#include "Parallel/CheckPointer.h" |
|
131
by slatham
More check-pointing implementation. |
15 |
#include "Parallel/CheckPointParams.h" |
162
by slatham
Further check-point implementation. |
16 |
#include "Parallel/CheckPointable.h" |
131
by slatham
More check-pointing implementation. |
17 |
#include "Parallel/mpivbuf.h" |
805
by steffen
- beginning of separation checkpointing / snapshots |
18 |
#include "Parallel/mpibarrier.h" |
19 |
#include "Foundation/console.h" |
|
20 |
||
21 |
//--- TML includes ---
|
|
22 |
#include "tml/comm/comm.h" |
|
125
by slatham
Beginnings of check-pointing functionality. |
23 |
|
24 |
#include <fstream> |
|
25 |
#include <sstream> |
|
26 |
||
162
by slatham
Further check-point implementation. |
27 |
using esys::lsm::CheckPointable; |
28 |
||
511
by slatham
Moved OpValue dependencies in CLatticeMaster to ParserLmInitialiser.cpp classes. |
29 |
CheckPointer::CheckPointer(CheckPointable &checkPointable, MPI_Comm mpiComm) |
30 |
: m_pCheckPointable(&checkPointable), |
|
31 |
m_mpiComm(mpiComm) |
|
125
by slatham
Beginnings of check-pointing functionality. |
32 |
{
|
33 |
}
|
|
34 |
||
35 |
CheckPointer::~CheckPointer() |
|
36 |
{
|
|
37 |
}
|
|
38 |
||
511
by slatham
Moved OpValue dependencies in CLatticeMaster to ParserLmInitialiser.cpp classes. |
39 |
MPI_Comm CheckPointer::getMpiComm() const |
40 |
{
|
|
41 |
return m_mpiComm; |
|
42 |
}
|
|
43 |
||
44 |
void CheckPointer::setMpiComm(MPI_Comm mpiComm) |
|
45 |
{
|
|
46 |
m_mpiComm = mpiComm; |
|
47 |
}
|
|
48 |
||
818
by steffen
first step towards checkpoint/restart |
49 |
void CheckPointer::saveRestartable() |
50 |
{
|
|
51 |
CVarMPIBuffer buffer(getMpiComm()); |
|
52 |
||
53 |
// get check-point parameters
|
|
54 |
buffer.receiveBroadcast(0); |
|
55 |
CheckPointParams checkPointParams = CheckPointParams::unpackFrom(&buffer, getMpiComm()); |
|
56 |
||
57 |
// Write the check-point info to file.
|
|
58 |
std::ofstream oStream(checkPointParams.getFileName().c_str()); |
|
1066
by Steffen Abe
- feature: Added parameter to Restart checkpoints to adjust output precision (digits). Python parameter class for createRestartCheckPointer is now RestartCheckPointPrms, which takes an additonal parameter "Precision" to set the number of output digits. If the "Precision" parameter is not given, the number of digits defaults to 12. |
59 |
// set output precision
|
60 |
console.Debug() << "output precision: " << checkPointParams.getPrecision() << "\n"; |
|
61 |
||
62 |
oStream.precision(checkPointParams.getPrecision()); |
|
63 |
||
818
by steffen
first step towards checkpoint/restart |
64 |
m_pCheckPointable->saveCheckPointData(oStream); |
65 |
oStream.close(); |
|
66 |
}
|
|
67 |
||
68 |
void CheckPointer::saveDump() |
|
69 |
{
|
|
70 |
CVarMPIBuffer buffer(getMpiComm()); |
|
71 |
||
72 |
// get check-point parameters
|
|
73 |
buffer.receiveBroadcast(0); |
|
74 |
CheckPointParams checkPointParams = CheckPointParams::unpackFrom(&buffer, getMpiComm()); |
|
75 |
||
76 |
// Write the check-point info to file.
|
|
77 |
std::ofstream oStream(checkPointParams.getFileName().c_str()); |
|
78 |
m_pCheckPointable->saveSnapShotData(oStream); |
|
131
by slatham
More check-pointing implementation. |
79 |
oStream.close(); |
125
by slatham
Beginnings of check-pointing functionality. |
80 |
}
|
156
by slatham
Moved parser PredefinedFunction classes out of LatticeMaster.cpp into ParserLmInitialiser.h and ParserLmInitialiser.cpp |
81 |
|
805
by steffen
- beginning of separation checkpointing / snapshots |
82 |
void CheckPointer::saveThroughMaster(TML_Comm& comm) |
83 |
{
|
|
84 |
CVarMPIBuffer buffer(getMpiComm()); |
|
85 |
CMPIBarrier barrier(getMpiComm()); |
|
86 |
||
87 |
console.Debug() << "CheckPointer::saveThroughMaster" << "\n"; |
|
88 |
// get check-point parameters
|
|
89 |
buffer.receiveBroadcast(0); |
|
90 |
CheckPointParams checkPointParams = CheckPointParams::unpackFrom(&buffer, getMpiComm()); |
|
91 |
||
92 |
// Write the check-point info to string stream.
|
|
93 |
std::ostringstream oStream; |
|
94 |
save(oStream); |
|
95 |
console.Debug() << "string length : " << oStream.str().size() << "\n"; |
|
96 |
string str_data=oStream.str(); |
|
97 |
||
98 |
||
99 |
barrier.wait("CheckPoint_1"); |
|
100 |
comm.send_gather(str_data,0); |
|
101 |
}
|
|
102 |
||
818
by steffen
first step towards checkpoint/restart |
103 |
void CheckPointer::loadCheckPoint() |
104 |
{
|
|
105 |
CVarMPIBuffer buffer(getMpiComm()); |
|
106 |
||
107 |
// get check-point parameters
|
|
108 |
buffer.receiveBroadcast(0); |
|
109 |
CheckPointParams checkPointParams = CheckPointParams::unpackFrom(&buffer, getMpiComm()); |
|
110 |
||
111 |
// Write the check-point info to file.
|
|
112 |
std::ifstream iStream(checkPointParams.getFileName().c_str()); |
|
113 |
m_pCheckPointable->loadCheckPointData(iStream); |
|
114 |
iStream.close(); |
|
115 |
}
|
|
116 |
||
117 |
||
118 |
||
156
by slatham
Moved parser PredefinedFunction classes out of LatticeMaster.cpp into ParserLmInitialiser.h and ParserLmInitialiser.cpp |
119 |
void CheckPointer::save(std::ostream &oStream) |
120 |
{
|
|
162
by slatham
Further check-point implementation. |
121 |
m_pCheckPointable->saveCheckPointData(oStream); |
156
by slatham
Moved parser PredefinedFunction classes out of LatticeMaster.cpp into ParserLmInitialiser.h and ParserLmInitialiser.cpp |
122 |
}
|