Skip to content
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

Simple segmented ranges #1601

Merged
merged 10 commits into from
Aug 8, 2024
Merged

Simple segmented ranges #1601

merged 10 commits into from
Aug 8, 2024

Conversation

upsj
Copy link
Member

@upsj upsj commented Apr 29, 2024

This removes all stride support from #1582, which removes most of the heavy iterator functionality added in the other PR.
It relies on zip_iterator to provide both enumerating
for (auto [nonzero_index, column, value] : matrix.enumerated()[row]) and non-enumerating
for (auto [column, value] : matrix[row]) iteration through a matrix, and uses pairs of pointers to represent ranges of column indices or values.
The two commits add the baseline first and C++17 structured binding support second.

TODO

@upsj upsj added the 1:ST:ready-for-review This PR is ready for review label Apr 29, 2024
@upsj upsj requested a review from a team April 29, 2024 09:53
@upsj upsj self-assigned this Apr 29, 2024
@ginkgo-bot ginkgo-bot added reg:build This is related to the build system. reg:testing This is related to testing. mod:core This is related to the core module. labels Apr 29, 2024
@upsj upsj mentioned this pull request Apr 29, 2024
@upsj upsj changed the base branch from develop to irange April 29, 2024 10:22
@MarcelKoch
Copy link
Member

First up, the zip iterator also need to be made constexpr for this to work on the device.

Copy link
Member

@MarcelKoch MarcelKoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks a lot cleaner than the old PR, thanks for that. I have mostly smaller remarks, the biggest issue is the zip_iterator which is not available on the device. Maybe it would be possible to use different types for the zip_iterator depending on the backend.

core/base/segmented_range.hpp Outdated Show resolved Hide resolved
core/base/segmented_range.hpp Outdated Show resolved Hide resolved
core/base/segmented_range.hpp Outdated Show resolved Hide resolved
core/base/segmented_range.hpp Outdated Show resolved Hide resolved
core/base/segmented_range.hpp Show resolved Hide resolved
core/test/base/segmented_range.cpp Outdated Show resolved Hide resolved
core/test/base/segmented_range.cpp Show resolved Hide resolved
core/test/base/segmented_range.cpp Show resolved Hide resolved
Base automatically changed from irange to develop April 29, 2024 20:05
@upsj upsj force-pushed the simple_segmented_ranges branch from 4b9a6cd to 03a95bf Compare May 1, 2024 11:33
@upsj upsj requested a review from MarcelKoch May 1, 2024 11:33
@upsj upsj force-pushed the simple_segmented_ranges branch from 6b2393e to 86218ce Compare May 1, 2024 13:46
@upsj upsj changed the base branch from develop to device_zip_iterator May 1, 2024 13:46
@upsj upsj force-pushed the simple_segmented_ranges branch from 86218ce to e94ad77 Compare May 1, 2024 15:37
@tcojean tcojean added this to the Ginkgo 1.9.0 milestone May 3, 2024
@upsj upsj force-pushed the device_zip_iterator branch 2 times, most recently from b22f9fe to 76dd812 Compare July 8, 2024 22:09
@upsj upsj force-pushed the simple_segmented_ranges branch from 758f690 to cddc108 Compare July 8, 2024 22:12
Comment on lines +42 to +44
index_type index;
segment_type segment;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do find the naming a bit confusing. I think index is the index of the segment, and not an index of the range. And segment is not the index of the segment, but a full range by itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "entries" of a segmented range are segments, and enumerating them you get a segment index and segment value back. Do you have a suggestion how to make this more clear through naming?

core/base/segmented_range.hpp Outdated Show resolved Hide resolved
core/base/segmented_range.hpp Show resolved Hide resolved
* @tparam ValueIterator the iterator type pointing to the values.
*/
template <typename IndexType, typename ValueIterator>
class segmented_value_range {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering a bit how this will work out with the device_segmented_array and device implementations of our classes in general.
In principle, device_segmented_array could be replaced directly by this. One thing I would not like about that is that the device_segmented_array basically consists only of data members, and in general I would prefer our device implementations to not have member functions. (My reason for that is that I want to generalize the device implementations so that they can be directly exposed to kokkos or similar.)
So right now, I would imagine conversion functions and having some redundancy, instead of replacing device_segmented_array.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is a heavy restriction. Is there a reason why having no member functions is necessary to expose these directly to kokkos ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary. But I would prefer to not provide methods, as I'm not sure if they would also be available in Kokkos code. I guess they would be, since this can run on the GPU, but I would still be a bit hesitant.

Base automatically changed from device_zip_iterator to develop July 11, 2024 20:54
@upsj upsj mentioned this pull request Jul 15, 2024
3 tasks
Copy link
Member

@pratikvn pratikvn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

* @tparam ValueIterator the iterator type pointing to the values.
*/
template <typename IndexType, typename ValueIterator>
class segmented_value_range {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is a heavy restriction. Is there a reason why having no member functions is necessary to expose these directly to kokkos ?

@upsj upsj added 1:ST:ready-to-merge This PR is ready to merge. and removed 1:ST:ready-for-review This PR is ready for review labels Aug 1, 2024
@upsj upsj added the 1:ST:no-changelog-entry Skip the wiki check for changelog update label Aug 8, 2024
@upsj upsj merged commit 1307007 into develop Aug 8, 2024
10 of 14 checks passed
@upsj upsj deleted the simple_segmented_ranges branch August 8, 2024 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1:ST:no-changelog-entry Skip the wiki check for changelog update 1:ST:ready-to-merge This PR is ready to merge. mod:core This is related to the core module. reg:build This is related to the build system. reg:testing This is related to testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants