Repository navigation
Remove kernel keyword arguments that caused a per-thread copy of prob - #145
Merged
Merged
Conversation
The c1/c2 keyword arguments on the update kernels were never passed by any caller, but they made Julia split each kernel into a wrapper and a separate body function. That body function was not inlined on GPU, so every thread copied prob onto its stack. Use constants instead, and add an inlined rand_static for the SVector random draws.
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.
The update kernels had
c1/c2keyword arguments that no caller passes. Keyword arguments make Julia split the kernel into a wrapper and a separate body function, and on GPU that body function was not inlined, so every thread copiedprobonto its stack before calling it.This replaces them with constants (
PSO_C1,PSO_C2). It also adds a small inlinedrand_staticfor the SVector random draws, since StaticArrays'randwas not inlined either and used stack for its return value.Stack per thread from
ptxas -v(sm_75, D = 10, defaultCUDABackend()):always_inlineFor BBOB the remaining stack comes from the objective itself (
BBOBFunctionholds ~844 B of data and its call is not inlined), so that part still needsalways_inline = true.CPU Core tests pass locally. I haven't run the CUDA tests or timed it on a GPU.