Skip to content

Use environment based CUB APIs when possible in PSTL - #8526

Merged
miscco merged 6 commits into
NVIDIA:mainfrom
miscco:env_pstl
Apr 20, 2026
Merged

miscco merged 6 commits into
NVIDIA:mainfrom
miscco:env_pstl

Conversation

@miscco

@miscco miscco commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Some of our PSTL algorithms can use the new environment based CUB APIs

This gives us the advantage that the user can pass tunings / guarantees along with the execution policy.

@miscco
miscco requested a review from a team as a code owner April 20, 2026 09:11
@miscco
miscco requested a review from fbusato April 20, 2026 09:11
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Apr 20, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Apr 20, 2026
@miscco
miscco requested a review from bernhardmgruber April 20, 2026 09:11
_OffsetType __ret;

auto __stream = ::cuda::__call_or(::cuda::get_stream, ::cuda::stream_ref{cudaStreamPerThread}, __policy);
auto __stream = ::cuda::__call_or(::cuda::get_stream, ::cuda::stream_ref{cudaStream_t{}}, __policy);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bernhardmgruber using an open coded stream seems to be very error prone. I believe we should put that into a separate function in get_stream.h so that all algorithms in CCCL use the same default stream when possible?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree! But I am certain we have different defaults in different places. CUB's public API has a lot of cudaSteam_t stream = nullptr parameters. git grep shows me 35 instances of cudaStream_t{} and 25 cudaStreamPerThread{}.

We should definitely use the same default for PSTL, which hasn't shipped yet. So we can at least make a common function for PSTL.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The problem is that PSTL must use the same stream if we want to use the CUB environment APIs

Otherwise us synchronizing after the algorithm wont have any effect

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, I see the problem. I think we use the null stream everywhere at the CUB public API, so that's what we should use in the PSTL then as well.


// Allocate memory for result
auto __stream = ::cuda::__call_or(::cuda::get_stream, ::cuda::stream_ref{cudaStreamPerThread}, __policy);
auto __stream = ::cuda::__call_or(::cuda::get_stream, ::cuda::stream_ref{cudaStream_t{}}, __policy);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pciolkosz which stream is actually better as a default? The per thread or the per stream one?

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 02m: Pass: 100%/108 | Total: 1d 08h | Max: 1h 42m | Hits: 96%/282975

See results here.

@miscco
miscco merged commit 90f9483 into NVIDIA:main Apr 20, 2026
133 checks passed
@miscco
miscco deleted the env_pstl branch April 20, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants