2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
27 // numa_num_nodes and numa_node_set are always defined. They are initialized to
28 // 1 (which is the value when libnuma isn't used).
29 extern uint32_t numa_num_nodes
;
30 extern uint32_t numa_node_set
;
34 extern uint32_t numa_node_mask
;
35 extern std::vector
<bitmask
*> node_to_cpu_mask
;
39 * init_numa() is called very early during process initialization, before
40 * parsing runtime options. It initializes `numa_num_nodes`, `numa_node_set`,
41 * and `numa_node_mask`, when NUMA APIs are usable.
46 * enable_numa() is called after parsing runtime options. It initializes
47 * `use_numa`, which is used to decide whether we actually call NUMA APIs. Note
48 * that on single-node systems, we don't set use_numa.
53 * Determine the next NUMA node according to state maintained in `curr_node`.
55 uint32_t next_numa_node(std::atomic
<uint32_t>& curr_node
);
57 * The number of numa nodes in the system
59 inline uint32_t num_numa_nodes() {
60 return use_numa
? numa_num_nodes
: 1;
63 * Enable numa interleaving for the specified address range
65 void numa_interleave(void* start
, size_t size
);
67 * Allocate the specified address range on the given node
69 void numa_bind_to(void* start
, size_t size
, uint32_t node
);
71 * Return true if node is part of the allowed set of numa nodes
73 inline bool numa_node_allowed(uint32_t node
) {
74 if (numa_node_set
== 0) return true;
75 return numa_node_set
& (1u << node
);
78 #else // HAVE_NUMA undefined
80 inline void init_numa() {}
81 inline void enable_numa() {}
82 inline constexpr uint32_t next_numa_node(std::atomic
<uint32_t>& curr_node
) {
85 inline constexpr uint32_t num_numa_nodes() { return 1; }
86 inline void numa_interleave(void* start
, size_t size
) {}
87 inline void numa_bind_to(void* start
, size_t size
, uint32_t node
) {}
88 inline constexpr bool numa_node_allowed(int node
) { return true; }