Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:16

0001 /*
0002  * Copyright © 2009 CNRS
0003  * Copyright © 2009-2023 Inria.  All rights reserved.
0004  * Copyright © 2009-2011 Université Bordeaux
0005  * See COPYING in top-level directory.
0006  */
0007 
0008 /** \file
0009  * \brief Macros to help interaction between hwloc and Linux.
0010  *
0011  * Applications that use hwloc on Linux may want to include this file
0012  * if using some low-level Linux features.
0013  */
0014 
0015 #ifndef HWLOC_LINUX_H
0016 #define HWLOC_LINUX_H
0017 
0018 #include "hwloc.h"
0019 
0020 #include <stdio.h>
0021 
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026 
0027 
0028 /** \defgroup hwlocality_linux Linux-specific helpers
0029  *
0030  * This includes helpers for manipulating Linux kernel cpumap files, and hwloc
0031  * equivalents of the Linux sched_setaffinity and sched_getaffinity system calls.
0032  *
0033  * @{
0034  */
0035 
0036 /** \brief Bind a thread \p tid on cpus given in cpuset \p set
0037  *
0038  * The behavior is exactly the same as the Linux sched_setaffinity system call,
0039  * but uses a hwloc cpuset.
0040  *
0041  * \return 0 on success, -1 on error.
0042  *
0043  * \note This is equivalent to calling hwloc_set_proc_cpubind() with
0044  * HWLOC_CPUBIND_THREAD as flags.
0045  */
0046 HWLOC_DECLSPEC int hwloc_linux_set_tid_cpubind(hwloc_topology_t topology, pid_t tid, hwloc_const_cpuset_t set);
0047 
0048 /** \brief Get the current binding of thread \p tid
0049  *
0050  * The CPU-set \p set (previously allocated by the caller)
0051  * is filled with the list of PUs which the thread
0052  * was last bound to.
0053  *
0054  * The behavior is exactly the same as the Linux sched_getaffinity system call,
0055  * but uses a hwloc cpuset.
0056  *
0057  * \return 0 on success, -1 on error.
0058  *
0059  * \note This is equivalent to calling hwloc_get_proc_cpubind() with
0060  * ::HWLOC_CPUBIND_THREAD as flags.
0061  */
0062 HWLOC_DECLSPEC int hwloc_linux_get_tid_cpubind(hwloc_topology_t topology, pid_t tid, hwloc_cpuset_t set);
0063 
0064 /** \brief Get the last physical CPU where thread \p tid ran.
0065  *
0066  * The CPU-set \p set (previously allocated by the caller)
0067  * is filled with the PU which the thread last ran on.
0068  *
0069  * \return 0 on success, -1 on error.
0070  *
0071  * \note This is equivalent to calling hwloc_get_proc_last_cpu_location() with
0072  * ::HWLOC_CPUBIND_THREAD as flags.
0073  */
0074 HWLOC_DECLSPEC int hwloc_linux_get_tid_last_cpu_location(hwloc_topology_t topology, pid_t tid, hwloc_bitmap_t set);
0075 
0076 /** \brief Convert a linux kernel cpumask file \p path into a hwloc bitmap \p set.
0077  *
0078  * Might be used when reading CPU set from sysfs attributes such as topology
0079  * and caches for processors, or local_cpus for devices.
0080  *
0081  * \return 0 on success, -1 on error.
0082  *
0083  * \note This function ignores the HWLOC_FSROOT environment variable.
0084  */
0085 HWLOC_DECLSPEC int hwloc_linux_read_path_as_cpumask(const char *path, hwloc_bitmap_t set);
0086 
0087 /** @} */
0088 
0089 
0090 #ifdef __cplusplus
0091 } /* extern "C" */
0092 #endif
0093 
0094 
0095 #endif /* HWLOC_LINUX_H */