Skip to content

Commit dcfbfe9

Browse files
committed
Fix flushing of ADIOS2 files
1 parent a307fd2 commit dcfbfe9

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

include/openPMD/IO/AbstractIOHandlerImplCommon.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
#include "openPMD/auxiliary/StringManip.hpp"
2929
#include "openPMD/backend/Writable.hpp"
3030

31+
#include <set>
3132
#include <stdexcept>
3233
#include <string>
3334
#include <unordered_map>
34-
#include <unordered_set>
3535

3636
namespace openPMD
3737
{
@@ -50,7 +50,10 @@ class AbstractIOHandlerImplCommon : public AbstractIOHandlerImpl
5050
* without the OS path
5151
*/
5252
std::unordered_map<Writable *, InvalidatableFile> m_files;
53-
std::unordered_set<InvalidatableFile> m_dirty;
53+
// MUST be an ordered set in order to consistently flush on different
54+
// parallel processes (same logic cant apply to m_files since Writable*
55+
// pointers are not predictable)
56+
std::set<InvalidatableFile> m_dirty;
5457

5558
enum PossiblyExisting
5659
{

include/openPMD/IO/InvalidatableFile.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,14 @@ struct hash<openPMD::InvalidatableFile>
8282

8383
result_type operator()(argument_type const &s) const noexcept;
8484
};
85+
86+
template <>
87+
struct less<openPMD::InvalidatableFile>
88+
{
89+
using first_argument_type = openPMD::InvalidatableFile;
90+
using second_argument_type = first_argument_type;
91+
using result_type = typename std::less<std::string>::result_type;
92+
result_type
93+
operator()(first_argument_type const &, second_argument_type const &) const;
94+
};
8595
} // namespace std

src/IO/ADIOS/ADIOS2IOHandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ void ADIOS2IOHandlerImpl::listPaths(
17471747
*/
17481748
auto &fileData = getFileData(file, IfFileNotOpen::ThrowError);
17491749

1750-
std::unordered_set<std::string> subdirs;
1750+
std::set<std::string> subdirs;
17511751
/*
17521752
* When reading an attribute, we cannot distinguish
17531753
* whether its containing "folder" is a group or a
@@ -1889,7 +1889,7 @@ void ADIOS2IOHandlerImpl::listDatasets(
18891889

18901890
auto &fileData = getFileData(file, IfFileNotOpen::ThrowError);
18911891

1892-
std::unordered_set<std::string> subdirs;
1892+
std::set<std::string> subdirs;
18931893
for (auto var : fileData.availableVariablesPrefixed(myName))
18941894
{
18951895
// if string still contains a slash, variable is a dataset below the

src/IO/InvalidatableFile.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,9 @@ std::hash<openPMD::InvalidatableFile>::operator()(
8080
return std::hash<shared_ptr<openPMD::InvalidatableFile::FileState>>{}(
8181
s.fileState);
8282
}
83+
auto std::less<openPMD::InvalidatableFile>::operator()(
84+
first_argument_type const &first, second_argument_type const &second) const
85+
-> result_type
86+
{
87+
return less<>()(*first, *second);
88+
};

0 commit comments

Comments
 (0)