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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* Copyright (C) Mellanox Technologies Ltd. 2018. ALL RIGHTS RESERVED.
* See file LICENSE for terms.
*/
/** @file strided_alloc.h */
/* the distance between allocated elements */
/**
* Get a pointer to another element in the strided object
*
* Example with stride_count=3:
*
* chunk
* start -+
* |
* |
* | <-- 128 kB --> . <-- 128 kB --> .
* | . .
* \/ . .
* +--------+-- ... --+--------+-- ... --+--------+
* | stride | | stride | | stride |
* obj0: | elem 0 | | elem 1 | | elem 2 |
* | (base) | | | | |
* +--------+-- ... --+--------+-- ... --+--------+
* +--------+-- ... --+--------+-- ... --+--------+
* | stride | | stride | | stride |
* obj1: | elem 0 | | elem 1 | | elem 2 |
* | (base) | | | | |
* +--------+-- ... -+--------+-- ... --+--------+
* +--------+-- ... --+--------+-- ... --+--------+
* | stride | | stride | | stride |
* obj2: | elem 0 | | elem 1 | | elem 2 |
* | (base) | | | | |
* +--------+-- ... -+--------+-- ... --+--------+
*
* ...
*
* @param _elem Pointer to the current element
* @param _stride_idx Stride index of the current element
* @param _wanted_idx Stride index of the desired element
*
* @return Pointer to the desired element
*/
/* Forward declaration, used internally */
typedef struct ucs_strided_alloc_elem ucs_strided_alloc_elem_t;
/**
* Strided allocator - allows allocating objects which are split to several
* memory areas with a constant stride (gap) in-between.
* This improves the cache locality when the first memory area is used mostly.
*/
typedef struct ucs_strided_alloc ucs_strided_alloc_t;
/**
* Initialize the split allocator context
*
* @param [in] sa Strided allocator structure to initialize
* @param [in] elem_size Size of a single stride element
* @param [in] stride_count How many memory strides per object
*/
void ;
/**
* Cleanup the split allocator context
*
* @param [in] sa Strided allocator structure to cleanup
*/
void ;
/**
* Allocate an object
*
* @param [in] sa Strided allocator to allocate on
* @param [in] alloc_name Debug name of the allocation
*
* @return Pointer to the first stride of the allocated object.
*/
void* ;
/**
* Release an object
*
* @param [in] sa Strided allocator to release the object to
* @param [in] base Pointer to the first stride of the object to release
*/
void ;
/**
* Get the number of currently allocated objects
*
* @param [in] sa Strided allocator to get the information for
*
* @return Number of currently allocated objects
*/
unsigned ;