Open MPI logo

Hardware Locality Development Mailing List Archives

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

Subject: [hwloc-devel] hwloc on netBSD
From: Kevin.Buckley_at_[hidden]
Date: 2010-08-26 02:37:31


Hi there,

Firstly, I should say I am not a NetBSD developer at this (or any)
level however, I can usually find my way around a system's internals
by judicious use of the man3 content and can type code.

Jeff Squyres suggested we, ECS VUW, try and come up with a

 src/topology-netbsd.c

as we seem to be one of the few places running OpenMPI on a NetBSD
platform and Jeff thinks it'd be useful to have a NetBSD version of
hwloc for when we do.

I think I have found most of the system calls needed to duplicate
the functionality of say, topology-freebsd.c in NetBSD-land, although
NetBSD may be missing one piece.

What I have done so far is to patch hwloc-1.0.1 so that it recognises
and looks to then compile a src/topology-netbsd.c

As thing stand, the procedures still have their FreeBSD names but
as you only compile one of the sources that's not an issue for now.

Suffice to say things configure and start to compile under PkgSrc.

What NetBSD does not seem to have is the CPU_SETSIZE seen in something
like:

hwloc_freebsd_bsd2hwloc(hwloc_cpuset_t hwloc_cpuset, const cpuset_t *cpuset)
{
  unsigned cpu;
  hwloc_cpuset_zero(hwloc_cpuset);
  for (cpu = 0; cpu < HWLOC_NBMAXCPUS && cpu < CPU_SETSIZE; cpu++)
    if (CPU_ISSET(cpu, cpuset))
      hwloc_cpuset_set(hwloc_cpuset, cpu);
}

NetBSD does have this macro (rather hidden away as it turned out, in:
 common/lib/libc/sys/cpuset.c )

#ifndef __lint__
#define CPUSET_SIZE() sizeof( \
        struct { \
                uint32_t bits[cpuset_nentries]; \
        })
#else
#define CPUSET_SIZE() 0
#endif

but my code I don't, currently, have access to anything called
"cpuset_nentries".

It also seems as though it only gets used after actually creating
a cpuset.

_cpuset_create(void)
{
        if (cpuset_size == 0) {
                static int mib[2] = { CTL_HW, HW_NCPU };
                size_t len;
                u_int nc;

                if (sysctl(mib, __arraycount(mib), &nc, &len, NULL, 0) == -1)
                        return NULL;

                cpuset_nentries = CPUSET_NENTRIES(nc);
                cpuset_size = CPUSET_SIZE();
        }
        return calloc(1, cpuset_size);
}

where we have:

#define CPUSET_SHIFT 5
#define CPUSET_NENTRIES(nc) ((nc) > 32 ? ((nc) >> CPUSET_SHIFT) : 1)

So, before I go pester the people who speak NetBSD-cpusets, my
question is, what is the hwloc CPU_SETSIZE actually representing?

Is it apparant to anyone on here, that what I might be able to get
from the above

 create a cpuset just to get a value for cpuset_nentries so as to be
 able to define CPUSET_SIZE/CPUSET_SIZE()

will give me what hwloc wants, or am I barking up the wrong tree
entirely?

Kevin

-- 
Kevin M. Buckley                                  Room:  CO327
School of Engineering and                         Phone: +64 4 463 5971
 Computer Science
Victoria University of Wellington
New Zealand