Skip to content

Commit 2c771b6

Browse files
committed
Testing
1 parent eb88851 commit 2c771b6

File tree

2 files changed

+82
-9
lines changed

2 files changed

+82
-9
lines changed

test/ParallelIOTest.cpp

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,42 @@ void available_chunks_test(std::string const &file_ending)
413413
}
414414
)END";
415415

416-
std::vector<int> data{2, 4, 6, 8};
416+
std::vector<int> xdata{2, 4, 6, 8};
417+
std::vector<int> ydata{0, 0, 0, 0, 0, //
418+
0, 1, 2, 3, 0, //
419+
0, 4, 5, 6, 0, //
420+
0, 7, 8, 9, 0, //
421+
0, 0, 0, 0, 0};
422+
std::vector<int> ydata_firstandlastrow{-1, -1, -1};
417423
{
418424
Series write(name, Access::CREATE, MPI_COMM_WORLD, parameters.str());
419425
Iteration it0 = write.iterations[0];
420426
auto E_x = it0.meshes["E"]["x"];
421427
E_x.resetDataset({Datatype::INT, {mpi_size, 4}});
422-
E_x.storeChunk(data, {mpi_rank, 0}, {1, 4});
428+
E_x.storeChunk(xdata, {mpi_rank, 0}, {1, 4});
429+
auto E_y = it0.meshes["E"]["y"];
430+
E_y.resetDataset({Datatype::INT, {5, 3ul * mpi_size}});
431+
E_y.prepareLoadStore()
432+
.withContiguousContainer(ydata_firstandlastrow)
433+
.offset({0, 3ul * mpi_rank})
434+
.extent({1, 3})
435+
.enqueueStore();
436+
E_y.prepareLoadStore()
437+
.offset({1, 3ul * mpi_rank})
438+
.extent({3, 3})
439+
.withContiguousContainer(ydata)
440+
.memorySelection({{1, 1}, {5, 5}})
441+
.enqueueStore();
442+
// if condition checks if this PR is available in ADIOS2:
443+
// https://github.com/ornladios/ADIOS2/pull/4169
444+
if constexpr (CanTheMemorySelectionBeReset)
445+
{
446+
E_y.prepareLoadStore()
447+
.withContiguousContainer(ydata_firstandlastrow)
448+
.offset({4, 3ul * mpi_rank})
449+
.extent({1, 3})
450+
.enqueueStore();
451+
}
423452
it0.close();
424453
}
425454

@@ -451,6 +480,42 @@ void available_chunks_test(std::string const &file_ending)
451480
{
452481
REQUIRE(ranks[i] == i);
453482
}
483+
484+
auto E_y = it0.meshes["E"]["y"];
485+
auto width = E_y.getExtent()[1];
486+
auto first_row =
487+
E_y.prepareLoadStore().extent({1, width}).enqueueLoad<int>().get();
488+
auto middle_rows = E_y.prepareLoadStore()
489+
.offset({1, 0})
490+
.extent({3, width})
491+
.enqueueLoad<int>()
492+
.get();
493+
auto last_row =
494+
E_y.prepareLoadStore().offset({4, 0}).enqueueLoad<int>().get();
495+
read.flush();
496+
497+
for (auto row : [&]() -> std::vector<std::shared_ptr<int> *> {
498+
if constexpr (CanTheMemorySelectionBeReset)
499+
{
500+
return {&first_row, &last_row};
501+
}
502+
else
503+
{
504+
return {&first_row};
505+
}
506+
}())
507+
{
508+
for (size_t i = 0; i < width; ++i)
509+
{
510+
REQUIRE(row->get()[i] == -1);
511+
}
512+
}
513+
for (size_t i = 0; i < width * 3; ++i)
514+
{
515+
size_t row = i / width;
516+
int required_value = row * 3 + (i % 3) + 1;
517+
REQUIRE(middle_rows.get()[i] == required_value);
518+
}
454519
}
455520
}
456521

test/SerialIOTest.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,11 @@ inline void constant_scalar(std::string const &file_ending)
913913
new unsigned int[6], [](unsigned int const *p) { delete[] p; });
914914
unsigned int e{0};
915915
std::generate(E.get(), E.get() + 6, [&e] { return e++; });
916-
E_y.storeChunk(std::move(E), {0, 0, 0}, {1, 2, 3});
916+
// check that const-type unique pointers work in the builder pattern
917+
E_y.prepareLoadStore()
918+
.extent({1, 2, 3})
919+
.withUniquePtr(std::move(E).static_cast_<unsigned int const>())
920+
.enqueueStore();
917921

918922
// store a number of predefined attributes in E
919923
Mesh &E_mesh = s.snapshots()[1].meshes["E"];
@@ -1724,13 +1728,17 @@ inline void write_test(
17241728
auto opaqueTypeDataset = rc.visit<ReadFromAnyType>();
17251729

17261730
auto variantTypeDataset = rc.loadChunkVariant();
1731+
auto variantTypeDataset2 = rc.prepareLoadStore().enqueueLoadVariant().get();
17271732
rc.seriesFlush();
1728-
std::visit(
1729-
[](auto &&shared_ptr) {
1730-
std::cout << "First value in loaded chunk: '" << shared_ptr.get()[0]
1731-
<< '\'' << std::endl;
1732-
},
1733-
variantTypeDataset);
1733+
for (auto ptr : {&variantTypeDataset, &variantTypeDataset2})
1734+
{
1735+
std::visit(
1736+
[](auto &&shared_ptr) {
1737+
std::cout << "First value in loaded chunk: '"
1738+
<< shared_ptr.get()[0] << '\'' << std::endl;
1739+
},
1740+
*ptr);
1741+
}
17341742

17351743
#ifndef _WIN32
17361744
if (test_rank_table)

0 commit comments

Comments
 (0)