hwlocality icon indicating copy to clipboard operation
hwlocality copied to clipboard

Expose Linux libc interop

Open HadrienG2 opened this issue 2 years ago • 3 comments

Expose libc::sched_(get|set)affinity interoperability behind suitable cfg flags with associated doc(cfg)/cfg(doc): https://hwloc.readthedocs.io/en/v2.9/group__hwlocality__glibc__sched.html

HadrienG2 avatar Feb 16 '23 16:02 HadrienG2

That actually looks quite Linux specific. Also, at the time of writing, there is no safe way to create a libc::cpu_set_t, which means that interfacing hwloc_cpuset_to_glibc_sched_affinity() would require some use of MaybeUninit.

HadrienG2 avatar Feb 22 '23 07:02 HadrienG2

Ah, well, I see, the issue is that the cpu_set_t of one libc may theoretically not match that of another libc. Then indeed, we need cfg(all(target_os = "linux", target_env = "gnu"))

HadrienG2 avatar Feb 22 '23 16:02 HadrienG2

Unfortunately, with the libc crate in its current state, it is not possible to implement this, because the hwloc functions are static functions (so we need to rewrite them in the rust bindings), and the libc crate 1/does not seem to allow safely creating a cpu_set_t and 2/expects &mut cpu_set_t in all functions that manipulate cpusets.

HadrienG2 avatar Apr 12 '23 16:04 HadrienG2