Skip to content

Commit

Permalink
Add review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed May 8, 2024
1 parent eae4865 commit 950da6d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
8 changes: 8 additions & 0 deletions include/openPMD/auxiliary/StringManip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ namespace auxiliary
return std::forward<S>(s);
}

/** Create a string representation of a vector or another iterable
* container.
*
* @param v The vector or other iterable container.
* @return A string that shows the items of the container. Each item is
* formatted using the default definition for operator<<().
*/
template <typename Vec>
auto format_vec(Vec const &v) -> std::string
{
Expand All @@ -254,6 +261,7 @@ namespace auxiliary
auto end = v.end();
std::stringstream res;
res << '[' << *it++;
res.operator<<(*it);
for (; it != end; ++it)
{
res << ", " << *it;
Expand Down
40 changes: 38 additions & 2 deletions test/ParallelIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "openPMD/IO/ADIOS/macros.hpp"
#include "openPMD/auxiliary/Environment.hpp"
#include "openPMD/auxiliary/Filesystem.hpp"
#include "openPMD/backend/PatchRecordComponent.hpp"
#include "openPMD/openPMD.hpp"
#include <catch2/catch.hpp>

Expand Down Expand Up @@ -397,7 +398,7 @@ void available_chunks_test(std::string const &file_ending)
MPI_Comm_size(MPI_COMM_WORLD, &r_mpi_size);
unsigned mpi_rank{static_cast<unsigned>(r_mpi_rank)},
mpi_size{static_cast<unsigned>(r_mpi_size)};
std::string name = "../samples/available_chunks." + file_ending;
std::string name = "../samples/parallel_available_chunks." + file_ending;

/*
* ADIOS2 assigns writerIDs to blocks in a BP file by id of the substream
Expand All @@ -410,7 +411,6 @@ void available_chunks_test(std::string const &file_ending)
{
"engine":
{
"type": "bp4",
"parameters":
{
"NumAggregators":)END"
Expand All @@ -429,6 +429,14 @@ void available_chunks_test(std::string const &file_ending)
E_x.resetDataset({Datatype::INT, {mpi_size, 4}});
E_x.storeChunk(data, {mpi_rank, 0}, {1, 4});

/*
* Verify that block decomposition also works in "local value" variable
* shape. That shape instructs the data to participate in ADIOS2
* metadata aggregation, hence there is only one "real" written block,
* the aggregated one. We still need the original logical blocks to be
* present in reading.
*/

auto electrons = it0.particles["e"].particlePatches;
auto numParticles = electrons["numParticles"];
auto numParticlesOffset = electrons["numParticlesOffset"];
Expand Down Expand Up @@ -501,12 +509,40 @@ void available_chunks_test(std::string const &file_ending)
{
REQUIRE(ranks[i] == i);
}

auto electrons = it0.particles["e"].particlePatches;
for (PatchRecordComponent *prc :
{static_cast<PatchRecordComponent *>(&electrons["numParticles"]),
static_cast<PatchRecordComponent *>(
&electrons["numParticlesOffset"]),
&electrons["offset"]["x"],
&electrons["offset"]["y"],
&electrons["extent"]["z"],
&electrons["offset"]["x"],
&electrons["extent"]["y"],
&electrons["extent"]["z"]})
{
auto available_chunks = prc->availableChunks();
REQUIRE(size_t(r_mpi_size) == available_chunks.size());
for (size_t i = 0; i < available_chunks.size(); ++i)
{
auto const &chunk = available_chunks[i];
REQUIRE(chunk.extent == Extent{1});
REQUIRE(chunk.offset == Offset{i});
REQUIRE(chunk.sourceID == i);
}
}
}
}

TEST_CASE("available_chunks_test", "[parallel][adios]")
{
#if HAS_ADIOS_2_9
available_chunks_test("bp4");
available_chunks_test("bp5");
#else
available_chunks_test("bp");
#endif
}
#endif

Expand Down

0 comments on commit 950da6d

Please sign in to comment.