JuliaLang/julia — pull request #9202 by amitmurthy (2014-11-30 13:02:16+00:00)
Title: Auto launch of additional workers depending on number of cores at a host.

This PR is inspired by https://groups.google.com/d/msg/julia-dev/J8plDsw76dI/VQbedWJXi20J and https://groups.google.com/d/msg/julia-dev/Ui7G-99jBpI/VDmO-s0YFiMJ

`addprocs` has a new keyword argument `clone_worker`. Default value is 0. Any positive value 'n' will result in 'n' additional workers to be created for every new worker created. `clone_worker="auto"` will launch `Base.CPU_CORES - 1` additional workers.

Users will use this by having ClusterManagers launch a single worker per host. With `clone_worker="auto"` , `addprocs` will automatically launch additional workers depending on the number of cores available on the host.

For example, on 2 hosts, each with 8 cores, `addprocs(["host1", "host2"]; clone_worker="auto")` will first launch a single worker each on "host1" and "host2". Next it will launch 7 additional workers on each host *via* the 2 newly created workers. Thus only a single ssh session is used to connect to a host.

One issue is that the process which launches the clones does not know the pids of the clones. And hence console output from the clones (which is channeled back to the master via the launching worker) is displayed as shown below:
```
julia> addprocs(1; clone_worker=3)
4-element Array{Int64,1}:
2
3
4
5

julia> @everywhere println(myid())
1
From worker 10: 2
From worker 10.clone: 3
From worker 10.clone: 4
From worker 10.clone: 5
```

But other than the above, I think it is a good option to launch required number of workers per host.