Pass cpu affinity to julia's child processes

355 Views Asked by At

I am trying to control the CPU affinity of julia using taskset using

taskset -c 1,2 julia Foo.jl

However, internally Julia spawns may child processes to which this affinity mask does not seem to apply.

So mu question is: can I force a process and all its child processes to be limited to cpu-s 1 to 2.

1

There are 1 best solutions below

0
On

I can see the use case in an HPC environment, so this seems worth a feature-request on github.

That said, taskset takes a PID argument, so here is a potential interim solution:

pids = map(x -> fetch(@spawnat x getpid()), procs())
map(x -> run(`taskset -c 1,2 -p $x`), pids)

(untested though, currently on a mac)