More efficient eval_f
in RBC on GPU
#492
Merged
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.
After profiling the code on GPUs some more, I noticed some efficiency can be gained from reducing the number of matrix multiplications. That is all that I am doing here: Rather than computing derivatives by multiplying each component with the derivative matrix separately, I construct a large matrix containing the derivative matrix multiple times in order to compute all derivatives simultaneously. Also, I cache the$L$ matrix in the basis of Chebychov T polynomials, rather than computing it every time. This is not a huge difference, but saves a few ms in every call of the function on both CPU and GPU.