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] IMT parallel for in the computation library #7874

Closed
hageboeck opened this issue Apr 14, 2021 · 2 comments
Closed

[RF] IMT parallel for in the computation library #7874

hageboeck opened this issue Apr 14, 2021 · 2 comments

Comments

@hageboeck
Copy link
Member

hageboeck commented Apr 14, 2021

Is your feature request related to a problem? Please describe.

The problem is only speed. :-)

Describe the solution you'd like

Use TExecutor to parallelise for loops in RooFit. Currently, you have to use something like

void runParallel() {
  ROOT::Internal::TExecutor ex; 
  constexpr std::size_t nTotal = 101;

  const auto nChunk = ROOT::IsImplicitMTEnabled() ? ex.GetPoolSize() : 1u; 
  auto printRange = [=](std::size_t i) {
    const auto nEvent = nTotal / nChunk + (nTotal%nChunk != 0); 
    const auto begin = nEvent * i;
    const auto end = std::min( nEvent * (i+1), nTotal);

    std::cout << "[" << i << "] does " << begin << "\t" << end << std::endl; sleep(1);
    // <Do the computation work here>

    // We are forced to return a dummy value with `TExecutor::Map()`
    return 0;
  };  
  ex.Map(printRange, ROOT::TSeq<std::size_t>(0, nChunk));
}

Alternatively, one can fill a vector with something like pair<size_t, size_t>(begin, end), and run this in parallel using TExecutor.

Describe alternatives you've considered

#7873

@hageboeck hageboeck changed the title [RF [RF] IMT parallel for in the computation library Apr 14, 2021
@hageboeck hageboeck added this to the 6.26/00 milestone Apr 14, 2021
@hageboeck
Copy link
Member Author

Some details on why to use the Executor:

  • When ROOT doesn't have IMT enabled, it will fall back to single-thread computation.
  • It integrates well into tbb scheduling. If ROOT runs with other tbb things in the same process, one can configure the number of threads that ROOT uses.
  • It listens to ROOT::EnableImplicitMT(N)

When done, the feature should be announced in release notes and documentation.

@guitargeek
Copy link
Contributor

Fixed by #9004, more specifically commit 8d7e69d.

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

No branches or pull requests

3 participants