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] change default LikelihoodJob task splitting mode #16507

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions roofit/roofitcore/src/TestStatistics/LikelihoodJob.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,26 @@ void LikelihoodJob::update_state()
}
}

/// \warning In automatic mode, this function can start MultiProcess (forks, starts workers, etc)!
std::size_t LikelihoodJob::getNEventTasks()
{
std::size_t val = n_event_tasks_;
if (val == MultiProcess::Config::LikelihoodJob::automaticNEventTasks) {
val = get_manager()->process_manager().N_workers();
val = 1;
}
if (val > likelihood_->getNEvents()) {
val = likelihood_->getNEvents();
}
return val;
}

/// \warning In automatic mode, this function can start MultiProcess (forks, starts workers, etc)!
std::size_t LikelihoodJob::getNComponentTasks()
{
std::size_t val = n_component_tasks_;
if (val == MultiProcess::Config::LikelihoodJob::automaticNComponentTasks) {
val = 1;
val = get_manager()
->process_manager()
.N_workers(); // get_manager() is the call that can start MultiProcess, mentioned above
}
if (val > likelihood_->getNComponents()) {
val = likelihood_->getNComponents();
Expand Down
10 changes: 10 additions & 0 deletions roofit/roofitcore/test/TestStatistics/testLikelihoodJob.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ TEST_F(LikelihoodJobTest, UnbinnedGaussian1DSelectedParameterValues)
// Bisecting the number of events to find the number at which the deviation starts occurring in the
// likelihood result showed that event 9860 was the main culprit (which has index 9859)

// We also need to split over events precisely with 2 workers to trigger the deviation:
RooFit::MultiProcess::Config::LikelihoodJob::defaultNEventTasks = RooFit::MultiProcess::Config::getDefaultNWorkers();
RooFit::MultiProcess::Config::LikelihoodJob::defaultNComponentTasks = 1;

RooRealVar *mu = w.var("mu");
mu->setVal(-2.8991551193432676392);

Expand All @@ -146,6 +150,12 @@ TEST_F(LikelihoodJobTest, UnbinnedGaussian1DSelectedParameterValues)
EXPECT_NE(nll0, nll1.Sum());
// they differ only a bit:
EXPECT_DOUBLE_EQ(nll0, nll1.Sum());

// reset static variables to automatic
RooFit::MultiProcess::Config::LikelihoodJob::defaultNEventTasks =
RooFit::MultiProcess::Config::LikelihoodJob::automaticNEventTasks;
RooFit::MultiProcess::Config::LikelihoodJob::defaultNComponentTasks =
RooFit::MultiProcess::Config::LikelihoodJob::automaticNComponentTasks;
}

TEST_F(LikelihoodJobTest, UnbinnedGaussian1DTwice)
Expand Down
Loading