Skip to content

Commit b9443eb

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 ef3c957 commit b9443eb

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
@@ -1148,17 +1148,17 @@ Series::readGorVBased( bool do_init )
11481148
return auxiliary::Option< std::deque< uint64_t > >();
11491149
}
11501150
}
1151-
case IterationEncoding::variableBased:
1152-
{
1153-
uint64_t index = 0;
1151+
case IterationEncoding::variableBased: {
1152+
std::deque< uint64_t > res = { 0 };
11541153
if( currentSteps.has_value() && !currentSteps.get().empty() )
11551154
{
1156-
// variable-based layout can only read one iteration at a time
1157-
// @todo warning or exception if the size is any other than 1?
1158-
index = currentSteps.get().at( 0 );
1155+
res = { currentSteps.get().begin(), currentSteps.get().end() };
1156+
}
1157+
for( auto it : res )
1158+
{
1159+
readSingleIteration( it, "", false );
11591160
}
1160-
readSingleIteration( index, "", false );
1161-
return std::deque< uint64_t >{ index };
1161+
return res;
11621162
}
11631163
}
11641164
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)