@@ -421,13 +421,42 @@ void available_chunks_test(std::string const &file_ending)
421421}
422422)END" ;
423423
424- std::vector<int > data{2 , 4 , 6 , 8 };
424+ std::vector<int > xdata{2 , 4 , 6 , 8 };
425+ std::vector<int > ydata{0 , 0 , 0 , 0 , 0 , //
426+ 0 , 1 , 2 , 3 , 0 , //
427+ 0 , 4 , 5 , 6 , 0 , //
428+ 0 , 7 , 8 , 9 , 0 , //
429+ 0 , 0 , 0 , 0 , 0 };
430+ std::vector<int > ydata_firstandlastrow{-1 , -1 , -1 };
425431 {
426432 Series write (name, Access::CREATE, MPI_COMM_WORLD, parameters.str ());
427433 Iteration it0 = write.iterations [0 ];
428434 auto E_x = it0.meshes [" E" ][" x" ];
429435 E_x.resetDataset ({Datatype::INT, {mpi_size, 4 }});
430- E_x.storeChunk (data, {mpi_rank, 0 }, {1 , 4 });
436+ E_x.storeChunk (xdata, {mpi_rank, 0 }, {1 , 4 });
437+ auto E_y = it0.meshes [" E" ][" y" ];
438+ E_y.resetDataset ({Datatype::INT, {5 , 3ul * mpi_size}});
439+ E_y.prepareStoreChunk ()
440+ .fromContiguousContainer (ydata_firstandlastrow)
441+ .offset ({0 , 3ul * mpi_rank})
442+ .extent ({1 , 3 })
443+ .enqueue ();
444+ E_y.prepareStoreChunk ()
445+ .offset ({1 , 3ul * mpi_rank})
446+ .extent ({3 , 3 })
447+ .fromContiguousContainer (ydata)
448+ .memorySelection ({{1 , 1 }, {5 , 5 }})
449+ .enqueue ();
450+ // if condition checks if this PR is available in ADIOS2:
451+ // https://github.com/ornladios/ADIOS2/pull/4169
452+ if constexpr (CanTheMemorySelectionBeReset)
453+ {
454+ E_y.prepareStoreChunk ()
455+ .fromContiguousContainer (ydata_firstandlastrow)
456+ .offset ({4 , 3ul * mpi_rank})
457+ .extent ({1 , 3 })
458+ .enqueue ();
459+ }
431460 it0.close ();
432461 }
433462
@@ -459,6 +488,36 @@ void available_chunks_test(std::string const &file_ending)
459488 {
460489 REQUIRE (ranks[i] == i);
461490 }
491+
492+ auto E_y = it0.meshes [" E" ][" y" ];
493+ auto width = E_y.getExtent ()[1 ];
494+ auto first_row = E_y.loadChunk <int >({0 , 0 }, {1 , width});
495+ auto middle_rows = E_y.loadChunk <int >({1 , 0 }, {3 , width});
496+ auto last_row = E_y.loadChunk <int >({4 , 0 }, {1 , width});
497+ read.flush ();
498+
499+ for (auto row : [&]() -> std::vector<std::shared_ptr<int > *> {
500+ if constexpr (CanTheMemorySelectionBeReset)
501+ {
502+ return {&first_row, &last_row};
503+ }
504+ else
505+ {
506+ return {&first_row};
507+ }
508+ }())
509+ {
510+ for (size_t i = 0 ; i < width; ++i)
511+ {
512+ REQUIRE (row->get ()[i] == -1 );
513+ }
514+ }
515+ for (size_t i = 0 ; i < width * 3 ; ++i)
516+ {
517+ size_t row = i / width;
518+ int required_value = row * 3 + (i % 3 ) + 1 ;
519+ REQUIRE (middle_rows.get ()[i] == required_value);
520+ }
462521 }
463522}
464523
0 commit comments