MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / mi_os_numa_node_countx

Function mi_os_numa_node_countx

3rd/mimalloc-2.0.9/src/os.c:1365–1388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1363}
1364
1365static size_t mi_os_numa_node_countx(void) {
1366 ULONG numa_max = 0;
1367 GetNumaHighestNodeNumber(&numa_max);
1368 // find the highest node number that has actual processors assigned to it. Issue #282
1369 while(numa_max > 0) {
1370 if (pGetNumaNodeProcessorMaskEx != NULL) {
1371 // Extended API is supported
1372 GROUP_AFFINITY affinity;
1373 if ((*pGetNumaNodeProcessorMaskEx)((USHORT)numa_max, &affinity)) {
1374 if (affinity.Mask != 0) break; // found the maximum non-empty node
1375 }
1376 }
1377 else {
1378 // Vista or earlier, use older API that is limited to 64 processors.
1379 ULONGLONG mask;
1380 if (GetNumaNodeProcessorMask((UCHAR)numa_max, &mask)) {
1381 if (mask != 0) break; // found the maximum non-empty node
1382 };
1383 }
1384 // max node was invalid or had no processor assigned, try again
1385 numa_max--;
1386 }
1387 return ((size_t)numa_max + 1);
1388}
1389#elif defined(__linux__)
1390#include <sys/syscall.h> // getcpu
1391#include <stdio.h> // access

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected