Skip to content
Merged
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
7 changes: 5 additions & 2 deletions cpp/tests/utilities_tests/stream_pool_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ TEST_F(StreamPoolTest, ConcurrentThreadsGetDistinctStreams)
auto constexpr num_streams = 8;

// Repeated requests make a shared round-robin counter very likely to hand the same stream to both
// threads. The latch makes them overlap; a thread starting after the other exited would adopt its
// retired pool and see the same streams.
// threads. Each thread takes its pool before the latch: a pool is created on first use and
// returned to the free list when its thread exits, so a thread that made its first request after
// the other one exited would adopt the retired pool and see the same streams.
auto collect = [](std::unordered_set<cudaStream_t>& out, std::latch& ready) {
auto const first = get_hashable_streams(num_streams);
out.insert(first.begin(), first.end());
ready.arrive_and_wait();
for (auto request = 0; request < num_requests; request++) {
auto const streams = get_hashable_streams(num_streams);
Expand Down
Loading