Skip to content

Commit 4ae4a72

Browse files
committed
Add review suggestions
1 parent 51b7234 commit 4ae4a72

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

@@ -403,7 +404,7 @@ void available_chunks_test(std::string const &file_ending)
403404
MPI_Comm_size(MPI_COMM_WORLD, &r_mpi_size);
404405
unsigned mpi_rank{static_cast<unsigned>(r_mpi_rank)},
405406
mpi_size{static_cast<unsigned>(r_mpi_size)};
406-
std::string name = "../samples/available_chunks." + file_ending;
407+
std::string name = "../samples/parallel_available_chunks." + file_ending;
407408

408409
/*
409410
* ADIOS2 assigns writerIDs to blocks in a BP file by id of the substream
@@ -416,7 +417,6 @@ void available_chunks_test(std::string const &file_ending)
416417
{
417418
"engine":
418419
{
419-
"type": "bp4",
420420
"parameters":
421421
{
422422
"NumAggregators":)END"
@@ -437,6 +437,14 @@ void available_chunks_test(std::string const &file_ending)
437437
E_x.resetDataset({Datatype::INT, {mpi_size, 4}});
438438
E_x.storeChunk(data, {mpi_rank, 0}, {1, 4});
439439

440+
/*
441+
* Verify that block decomposition also works in "local value" variable
442+
* shape. That shape instructs the data to participate in ADIOS2
443+
* metadata aggregation, hence there is only one "real" written block,
444+
* the aggregated one. We still need the original logical blocks to be
445+
* present in reading.
446+
*/
447+
440448
auto electrons = it0.particles["e"].particlePatches;
441449
auto numParticles = electrons["numParticles"];
442450
auto numParticlesOffset = electrons["numParticlesOffset"];
@@ -509,12 +517,40 @@ void available_chunks_test(std::string const &file_ending)
509517
{
510518
REQUIRE(ranks[i] == i);
511519
}
520+
521+
auto electrons = it0.particles["e"].particlePatches;
522+
for (PatchRecordComponent *prc :
523+
{static_cast<PatchRecordComponent *>(&electrons["numParticles"]),
524+
static_cast<PatchRecordComponent *>(
525+
&electrons["numParticlesOffset"]),
526+
&electrons["offset"]["x"],
527+
&electrons["offset"]["y"],
528+
&electrons["extent"]["z"],
529+
&electrons["offset"]["x"],
530+
&electrons["extent"]["y"],
531+
&electrons["extent"]["z"]})
532+
{
533+
auto available_chunks = prc->availableChunks();
534+
REQUIRE(size_t(r_mpi_size) == available_chunks.size());
535+
for (size_t i = 0; i < available_chunks.size(); ++i)
536+
{
537+
auto const &chunk = available_chunks[i];
538+
REQUIRE(chunk.extent == Extent{1});
539+
REQUIRE(chunk.offset == Offset{i});
540+
REQUIRE(chunk.sourceID == i);
541+
}
542+
}
512543
}
513544
}
514545

515546
TEST_CASE("available_chunks_test", "[parallel][adios]")
516547
{
548+
#if HAS_ADIOS_2_9
549+
available_chunks_test("bp4");
550+
available_chunks_test("bp5");
551+
#else
517552
available_chunks_test("bp");
553+
#endif
518554
}
519555
#endif
520556

0 commit comments

Comments
 (0)