Re: Help with parallelizing a loop

2017-11-03 Thread mikra
sync() simply waits till all your spawned threads are finished. If you call spawn n-times on the same proc it´s almost the same as parallel except that parallel does some additionally checks for you. Also you don't need to collect the FLowVars and check manually with ^ (on each FlowVar) (or use

Re: Help with parallelizing a loop

2017-11-03 Thread jlp765
Good call. [The doco](https://nim-lang.org/docs/manual.html#parallel-spawn-parallel-statement) doesn't use the `sync()`

Re: Help with parallelizing a loop

2017-11-03 Thread Stefan_Salewski
Indeed Jack, I think sync() is nonsense when parallel statement is used.

Re: Help with parallelizing a loop

2017-11-03 Thread jackmott
what does the call to sync() do?

Re: Help with parallelizing a loop

2017-11-03 Thread jlp765
from [this post](https://forum.nim-lang.org/t/3257/2) convert something like the following to suit your specific usage var LoopSz = faces.len res: array[LoopSz, int] parallel: for i in 0..LoopSz-1: spawn whateverNeedsDoingInParallel(...,

Re: Help with parallelizing a loop

2017-11-02 Thread niofis
I would suggest you check this page: [10 Nim One Liners to Impress Your Friends](https://blog.ubergarm.com/blog/archive/archive-ten-nim-one-liners.md), and also, check my own implementation of a parallel map with some improvements here:

Help with parallelizing a loop

2017-11-02 Thread jackmott
I would like some guidance on how to best parallelize this loop. I've played around with the parallel: macro, and using spawn, but haven't gotten a working solution yet. It isn't entirely clear what the best approach should be: for i,face in faces: #face is a path to an image file