Skip to content

Commit 49b75ee

Browse files
committed
Variable-b. encoding: Allow several (equivalent) iterations per step
This means that a single step can be marked by /data/snapshot to represent iterations 0,10,20,30 at the same time. The underlying data is the same, but the API will treat it as 4 times a different iteration with equivalent content.
1 parent e89336c commit 49b75ee

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

src/ReadIterations.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ SeriesIterator::SeriesIterator( Series series )
119119
}
120120
}
121121

122-
if( !setCurrentIteration() )
122+
if( status == AdvanceStatus::OVER )
123123
{
124124
*this = end();
125125
return;
126126
}
127-
if( status == AdvanceStatus::OVER )
127+
if( !setCurrentIteration() )
128128
{
129129
*this = end();
130130
return;

src/Series.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,17 +1135,17 @@ SeriesInterface::readGorVBased( bool do_init )
11351135
return auxiliary::Option< std::deque< uint64_t > >();
11361136
}
11371137
}
1138-
case IterationEncoding::variableBased:
1139-
{
1140-
uint64_t index = 0;
1138+
case IterationEncoding::variableBased: {
1139+
std::deque< uint64_t > res = { 0 };
11411140
if( currentSteps.has_value() && !currentSteps.get().empty() )
11421141
{
1143-
// variable-based layout can only read one iteration at a time
1144-
// @todo warning or exception if the size is any other than 1?
1145-
index = currentSteps.get().at( 0 );
1142+
res = { currentSteps.get().begin(), currentSteps.get().end() };
1143+
}
1144+
for( auto it : res )
1145+
{
1146+
readSingleIteration( it, "", false );
11461147
}
1147-
readSingleIteration( index, "", false );
1148-
return std::deque< uint64_t >{ index };
1148+
return res;
11491149
}
11501150
}
11511151
throw std::runtime_error( "Unreachable!" );
@@ -1605,7 +1605,7 @@ SeriesInternal::~SeriesInternal()
16051605
* needlessly flushed a second time. Otherwise, error messages can get
16061606
* very confusing.
16071607
*/
1608-
if( get().m_lastFlushSuccessful )
1608+
if( series.m_lastFlushSuccessful )
16091609
{
16101610
flush();
16111611
flushStep( /* doFlush = */ true );

test/SerialIOTest.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4172,7 +4172,8 @@ iterate_nonstreaming_series(
41724172
auto E_x = iteration.meshes[ "E" ][ "x" ];
41734173
E_x.resetDataset(
41744174
openPMD::Dataset( openPMD::Datatype::INT, { 2, extent } ) );
4175-
std::vector< int > data( extent, i );
4175+
int value = variableBasedLayout ? 0 : i;
4176+
std::vector< int > data( extent, value );
41764177
E_x.storeChunk( data, { 0, 0 }, { 1, extent } );
41774178
bool taskSupportedByBackend = true;
41784179
DynamicMemoryView< int > memoryView = E_x.storeChunk< int >(
@@ -4252,10 +4253,11 @@ iterate_nonstreaming_series(
42524253
iteration.close();
42534254
}
42544255

4256+
int value = variableBasedLayout ? 0 : iteration.iterationIndex;
42554257
for( size_t i = 0; i < extent; ++i )
42564258
{
4257-
REQUIRE( chunk.get()[ i ] == int(iteration.iterationIndex) );
4258-
REQUIRE( chunk2.get()[ i ] == int(i) );
4259+
REQUIRE( chunk.get()[ i ] == value );
4260+
REQUIRE( chunk2.get()[ i ] == int( i ) );
42594261
}
42604262
last_iteration_index = iteration.iterationIndex;
42614263
}

0 commit comments

Comments
 (0)