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

[REVIEW] mdspan-ify rmat_rectangular_gen #833

Merged

Conversation

mhoemmen
Copy link
Contributor

@mhoemmen mhoemmen commented Sep 20, 2022

I added two overloads of rmat_rectangular_gen, one for each of the existing overloads, that take device mdspan instead of raw arrays. I've added a unit test that imitates the existing unit test for the raw-array overloads; it builds and passes.

I also opportunistically fixed some unrelated existing small build errors that were blocking forward progress.

@mhoemmen mhoemmen requested a review from a team as a code owner September 20, 2022 21:49
@github-actions github-actions bot added the cpp label Sep 20, 2022
@mhoemmen mhoemmen added feature request New feature or request non-breaking Non-breaking change cpp and removed cpp labels Sep 20, 2022
@mhoemmen mhoemmen force-pushed the mdspanify-rmat_rectangular_gen branch from 039a3b1 to 1f54a42 Compare September 20, 2022 21:51
@mhoemmen mhoemmen changed the title mdspan-ify rmat_rectangular_gen [WIP] mdspan-ify rmat_rectangular_gen Sep 21, 2022
@mhoemmen mhoemmen changed the title [WIP] mdspan-ify rmat_rectangular_gen [REVIEW] mdspan-ify rmat_rectangular_gen Sep 21, 2022
I added two mdspan overloads of rmat_rectangular_gen,
each corresponding to one of the existing overloads.
I also added tests for the two overloads.
Both tests build and pass.
Fix order of parameters (handle, RngState, in, out, params).

Remove redundancy in documentation, and make it clear
that the mdspan overloads are favored
and the raw array overloads are legacy.
@mhoemmen mhoemmen force-pushed the mdspanify-rmat_rectangular_gen branch from aa09e62 to fe9a454 Compare September 22, 2022 17:32
Copy link
Member

@cjnolet cjnolet left a comment

Choose a reason for hiding this comment

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

Looking good so far. Fairly minor things as usual

cpp/include/raft/random/rmat_rectangular_generator.cuh Outdated Show resolved Hide resolved
cpp/include/raft/random/rmat_rectangular_generator.cuh Outdated Show resolved Hide resolved
cpp/include/raft/random/rmat_rectangular_generator.cuh Outdated Show resolved Hide resolved
cpp/include/raft/random/rmat_rectangular_generator.cuh Outdated Show resolved Hide resolved
rapids-bot bot pushed a commit that referenced this pull request Sep 23, 2022
I added an overload of `raft::random::permute` that takes device mdspan instead of raw arrays, and `std::optional<mdspan<...>>` for optional output arrays.  I also added two overloads that let users pass in `std::nullopt`.

I've added a unit test that imitates the existing unit test for the raw-array overloads; it builds and passes.  The test ensures that the two `std::nullopt` overloads also compile.

I also opportunistically fixed some unrelated existing small build errors that were blocking forward progress.  That commit is included in PRs #830 and #833 as well, so if it merges, the change should rebase correctly.

Authors:
  - Mark Hoemmen (https://github.com/mhoemmen)

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

URL: #834
1. Validate sizes of output arrays (if provided)

2. Remove n_edges parameter, since it can be inferred
   from the output arrays (if provided)

3. Express the idea that the raw pointers interface
   currently lets users provide either out,
   (out_src and out_dst), or (out, out_src, and out_dst).
   Make users pass in the mdspan in a way that
   prevents run-time errors as early as possible.
@mhoemmen mhoemmen force-pushed the mdspanify-rmat_rectangular_gen branch from f63415f to 0ca5c55 Compare September 23, 2022 23:03
Copy link
Member

@cjnolet cjnolet left a comment

Choose a reason for hiding this comment

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

Once again, thanks for these changes! I keep going back and forth about the added complexity of the additional class vs the oversimplification of just providing more overloads. I really haven't come to a good resolution in my head yet about it so I'm definitely okay deferring your thoughts and opinions there.

If we do go the route of the additional class, though, we should move it out into its own _types.hpp file.

cpp/include/raft/random/rmat_rectangular_generator.cuh Outdated Show resolved Hide resolved
Instead of consolidating overloads by using
rmat_rectangular_gen_output, introduce an overload
for each of the three cases of output
(1, 2, or 3 output vectors).
Copy link
Member

@cjnolet cjnolet left a comment

Choose a reason for hiding this comment

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

Looks great, Mark. Thanks again!

Address review feedback by moving the helper class
rmat_rectangular_generator_output into a new separate header.

Remove rmat_rectangular_generator_output's nullopt_t case,
as it's no longer possible for users to reach that case.
@mhoemmen
Copy link
Contributor Author

@cjnolet wrote:

If we do go the route of the additional class, though, we should move it out into its own _types.hpp file.

I just moved it into its own new header file in raft/random/detail.

The class does add complexity, but it's nice to consolidate all the error code in one place. With a bit more cleverness later, we could reduce code duplication in the class' member functions by using std::visit with an auto lambda.

@cjnolet
Copy link
Member

cjnolet commented Sep 27, 2022

Sounds great. Let me know when you are ready for this to go in and I'll merge it over

@mhoemmen
Copy link
Contributor Author

@cjnolet wrote:

Sounds great. Let me know when you are ready for this to go in and I'll merge it over

It's ready to merge now -- thanks! : - D

@cjnolet
Copy link
Member

cjnolet commented Sep 27, 2022

@gpucibot merge

1 similar comment
@cjnolet
Copy link
Member

cjnolet commented Sep 27, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit faa4d9d into rapidsai:branch-22.10 Sep 27, 2022
@mhoemmen mhoemmen deleted the mdspanify-rmat_rectangular_gen branch September 27, 2022 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp feature request New feature or request non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants