Skip to content

Commit d53f6a7

Browse files
committed
Add review suggestions
1 parent cc65bd9 commit d53f6a7

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
@@ -120,7 +120,8 @@ void WriteDataset::call(ADIOS2File &ba, detail::BufferedPut &bp)
120120
"Can only write a single element to LocalValue "
121121
"variables (extent == Extent{1}, but extent of '" +
122122
bp.name + " was " +
123-
auxiliary::format_vec(bp.param.extent) + "').");
123+
auxiliary::vec_as_string(bp.param.extent) +
124+
"').");
124125
}
125126
engine.Put(var, *ptr);
126127
}
@@ -208,7 +209,7 @@ struct RunUniquePtrPut
208209
"Can only write a single element to LocalValue "
209210
"variables (extent == Extent{1}, but extent of '" +
210211
bufferedPut.name + " was " +
211-
auxiliary::format_vec(bufferedPut.extent) + "').");
212+
auxiliary::vec_as_string(bufferedPut.extent) + "').");
212213
}
213214
engine.Put(var, *ptr);
214215
}

src/IO/ADIOS/ADIOS2IOHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ void ADIOS2IOHandlerImpl::createDataset(
974974
"Shape for local value array must be a 1D array "
975975
"equivalent to the MPI size ('" +
976976
varName + "' has shape " +
977-
auxiliary::format_vec(parameters.extent) +
977+
auxiliary::vec_as_string(parameters.extent) +
978978
", but should have shape [" +
979979
std::to_string(required_size) + "]).");
980980
}

test/ParallelIOTest.cpp

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "openPMD/auxiliary/Environment.hpp"
1010
#include "openPMD/auxiliary/Filesystem.hpp"
1111
#include "openPMD/auxiliary/Mpi.hpp"
12+
#include "openPMD/backend/PatchRecordComponent.hpp"
1213
#include "openPMD/openPMD.hpp"
1314
// @todo change includes
1415
#include "openPMD/auxiliary/OneDimensionalBlockSlicer.hpp"
@@ -406,7 +407,7 @@ void available_chunks_test(std::string const &file_ending)
406407
MPI_Comm_size(MPI_COMM_WORLD, &r_mpi_size);
407408
unsigned mpi_rank{static_cast<unsigned>(r_mpi_rank)},
408409
mpi_size{static_cast<unsigned>(r_mpi_size)};
409-
std::string name = "../samples/available_chunks." + file_ending;
410+
std::string name = "../samples/parallel_available_chunks." + file_ending;
410411

411412
/*
412413
* ADIOS2 assigns writerIDs to blocks in a BP file by id of the substream
@@ -419,7 +420,6 @@ void available_chunks_test(std::string const &file_ending)
419420
{
420421
"engine":
421422
{
422-
"type": "bp4",
423423
"parameters":
424424
{
425425
"NumAggregators":)END"
@@ -440,6 +440,14 @@ void available_chunks_test(std::string const &file_ending)
440440
E_x.resetDataset({Datatype::INT, {mpi_size, 4}});
441441
E_x.storeChunk(data, {mpi_rank, 0}, {1, 4});
442442

443+
/*
444+
* Verify that block decomposition also works in "local value" variable
445+
* shape. That shape instructs the data to participate in ADIOS2
446+
* metadata aggregation, hence there is only one "real" written block,
447+
* the aggregated one. We still need the original logical blocks to be
448+
* present in reading.
449+
*/
450+
443451
auto electrons = it0.particles["e"].particlePatches;
444452
auto numParticles = electrons["numParticles"];
445453
auto numParticlesOffset = electrons["numParticlesOffset"];
@@ -512,12 +520,40 @@ void available_chunks_test(std::string const &file_ending)
512520
{
513521
REQUIRE(ranks[i] == i);
514522
}
523+
524+
auto electrons = it0.particles["e"].particlePatches;
525+
for (PatchRecordComponent *prc :
526+
{static_cast<PatchRecordComponent *>(&electrons["numParticles"]),
527+
static_cast<PatchRecordComponent *>(
528+
&electrons["numParticlesOffset"]),
529+
&electrons["offset"]["x"],
530+
&electrons["offset"]["y"],
531+
&electrons["extent"]["z"],
532+
&electrons["offset"]["x"],
533+
&electrons["extent"]["y"],
534+
&electrons["extent"]["z"]})
535+
{
536+
auto available_chunks = prc->availableChunks();
537+
REQUIRE(size_t(r_mpi_size) == available_chunks.size());
538+
for (size_t i = 0; i < available_chunks.size(); ++i)
539+
{
540+
auto const &chunk = available_chunks[i];
541+
REQUIRE(chunk.extent == Extent{1});
542+
REQUIRE(chunk.offset == Offset{i});
543+
REQUIRE(chunk.sourceID == i);
544+
}
545+
}
515546
}
516547
}
517548

518549
TEST_CASE("available_chunks_test", "[parallel][adios]")
519550
{
551+
#if HAS_ADIOS_2_9
552+
available_chunks_test("bp4");
553+
available_chunks_test("bp5");
554+
#else
520555
available_chunks_test("bp");
556+
#endif
521557
}
522558
#endif
523559

0 commit comments

Comments
 (0)