-
Notifications
You must be signed in to change notification settings - Fork 57
Test: Attribute Only Iterations #1916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2491,6 +2491,100 @@ | |
| } | ||
| } | ||
|
|
||
| void attributes_only_over_iterations_test( | ||
| std::string const &file_ending, IterationEncoding const it_encoding) | ||
| { | ||
| std::string name = "../samples/attributes_only_over_iterations_"; | ||
| if (it_encoding == IterationEncoding::fileBased) | ||
| name.append("f_%T"); | ||
| else if (it_encoding == IterationEncoding::groupBased) | ||
| name.append("g"); | ||
| else if (it_encoding == IterationEncoding::variableBased) | ||
| name.append("v"); | ||
| name.append(".").append(file_ending); | ||
| std::cout << name << std::endl; | ||
|
|
||
| constexpr uint64_t numberOfIterations = 3; | ||
|
|
||
| /* | ||
| * Write iterations that contain ONLY attributes: no meshes, no particles, | ||
| * no datasets. A Series-level attribute stays constant, while a | ||
| * per-iteration attribute varies over the iterations. | ||
| */ | ||
| { | ||
| Series write(name, Access::CREATE); | ||
| write.setIterationEncoding(it_encoding); | ||
|
|
||
| write.setAttribute( | ||
| "constantSeriesAttribute", std::string("attributes-only")); | ||
|
|
||
| auto iterations = write.writeIterations(); | ||
| for (uint64_t i = 0; i < numberOfIterations; ++i) | ||
| { | ||
| auto it = iterations[i]; | ||
| it.setAttribute("varyingIterationAttribute", i * 10); | ||
| it.close(); | ||
| } | ||
| write.close(); | ||
| } | ||
|
|
||
| /* | ||
| * Read the attributes back and verify that the per-iteration attribute | ||
| * carries the value written for its iteration. | ||
| */ | ||
| { | ||
| Series read(name, Access::READ_ONLY); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the parsing procedures for Series read(name, Access::READ_LINEAR);
read.parseBase(); |
||
|
|
||
| REQUIRE( | ||
| read.getAttribute("constantSeriesAttribute").get<std::string>() == | ||
| "attributes-only"); | ||
|
|
||
| uint64_t iterationsRead = 0; | ||
| for (auto const &iteration : read.readIterations()) | ||
| { | ||
| uint64_t const idx = iteration.iterationIndex; | ||
| REQUIRE( | ||
| iteration.getAttribute("varyingIterationAttribute") | ||
| .get<uint64_t>() == idx * 10); | ||
| ++iterationsRead; | ||
| } | ||
| REQUIRE(iterationsRead == numberOfIterations); | ||
| read.close(); | ||
| } | ||
| } | ||
|
|
||
| TEST_CASE("attributes_only_over_iterations_test", "[serial]") | ||
Check noticeCode scanning / CodeQL Unused static function Note test
Static function CATCH2_INTERNAL_TEST_40 is unreachable (
autoRegistrar41 Error loading related location Loading |
||
|
|
||
| { | ||
| for (auto const &t : testedFileExtensions()) | ||
| { | ||
| // ADIOS2 file endings all start with "bp" (bp, bp4, ...) | ||
| bool const isADIOS2 = t.size() >= 2 && t.substr(0, 2) == "bp"; | ||
|
|
||
| // fileBased encoding: all backends | ||
| attributes_only_over_iterations_test(t, IterationEncoding::fileBased); | ||
|
|
||
| if (isADIOS2) | ||
| { | ||
| // ADIOS2 encodings: variableBased (groupBased skipped as | ||
| // requested). variableBased maps each iteration to one ADIOS2 | ||
| // step. An iteration that holds only attributes is an | ||
| // attribute-only step, which only BP5 records as a distinct step; | ||
| // BP4 materializes a step only when variable data is written and | ||
| // therefore collapses attribute-only steps, so it is skipped here. | ||
| if (t != "bp4") | ||
| attributes_only_over_iterations_test( | ||
| t, IterationEncoding::variableBased); | ||
| } | ||
| else | ||
| { | ||
| // Non-ADIOS2 backends support groupBased. Multi-iteration | ||
| // variableBased encoding requires IO steps and is ADIOS2-only. | ||
| attributes_only_over_iterations_test( | ||
| t, IterationEncoding::groupBased); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| inline void patch_test(const std::string &backend) | ||
| { | ||
| Series o = | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move new test code to separate files under test/Files_SerialIO
to not blow upSerialIOTests.cpp` further :)