Skip to content

Commit

Permalink
Rename WrittenChunkInfo.mpi_rank -> WrittenChunkInfo.sourceID (openPM…
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jan 29, 2021
1 parent 5303640 commit d655e99
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
16 changes: 10 additions & 6 deletions include/openPMD/ChunkInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,23 @@ struct ChunkInfo
* data producing application.
* Produced by BaseRecordComponent::availableChunk.
*
* Carries along the usual chunk meta info also the rank from which
* it was written.
* If not specified explicitly, the rank will be assumed to be 0.
* Carries along the usual chunk meta info also the ID for the data source from
* which the chunk is received.
* Examples for this include the writing MPI rank in streaming setups or the
* subfile containing the chunk.
* If not specified explicitly, the sourceID will be assumed to be 0.
* This information will vary between different backends and should be used
* for optimization purposes only.
*/
struct WrittenChunkInfo : ChunkInfo
{
unsigned int mpi_rank = 0; //!< the MPI rank of the writing process
unsigned int sourceID = 0; //!< ID of the data source containing the chunk

explicit WrittenChunkInfo() = default;
/*
* If rank is smaller than zero, will be converted to zero.
*/
explicit WrittenChunkInfo() = default;
WrittenChunkInfo( Offset, Extent, int mpi_rank );
WrittenChunkInfo( Offset, Extent, int sourceID );
WrittenChunkInfo( Offset, Extent );

bool
Expand Down
6 changes: 3 additions & 3 deletions src/ChunkInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ ChunkInfo::operator==( ChunkInfo const & other ) const
WrittenChunkInfo::WrittenChunkInfo(
Offset offset_in,
Extent extent_in,
int mpi_rank_in )
int sourceID_in )
: ChunkInfo( std::move( offset_in ), std::move( extent_in ) )
, mpi_rank( mpi_rank_in < 0 ? 0 : mpi_rank_in )
, sourceID( sourceID_in < 0 ? 0 : sourceID_in )
{
}

Expand All @@ -50,7 +50,7 @@ WrittenChunkInfo::WrittenChunkInfo( Offset offset_in, Extent extent_in )
bool
WrittenChunkInfo::operator==( WrittenChunkInfo const & other ) const
{
return this->mpi_rank == other.mpi_rank &&
return this->sourceID == other.sourceID &&
this->ChunkInfo::operator==( other );
}
} // namespace openPMD
2 changes: 1 addition & 1 deletion src/IO/JSON/JSONIOHandlerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ namespace openPMD
e.push_back( entry );
}
res.emplace_back(
std::move( o ), std::move( e ), chunk.mpi_rank );
std::move( o ), std::move( e ), chunk.sourceID );
}
}
return res;
Expand Down
2 changes: 1 addition & 1 deletion src/binding/python/ChunkInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void init_Chunk(py::module &m) {
)
.def_readwrite("offset", &WrittenChunkInfo::offset )
.def_readwrite("extent", &WrittenChunkInfo::extent )
.def_readwrite("mpi_rank", &WrittenChunkInfo::mpi_rank )
.def_readwrite("source_id", &WrittenChunkInfo::sourceID )
;
}

4 changes: 2 additions & 2 deletions test/ParallelIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ available_chunks_test( std::string file_ending )
{
REQUIRE(
chunk.offset ==
Offset{ static_cast< unsigned >( chunk.mpi_rank ), 0 } );
Offset{ static_cast< unsigned >( chunk.sourceID ), 0 } );
REQUIRE( chunk.extent == Extent{ 1, 4 } );
ranks.emplace_back( chunk.mpi_rank );
ranks.emplace_back( chunk.sourceID );
}
std::sort( ranks.begin(), ranks.end() );
for( size_t i = 0; i < ranks.size(); ++i )
Expand Down
2 changes: 2 additions & 0 deletions test/python/unittest/API/APITest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,8 @@ def makeAvailableChunksRoundTrip(self, ext):

chunks = read.iterations[0].meshes["E"]["x"].available_chunks()
chunks = sorted(chunks, key=lambda chunk: chunk.offset)
for chunk in chunks:
self.assertEqual(chunk.source_id, 0)
# print("EXTENSION:", ext)
# for chunk in chunks:
# print("{} -- {}".format(chunk.offset, chunk.extent))
Expand Down

0 comments on commit d655e99

Please sign in to comment.