ENH: Avoid repeated CUDA device selection queries - #100
Merged
Conversation
SimonRit
reviewed
Jul 7, 2026
| } | ||
|
|
||
| return max_flops_device; | ||
| }(); |
Collaborator
There was a problem hiding this comment.
It wasn't obvious to me why you had parentheses here. I think using std::invoke would make it clearer?
axel-grc
force-pushed
the
CudaBuffer
branch
2 times, most recently
from
July 8, 2026 12:36
4bcdd38 to
660d6ac
Compare
SimonRit
reviewed
Jul 8, 2026
|
|
||
| // Return the device that has the maximum FLOPS. The result is cached for future calls. | ||
| int | ||
| CudaGetCachedDevice() |
Collaborator
There was a problem hiding this comment.
That's too vague of a name. Maybe CudaGetCachedMaxFlopsDevice?
Collaborator
There was a problem hiding this comment.
Actually, I would keep the original name, Cached is not necessary
CudaDataManager calls CudaGetMaxFlopsDev during construction, so iterative pipelines can repeatedly query CUDA device properties when many temporary CUDA images or filters are created. Compute the max-FLOPS device once with function-local static initialization and reuse the selected device for subsequent CudaGetMaxFlopsDev calls. This avoids repeated cudaGetDeviceProperties and cudaDeviceGetAttribute
SimonRit
approved these changes
Jul 8, 2026
SimonRit
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me. I think you could
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CudaDataManager calls CudaGetMaxFlopsDev during construction, so iterative pipelines can repeatedly query CUDA device properties when many temporary CUDA images or filters are created.
Compute the max-FLOPS device once with function-local static initialization and reuse the selected device for subsequent CudaGetMaxFlopsDev calls.
This avoids repeated cudaGetDeviceProperties and cudaDeviceGetAttribute