On Tue, Apr 6, 2010 at 17:36, <bgog...@osl.iu.edu> wrote: > Author: bgoglin > Date: 2010-04-06 11:36:17 EDT (Tue, 06 Apr 2010) > New Revision: 1940 > URL: https://svn.open-mpi.org/trac/hwloc/changeset/1940 > > Log: > Stop using HWLOC_NBMAXCPUS in Linux hwloc_linux_set/get_tid_cpubind > Text files modified: > branches/dyncpusets/src/topology-linux.c | 31 > ++++++++++++++++++++++--------- > 1 files changed, 22 insertions(+), 9 deletions(-) > > Modified: branches/dyncpusets/src/topology-linux.c > ============================================================================== > --- branches/dyncpusets/src/topology-linux.c (original) > +++ branches/dyncpusets/src/topology-linux.c 2010-04-06 11:36:17 EDT (Tue, > 06 Apr 2010) > @@ -192,8 +192,6 @@ > #endif > } > > -#define HWLOC_NBMAXCPUS 1024 /* FIXME: drop */ > - > int > hwloc_linux_set_tid_cpubind(hwloc_topology_t topology > __hwloc_attribute_unused, pid_t tid, hwloc_const_cpuset_t hwloc_set) > { > @@ -205,13 +203,21 @@ > > /* The resulting binding is always strict */ > > -#if defined(HWLOC_HAVE_CPU_SET_S) && > !defined(HWLOC_HAVE_OLD_SCHED_SETAFFINITY) && CPU_SETSIZE < HWLOC_NBMAXCPUS > +#if defined(HWLOC_HAVE_CPU_SET_S) && > !defined(HWLOC_HAVE_OLD_SCHED_SETAFFINITY) > cpu_set_t *plinux_set; > unsigned cpu; > - size_t setsize = CPU_ALLOC_SIZE(HWLOC_NBMAXCPUS); > + int last; > + size_t setsize; > int err; > > - plinux_set = CPU_ALLOC(HWLOC_NBMAXCPUS); > + last = hwloc_cpuset_last(hwloc_set); > + if (last == -1) { > + errno = -EINVAL; > + return -1; > + } > + > + setsize = CPU_ALLOC_SIZE(last+1); > + plinux_set = CPU_ALLOC(last+1); > > CPU_ZERO_S(setsize, plinux_set); > hwloc_cpuset_foreach_begin(cpu, hwloc_set) > @@ -253,12 +259,17 @@ > int err; > /* TODO Kerrighed */ > > -#if defined(HWLOC_HAVE_CPU_SET_S) && > !defined(HWLOC_HAVE_OLD_SCHED_SETAFFINITY) && CPU_SETSIZE < HWLOC_NBMAXCPUS > +#if defined(HWLOC_HAVE_CPU_SET_S) && > !defined(HWLOC_HAVE_OLD_SCHED_SETAFFINITY) > cpu_set_t *plinux_set; > unsigned cpu; > - size_t setsize = CPU_ALLOC_SIZE(HWLOC_NBMAXCPUS); > + int last; > + size_t setsize; > + > + last = hwloc_cpuset_last(topology->levels[0][0]->complete_cpuset); > + assert(last != -1); > > - plinux_set = CPU_ALLOC(HWLOC_NBMAXCPUS); > + setsize = CPU_ALLOC_SIZE(last+1); > + plinux_set = CPU_ALLOC(last+1); > > err = sched_getaffinity(tid, setsize, plinux_set); > > @@ -268,7 +279,7 @@ > } > > hwloc_cpuset_zero(hwloc_set); > - for(cpu=0; cpu<HWLOC_NBMAXCPUS; cpu++) > + for(cpu=0; cpu<last; cpu++)
Shouldn't this be "cpu<=last"? Bert