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

[Opt] Expose the detail::popc as public API #2346

Merged
merged 4 commits into from
Jul 24, 2024

Conversation

rhdong
Copy link
Member

@rhdong rhdong commented May 30, 2024

@rhdong rhdong requested a review from cjnolet May 30, 2024 21:58
@rhdong rhdong requested review from a team as code owners May 30, 2024 21:58
* @param[out] counter Device scalar view to store the number of bits that are set to 1.
*/
template <typename value_t, typename index_t>
void popc(const raft::resources& res,
Copy link
Member

Choose a reason for hiding this comment

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

To be quite honest, I'm not sure this is something that belongs in raft::core.

Also, I'm a little confused by the max_len- can you explain why this additional argument is needed? This API seems a little implementation-specific, which makes me wonder if it should be more strongly coupled to the bitset/bitmap.

Copy link
Member Author

@rhdong rhdong May 31, 2024

Choose a reason for hiding this comment

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

The original wrap of popc is here: https://github.com/rapidsai/raft/blob/branch-24.08/cpp/include/raft/core/detail/mdspan_util.cuh#L48. But it can only calc nonzero bits in one int32/int64, while this one can calculate on an integer array. Would you have some recommendations on the namespace? Maybe the raft::linalg is another choice.

The max_len should be required to indicate the max bits to be processed. For example, we have 100 bits needed to be calculated and at least 4 uint32_ts to present them(get 128 bits physically). In this situation, a max_len or similar parameter is needed to tell the popc to stop on the right bits.

Copy link
Member Author

Choose a reason for hiding this comment

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

This API is mainly for clean code. The detail::popc includes at least 10 lines of code because it has to process the corner cases. If we were using the original code, we would have to copy that block of code anywhere, that is ugly.

Copy link
Member

Choose a reason for hiding this comment

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

Since this is a computational function, I don't think it belongs in raft/core. I question whether or not it actually belongs in raft/matrix or in raft/utils, though. Hmm.

Copy link
Member Author

@rhdong rhdong Jul 2, 2024

Choose a reason for hiding this comment

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

I prefer raft/utils as it seems more reasonable. If you agree, I will move it there. @cjnolet

@rhdong rhdong added enhancement New feature or request 3 - Ready for Review Public API non-breaking Non-breaking change 4 - Waiting on Reviewer Waiting for reviewer to review or respond feature request New feature or request and removed cpp CMake 4 - Waiting on Reviewer Waiting for reviewer to review or respond labels May 31, 2024
@rhdong rhdong requested a review from cjnolet July 3, 2024 16:45
@cjnolet
Copy link
Member

cjnolet commented Jul 24, 2024

/merge

@rapids-bot rapids-bot bot merged commit fa7c193 into rapidsai:branch-24.08 Jul 24, 2024
69 checks passed
@divyegala divyegala added breaking Breaking change and removed non-breaking Non-breaking change labels Jul 24, 2024
rapids-bot bot pushed a commit to rapidsai/cuvs that referenced this pull request Jul 26, 2024
rapidsai/raft#2346 introduced a breaking change in the API. This PR fixes the API usage.

Authors:
  - Divye Gala (https://github.com/divyegala)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #249
divyegala added a commit to divyegala/cuvs that referenced this pull request Jul 31, 2024
rapidsai/raft#2346 introduced a breaking change in the API. This PR fixes the API usage.

Authors:
  - Divye Gala (https://github.com/divyegala)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)

URL: rapidsai#249
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants