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

Precompute annuities #1965

Conversation

eleanorTurintech
Copy link
Contributor

Pre-computation of Annuities: The updated code introduces a pre-computation of annuities for all rates and stores them in a vector. This avoids repeated calls to cs.coterminalSwapAnnuity() within the nested loops, potentially reducing computational overhead and improving performance.

Corresponding unit test runs ~30% faster on a single processor (standard build, g++ 11.4.0)

Copy link

boring-cyborg bot commented May 6, 2024

Thanks for opening this pull request! It might take a while before we look at it, so don't worry if there seems to be no feedback. We'll get to it.

@CLAassistant
Copy link

CLAassistant commented May 6, 2024

CLA assistant check
All committers have signed the CLA.

for (Size k=0; k<numberOfFactors_; ++k) {
// taken care in the constructor
// wkpj1_[k][numberOfRates_-1]= 0.0;
// wkaj_[k][numberOfRates_-1] = 0.0;
for (Integer j=numberOfRates_-2; j>=static_cast<Integer>(alive_)-1; --j) {
// < W(k) | P(j+1)/P(n) > =
// = SR(j+1) a(j+1,k) A(j+1) / P(n) + SR(j+1) < W(k) | A(j+1)/P(n) >
Real annuity = cs.coterminalSwapAnnuity(numberOfRates_,j+1);
Real annuity = annuities[j+1];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the same vector annuities be used also in the other loop ~20 lines below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I'll make that change too, thanks for pointing it out. In fact the quantitative results stated above were including this change, but I forgot to add it when making the final PR.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks.

@eleanorTurintech eleanorTurintech force-pushed the feature/smmdrift-calculator-performance branch from 5f3b8e0 to 3dabf86 Compare May 7, 2024 17:20
@lballabio lballabio added this to the Release 1.35 milestone May 9, 2024
@coveralls
Copy link

Coverage Status

coverage: 72.497% (+0.001%) from 72.496%
when pulling 3dabf86 on turintech:feature/smmdrift-calculator-performance
into 41b7ddc on lballabio:master.

@lballabio lballabio merged commit 40c6e77 into lballabio:master May 9, 2024
41 checks passed
Copy link

boring-cyborg bot commented May 9, 2024

Congratulations on your first merged pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants