Description
Parallel computation is currently in a messy state. The functions that we have are distributed between the Parallel
and the Experimental
submodules but we do not export any symbols yet; that means that they are considered internal and are not subject to semantic versioning. But that probably also means that barely any one is using them.
Some algorithms currently allow the user to choose between threaded (tasks distributed between multiple threads on the same machine) and distributed computation (potentially multiple multiple machines). We don't have any mechanism to select how many threads/cores are used and which ones we want to use. This is currently done with the keyword argument parallel=:threads
or parallel=:distributed
.
What I would like to propose is that we create a type to select what kind of execution policy we want. This means something like:
# Name is inspired from C++, but we can also use something like Execution or Parallel
abstract type ExecutionPolicy end
# No parallel computation
struct Singular <: ExecutionPolicy end
# Using threads
struct Threads <: ExecutionPolicy end
# Using the Distributed module
struct Distributed <: Distributed end
# The algorithm should select the best policy
struct Auto <: ExecutionPolicy end
With this
- We can dispatch on the policy - or a union of a subset of the policies.
- We can add further information like the number of cores or the core ids later
- We have an unified mechanism that would select the best policy for a certain algorithm - not only the parallel ones but also some of the sequential ones.
- Other packages can define even more policies - for example a a
GPU
policy if someone implements graph algorithms on a GPU.
Furthermore we should add
- Some helper functions to select the best policy according to some constraints
- Useful warnings if for example someone selects the
Threads
policy but there is only one thread available.
I would like to hear peoples feedback on this. Also perhaps someone knows another Julia package that implements something similar?