Add functionality to print fields in list format.#506
Conversation
There was a problem hiding this comment.
Nice work, no comments on the print function. Only the BareField function perhaps needs some additional doc, see below.
Please also add a quick unit test for the os << BareField operator you added. Just a small 2x2 field that you fill with some values, print and then compare the printed string to the expected string is probably enough. Can be appended to unit_tests/BareField/BareField.cpp.
|
Should be ready for the final review and merge. |
aliemen
left a comment
There was a problem hiding this comment.
Test looks good, but I believe the more-than-2-ranks skip is in the wrong place.
|
cscs-ci run cscs-ci-gh200, cscs-ci-mi300, cscs-ci-openmp |
|
cscs-ci run cscs-ci-gh200, cscs-ci-mi300, cscs-ci-openmp |
aliemen
left a comment
There was a problem hiding this comment.
Looks good now. There is a std::cout call that's technically not good in mpi programs, but not a problem here since tests are evaluated with the string stream anyways.
|
Something is failing here ... |
aaadelmann
left a comment
There was a problem hiding this comment.
Tests must pass then I can approve
…_in_list_format' into feature_write_field_in_list_format
There was a problem hiding this comment.
I think I know what the error is, it's probably a GPU template bug and ViewArgs are not propagated correctly. On GH200 compilation I get the following errors:
- Incompatible View copy construction
- View assignment must have compatible spaces
- View assignment must have compatible layout or have rank <= 1
Basically when passing the Kokkos::View<T**, Kokkos::LayoutRight, ExecSpace> view to BareField<T, Dim, ViewArgs...>::write_as_list, it wants to call detail::write_as_list<T, Dim>(dview_m, out);, but the latter one resolves to/expects const typename ViewType<T, Dim>::view_type& view.
...which is effectively Kokkos ::View<T**> with default layout/space. But dview_m is Kokkos ::View<T**, Kokkos::LayoutRight, ExecSpace>, so Kokkos tries an incompatible view conversion.
I think a quick fix is calling detail::write_as_list<T, Dim, ViewArgs...>(dview_m, out); instead. Alternatively, template detail::write_as_list directly on the view with e.g. template <typename View>.
|
Templating directly on the view would be better, but that should be done consistently for all functions in |
For debugging, a feature to print fields in python list or C++ initializer_list compatible format is needed.
e.g.
[[0, 1], [2, 3]]This adds it.