Something like this is not hard to do, but it doesn't capture many use cases as 
the working set sizes and how the splitting of work is done is not abstracted 
over:
    
    
    template forkAndJoin(n, fork, join: untyped) {.dirty.} =
      var ch = newSeq[type(fork(0))](n)
      parallel:
        for k in 0..ch.high:
          ch[k] = spawn fork(k)
      for k in 0..ch.high:
        join(result, ch[k])
    
    forkAndJoin(n, term(float(k)), `+=`)
    

Food for thought. :)

Reply via email to