Skip to content

Commit a9b6919

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 4ea7426 commit a9b6919

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

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: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,17 +1150,17 @@ Series::readGorVBased( bool do_init )
11501150
return auxiliary::Option< std::deque< uint64_t > >();
11511151
}
11521152
}
1153-
case IterationEncoding::variableBased:
1154-
{
1155-
uint64_t index = 0;
1153+
case IterationEncoding::variableBased: {
1154+
std::deque< uint64_t > res = { 0 };
11561155
if( currentSteps.has_value() && !currentSteps.get().empty() )
11571156
{
1158-
// variable-based layout can only read one iteration at a time
1159-
// @todo warning or exception if the size is any other than 1?
1160-
index = currentSteps.get().at( 0 );
1157+
res = { currentSteps.get().begin(), currentSteps.get().end() };
1158+
}
1159+
for( auto it : res )
1160+
{
1161+
readSingleIteration( it, "", false );
11611162
}
1162-
readSingleIteration( index, "", false );
1163-
return std::deque< uint64_t >{ index };
1163+
return res;
11641164
}
11651165
}
11661166
throw std::runtime_error( "Unreachable!" );

test/SerialIOTest.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4471,7 +4471,8 @@ void iterate_nonstreaming_series(
44714471
auto E_x = iteration.meshes[ "E" ][ "x" ];
44724472
E_x.resetDataset(
44734473
openPMD::Dataset( openPMD::Datatype::INT, { 2, extent } ) );
4474-
std::vector< int > data( extent, i );
4474+
int value = variableBasedLayout ? 0 : i;
4475+
std::vector< int > data( extent, value );
44754476
E_x.storeChunk( data, { 0, 0 }, { 1, extent } );
44764477
bool taskSupportedByBackend = true;
44774478
DynamicMemoryView< int > memoryView;
@@ -4560,10 +4561,11 @@ void iterate_nonstreaming_series(
45604561
iteration.close();
45614562
}
45624563

4564+
int value = variableBasedLayout ? 0 : iteration.iterationIndex;
45634565
for( size_t i = 0; i < extent; ++i )
45644566
{
4565-
REQUIRE( chunk.get()[ i ] == int(iteration.iterationIndex) );
4566-
REQUIRE( chunk2.get()[ i ] == int(i) );
4567+
REQUIRE( chunk.get()[ i ] == value );
4568+
REQUIRE( chunk2.get()[ i ] == int( i ) );
45674569
}
45684570
last_iteration_index = iteration.iterationIndex;
45694571
}

0 commit comments

Comments
 (0)