Skip to content

Commit f8891f9

Browse files
committed
Add review suggestions
1 parent 65eb8be commit f8891f9

5 files changed

Lines changed: 59 additions & 7 deletions

File tree

examples/10_streaming_read.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ int main()
6767
for (auto const &chunk : rc.second.availableChunks())
6868
{
6969
std::cout << "\n\tRank " << chunk.sourceID << "\t"
70-
<< auxiliary::format_vec(chunk.offset) << "\t"
71-
<< auxiliary::format_vec(chunk.extent);
70+
<< auxiliary::vec_as_string(chunk.offset) << "\t"
71+
<< auxiliary::vec_as_string(chunk.extent);
7272
}
7373
std::cout << std::endl;
7474
}

include/openPMD/auxiliary/StringManip.hpp

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

246+
/** Write a string representation of a vector or another iterable
247+
* container to a stream.
248+
*
249+
* @param s The stream to write to.
250+
* @param vec The vector or other iterable container.
251+
* @return The modified stream. Each item is
252+
* formatted using the default definition for operator<<().
253+
*/
246254
template <typename Stream, typename Vec>
247255
auto write_vec_to_stream(Stream &&s, Vec const &vec) -> Stream &&
248256
{
@@ -265,6 +273,13 @@ namespace auxiliary
265273
return std::forward<Stream>(s);
266274
}
267275

276+
/** Create a string representation of a vector or another iterable
277+
* container.
278+
*
279+
* @param vec The vector or other iterable container.
280+
* @return A string that shows the items of the container. Each item is
281+
* formatted using the default definition for operator<<().
282+
*/
268283
template <typename Vec>
269284
auto vec_as_string(Vec const &vec) -> std::string
270285
{

src/IO/ADIOS/ADIOS2File.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ void WriteDataset::call(ADIOS2File &ba, detail::BufferedPut &bp)
119119
"Can only write a single element to LocalValue "
120120
"variables (extent == Extent{1}, but extent of '" +
121121
bp.name + " was " +
122-
auxiliary::format_vec(bp.param.extent) + "').");
122+
auxiliary::vec_as_string(bp.param.extent) +
123+
"').");
123124
}
124125
engine.Put(var, *ptr);
125126
}
@@ -207,7 +208,7 @@ struct RunUniquePtrPut
207208
"Can only write a single element to LocalValue "
208209
"variables (extent == Extent{1}, but extent of '" +
209210
bufferedPut.name + " was " +
210-
auxiliary::format_vec(bufferedPut.extent) + "').");
211+
auxiliary::vec_as_string(bufferedPut.extent) + "').");
211212
}
212213
engine.Put(var, *ptr);
213214
}

src/IO/ADIOS/ADIOS2IOHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ void ADIOS2IOHandlerImpl::createDataset(
944944
"Shape for local value array must be a 1D array "
945945
"equivalent to the MPI size ('" +
946946
varName + "' has shape " +
947-
auxiliary::format_vec(parameters.extent) +
947+
auxiliary::vec_as_string(parameters.extent) +
948948
", but should have shape [" +
949949
std::to_string(required_size) + "]).");
950950
}

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

@@ -387,7 +388,7 @@ void available_chunks_test(std::string const &file_ending)
387388
MPI_Comm_size(MPI_COMM_WORLD, &r_mpi_size);
388389
unsigned mpi_rank{static_cast<unsigned>(r_mpi_rank)},
389390
mpi_size{static_cast<unsigned>(r_mpi_size)};
390-
std::string name = "../samples/available_chunks." + file_ending;
391+
std::string name = "../samples/parallel_available_chunks." + file_ending;
391392

392393
/*
393394
* ADIOS2 assigns writerIDs to blocks in a BP file by id of the substream
@@ -400,7 +401,6 @@ void available_chunks_test(std::string const &file_ending)
400401
{
401402
"engine":
402403
{
403-
"type": "bp4",
404404
"parameters":
405405
{
406406
"NumAggregators":)END"
@@ -421,6 +421,14 @@ void available_chunks_test(std::string const &file_ending)
421421
E_x.resetDataset({Datatype::INT, {mpi_size, 4}});
422422
E_x.storeChunk(data, {mpi_rank, 0}, {1, 4});
423423

424+
/*
425+
* Verify that block decomposition also works in "local value" variable
426+
* shape. That shape instructs the data to participate in ADIOS2
427+
* metadata aggregation, hence there is only one "real" written block,
428+
* the aggregated one. We still need the original logical blocks to be
429+
* present in reading.
430+
*/
431+
424432
auto electrons = it0.particles["e"].particlePatches;
425433
auto numParticles = electrons["numParticles"];
426434
auto numParticlesOffset = electrons["numParticlesOffset"];
@@ -493,12 +501,40 @@ void available_chunks_test(std::string const &file_ending)
493501
{
494502
REQUIRE(ranks[i] == i);
495503
}
504+
505+
auto electrons = it0.particles["e"].particlePatches;
506+
for (PatchRecordComponent *prc :
507+
{static_cast<PatchRecordComponent *>(&electrons["numParticles"]),
508+
static_cast<PatchRecordComponent *>(
509+
&electrons["numParticlesOffset"]),
510+
&electrons["offset"]["x"],
511+
&electrons["offset"]["y"],
512+
&electrons["extent"]["z"],
513+
&electrons["offset"]["x"],
514+
&electrons["extent"]["y"],
515+
&electrons["extent"]["z"]})
516+
{
517+
auto available_chunks = prc->availableChunks();
518+
REQUIRE(size_t(r_mpi_size) == available_chunks.size());
519+
for (size_t i = 0; i < available_chunks.size(); ++i)
520+
{
521+
auto const &chunk = available_chunks[i];
522+
REQUIRE(chunk.extent == Extent{1});
523+
REQUIRE(chunk.offset == Offset{i});
524+
REQUIRE(chunk.sourceID == i);
525+
}
526+
}
496527
}
497528
}
498529

499530
TEST_CASE("available_chunks_test", "[parallel][adios]")
500531
{
532+
#if HAS_ADIOS_2_9
533+
available_chunks_test("bp4");
534+
available_chunks_test("bp5");
535+
#else
501536
available_chunks_test("bp");
537+
#endif
502538
}
503539
#endif
504540

0 commit comments

Comments
 (0)