Skip to content

Commit 77a7aae

Browse files
authored
- HDF5 files in campaign version 0.5 has arrays with <=128 elements stored locally. Read them locally in the HDF5 engine instead going remote. (#4609)
- Add DestructorClose() to HDF5 engine like other engines to avoid unnecessary warning from ~Engine()
1 parent e119f3f commit 77a7aae

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

source/adios2/engine/hdf5/HDF5ReaderP.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ HDF5ReaderP::HDF5ReaderP(IO &io, const std::string &name, const Mode openMode, h
4949
m_IsOpen = true;
5050
}
5151

52-
HDF5ReaderP::~HDF5ReaderP()
53-
{
54-
if (IsValid())
55-
DoClose();
56-
}
52+
HDF5ReaderP::~HDF5ReaderP() { DestructorClose(m_FailVerbose); }
5753

5854
bool HDF5ReaderP::IsValid()
5955
{
@@ -132,6 +128,7 @@ size_t HDF5ReaderP::ReadDataset(hid_t dataSetId, hid_t h5Type, Variable<T> &vari
132128
std::vector<hsize_t> start(ndims), count(ndims), stride(ndims);
133129
bool isOrderC = (m_IO.m_ArrayOrder == ArrayOrdering::RowMajor);
134130

131+
size_t total_size = 1;
135132
for (size_t i = 0u; i < ndims; i++)
136133
{
137134
if (isOrderC)
@@ -146,6 +143,7 @@ size_t HDF5ReaderP::ReadDataset(hid_t dataSetId, hid_t h5Type, Variable<T> &vari
146143
}
147144
slabsize *= count[i];
148145
stride[i] = 1;
146+
total_size *= variable.m_Shape[i];
149147
}
150148
hid_t ret = H5Sselect_hyperslab(fileSpace, H5S_SELECT_SET, start.data(), stride.data(),
151149
count.data(), NULL);
@@ -166,7 +164,10 @@ size_t HDF5ReaderP::ReadDataset(hid_t dataSetId, hid_t h5Type, Variable<T> &vari
166164
elementsRead *= count[i];
167165
}
168166

169-
bool useRemote = CheckRemote();
167+
/* FIXME: Right now it's baked into campaign management that HDF5 metadata files contain
168+
data for arrays of <= 128 elements. This code must be in sync with what the
169+
hpc_campaign_hdf5_metadata.py script does */
170+
bool useRemote = (total_size > 128 && CheckRemote());
170171

171172
if (useRemote)
172173
{
@@ -399,12 +400,15 @@ ADIOS2_FOREACH_STDTYPE_1ARG(declare_type)
399400

400401
void HDF5ReaderP::DoClose(const int transportIndex)
401402
{
402-
/*
403-
*/
404403
EndStep();
405-
/*
406-
*/
407404
m_H5File.Close();
405+
m_IsOpen = false;
406+
}
407+
408+
void HDF5ReaderP::DestructorClose(bool Verbose) noexcept
409+
{
410+
if (IsValid())
411+
DoClose();
408412
}
409413

410414
size_t HDF5ReaderP::DoSteps() const { return m_H5File.GetAdiosStep(); }

source/adios2/engine/hdf5/HDF5ReaderP.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class HDF5ReaderP : public Engine
100100

101101
size_t DoSteps() const final;
102102

103+
void DestructorClose(bool Verbose) noexcept final;
104+
103105
// Remote data access variables and functions
104106
std::unique_ptr<Remote> m_Remote;
105107
bool CheckRemote();

0 commit comments

Comments
 (0)