Skip to content

Commit 3bfbbbe

Browse files
committed
wip: try splitting m_work in two
1 parent a17bc8a commit 3bfbbbe

5 files changed

Lines changed: 82 additions & 43 deletions

File tree

include/openPMD/IO/AbstractIOHandler.hpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ enum class FlushLevel
5959
* This mode defines a flush point (see docs/source/usage/workflow.rst.rst).
6060
*/
6161
UserFlush,
62+
/**
63+
* Flush triggered by storeChunk in immediate flush mode.
64+
* Must not perform storeChunk operations of the Span API.
65+
*/
66+
ImmediateFlush,
6267
/**
6368
* Default mode, used when flushes are triggered internally, e.g. during
6469
* parsing to read attributes. Does not trigger a flush point.
@@ -81,6 +86,66 @@ enum class FlushLevel
8186
CreateOrOpenFiles
8287
};
8388

89+
namespace flush_level
90+
{
91+
inline constexpr auto global_flushpoint(FlushLevel fl)
92+
{
93+
switch (fl)
94+
{
95+
case FlushLevel::UserFlush:
96+
return true;
97+
case FlushLevel::ImmediateFlush:
98+
case FlushLevel::InternalFlush:
99+
case FlushLevel::SkeletonOnly:
100+
case FlushLevel::CreateOrOpenFiles:
101+
return false;
102+
}
103+
return false; // unreachable
104+
}
105+
inline constexpr auto write_datasets(FlushLevel fl)
106+
{
107+
switch (fl)
108+
{
109+
case FlushLevel::UserFlush:
110+
case FlushLevel::ImmediateFlush:
111+
return true;
112+
case FlushLevel::InternalFlush:
113+
case FlushLevel::SkeletonOnly:
114+
case FlushLevel::CreateOrOpenFiles:
115+
return false;
116+
}
117+
return false; // unreachable
118+
}
119+
inline constexpr auto write_attributes(FlushLevel fl)
120+
{
121+
switch (fl)
122+
{
123+
case FlushLevel::UserFlush:
124+
case FlushLevel::ImmediateFlush:
125+
case FlushLevel::InternalFlush:
126+
return true;
127+
case FlushLevel::SkeletonOnly:
128+
case FlushLevel::CreateOrOpenFiles:
129+
return false;
130+
}
131+
return false; // unreachable
132+
}
133+
inline constexpr auto flush_hierarchy(FlushLevel fl)
134+
{
135+
switch (fl)
136+
{
137+
case FlushLevel::UserFlush:
138+
case FlushLevel::ImmediateFlush:
139+
case FlushLevel::InternalFlush:
140+
case FlushLevel::SkeletonOnly:
141+
return true;
142+
case FlushLevel::CreateOrOpenFiles:
143+
return false;
144+
}
145+
return false; // unreachable
146+
}
147+
} // namespace flush_level
148+
84149
enum class OpenpmdStandard
85150
{
86151
v_1_0_0,

include/openPMD/RecordComponent.tpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,14 @@ inline DynamicMemoryView<T> RecordComponent::storeChunkSpanCreateBuffer_impl(
155155
getBufferView.out->ptr = static_cast<void *>(data.get());
156156
if (size > 0)
157157
{
158-
storeChunk(std::move(data), std::move(o), std::move(e));
158+
internal::LoadStoreConfigWithBuffer ls_cfg{
159+
std::move(o), std::move(e), std::nullopt};
160+
storeChunk_impl(
161+
auxiliary::WriteBuffer(std::move(data)),
162+
getBufferView.dtype,
163+
std::move(ls_cfg));
159164
}
165+
// storeChunk(std::move(data), std::move(o), std::move(e));
160166
}
161167
setDirtyRecursive(true);
162168
return DynamicMemoryView<T>{std::move(getBufferView), size, *this};

src/IO/ADIOS/ADIOS2File.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,25 +1080,16 @@ void ADIOS2File::flush_impl(
10801080
drainedUniquePtrPuts.swap(m_uniquePtrPuts);
10811081
}
10821082

1083-
if (readOnly(m_mode))
1083+
if (readOnly(m_mode) || flush_level::write_datasets(level))
10841084
{
1085-
level = FlushLevel::UserFlush;
1086-
}
1087-
1088-
switch (level)
1089-
{
1090-
case FlushLevel::UserFlush:
10911085
performPutGets(*this, eng);
10921086
m_updateSpans.clear();
10931087
m_buffer.clear();
10941088
m_alreadyEnqueued.clear();
10951089
drainedUniquePtrPuts.clear();
1096-
1097-
break;
1098-
1099-
case FlushLevel::InternalFlush:
1100-
case FlushLevel::SkeletonOnly:
1101-
case FlushLevel::CreateOrOpenFiles:
1090+
}
1091+
else
1092+
{
11021093
/*
11031094
* Tasks have been given to ADIOS2, but we don't flush them
11041095
* yet. So, move everything to m_alreadyEnqueued to avoid
@@ -1115,7 +1106,6 @@ void ADIOS2File::flush_impl(
11151106
"wrong time.");
11161107
}
11171108
m_buffer.clear();
1118-
break;
11191109
}
11201110
}
11211111

src/Iteration.cpp

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,9 @@ void Iteration::flushFileBased(
320320
s.openIteration(i, *this);
321321
}
322322

323-
switch (flushParams.flushLevel)
323+
if (flush_level::flush_hierarchy(flushParams.flushLevel))
324324
{
325-
case FlushLevel::CreateOrOpenFiles:
326-
break;
327-
case FlushLevel::SkeletonOnly:
328-
case FlushLevel::InternalFlush:
329-
case FlushLevel::UserFlush:
330325
flush(flushParams);
331-
break;
332326
}
333327
}
334328

@@ -343,15 +337,9 @@ void Iteration::flushGroupBased(
343337
IOHandler()->enqueue(IOTask(this, pCreate));
344338
}
345339

346-
switch (flushParams.flushLevel)
340+
if (flush_level::flush_hierarchy(flushParams.flushLevel))
347341
{
348-
case FlushLevel::CreateOrOpenFiles:
349-
break;
350-
case FlushLevel::SkeletonOnly:
351-
case FlushLevel::InternalFlush:
352-
case FlushLevel::UserFlush:
353342
flush(flushParams);
354-
break;
355343
}
356344
}
357345

@@ -366,17 +354,13 @@ void Iteration::flushVariableBased(
366354
IOHandler()->enqueue(IOTask(this, pOpen));
367355
}
368356

369-
switch (flushParams.flushLevel)
357+
if (!flush_level::flush_hierarchy(flushParams.flushLevel))
370358
{
371-
case FlushLevel::CreateOrOpenFiles:
372359
return;
373-
case FlushLevel::SkeletonOnly:
374-
case FlushLevel::InternalFlush:
375-
case FlushLevel::UserFlush:
376-
flush(flushParams);
377-
break;
378360
}
379361

362+
flush(flushParams);
363+
380364
if (!written())
381365
{
382366
/* create iteration path */

src/backend/Attributable.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,9 @@ Attributable::seriesFlush_impl<false>(internal::FlushParams const &flushParams);
312312

313313
void Attributable::flushAttributes(internal::FlushParams const &flushParams)
314314
{
315-
switch (flushParams.flushLevel)
315+
if (!flush_level::write_attributes(flushParams.flushLevel))
316316
{
317-
case FlushLevel::SkeletonOnly:
318-
case FlushLevel::CreateOrOpenFiles:
319317
return;
320-
case FlushLevel::InternalFlush:
321-
case FlushLevel::UserFlush:
322-
// pass
323-
break;
324318
}
325319
if (dirty())
326320
{

0 commit comments

Comments
 (0)