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

[FEA] Replace defaulted stream value in libcudf APIs with cudf::cuda_default_stream #10864

Closed
jrhemstad opened this issue May 16, 2022 · 8 comments · Fixed by #11082
Closed
Labels
feature request New feature or request libcudf Affects libcudf (C++/CUDA) code.

Comments

@jrhemstad
Copy link
Contributor

jrhemstad commented May 16, 2022

Is your feature request related to a problem? Please describe.

libcudf public APIs do not current expose CUDA stream arguments (#925).

However, every public API internally invokes a corresponding detail:: API that has a rmm::cuda_stream_view parameter defaulted to rmm::cuda_stream_default.

I would like to be able to globally control this default value at the scope of libcudf (meaning, not changing it at the RMM level which could be much broader).

Describe the solution you'd like

Add a global cudf::cuda_default_stream much like the rmm::cuda_default_stream
and replace every use of rmm::cuda:default_stream with cudf::cuda_default_stream.

Furthermore, I would like the value of this cudf::cuda_default_stream to depend on the CUDF_USE_PER_THREAD_DEFAULT_STREAM option.

namespace cudf{
#if define(CUDF_USE_PER_THREAD_DEFAULT_STREAM)
   static constexpr rmm::cuda_stream_view cuda_default_stream{rmm::cuda_stream_per_thread};
#else
   static constexpr rmm::cuda_stream_view cuda_default_stream{};
#endif
}

Additional Context

I explicitly made the configuration of cuda_default_stream's value depend on the cudf specific CUDF_USE_PER_THREAD_DEFAULT_STREAM option instead of the CUDA_API_PER_THREAD_DEFAULT_STREAMoption even though the former implies the latter.

This is to minimize potential astonishment. If someone were to compile libcudf manually using --default-stream per-thread they would not expect the behavior described above. The behavior above requires opting in explicitly through the cudf specific option.

@jbrennan333
Copy link
Contributor

In terms of the build process, would this still be keyed off of PER_THREAD_DEFAULT_STREAM?
That is, will we define both CUDA_API_PER_THREAD_DEFAULT_STREAM and CUDF_USE_PER_THREAD_DEFAULT_STREAM when PER_THREAD_DEFAULT_STREAM=ON?

@jrhemstad
Copy link
Contributor Author

jrhemstad commented May 16, 2022

In terms of the build process, would this still be keyed off of PER_THREAD_DEFAULT_STREAM? That is, will we define both CUDA_API_PER_THREAD_DEFAULT_STREAM and CUDF_USE_PER_THREAD_DEFAULT_STREAM when PER_THREAD_DEFAULT_STREAM=ON?

See #10862

TL;DR

CUDF_USE_PER_THREAD_DEFAULT_STREAM replaces PER_THREAD_DEFAULT_STREAM and implies CUDA_API_PER_THREAD_DEFAULT_STREAM.

@jbrennan333
Copy link
Contributor

Clarification: The rmm name is rmm::cuda_stream_default. I'm assuming we want the new default to be cudf::cuda_stream_default, to match the rmm value, not cudf::cuda_default_stream?

@jrhemstad
Copy link
Contributor Author

Clarification: The rmm name is rmm::cuda_stream_default. I'm assuming we want the new default to be cudf::cuda_stream_default, to match the rmm value, not cudf::cuda_default_stream?

I was actually considering an alternative that would perhaps be less ambiguous.

"default stream" is ambiguous because it could mean "The CUDA default stream" or "the default value of the stream parameter in every function". Really, we want the latter. It's a subtle and pedantic difference, but one I think that is important.

Therefore, something like cudf::default_stream_value appeals to me for being more explicit about what it means. Or even cudf::defaulted_stream_value.

@jbrennan333
Copy link
Contributor

Thanks @jrhemstad!

@jbrennan333
Copy link
Contributor

I put up PR #10877 for this. It only replaces rmm::cuda_stream_default in the cases that impact nvcomp.
Will need to follow up to change the rest.

rapids-bot bot pushed a commit that referenced this issue May 24, 2022
This PR addresses #10862, but does not completely remove `PER_THREAD_DEFAULT_STREAM`.   I just adds the new define `CUDF_USE_PER_THREAD_DEFAULT_STREAM` and adds a deprecation warning for `PER_THREAD_DEFAULT_STREAM`.

This PR also addresses #10864, but only changes the default parameter for `read_avro` and `read_parquet` to `cudf::default_stream_value`, which is defined as `rmm::cuda_stream_per_thread` when `CUDF_USE_PER_THREAD_DEFAULT_STREAM` is defined.  These cover the current interfaces to nvcomp.

The goal for this PR is to ensure that we pass `rmm::cuda_stream_per_thread` to the nvcomp apis when `CUDF_USE_PER_THREAD_DEFAULT_STREAM` is defined.  This is needed for nvcomp-2.3, which is provided as dynamic libraries where we cannot recompile with PTDS enabled.  nvcomp-2.3 is being enabled in #10851.

I have not marked this PR as closing the above issues, because we will need to follow up in a future PR to remove  `PER_THREAD_DEFAULT_STREAM` and in another to replace all of the rest of the cuDF API call sites to use the new `cudf::default_stream_value`.

i am putting this up as a draft PR because I have not tested with nvcomp-2.3 yet.

Authors:
  - Jim Brennan (https://github.com/jbrennan333)

Approvers:
  - https://github.com/nvdbaranec
  - AJ Schmidt (https://github.com/ajschmidt8)
  - Jason Lowe (https://github.com/jlowe)
  - Vukasin Milovanovic (https://github.com/vuule)
  - Jake Hemstad (https://github.com/jrhemstad)
  - Robert Maynard (https://github.com/robertmaynard)

URL: #10877
@github-actions
Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

@jbrennan333
Copy link
Contributor

This issue is still in progress. The remaining work is covered by #11082.

rapids-bot bot pushed a commit that referenced this issue Jun 22, 2022
…fault_stream_value (#11082)

Closes #10864.
Also closes #9614.

This PR is a follow-up to #10877.  It replaces all of the remaining instances of `rmm::cuda_stream_default` with `cudf::default_stream_value`.

There are a lot of replacements and addition of includes, along with some reformatting due to clang-format, but like #10877, there should be no noticeable functional change here.

Authors:
  - Jim Brennan (https://github.com/jbrennan333)

Approvers:
  - Robert (Bobby) Evans (https://github.com/revans2)
  - https://github.com/nvdbaranec
  - Nghia Truong (https://github.com/ttnghia)
  - Karthikeyan (https://github.com/karthikeyann)

URL: #11082
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request libcudf Affects libcudf (C++/CUDA) code.
Projects
None yet
2 participants