Skip to content

Support a blocked range in TExecutor? #7873

@hageboeck

Description

@hageboeck

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

Not a problem, just ease of use when processing e.g. a large array with a lot of entries in parallel (with using SIMD in each thread).

Describe the solution you'd like

ROOT

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);

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

TBB

void runParallel() {
  constexpr std::size_t nTotal = 101;

  auto printRange = [](const tbb::blocked_range<std::size_t>& range) {
    std::cout << "Doing " << range.begin() << "\t" << range.end() << std::endl; sleep(1);
  };  
  tbb::parallel_for(tbb::blocked_range<std::size_t>(0, nTotal), printRange, tbb::static_partitioner());
}

OMP

+ #pragma omp parallel for schedule(static)
  for (std::size_t i = 0; i < end; ++i) {

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions