diff options
author | asau <asau@pkgsrc.org> | 2012-03-21 13:31:35 +0000 |
---|---|---|
committer | asau <asau@pkgsrc.org> | 2012-03-21 13:31:35 +0000 |
commit | 6f8702dbe2dedb80fa5ff94da268838bb47c3d94 (patch) | |
tree | 2065b652ca643224d83cc466fa5774623a5d92a2 /parallel/hwloc/patches/patch-src_topology-netbsd.c | |
parent | 55396f340cb57a9d7dbe0279051ca88a337a5c8f (diff) | |
download | pkgsrc-6f8702dbe2dedb80fa5ff94da268838bb47c3d94.tar.gz |
Import Portable Hardware Locality (hwloc) version 1.4 as parallel/hwloc.
The Portable Hardware Locality (hwloc) software package provides
a portable abstraction (across OS, versions, architectures, ...)
of the hierarchical topology of modern architectures, including
NUMA memory nodes, sockets, shared caches, cores and
simultaneous multithreading. It also gathers various system
attributes such as cache and memory information as well as the
locality of I/O devices such as network interfaces, InfiniBand
HCAs or GPUs. It primarily aims at helping applications with
gathering information about modern computing hardware so as to
exploit it accordingly and efficiently.
Diffstat (limited to 'parallel/hwloc/patches/patch-src_topology-netbsd.c')
-rw-r--r-- | parallel/hwloc/patches/patch-src_topology-netbsd.c | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/parallel/hwloc/patches/patch-src_topology-netbsd.c b/parallel/hwloc/patches/patch-src_topology-netbsd.c new file mode 100644 index 00000000000..04bdbe3853a --- /dev/null +++ b/parallel/hwloc/patches/patch-src_topology-netbsd.c @@ -0,0 +1,171 @@ +$NetBSD: patch-src_topology-netbsd.c,v 1.1.1.1 2012/03/21 13:31:35 asau Exp $ + +--- src/topology-netbsd.c.orig 2012-03-21 11:13:38.000000000 +0000 ++++ src/topology-netbsd.c +@@ -0,0 +1,166 @@ ++/* ++ * Copyright © 2012 Aleksej Saushev, The NetBSD Foundation ++ * Copyright © 2009-2011 inria. All rights reserved. ++ * Copyright © 2009-2010 Université Bordeaux 1 ++ * Copyright © 2011 Cisco Systems, Inc. All rights reserved. ++ * See COPYING in top-level directory. ++ */ ++ ++#define _NETBSD_SOURCE /* request "_np" functions */ ++ ++#include <private/autogen/config.h> ++ ++#include <sys/types.h> ++#include <stdlib.h> ++#include <inttypes.h> ++#include <sys/param.h> ++#include <pthread.h> ++#include <sched.h> ++ ++#include <hwloc.h> ++#include <private/private.h> ++#include <private/debug.h> ++ ++/* #ifdef HAVE_SCHED_H */ ++static void ++hwloc_netbsd_bsd2hwloc(hwloc_bitmap_t hwloc_cpuset, const cpuset_t *cpuset) ++{ ++ unsigned cpu, cpulimit; ++ hwloc_bitmap_zero(hwloc_cpuset); ++ cpulimit = cpuset_size(cpuset) * CHAR_BIT; ++ for (cpu = 0; cpu < cpulimit; cpu++) ++ if (cpuset_isset(cpu, cpuset)) ++ hwloc_bitmap_set(hwloc_cpuset, cpu); ++} ++ ++static void ++hwloc_netbsd_hwloc2bsd(hwloc_const_bitmap_t hwloc_cpuset, cpuset_t *cpuset) ++{ ++ unsigned cpu, cpulimit; ++ cpuset_zero(cpuset); ++ cpulimit = cpuset_size(cpuset) * CHAR_BIT; ++ for (cpu = 0; cpu < cpulimit; cpu++) ++ if (hwloc_bitmap_isset(hwloc_cpuset, cpu)) ++ cpuset_set(cpu, cpuset); ++} ++ ++static int ++hwloc_netbsd_set_proc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid, hwloc_const_bitmap_t hwloc_cpuset, int flags __hwloc_attribute_unused) ++{ ++ int status; ++ cpuset_t *cpuset = cpuset_create(); ++ ++ hwloc_netbsd_hwloc2bsd(hwloc_cpuset, cpuset); ++ ++ status = sched_setaffinity_np(pid, cpuset_size(cpuset), cpuset); ++ ++ cpuset_destroy(cpuset); ++ return status; ++} ++ ++static int ++hwloc_netbsd_get_proc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid, hwloc_bitmap_t hwloc_cpuset, int flags __hwloc_attribute_unused) ++{ ++ int status; ++ cpuset_t *cpuset = cpuset_create(); ++ ++ status = sched_setaffinity_np(pid, cpuset_size(cpuset), cpuset); ++ hwloc_netbsd_bsd2hwloc(hwloc_cpuset, cpuset); ++ ++ cpuset_destroy(cpuset); ++ return status; ++} ++ ++ ++static int ++hwloc_netbsd_set_thisproc_cpubind(hwloc_topology_t topology, hwloc_const_bitmap_t hwloc_cpuset, int flags) ++{ ++ return hwloc_netbsd_set_proc_cpubind(topology, 0, hwloc_cpuset, flags); ++} ++ ++static int ++hwloc_netbsd_get_thisproc_cpubind(hwloc_topology_t topology, hwloc_bitmap_t hwloc_cpuset, int flags) ++{ ++ return hwloc_netbsd_get_proc_cpubind(topology, 0, hwloc_cpuset, flags); ++} ++ ++ ++static int ++hwloc_netbsd_set_thread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_thread_t tid, hwloc_const_bitmap_t hwloc_cpuset, int flags __hwloc_attribute_unused) ++{ ++ int status; ++ cpuset_t *cpuset = cpuset_create(); ++ ++ hwloc_netbsd_hwloc2bsd(hwloc_cpuset, cpuset); ++ ++ status = pthread_setaffinity_np(tid, cpuset_size(cpuset), cpuset); ++ ++ cpuset_destroy(cpuset); ++ ++ if (status) { ++ errno = status; ++ return -1; ++ } ++ ++ return 0; ++} ++ ++static int ++hwloc_netbsd_get_thread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_thread_t tid, hwloc_bitmap_t hwloc_cpuset, int flags __hwloc_attribute_unused) ++{ ++ int status; ++ cpuset_t *cpuset = cpuset_create(); ++ ++ status = pthread_getaffinity_np(tid, cpuset_size(cpuset), cpuset); ++ ++ hwloc_netbsd_bsd2hwloc(hwloc_cpuset, cpuset); ++ cpuset_destroy(cpuset); ++ ++ if (status) { ++ errno = status; ++ return -1; ++ } ++ ++ return 0; ++} ++ ++ ++static int ++hwloc_netbsd_set_thisthread_cpubind(hwloc_topology_t topology, hwloc_const_bitmap_t hwloc_cpuset, int flags) ++{ ++ return hwloc_netbsd_set_thread_cpubind(topology, pthread_self(), hwloc_cpuset, flags); ++} ++ ++static int ++hwloc_netbsd_get_thisthread_cpubind(hwloc_topology_t topology, hwloc_bitmap_t hwloc_cpuset, int flags) ++{ ++ return hwloc_netbsd_get_thread_cpubind(topology, pthread_self(), hwloc_cpuset, flags); ++} ++ ++ ++void ++hwloc_look_netbsd(struct hwloc_topology *topology) ++{ ++ unsigned nbprocs = hwloc_fallback_nbprocessors(topology); ++ ++ hwloc_set_netbsd_hooks(topology); ++ hwloc_look_x86(topology, nbprocs); ++ ++ hwloc_setup_pu_level(topology, nbprocs); ++ ++ hwloc_obj_add_info(topology->levels[0][0], "Backend", "NetBSD"); ++} ++ ++void ++hwloc_set_netbsd_hooks(struct hwloc_topology *topology) ++{ ++ topology->set_proc_cpubind = hwloc_netbsd_set_proc_cpubind; ++ topology->get_proc_cpubind = hwloc_netbsd_get_proc_cpubind; ++ topology->set_thisproc_cpubind = hwloc_netbsd_set_thisproc_cpubind; ++ topology->get_thisproc_cpubind = hwloc_netbsd_get_thisproc_cpubind; ++ ++ topology->set_thread_cpubind = hwloc_netbsd_set_thread_cpubind; ++ topology->get_thread_cpubind = hwloc_netbsd_get_thread_cpubind; ++ topology->set_thisthread_cpubind = hwloc_netbsd_set_thisthread_cpubind; ++ topology->get_thisthread_cpubind = hwloc_netbsd_get_thisthread_cpubind; ++} |