Skip to content

Commit 7542b92

Browse files
committed
Add review suggestions
1 parent cfe83e8 commit 7542b92

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

include/openPMD/auxiliary/StringManip.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ namespace auxiliary
243243
return std::forward<S>(s);
244244
}
245245

246+
/** Create a string representation of a vector or another iterable
247+
* container.
248+
*
249+
* @param v The vector or other iterable container.
250+
* @return A string that shows the items of the container. Each item is
251+
* formatted using the default definition for operator<<().
252+
*/
246253
template <typename Vec>
247254
auto format_vec(Vec const &v) -> std::string
248255
{
@@ -254,6 +261,7 @@ namespace auxiliary
254261
auto end = v.end();
255262
std::stringstream res;
256263
res << '[' << *it++;
264+
res.operator<<(*it);
257265
for (; it != end; ++it)
258266
{
259267
res << ", " << *it;

test/ParallelIOTest.cpp

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "openPMD/IO/Access.hpp"
88
#include "openPMD/auxiliary/Environment.hpp"
99
#include "openPMD/auxiliary/Filesystem.hpp"
10+
#include "openPMD/backend/PatchRecordComponent.hpp"
1011
#include "openPMD/openPMD.hpp"
1112
#include <catch2/catch.hpp>
1213

@@ -375,7 +376,7 @@ void available_chunks_test(std::string const &file_ending)
375376
MPI_Comm_size(MPI_COMM_WORLD, &r_mpi_size);
376377
unsigned mpi_rank{static_cast<unsigned>(r_mpi_rank)},
377378
mpi_size{static_cast<unsigned>(r_mpi_size)};
378-
std::string name = "../samples/available_chunks." + file_ending;
379+
std::string name = "../samples/parallel_available_chunks." + file_ending;
379380

380381
/*
381382
* ADIOS2 assigns writerIDs to blocks in a BP file by id of the substream
@@ -388,7 +389,6 @@ void available_chunks_test(std::string const &file_ending)
388389
{
389390
"engine":
390391
{
391-
"type": "bp4",
392392
"parameters":
393393
{
394394
"NumAggregators":)END"
@@ -409,6 +409,14 @@ void available_chunks_test(std::string const &file_ending)
409409
E_x.resetDataset({Datatype::INT, {mpi_size, 4}});
410410
E_x.storeChunk(data, {mpi_rank, 0}, {1, 4});
411411

412+
/*
413+
* Verify that block decomposition also works in "local value" variable
414+
* shape. That shape instructs the data to participate in ADIOS2
415+
* metadata aggregation, hence there is only one "real" written block,
416+
* the aggregated one. We still need the original logical blocks to be
417+
* present in reading.
418+
*/
419+
412420
auto electrons = it0.particles["e"].particlePatches;
413421
auto numParticles = electrons["numParticles"];
414422
auto numParticlesOffset = electrons["numParticlesOffset"];
@@ -481,12 +489,40 @@ void available_chunks_test(std::string const &file_ending)
481489
{
482490
REQUIRE(ranks[i] == i);
483491
}
492+
493+
auto electrons = it0.particles["e"].particlePatches;
494+
for (PatchRecordComponent *prc :
495+
{static_cast<PatchRecordComponent *>(&electrons["numParticles"]),
496+
static_cast<PatchRecordComponent *>(
497+
&electrons["numParticlesOffset"]),
498+
&electrons["offset"]["x"],
499+
&electrons["offset"]["y"],
500+
&electrons["extent"]["z"],
501+
&electrons["offset"]["x"],
502+
&electrons["extent"]["y"],
503+
&electrons["extent"]["z"]})
504+
{
505+
auto available_chunks = prc->availableChunks();
506+
REQUIRE(size_t(r_mpi_size) == available_chunks.size());
507+
for (size_t i = 0; i < available_chunks.size(); ++i)
508+
{
509+
auto const &chunk = available_chunks[i];
510+
REQUIRE(chunk.extent == Extent{1});
511+
REQUIRE(chunk.offset == Offset{i});
512+
REQUIRE(chunk.sourceID == i);
513+
}
514+
}
484515
}
485516
}
486517

487518
TEST_CASE("available_chunks_test", "[parallel][adios]")
488519
{
520+
#if HAS_ADIOS_2_9
521+
available_chunks_test("bp4");
522+
available_chunks_test("bp5");
523+
#else
489524
available_chunks_test("bp");
525+
#endif
490526
}
491527
#endif
492528

0 commit comments

Comments
 (0)