Skip to content

Commit

Permalink
Variable-b. encoding: Allow several (equivalent) iterations per step
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
franzpoeschel committed Jan 3, 2022
1 parent 4ea7426 commit a9b6919
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/ReadIterations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ SeriesIterator::SeriesIterator( Series series )
}
}

if( !setCurrentIteration() )
if( status == AdvanceStatus::OVER )
{
*this = end();
return;
}
if( status == AdvanceStatus::OVER )
if( !setCurrentIteration() )
{
*this = end();
return;
Expand Down
16 changes: 8 additions & 8 deletions src/Series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,17 +1150,17 @@ Series::readGorVBased( bool do_init )
return auxiliary::Option< std::deque< uint64_t > >();
}
}
case IterationEncoding::variableBased:
{
uint64_t index = 0;
case IterationEncoding::variableBased: {
std::deque< uint64_t > res = { 0 };
if( currentSteps.has_value() && !currentSteps.get().empty() )
{
// variable-based layout can only read one iteration at a time
// @todo warning or exception if the size is any other than 1?
index = currentSteps.get().at( 0 );
res = { currentSteps.get().begin(), currentSteps.get().end() };
}
for( auto it : res )
{
readSingleIteration( it, "", false );
}
readSingleIteration( index, "", false );
return std::deque< uint64_t >{ index };
return res;
}
}
throw std::runtime_error( "Unreachable!" );
Expand Down
8 changes: 5 additions & 3 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4471,7 +4471,8 @@ void iterate_nonstreaming_series(
auto E_x = iteration.meshes[ "E" ][ "x" ];
E_x.resetDataset(
openPMD::Dataset( openPMD::Datatype::INT, { 2, extent } ) );
std::vector< int > data( extent, i );
int value = variableBasedLayout ? 0 : i;
std::vector< int > data( extent, value );
E_x.storeChunk( data, { 0, 0 }, { 1, extent } );
bool taskSupportedByBackend = true;
DynamicMemoryView< int > memoryView;
Expand Down Expand Up @@ -4560,10 +4561,11 @@ void iterate_nonstreaming_series(
iteration.close();
}

int value = variableBasedLayout ? 0 : iteration.iterationIndex;
for( size_t i = 0; i < extent; ++i )
{
REQUIRE( chunk.get()[ i ] == int(iteration.iterationIndex) );
REQUIRE( chunk2.get()[ i ] == int(i) );
REQUIRE( chunk.get()[ i ] == value );
REQUIRE( chunk2.get()[ i ] == int( i ) );
}
last_iteration_index = iteration.iterationIndex;
}
Expand Down

0 comments on commit a9b6919

Please sign in to comment.