On 18.08.2021 15:58, Chris Angelico wrote:
> On Wed, Aug 18, 2021 at 10:37 PM Joao S. O. Bueno <jsbu...@python.org.br> 
> wrote:
>>
>> So,
>> It is out of scope of Pythonmultiprocessing, and, as I perceive it, from
>> the stdlib as a whole to be able to allocate specific cores for each 
>> subprocess -
>> that is automatically done by the O.S. (and of course, the O.S. having an 
>> interface
>> for it, one can write a specific Python library which would allow this 
>> granularity,
>> and it could even check core capabilities).
> 
> Python does have a way to set processor affinity, so it's entirely
> possible that this would be possible. Might need external tools
> though.

There's os.sched_setaffinity(pid, mask) you could use from within
a Python task scheduler, if this is managing child processes (you need
the right permissions to set the affinity).

Or you could use the taskset command available on Linux to fire
up a process on a specific CPU core. lscpu gives you more insight
into the installed set of available cores.

multiprocessing itself does not have functionality to define the
affinity upfront or to select which payload goes to which worker.
I suppose you could implement a Pool subclass to handle such cases,
though.

Changing the calculation model is probably better, as already
suggested. Having smaller chunks of work makes it easier to even
out work load across workers in a cluster of different CPUs. You
then don't have to worry about the details of the CPUs - you just
need to play with the chunk size parameter a bit.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Aug 18 2021)
>>> Python Projects, Coaching and Support ...    https://www.egenix.com/
>>> Python Product Development ...        https://consulting.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               https://www.egenix.com/company/contact/
                     https://www.malemburg.com/

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QJBYMO2FDD2PHHAACNI2BQZIBXJV7AZT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to