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

Testing stream pool implementation #14437

Merged
merged 12 commits into from
Dec 19, 2023

Conversation

shrshi
Copy link
Contributor

@shrshi shrshi commented Nov 16, 2023

Description

The goal of this PR is to create a global pool containing only the cudf test stream which is to be used all stream tests that invoke fork_streams in their execution path. The stream pool is constructed by create_global_cuda_stream_pool() in identify_stream_usage.cpp, and overrides the function implementation in utilities/stream_pool.cpp when preloaded.

The test checks for only cudaLaunchKernel being invoked with the wrong stream.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@shrshi shrshi added CMake CMake build issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Nov 16, 2023
Copy link

copy-pr-bot bot commented Nov 16, 2023

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions bot added the libcudf Affects libcudf (C++/CUDA) code. label Nov 16, 2023
@shrshi
Copy link
Contributor Author

shrshi commented Nov 17, 2023

/ok to test

@shrshi
Copy link
Contributor Author

shrshi commented Nov 17, 2023

/ok to test

@shrshi
Copy link
Contributor Author

shrshi commented Nov 17, 2023

/ok to test

@shrshi shrshi marked this pull request as ready for review November 17, 2023 19:49
@shrshi shrshi requested a review from a team as a code owner November 17, 2023 19:49
Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

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

The code looks fine, but I have a little bit of confusion that I would like to clear up. Thanks!

cpp/tests/streams/pool_test.cu Outdated Show resolved Hide resolved
cpp/tests/streams/pool_test.cu Outdated Show resolved Hide resolved
cpp/tests/utilities/identify_stream_usage.cpp Show resolved Hide resolved
cpp/tests/utilities/identify_stream_usage.cpp Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just a copy-paste of the declarations from stream_pool.cpp, right? It's a good change, just want to make sure I'm not missing any other changes.

Copy link
Contributor Author

@shrshi shrshi Dec 12, 2023

Choose a reason for hiding this comment

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

Yes, I have moved the parent class declaration and create_global_cuda_stream_pool from stream_pool.cpp to the header file so that test_cuda_stream_pool in identify_stream_usage.cpp can include it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Notes from an offline discussion - cuda_stream_pool was "hidden" in the source file on purpose; we want the pool usage to be limited to fork_streams/join_streams. The change here exposes more of the stream pool than we'd like.
However, we don't see a better solution, since the current approach at least does not require additional APIs in libcudf.

cpp/tests/utilities/identify_stream_usage.cpp Show resolved Hide resolved
class test_cuda_stream_pool : public cuda_stream_pool {
public:
rmm::cuda_stream_view get_stream() override { return cudf::test::get_default_stream(); }
rmm::cuda_stream_view get_stream(stream_id_type stream_id) override
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove the variable name since it's never used (or if that causes unforeseen problems, mark it as [[ maybe_unused ]])?

Suggested change
rmm::cuda_stream_view get_stream(stream_id_type stream_id) override
rmm::cuda_stream_view get_stream(stream_id_type) override

cpp/tests/utilities/identify_stream_usage.cpp Show resolved Hide resolved
cpp/tests/utilities/identify_stream_usage.cpp Show resolved Hide resolved
@shrshi
Copy link
Contributor Author

shrshi commented Dec 12, 2023

/ok to test

@shrshi
Copy link
Contributor Author

shrshi commented Dec 12, 2023

/ok to test

@shrshi shrshi requested a review from vyasr December 12, 2023 01:17
… comment

Co-authored-by: Vyas Ramasubramani <vyas.ramasubramani@gmail.com>
@shrshi
Copy link
Contributor Author

shrshi commented Dec 12, 2023

/ok to test

@shrshi
Copy link
Contributor Author

shrshi commented Dec 12, 2023

/ok to test

Co-authored-by: Vukasin Milovanovic <vmilovanovic@nvidia.com>
@shrshi
Copy link
Contributor Author

shrshi commented Dec 13, 2023

/ok to test

*
* @return the number of stream objects in the pool
*/
virtual std::size_t get_stream_pool_size() const = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

The name is a bit redundant. We know that this is a stream pool.

Suggested change
virtual std::size_t get_stream_pool_size() const = 0;
virtual std::size_t get_pool_size() const = 0;

or just size().

Copy link
Contributor

Choose a reason for hiding this comment

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

get_pool_size() is consistent with rmm::cuda_stream_pool. Surprised this wasn't caught before.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, should be get_pool_size. Not a change for this PR, IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, but then please address it in a follow up work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing this out! I'll work on this change in a follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

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

Why isn't this a change for this PR, if all the code in this section is new in this PR?


class StreamPoolTest : public cudf::test::BaseFixture {};

__global__ void do_nothing_kernel() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if this kernel without any code will be optimized out so the for loop below will never be executed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out! I printed the GPU trace from the nsys profiler to check this and it shows that the do_nothing_kernel is being executed.

@shrshi
Copy link
Contributor Author

shrshi commented Dec 14, 2023

/ok to test

@vuule vuule requested a review from harrism December 14, 2023 23:34
Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

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

Nice work.

@vuule
Copy link
Contributor

vuule commented Dec 19, 2023

/merge

@rapids-bot rapids-bot bot merged commit 5dfafaf into rapidsai:branch-24.02 Dec 19, 2023
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMake CMake build issue improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants