Open MPI logo

PLPA Users' Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all PLPA Users mailing list

Subject: Re: [PLPA users] setting affinity of threads
From: Fawzi Mohamed (fawzi_at_[hidden])
Date: 2009-01-24 13:12:42


On Jan 23, 2009, at 11:10 PM, Fawzi Mohamed wrote:

>
> On Jan 23, 2009, at 7:33 PM, Bert Wesarg wrote:
>
>> On Fri, Jan 23, 2009 at 19:22, Fawzi Mohamed <fawzi_at_[hidden]> wrote:
>>> I was wondering if there was any plan to support the setting/
>>> getting of the
>>> affinity of threads.
>>>
>>> I tried to understand a little the situation:
>>>
>>> Using LinuxThreads one has a pid for each thread, so one can use the
>>> sched_setaffinity after getting the bit with gettid.
>>>
>>> Using NPTL starting with libgc 2.3.4 one can use
>>> pthread_[attr_]_[get|set]affinity_np (defining _GNU_SOURCE)
>>> This is very nice, but not always available.
>>>
>>> Looking at the documentation in one place it is said that using
>>> sched_setaffinity(0,...) one sets only the current thread. Is this
>>> so
>>> everywhere? If so I could use that in my code.
>> Whats 'everywhere'?
>
> in all system where plpa set/get affinity works.

at least in the two systems in which I tested this did work

>>> Is there a plan to directly support thread affinity (vs process)?
>> You can use PLPA with NPTL, just use the tid (from gettid(2)) as the
>> pid.
>
> ok thanks I was not sure that that would work with NPTL, because the
> documentation was very unclear about it.
> I thought that as NPTL did not use pids, so that one could not use
> that (because of collisions between process ids and thread pids...
> So that gettid would return different pids only for thread groups,
> i.e. threads created with clone, and not those created with NPTL...
> I have to test it then.

I was not able to make it work using gettid (but passing 0 works).
I think that I will hope that it works on all systems, and try to use
that as default method (if one does not specify the availability of
libnuma and NPTL via a define).
But if anybody has more information on thread affinity issues I would
love to hear it...

thanks
Fawzi