Skip to content

Commit 950da6d

Browse files
committed
Add review suggestions
1 parent eae4865 commit 950da6d

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
@@ -4,6 +4,7 @@
44
#include "openPMD/IO/ADIOS/macros.hpp"
55
#include "openPMD/auxiliary/Environment.hpp"
66
#include "openPMD/auxiliary/Filesystem.hpp"
7+
#include "openPMD/backend/PatchRecordComponent.hpp"
78
#include "openPMD/openPMD.hpp"
89
#include <catch2/catch.hpp>
910

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

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

432+
/*
433+
* Verify that block decomposition also works in "local value" variable
434+
* shape. That shape instructs the data to participate in ADIOS2
435+
* metadata aggregation, hence there is only one "real" written block,
436+
* the aggregated one. We still need the original logical blocks to be
437+
* present in reading.
438+
*/
439+
432440
auto electrons = it0.particles["e"].particlePatches;
433441
auto numParticles = electrons["numParticles"];
434442
auto numParticlesOffset = electrons["numParticlesOffset"];
@@ -501,12 +509,40 @@ void available_chunks_test(std::string const &file_ending)
501509
{
502510
REQUIRE(ranks[i] == i);
503511
}
512+
513+
auto electrons = it0.particles["e"].particlePatches;
514+
for (PatchRecordComponent *prc :
515+
{static_cast<PatchRecordComponent *>(&electrons["numParticles"]),
516+
static_cast<PatchRecordComponent *>(
517+
&electrons["numParticlesOffset"]),
518+
&electrons["offset"]["x"],
519+
&electrons["offset"]["y"],
520+
&electrons["extent"]["z"],
521+
&electrons["offset"]["x"],
522+
&electrons["extent"]["y"],
523+
&electrons["extent"]["z"]})
524+
{
525+
auto available_chunks = prc->availableChunks();
526+
REQUIRE(size_t(r_mpi_size) == available_chunks.size());
527+
for (size_t i = 0; i < available_chunks.size(); ++i)
528+
{
529+
auto const &chunk = available_chunks[i];
530+
REQUIRE(chunk.extent == Extent{1});
531+
REQUIRE(chunk.offset == Offset{i});
532+
REQUIRE(chunk.sourceID == i);
533+
}
534+
}
504535
}
505536
}
506537

507538
TEST_CASE("available_chunks_test", "[parallel][adios]")
508539
{
540+
#if HAS_ADIOS_2_9
541+
available_chunks_test("bp4");
542+
available_chunks_test("bp5");
543+
#else
509544
available_chunks_test("bp");
545+
#endif
510546
}
511547
#endif
512548

0 commit comments

Comments
 (0)