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: Bert Wesarg (bert.wesarg_at_[hidden])
Date: 2009-01-23 13:33:19


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'?
> 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. The only problem left is the mapping from pthread_t to tid (so
you could set the affinity for one thread from another thread (of the
same process of course)). This is the only advantage of the
pthread_[get|set]affinity_np interface. To simulate the
pthread_attr__[get|set]affinity_np interface, the calling thread could
set his mask to the desired one, create the thread, and set the mask
back. This should work because the affinity mask will be inherited.

Bye
Bert

>
> Thank you very much
>
> Fawzi
> _______________________________________________
> plpa-users mailing list
> plpa-users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/plpa-users
>