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

Disallow zero-size stream pools #873

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions include/rmm/cuda_stream_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ class cuda_stream_pool {
static constexpr std::size_t default_size{16}; ///< Default stream pool size

/**
* @brief Construct a new cuda stream pool object of the given size
* @brief Construct a new cuda stream pool object of the given non-zero size
*
* @throws logic_error if `pool_size` is zero
* @param pool_size The number of streams in the pool
*/
explicit cuda_stream_pool(std::size_t pool_size = default_size) : streams_(pool_size) {}
explicit cuda_stream_pool(std::size_t pool_size = default_size) : streams_(pool_size)
{
RMM_EXPECTS(pool_size > 0, "Stream pool size must be greater than zero");
}
~cuda_stream_pool() = default;

cuda_stream_pool(cuda_stream_pool&&) = delete;
Expand Down
5 changes: 5 additions & 0 deletions tests/cuda_stream_pool_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ struct CudaStreamPoolTest : public ::testing::Test {
rmm::cuda_stream_pool pool{};
};

TEST_F(CudaStreamPoolTest, ZeroSizePoolException)
{
EXPECT_THROW(rmm::cuda_stream_pool pool{0}, rmm::logic_error);
}

TEST_F(CudaStreamPoolTest, Unequal)
{
auto const stream_a = this->pool.get_stream();
Expand Down