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
@@ -375,7 +376,7 @@ void available_chunks_test(std::string const &file_ending)
375376 MPI_Comm_size (MPI_COMM_WORLD, &r_mpi_size);
376377 unsigned mpi_rank{static_cast <unsigned >(r_mpi_rank)},
377378 mpi_size{static_cast <unsigned >(r_mpi_size)};
378- std::string name = " ../samples/available_chunks ." + file_ending;
379+ std::string name = " ../samples/parallel_available_chunks ." + file_ending;
379380
380381 /*
381382 * ADIOS2 assigns writerIDs to blocks in a BP file by id of the substream
@@ -388,7 +389,6 @@ void available_chunks_test(std::string const &file_ending)
388389 {
389390 "engine":
390391 {
391- "type": "bp4",
392392 "parameters":
393393 {
394394 "NumAggregators":)END"
@@ -409,6 +409,14 @@ void available_chunks_test(std::string const &file_ending)
409409 E_x.resetDataset ({Datatype::INT, {mpi_size, 4 }});
410410 E_x.storeChunk (data, {mpi_rank, 0 }, {1 , 4 });
411411
412+ /*
413+ * Verify that block decomposition also works in "local value" variable
414+ * shape. That shape instructs the data to participate in ADIOS2
415+ * metadata aggregation, hence there is only one "real" written block,
416+ * the aggregated one. We still need the original logical blocks to be
417+ * present in reading.
418+ */
419+
412420 auto electrons = it0.particles [" e" ].particlePatches ;
413421 auto numParticles = electrons[" numParticles" ];
414422 auto numParticlesOffset = electrons[" numParticlesOffset" ];
@@ -481,12 +489,40 @@ void available_chunks_test(std::string const &file_ending)
481489 {
482490 REQUIRE (ranks[i] == i);
483491 }
492+
493+ auto electrons = it0.particles [" e" ].particlePatches ;
494+ for (PatchRecordComponent *prc :
495+ {static_cast <PatchRecordComponent *>(&electrons[" numParticles" ]),
496+ static_cast <PatchRecordComponent *>(
497+ &electrons[" numParticlesOffset" ]),
498+ &electrons[" offset" ][" x" ],
499+ &electrons[" offset" ][" y" ],
500+ &electrons[" extent" ][" z" ],
501+ &electrons[" offset" ][" x" ],
502+ &electrons[" extent" ][" y" ],
503+ &electrons[" extent" ][" z" ]})
504+ {
505+ auto available_chunks = prc->availableChunks ();
506+ REQUIRE (size_t (r_mpi_size) == available_chunks.size ());
507+ for (size_t i = 0 ; i < available_chunks.size (); ++i)
508+ {
509+ auto const &chunk = available_chunks[i];
510+ REQUIRE (chunk.extent == Extent{1 });
511+ REQUIRE (chunk.offset == Offset{i});
512+ REQUIRE (chunk.sourceID == i);
513+ }
514+ }
484515 }
485516}
486517
487518TEST_CASE (" available_chunks_test" , " [parallel][adios]" )
488519{
520+ #if HAS_ADIOS_2_9
521+ available_chunks_test (" bp4" );
522+ available_chunks_test (" bp5" );
523+ #else
489524 available_chunks_test (" bp" );
525+ #endif
490526}
491527#endif
492528
0 commit comments