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

[RF] Make RooAbsReal::getValues use the batch mode via RooFitDriver #9986

Merged
merged 4 commits into from
Mar 7, 2022

Conversation

guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Feb 25, 2022

The RooAbsReal::getValues has already been established as the entry
point for evaluating RooFit objects with the batch mode and it should
not be broken.

In 6.26, the getValues function was broken to fall back on the scalar
mode all the time, because the evaluateSpan funtions it used got
replaced by computeBatch. In this commit, the desired behavior of
using the BatchMode is restored by using the RooFitDriver. To that end, a
new constructor has been added to the RooFitDriver that takes a
RooBatchCompute::RunContext directly.

The override of getValues in RooAbsPdf was also removed now, because
it's the job of the RooFitDriver to treat pdfs correctly.

This PR fixes the performance regression that was observed in the vectorized pdf tests in roottest. To fix the performance regression completely, this PR also includes a commit to avoid some overhead in the pure CPU batch mode with RooFitDriver.

This bugfix should also be backported to 6.26 as a bugfix for the patch release.

In the CPU mode, the order in which the RooFit objects are evaluated is
not dynamic and there is no need to use the code path for heterogeneous
evaluation. This speeds up the pure CPU mode significantly.
The `RooAbsReal::getValues` has already been established as the entry
point for evaluating RooFit objects with the batch mode and it should
not be broken.

In 6.26, the `getValues` function was broken to fall back on the scalar
mode all the time, because the `evaluateSpan` funtions it used got
replaced by `computeBatch`. In this commit, the desired behavior of
using the BatchMode is restored by using the RooFitDriver. To that end, a
new constructor has been added to the RooFitDriver that takes a
`RooBatchCompute::RunContext` directly.

The override of `getValues` in RooAbsPdf was also removed now, because
it's the job of the RooFitDriver to treat pdfs correctly.
@guitargeek guitargeek requested a review from lmoneta as a code owner February 25, 2022 18:41
@guitargeek guitargeek self-assigned this Feb 25, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Feb 26, 2022
@root-project root-project deleted a comment from phsft-bot Mar 4, 2022
@root-project root-project deleted a comment from phsft-bot Mar 4, 2022
@root-project root-project deleted a comment from phsft-bot Mar 4, 2022
@root-project root-project deleted a comment from phsft-bot Mar 4, 2022
@root-project root-project deleted a comment from phsft-bot Mar 4, 2022
@root-project root-project deleted a comment from phsft-bot Mar 4, 2022
@root-project root-project deleted a comment from phsft-bot Mar 4, 2022
@phsft-bot
Copy link
Collaborator

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Collaborator

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-performance-centos8-multicore/default.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Failing tests:

Copy link
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

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

LGTM ! Just a small comment.
Thank you for this fix

// Do running sum of coef/func pairs, calculate lastCoef.
RooSpan<double> values;
for (unsigned int j = 0; j < nEvents; ++j) {
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to use size_t instead of unsigned int here, and same also below, for the case nEvents>2^32.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! I'll change this

@phsft-bot
Copy link
Collaborator

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

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

Successfully merging this pull request may close these issues.

3 participants