Should Nim make it easier to perform the basic use-cases of parallelism (i.e., abstract away the looping)?
Three main use-cases that I am thinking of:
The third use-case would not be implemented, but can be performed by applying existing sequence accumulators to use-case 2.
My thoughts were around functional-programming style helper things like the following (using for example, 42 as the number of times to run these in parallel, i.e. 0..41 ):
If the "it" style syntax was used, then example 2. would be
where "it" would be 0..41
I don't understand the complexities of parallelism, but would this be possible, and would it be a good thing to implement if it is possible?
There are several types of parallelism.
Quoting myself
- data parallelism: executing the same instructions on multiple cores
- task parallelism: multiple different tasks/functions on multiple cores
- model parallelism: this is somewhat specific to science, if you need to evaluate A and B and they are independant, evaluate both in parallel.
In case of data parallelism, if it's done on a shared memory data structure there are non-trivial issues to solve that are better done through OpenMP or via a library like Rust rayon. Typical issues are static or dynamic scheduling, false sharing/CPU cache contention, race conditions.
In case of task parallelism, you can use parallel and spawn mentionned by cdome or channels.