Blender  V2.93
numaapi.h
Go to the documentation of this file.
1 // Copyright (c) 2016, libnumaapi authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 // IN THE SOFTWARE.
20 //
21 // Author: Sergey Sharybin <sergey.vfx@gmail.com>
22 
23 #ifndef __LIBNUMAAPI_H__
24 #define __LIBNUMAAPI_H__
25 
26 #include <stdbool.h>
27 #include <stddef.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #define NUMAAPI_VERSION_MAJOR 1
34 #define NUMAAPI_VERSION_MINOR 0
35 
36 typedef enum NUMAAPI_Result {
38  // NUMA is not available on this platform.
40  // Generic error, no real details are available,
42  // Error installing atexit() handlers.
45 
47 // Initialization.
48 
49 // Initialize NUMA API.
50 //
51 // This is first call which should be called before any other NUMA functions
52 // can be used.
54 
55 // Get string representation of NUMAPIResult.
57 
59 // Topology query.
60 
61 // Get number of available nodes.
62 //
63 // This is in fact an index of last node plus one and it's not guaranteed
64 // that all nodes up to this one are available.
65 int numaAPI_GetNumNodes(void);
66 
67 // Returns truth if the given node is available for compute.
69 
70 // Get number of available processors on a given node.
72 
74 // Topology helpers.
75 //
76 // Those are a bit higher level queries, but is still rather platform-specific
77 // and generally useful.
78 
79 // Get number of processors within the NUMA nodes on which current thread is
80 // set affinity on.
82 
84 // Affinities.
85 
86 // Runs the current process and its children on a specific node.
87 //
88 // Returns truth if affinity has successfully changed.
89 //
90 // NOTE: This function can not change active CPU group. Mainly designed to deal
91 // with Threadripper 2 topology, to make it possible to gain maximum performance
92 // for the main application thread.
94 
95 // Runs the current thread and its children on a specific node.
96 //
97 // Returns truth if affinity has successfully changed.
99 
101 // Memory management.
102 
103 // Allocate memory on a given node,
104 void* numaAPI_AllocateOnNode(size_t size, int node);
105 
106 // Allocate memory in the local memory, closest to the current node.
107 void* numaAPI_AllocateLocal(size_t size);
108 
109 // Frees size bytes of memory starting at start.
110 //
111 // TODO(sergey): Consider making it regular free() semantic.
112 void numaAPI_Free(void* start, size_t size);
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif // __LIBNUMAAPI_H__
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
OperationNode * node
bool numaAPI_IsNodeAvailable(int node)
Definition: numaapi_stub.c:45
bool numaAPI_RunProcessOnNode(int node)
Definition: numaapi_stub.c:65
void * numaAPI_AllocateOnNode(size_t size, int node)
Definition: numaapi_stub.c:78
NUMAAPI_Result numaAPI_Initialize(void)
Definition: numaapi_stub.c:34
NUMAAPI_Result
Definition: numaapi.h:36
@ NUMAAPI_SUCCESS
Definition: numaapi.h:37
@ NUMAAPI_ERROR
Definition: numaapi.h:41
@ NUMAAPI_ERROR_ATEXIT
Definition: numaapi.h:43
@ NUMAAPI_NOT_AVAILABLE
Definition: numaapi.h:39
const char * numaAPI_ResultAsString(NUMAAPI_Result result)
Definition: numaapi.c:27
void * numaAPI_AllocateLocal(size_t size)
Definition: numaapi_stub.c:84
void numaAPI_Free(void *start, size_t size)
Definition: numaapi_stub.c:89
int numaAPI_GetNumCurrentNodesProcessors(void)
Definition: numaapi_stub.c:58
int numaAPI_GetNumNodeProcessors(int node)
Definition: numaapi_stub.c:50
int numaAPI_GetNumNodes(void)
Definition: numaapi_stub.c:41
bool numaAPI_RunThreadOnNode(int node)
Definition: numaapi_stub.c:70