Pyrogenesis  trunk
numa.h
Go to the documentation of this file.
1 /* Copyright (c) 2010 Wildfire Games
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining
4  * a copy of this software and associated documentation files (the
5  * "Software"), to deal in the Software without restriction, including
6  * without limitation the rights to use, copy, modify, merge, publish,
7  * distribute, sublicense, and/or sell copies of the Software, and to
8  * permit persons to whom the Software is furnished to do so, subject to
9  * the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef INCLUDED_NUMA
24 #define INCLUDED_NUMA
25 
26 //-----------------------------------------------------------------------------
27 // node topology
28 
29 /**
30  * @return number of NUMA "nodes" (i.e. groups of CPUs with local memory).
31  **/
32 LIB_API size_t numa_NumNodes();
33 
34 /**
35  * @param processor
36  * @return node number (zero-based) to which <processor> belongs.
37  **/
38 LIB_API size_t numa_NodeFromProcessor(size_t processor);
39 
40 /**
41  * @param node
42  * @return bit-mask of all processors constituting <node>.
43  **/
44 LIB_API uintptr_t numa_ProcessorMaskFromNode(size_t node);
45 
46 
47 //-----------------------------------------------------------------------------
48 // memory
49 
50 
51 /**
52  * @param node
53  * @return bytes of memory available for allocation on <node>.
54  **/
55 LIB_API size_t numa_AvailableMemory(size_t node);
56 
57 /**
58  * @return the ratio between maximum and minimum times that one processor
59  * from each node required to fill a globally allocated array.
60  * in other words, this is the maximum slowdown for NUMA-oblivious
61  * memory accesses. Microsoft guidelines require it to be <= 3.
62  **/
63 LIB_API double numa_Factor();
64 
65 /**
66  * @return an indication of whether memory pages are node-interleaved.
67  *
68  * note: this requires ACPI access, which may not be available on
69  * least-permission accounts. the default is to return false so as
70  * not to cause callers to panic and trigger performance warnings.
71  **/
72 LIB_API bool numa_IsMemoryInterleaved();
73 
74 #endif // #ifndef INCLUDED_NUMA
LIB_API size_t numa_NodeFromProcessor(size_t processor)
Definition: unuma.cpp:34
LIB_API size_t numa_AvailableMemory(size_t node)
Definition: unuma.cpp:45
LIB_API double numa_Factor()
Definition: unuma.cpp:51
LIB_API uintptr_t numa_ProcessorMaskFromNode(size_t node)
Definition: unuma.cpp:39
LIB_API size_t numa_NumNodes()
Definition: unuma.cpp:29
LIB_API bool numa_IsMemoryInterleaved()
Definition: unuma.cpp:56