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

Use thread-local to track CUDA device in JNI [skip ci] #6597

Merged
merged 2 commits into from
Oct 26, 2020

Conversation

jlowe
Copy link
Member

@jlowe jlowe commented Oct 26, 2020

Looking at a recent Nsight profile of a Java application using cudf, I noticed a lot of CPU samples in cudaGetDevice. This is caused by the auto_set_device calls made in each cudf JNI function to ensure each thread is using the same device used when RMM was initialized. Initially we thought calling cudaGetDevice would be "cheap enough", but this is apparently not the case, at least when profiling under Nsight.

This changes the cudf JNI code to track the thread's CUDA device in a thread local rather than needing to call cudaGetDevice on each cudf call to obtain it. This saved 0.5ms per Table.contiguousSplit call in a microbenchmark, and I noticed it also significantly reduced the time dilation we've seen in Nsight profiles of cudf Java applications.

@jlowe jlowe added Java Affects Java cuDF API. 4 - Needs cuDF (Java) Reviewer labels Oct 26, 2020
@jlowe jlowe requested a review from a team as a code owner October 26, 2020 14:49
@jlowe jlowe self-assigned this Oct 26, 2020
@GPUtester
Copy link
Collaborator

Please update the changelog in order to start CI tests.

View the gpuCI docs here.

@jlowe jlowe merged commit cbd2726 into rapidsai:branch-0.17 Oct 26, 2020
@jlowe jlowe deleted the jni-cuda-device branch September 10, 2021 15:43
@vyasr vyasr added 4 - Needs Review Waiting for reviewer to review or respond and removed 4 - Needs cuDF (Java) Reviewer labels Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - Needs Review Waiting for reviewer to review or respond Java Affects Java cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants