Open MPI logo

Hardware Locality Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Development mailing list

Subject: Re: [hwloc-devel] [hwloc-svn] svn:hwloc r1333
From: Samuel Thibault (samuel.thibault_at_[hidden])
Date: 2009-11-11 16:44:37


bgoglin_at_[hidden], le Wed 11 Nov 2009 11:33:31 -0500, a écrit :
> +/** \brief Bind thread given by \p pid to CPU set \p cpuset.
> + *
> + * \note This function now manipulates hwloc cpusets.
> + */
> +static __inline int
> +hwloc_plpa_sched_setaffinity(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t cpuset)
> +{
> + /* FIXME: should be set_thread_cpubind with a pid */
> + return hwloc_set_proc_cpubind(topology, pid, cpuset, 0);
> +}

That's one instance where the Linux interface is odd (it talks about a
pid, but it's actually a thread, and there is no way to set the affinity
mask of a whole process...) and I believe we shouldn't try to support
all the cases. I'd suggest to bind a thread only when pid is 0. If
pid is not zero, that means that either the application is calling the
linux-only gettid() or some other linux-only way to get the tid of a
specific thread, or it assumes that the target is a single-threaded
process and thus providing the pid of that process is enough to change
its cpu affinity. In that case we can use hwloc_set_proc_cpubind like
already done above. Same for getaffinity.

Samuel