-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interface to query CPU setup, numa information and set affinity #14
Comments
I'd like to take up on this, I wrote the cpu topology used in OpenBSD ages ago so hopefully I can contribute something. What follows is just a collection of thoughts, so take it all with a grain of salt, please :). TopologyOn the very basic, we could provide a smt (thread) count, a core count and a package (socket) count, and also the relationship between them and so on. Domainsllib could provide this, but I don't think it belongs in the standard library. To build the topology on x86 we need to be able to at least retrieve the We can't assume x86 or POSIX, we also can't cover every operating system and architecture so we might consider making Domainsllib able to fail on any of the queries, I think this is better than silently returning I haven't dived into Windows but I'm sure it provides this information somewhere, I'll write from the top of my head what I know: Topology retrieval, from top of my head
Except for OpenBSD we can also just build our own by retrieving the pinning and fetching the NomenclatureNaming this is kinda tricky, people use threads, cores, cpus with different meanings, also a lot of the jargon is inheriting from x86, like smt (maybe sparc!?) and packages, at any rate this must be considered. NUMAI don't think any operating system provides any active toggles other than CPU affinity to a userland process, so pinning memory zones (as in the zones the acpi table gives you). Usually what they do (at least Linux/FreeBSD/NetBSD) is to try to map pages belonging to a memory zone of the affinity cpu, so if you say edit: I'm completely wrong here, linux has set_mempolicy(2), mbind(2) and more. AffinityDomainsllib could provide something like Set affinity support, from top of my head
|
So I'm building this: https://github.com/haesbaert/ocaml-cpu
|
Thanks @haesbaert. In general, we're avoiding the term "threads" in OCaml 5 since we have multiple notions of threading -- domains, fibers and systhreads. I'm leaning towards Before we expose |
If we avoid the term "threads" I think "cpus" should be used to refer to "logical cpus/threads". I believe most people associate "num_cores" with an actual core (as in the parent of threads). As discussed on Slack, most OSes usually just give us a "get_cpu_count" which return the total number of logical cpus (aka threads), so if hyperthreading is enabled it will return twice the number of cores, if disabled, threads==core. From now on I'll refer to "cpus" as in: total logical cpus available (total number of threads).
I'm not sure, it probably depends a lot on the OS and socket configuration, I assume Linux does a decent job at keeping the pthreads on cpus of the same socket. There is a social aspect to this discussion, think that no project out there is exposing much more than "number of cpus", I guess the affinity/pinning, when relevant, is done outside via |
I have released https://github.com/haesbaert/ocaml-processor which hopefully addresses this. |
It might be useful (at least experimentally) to add an interface that allows the user to easily:
Open questions for this are:
The text was updated successfully, but these errors were encountered: