|
1 | 1 | /*
|
2 |
| - * Copyright (C) 2022-2023 Intel Corporation |
| 2 | + * Copyright (C) 2022-2024 Intel Corporation |
3 | 3 | *
|
4 | 4 | * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
|
5 | 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
14 | 14 | extern "C" {
|
15 | 15 | #endif
|
16 | 16 |
|
| 17 | +/// @cond |
17 | 18 | #define UMF_OS_RESULTS_START_FROM 1000
|
| 19 | +/// @endcond |
18 | 20 |
|
19 | 21 | /// @brief Protection of the memory allocations
|
20 | 22 | typedef enum umf_mem_protection_flags_t {
|
21 | 23 | UMF_PROTECTION_NONE = (1 << 0), ///< Memory allocations can not be accessed
|
22 | 24 | UMF_PROTECTION_READ = (1 << 1), ///< Memory allocations can be read.
|
23 | 25 | UMF_PROTECTION_WRITE = (1 << 2), ///< Memory allocations can be written.
|
24 | 26 | UMF_PROTECTION_EXEC = (1 << 3), ///< Memory allocations can be executed.
|
25 |
| - |
| 27 | + /// @cond |
26 | 28 | UMF_PROTECTION_MAX // must be the last one
|
| 29 | + /// @endcond |
27 | 30 | } umf_mem_protection_flags_t;
|
28 | 31 |
|
29 | 32 | /// @brief Memory binding mode
|
30 |
| -/// |
31 | 33 | /// Specifies how memory is bound to NUMA nodes on systems that support NUMA.
|
32 | 34 | /// Not every mode is supported on every system.
|
33 | 35 | typedef enum umf_numa_mode_t {
|
34 |
| - UMF_NUMA_MODE_DEFAULT, ///< Default binding mode. Actual binding policy is system-specific. |
35 |
| - /// On linux this corresponds to MPOL_DEFAULT. If this mode is specified, |
36 |
| - /// nodemask must be NULL and maxnode must be 0. |
37 |
| - UMF_NUMA_MODE_BIND, ///< Restricts memory allocation to nodes specified in nodemask. Allocations |
38 |
| - /// might come from any of the allowed nodes. Nodemask must specify at least one node. |
39 |
| - UMF_NUMA_MODE_INTERLEAVE, ///< Interleaves memory allocations across the set of nodes specified in nodemask. |
40 |
| - /// Nodemask must specify at least one node. |
41 |
| - UMF_NUMA_MODE_PREFERRED, ///< Specifies preferred node for allocation. If allocation cannot be fulfilled, |
42 |
| - /// memory will be allocated from other nodes. |
43 |
| - UMF_NUMA_MODE_LOCAL, ///< The memory is allocated on the node of the CPU that triggered the allocation. |
44 |
| - /// If this mode is specified, nodemask must be NULL and maxnode must be 0. |
45 |
| - /// TODO: should this be a hint or strict policy? |
| 36 | + /// Default binding mode. Actual binding policy is system-specific. On |
| 37 | + /// linux this corresponds to MPOL_DEFAULT. If this mode is specified, |
| 38 | + /// nodemask must be NULL and maxnode must be 0. |
| 39 | + UMF_NUMA_MODE_DEFAULT, |
| 40 | + |
| 41 | + /// Restricts memory allocation to nodes specified in nodemask. Allocations |
| 42 | + /// might come from any of the allowed nodes. Nodemask must specify at |
| 43 | + // least one node. |
| 44 | + UMF_NUMA_MODE_BIND, |
| 45 | + |
| 46 | + /// Interleaves memory allocations across the set of nodes specified in |
| 47 | + /// nodemask. Nodemask must specify at least one node. |
| 48 | + UMF_NUMA_MODE_INTERLEAVE, |
| 49 | + |
| 50 | + /// Specifies preferred node for allocation. If allocation cannot be |
| 51 | + /// fulfilled, memory will be allocated from other nodes. |
| 52 | + UMF_NUMA_MODE_PREFERRED, |
| 53 | + |
| 54 | + /// The memory is allocated on the node of the CPU that triggered the |
| 55 | + /// allocation. If this mode is specified, nodemask must be NULL and |
| 56 | + /// maxnode must be 0. |
| 57 | + UMF_NUMA_MODE_LOCAL, // TODO: should this be a hint or strict policy? |
46 | 58 | } umf_numa_mode_t;
|
47 | 59 |
|
48 | 60 | /// @brief Memory provider settings struct
|
49 | 61 | typedef struct umf_os_memory_provider_params_t {
|
50 |
| - /// combination of 'umf_mem_protection_flags_t' flags |
| 62 | + /// Combination of 'umf_mem_protection_flags_t' flags |
51 | 63 | unsigned protection;
|
52 | 64 |
|
53 | 65 | // NUMA config
|
54 |
| - /// points to a bit mask of nodes containing up to maxnode bits, depending on |
| 66 | + /// Points to a bit mask of nodes containing up to maxnode bits, depending on |
55 | 67 | /// selected numa_mode newly allocated memory will be bound to those nodes
|
56 | 68 | unsigned long *nodemask;
|
57 |
| - /// max number of bits in nodemask |
| 69 | + /// Max number of bits in nodemask |
58 | 70 | unsigned long maxnode;
|
59 |
| - /// describes how nodemask is interpreted |
| 71 | + /// Describes how nodemask is interpreted |
60 | 72 | umf_numa_mode_t numa_mode;
|
61 | 73 |
|
62 | 74 | // others
|
63 |
| - /// log level of debug traces |
| 75 | + /// Log level of debug traces |
64 | 76 | int traces;
|
65 | 77 | } umf_os_memory_provider_params_t;
|
66 | 78 |
|
| 79 | +/// @brief OS Memory Provider operation results |
67 | 80 | typedef enum umf_os_memory_provider_native_error {
|
68 |
| - UMF_OS_RESULT_SUCCESS = UMF_OS_RESULTS_START_FROM, |
69 |
| - UMF_OS_RESULT_ERROR_ALLOC_FAILED, |
70 |
| - UMF_OS_RESULT_ERROR_ADDRESS_NOT_ALIGNED, |
71 |
| - UMF_OS_RESULT_ERROR_BIND_FAILED, |
72 |
| - UMF_OS_RESULT_ERROR_FREE_FAILED, |
73 |
| - UMF_OS_RESULT_ERROR_PURGE_LAZY_FAILED, |
74 |
| - UMF_OS_RESULT_ERROR_PURGE_FORCE_FAILED, |
75 |
| - UMF_OS_RESULT_ERROR_TOPO_DISCOVERY_FAILED, |
| 81 | + UMF_OS_RESULT_SUCCESS = UMF_OS_RESULTS_START_FROM, ///< Success |
| 82 | + UMF_OS_RESULT_ERROR_ALLOC_FAILED, ///< Memory allocation failed |
| 83 | + UMF_OS_RESULT_ERROR_ADDRESS_NOT_ALIGNED, ///< Allocated address is not aligned |
| 84 | + UMF_OS_RESULT_ERROR_BIND_FAILED, ///< Binding memory to NUMA node failed |
| 85 | + UMF_OS_RESULT_ERROR_FREE_FAILED, ///< Memory deallocation failed |
| 86 | + UMF_OS_RESULT_ERROR_PURGE_LAZY_FAILED, ///< Lazy purging failed |
| 87 | + UMF_OS_RESULT_ERROR_PURGE_FORCE_FAILED, ///< Force purging failed |
| 88 | + UMF_OS_RESULT_ERROR_TOPO_DISCOVERY_FAILED, ///< HWLOC topology discovery failed |
76 | 89 | } umf_os_memory_provider_native_error_t;
|
77 | 90 |
|
78 | 91 | umf_memory_provider_ops_t *umfOsMemoryProviderOps(void);
|
|
0 commit comments