Optimize backward propagation kernel (41% end-to-end speedup on the example) #53
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.
Motivation
The original backward propagation kernel,
renderCUDA
, usesatomicAdd
to accumulate gradients from render objects to Gaussians. This is OK for most Gaussians since they only cover a few tiles. However, for some large Gaussians that spawn over a large set of tiles,atomicAdd
leads to performance degradation.Modification
The new kernel automatically selects the best approach for gradient accumulation. We define a hyperparameter,$\alpha$ . If a Gaussian touches no more than $\alpha$ tiles, we use the original approach which uses $1/256$ . Furthermore, the "block-level reduction" is performed in batches to avoid the expensive block-level synchronization operations.
atomicAdd
. Otherwise, we first perform a block-level reduction, then add the gradient to global gradient arrays (dL_dcolors
and so on) byatomicAdd
. This reduces the number ofatomicAdd
s toEvaluation
We use the
tandt/truck
dataset with--iterations=5000
to evaluate our optimization.The following figure illustrates the end-to-end absolute time usage and relative speedup.
And the following figure shows that my modification has no problem with correctness.