1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* Copyright (C) 2021, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
* See file LICENSE for terms.
*/
/* All element sizes are power of two, except the cutoff by maximal allowed size
* (max_mp_entry_size in ucs_mpool_set_init). MSB is reserved to indicate
* presence of this cutoff.
*/
/* The structure represents a set of memory pools with different element sizes.
* The elements must be power of two. Requested memory size needs to be
* specified when fetching element from this set. Then it is actually fetched
* from the memory pool with the smallest element size which can fit the
* requested amount of data. This approach reduces wasting of memory when mpool
* elements are taken for different size objects. Due to performance constrains
* there are some restrictions for this structure:
* - memory pool sizes have to be power of two
* - maximal supported memory pool size is limited by UCS_MPOOL_SET_MAX_SIZE
*/
typedef struct ucs_mpool_set ucs_mpool_set_t;
/**
* Initialize a set of memory pools.
*
* @param mp_set Memory pool set structure.
* @param sizes Array of requested memory pool sizes. All values
* must be power of 2.
* @param sizes_count Length of @a sizes array.
* @param max_mp_entry_size Maximal size which needs to be supported by this
* set. Can be non power of 2.
* @param priv_size Size of user-defined private data area.
* @param priv_elem_size Size of auxiliary data which needs to be stored with
* every element of this set. Every created mpool will
* be capable of storing elements of requested size
* plus this value.
* @param align_offset Offset in the element which should be aligned to the
* given boundary.
* @param alignment Boundary to which align the given offset within the
* element.
* @param elems_per_chunk Number of elements in a single chunk of every memory
* pool.
* @param max_elems Maximal number of elements which can be allocated by
* every mpool in the current set. -1 or UINT_MAX means
* no limit.
* @param ops Memory pool operations.
* @param name Name of this memory pool set.
*
* @return UCS status code.
*/
ucs_status_t
;
/**
* Cleanup a memory pool set and release all its memory.
*
* @param mp_set Memory pool set structure.
* @param leak_check Whether to check for leaks (object which were not
* returned to the set).
*/
void ;
/**
* @param mp_set Memory pool set structure.
*
* @return Pointer to the private area of size specified in @a
* ucs_mpool_set_init().
*/
void *;
/**
* @param mp_set Memory pool set structure.
*
* @return Memory pool set name.
*/
const char *;
/* UCS_MPOOL_SET_H_ */