"git@code.ornl.gov:mantidproject/mantid.git" did not exist on "964686492feceb89aa1762f25a29f8189b61108c"
Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* HDFMixer.cpp
*
* Created on: Dec 19, 2016
* Author: Junmin GU
*/
#include "HDFMixer.h"
#include "HDFMixer.tcc"
#include "adios2/ADIOSMPI.h"
#include "adios2/core/IO.h"
#include "adios2/helper/adiosFunctions.h" //CheckIndexRange
#include "adios2/toolkit/transport/file/FileStream.h"
namespace adios2
{
HDFMixer::HDFMixer(IO &io, const std::string &name, const OpenMode openMode,
MPI_Comm mpiComm)
: Engine("HDFMixer", io, name, openMode, mpiComm),
m_HDFVDSWriter(mpiComm, m_DebugMode),
m_HDFSerialWriter(MPI_COMM_SELF, m_DebugMode),
m_TransportsManager(mpiComm, m_DebugMode)
{
m_EndMessage = " in call to IO Open HDFMixer " + m_Name + "\n";
Init();
}
HDFMixer::~HDFMixer() = default;
void HDFMixer::Init()
{
InitParameters();
InitTransports();
InitBuffer();
}
#define declare_type(T) \
void HDFMixer::DoWrite(Variable<T> &variable, const T *values) \
{ \
DoWriteCommon(variable, values); \
}
ADIOS2_FOREACH_TYPE_1ARG(declare_type)
#undef declare_type
void HDFMixer::Advance(const float /*timeout_sec*/)
{
m_HDFSerialWriter.Advance();
m_HDFVDSWriter.Advance();
}
void HDFMixer::Close(const int transportIndex)
{
if (m_DebugMode)
{
if (!m_TransportsManager.CheckTransportIndex(transportIndex))
{
auto transportsSize = m_TransportsManager.m_Transports.size();
throw std::invalid_argument(
"ERROR: transport index " + std::to_string(transportIndex) +
" outside range, -1 (default) to " +
std::to_string(transportsSize - 1) + ", in call to Close\n");
}
}
// close bp buffer by flattening data and metadata
m_HDFSerialWriter.Close();
m_HDFVDSWriter.Close();
// send data to corresponding transports
/*
m_TransportsManager.WriteFiles(m_HDFSerialWriter.m_HeapBuffer.GetData(),
m_HDFSerialWriter.m_HeapBuffer.m_DataPosition,
transportIndex);
m_TransportsManager.CloseFiles(transportIndex);
*/
/*
// do profiling later
if (m_HDFSerialWriter.m_Profiler.IsActive &&
m_TransportsManager.AllTransportsClosed())
{
WriteProfilingJSONFile();
}
*/
}
// PRIVATE FUNCTIONS
void HDFMixer::InitParameters()
{
// no need for hdf5
// m_HDFSerialWriter.InitParameters(m_IO.m_Parameters);
}
void HDFMixer::InitTransports()
{
if (m_IO.m_TransportsParameters.empty())
{
Params defaultTransportParameters;
defaultTransportParameters["transport"] = "File";
m_IO.m_TransportsParameters.push_back(defaultTransportParameters);
}
#ifdef NEVER
/*
// TODO need to add support for aggregators here later
// Names are std::vector<std::string>
auto transportsNames = m_TransportsManager.GetFilesBaseNames(
m_Name, m_IO.m_TransportsParameters);
auto bpBaseNames = m_HDFSerialWriter.GetBPBaseNames(transportsNames);
auto bpNames = m_HDFSerialWriter.GetBPNames(transportsNames);
m_TransportsManager.OpenFiles(bpBaseNames, bpNames, m_OpenMode,
m_IO.m_TransportsParameters,
m_HDFSerialWriter.m_Profiler.IsActive);
*/
#else
int rank;
MPI_Comm_rank(m_MPIComm, &rank);
m_HDFSerialWriter.Init(m_Name, rank);
m_HDFVDSWriter.Init(m_Name);
/*
auto transportsNames = m_TransportsManager.GetFilesBaseNames(
m_Name,
m_IO.m_TransportsParameters); auto baseNames =
m_HDFSerialWriter.GetBaseNames(transportsNames);
auto h5name = m_HDFSerialWriter.GetLocalFileNames(baseNames, m_Name); // e.g.
base=/my/path/xy_1.h5 m_TransportsManager.OpenFiles(baseNames, h5name,
m_OpenMode, m_IO.m_TransportsParameters, m_HDFSerialWriter.m_Profiler.IsActive);
*/
#endif
}
void HDFMixer::InitBuffer()
{
/*
if (m_OpenMode == OpenMode::Append)
{
throw std::invalid_argument(
"ADIOS2: OpenMode Append hasn't been implemented, yet");
// TODO: Get last pg timestep and update timestep counter in
}
else
{
m_HDFSerialWriter.WriteProcessGroupIndex(
m_IO.m_HostLanguage,
m_TransportsManager.GetTransportsTypes());
}
*/
}
auto transportTypes = m_TransportsManager.GetTransportsTypes();
auto transportProfilers = m_TransportsManager.GetTransportsProfilers();
const std::string lineJSON(
m_HDFSerialWriter.GetRankProfilingJSON(transportTypes,
transportProfilers));
const std::string profilingJSON(
m_HDFSerialWriter.AggregateProfilingJSON(lineJSON));
//if (m_HDFSerialWriter.m_BP1Aggregator.m_RankMPI == 0)
if (m_HDFSerialWriter.m_MPIRank == 0)
{
transport::FileStream profilingJSONStream(m_MPIComm, m_DebugMode);
auto baseNames = m_HDFSerialWriter.GetBaseNames({m_Name});
profilingJSONStream.Open(baseNames[0] + "/profiling.json",
OpenMode::Write);
profilingJSONStream.Write(profilingJSON.c_str(), profilingJSON.size());
profilingJSONStream.Close();
}
*/}
} // end namespace adios