Skip to content

Commit 7dd8f2f

Browse files
committed
Add review suggestions
1 parent 2c8b22c commit 7dd8f2f

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

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
@@ -5,6 +5,7 @@
55
#include "openPMD/IO/Access.hpp"
66
#include "openPMD/auxiliary/Environment.hpp"
77
#include "openPMD/auxiliary/Filesystem.hpp"
8+
#include "openPMD/backend/PatchRecordComponent.hpp"
89
#include "openPMD/openPMD.hpp"
910
#include <catch2/catch.hpp>
1011

@@ -398,7 +399,7 @@ void available_chunks_test(std::string const &file_ending)
398399
MPI_Comm_size(MPI_COMM_WORLD, &r_mpi_size);
399400
unsigned mpi_rank{static_cast<unsigned>(r_mpi_rank)},
400401
mpi_size{static_cast<unsigned>(r_mpi_size)};
401-
std::string name = "../samples/available_chunks." + file_ending;
402+
std::string name = "../samples/parallel_available_chunks." + file_ending;
402403

403404
/*
404405
* ADIOS2 assigns writerIDs to blocks in a BP file by id of the substream
@@ -411,7 +412,6 @@ void available_chunks_test(std::string const &file_ending)
411412
{
412413
"engine":
413414
{
414-
"type": "bp4",
415415
"parameters":
416416
{
417417
"NumAggregators":)END"
@@ -432,6 +432,14 @@ void available_chunks_test(std::string const &file_ending)
432432
E_x.resetDataset({Datatype::INT, {mpi_size, 4}});
433433
E_x.storeChunk(data, {mpi_rank, 0}, {1, 4});
434434

435+
/*
436+
* Verify that block decomposition also works in "local value" variable
437+
* shape. That shape instructs the data to participate in ADIOS2
438+
* metadata aggregation, hence there is only one "real" written block,
439+
* the aggregated one. We still need the original logical blocks to be
440+
* present in reading.
441+
*/
442+
435443
auto electrons = it0.particles["e"].particlePatches;
436444
auto numParticles = electrons["numParticles"];
437445
auto numParticlesOffset = electrons["numParticlesOffset"];
@@ -504,12 +512,40 @@ void available_chunks_test(std::string const &file_ending)
504512
{
505513
REQUIRE(ranks[i] == i);
506514
}
515+
516+
auto electrons = it0.particles["e"].particlePatches;
517+
for (PatchRecordComponent *prc :
518+
{static_cast<PatchRecordComponent *>(&electrons["numParticles"]),
519+
static_cast<PatchRecordComponent *>(
520+
&electrons["numParticlesOffset"]),
521+
&electrons["offset"]["x"],
522+
&electrons["offset"]["y"],
523+
&electrons["extent"]["z"],
524+
&electrons["offset"]["x"],
525+
&electrons["extent"]["y"],
526+
&electrons["extent"]["z"]})
527+
{
528+
auto available_chunks = prc->availableChunks();
529+
REQUIRE(size_t(r_mpi_size) == available_chunks.size());
530+
for (size_t i = 0; i < available_chunks.size(); ++i)
531+
{
532+
auto const &chunk = available_chunks[i];
533+
REQUIRE(chunk.extent == Extent{1});
534+
REQUIRE(chunk.offset == Offset{i});
535+
REQUIRE(chunk.sourceID == i);
536+
}
537+
}
507538
}
508539
}
509540

510541
TEST_CASE("available_chunks_test", "[parallel][adios]")
511542
{
543+
#if HAS_ADIOS_2_9
544+
available_chunks_test("bp4");
545+
available_chunks_test("bp5");
546+
#else
512547
available_chunks_test("bp");
548+
#endif
513549
}
514550
#endif
515551

0 commit comments

Comments
 (0)