OpenMPI  0.1.1
linux.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009 CNRS
3  * Copyright © 2009-2010 inria. All rights reserved.
4  * Copyright © 2009-2011 Université Bordeaux 1
5  * See COPYING in top-level directory.
6  */
7 
8 /** \file
9  * \brief Macros to help interaction between hwloc and Linux.
10  *
11  * Applications that use hwloc on Linux may want to include this file
12  * if using some low-level Linux features.
13  */
14 
15 #ifndef HWLOC_LINUX_H
16 #define HWLOC_LINUX_H
17 
18 #include <hwloc.h>
19 #include <stdio.h>
20 
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 
27 /** \defgroup hwlocality_linux Linux-only helpers
28  *
29  * This includes helpers for manipulating linux kernel cpumap files, and hwloc
30  * equivalents of the Linux sched_setaffinity and sched_getaffinity system calls.
31  *
32  * @{
33  */
34 
35 /** \brief Convert a linux kernel cpumap file \p file into hwloc CPU set.
36  *
37  * Might be used when reading CPU set from sysfs attributes such as topology
38  * and caches for processors, or local_cpus for devices.
39  */
40 HWLOC_DECLSPEC int hwloc_linux_parse_cpumap_file(FILE *file, hwloc_cpuset_t set);
41 
42 /** \brief Bind a thread \p tid on cpus given in cpuset \p set
43  *
44  * The behavior is exactly the same as the Linux sched_setaffinity system call,
45  * but uses a hwloc cpuset.
46  */
47 HWLOC_DECLSPEC int hwloc_linux_set_tid_cpubind(hwloc_topology_t topology, pid_t tid, hwloc_const_cpuset_t set);
48 
49 /** \brief Get the current binding of thread \p tid
50  *
51  * The behavior is exactly the same as the Linux sched_getaffinity system call,
52  * but uses a hwloc cpuset.
53  */
54 HWLOC_DECLSPEC int hwloc_linux_get_tid_cpubind(hwloc_topology_t topology, pid_t tid, hwloc_cpuset_t set);
55 
56 /** @} */
57 
58 
59 #ifdef __cplusplus
60 } /* extern "C" */
61 #endif
62 
63 
64 #endif /* HWLOC_GLIBC_SCHED_H */
HWLOC_DECLSPEC int hwloc_linux_set_tid_cpubind(hwloc_topology_t topology, pid_t tid, hwloc_const_cpuset_t set)
Bind a thread tid on cpus given in cpuset set.
HWLOC_DECLSPEC int hwloc_linux_parse_cpumap_file(FILE *file, hwloc_cpuset_t set)
Convert a linux kernel cpumap file file into hwloc CPU set.
Definition: topology-linux.c:1332
Definition: private.h:56
HWLOC_DECLSPEC int hwloc_linux_get_tid_cpubind(hwloc_topology_t topology, pid_t tid, hwloc_cpuset_t set)
Get the current binding of thread tid.
Definition: cpuset.c:38