2

I want to have a parallel function with different code paths depending on whether the function is being run in a system with an UMA or NUMA architecture, and I wonder how I can detect at runtime if the system is NUMA with more than 1 node.

I see Windows has some headers with kernel functions that can detect this, and Linux has a libnuma library that could be linked against to determine NUMA capabilities, but such library is not guaranteed to always be available. I see also there's lscpu in Linux as a command line utility that can get this info, but such function is not available in the BSDs.

Is there any reliable cross-platform and cross-compiler solution to detect at runtime if a program is being run on a system with NUMA architecture having more than 1 node?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
anymous.asker
  • 1,179
  • 9
  • 14
  • Do you have a cross platform cross compiler program that utilizes numa? – Daniel Nov 20 '21 at 21:45
  • @Dani : no, but I have a situation in which a NUMA architecture would benefit from a different way of allocating memory if it has a first-touch policy, which would be slightly slower in an UMA system due to e.g. repeated calls to `malloc`, and wanted to exploit that. – anymous.asker Nov 20 '21 at 21:49

0 Answers0