I want to know if this way uses one core per execution
No, not necessarily,
or just executes the program.py using threads
no, these are separate processes, not threads. And threads could be scheduled on the same or different cores, too.
So, you seem to be mixing up a few terms.
What your operating system does when you start processes is schedule them, which means they get executed on a free CPU core, when one is available. It's pretty clever about that, so most likely your different python processes will be run on different cores – but not necessarily (this works just as well if you have just 1 core!).
How can I use GNU Parallel for executing program.py concurrently, each time in a different core?
Not at all, that's not how multiprocessor scheduling works (without going through tricks like core pinning), and it would have no advantage, quite likely: If your programs don't already fully utilize your CPU cores the way you are already calling them, GNU parallels won't change that. If not all cores are used automatically, it means that your processes are competing for other resources than CPU time.
Quite likely, for example, they are relatively storage bandwidth-intense, as you seem to be using ipython (which loads a lot of Python modules that you don't need unless you're actually running interactively, which you can't, since you're starting them all in parallel) instead of plain python.
Generally, I find GNU parallel
quite unwieldy, i.e., unnecessarily hard to use. I find that echo argument1 argument2 argument3 | xargs -P0 -n1 python script.py
is a much easier way to start 3 three processes (python script.py argument1
, python script.py argument2
and python script.py argument3
) in parallel.
ipython
is meant to be used as interactive shell, not for batch processing. You probably just want to usepython
.