[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/yhcpp/taskflow/master/taskflow/core/algorithm/for_each.hpp [Back]  [Original]

// reference:
// - gomp: https://github.com/gcc-mirror/gcc/blob/master/libgomp/iter.c
// - komp: https://github.com/llvm-mirror/openmp/blob/master/runtime/src/kmp_dispatch.cpp


#pragma once

#include "../executor.hpp"

namespace tf {

// ----------------------------------------------------------------------------
// default parallel for
// ----------------------------------------------------------------------------

// Function: for_each
template 
Task FlowBuilder::for_each(B&& beg, E&& end, C&& c) {
  
  using I = stateful_iterator_t;
  using namespace std::string_literals;

  Task task = emplace(
  [b=std::forward(beg),
   e=std::forward(end), 
   c=std::forward(c)] (Subflow& sf) mutable {
    
    // fetch the stateful values
    I beg = b;
    I end = e;

    if(beg == end) {
      return;
    }
  
    size_t chunk_size = 1;
    size_t W = sf._executor.num_workers();
    size_t N = std::distance(beg, end);
    
    // only myself - no need to spawn another graph
    if(W 

Web Proxy Viewer  |  New URL  |  Original Page