• Home
  • Raw
  • Download

Lines Matching refs:suballocator

27 #define SKC_SUBALLOCATOR_DEBUG_ALLOC(suballocator,subbuf_id,ss)         \  argument
30 suballocator->name, \
31 suballocator->rem.avail, \
34 (skc_uint)suballocator->total);
36 #define SKC_SUBALLOCATOR_DEBUG_FREE(suballocator,subbuf_id,ss) \ argument
39 suballocator->name, \
40 suballocator->rem.avail, \
43 (skc_uint)suballocator->total);
47 #define SKC_SUBALLOCATOR_DEBUG_ALLOC(suballocator,subbuf_id,ss) argument
48 #define SKC_SUBALLOCATOR_DEBUG_FREE(suballocator,subbuf_id,ss) argument
58 struct skc_suballocator * const suballocator, in skc_suballocator_create() argument
64 size_t const subbufs_size = sizeof(*suballocator->subbufs) * subbufs; in skc_suballocator_create()
67suballocator->subbufs = skc_runtime_host_perm_alloc(runtime,SKC_MEM_FLAGS_READ_WRITE,subbufs_size); in skc_suballocator_create()
70 memset(suballocator->subbufs,0,subbufs_size); in skc_suballocator_create()
73 suballocator->subbufs[0].size = (skc_subbuf_size_t)size; in skc_suballocator_create()
76 suballocator->ids = skc_runtime_host_perm_alloc(runtime, in skc_suballocator_create()
78 sizeof(*suballocator->ids) * subbufs); in skc_suballocator_create()
80 suballocator->ids[ii] = ii; in skc_suballocator_create()
82 suballocator->rem.avail = 1; in skc_suballocator_create()
83 suballocator->rem.spare = subbufs - 1; in skc_suballocator_create()
85 suballocator->align = (skc_uint)align; in skc_suballocator_create()
86 suballocator->count = subbufs; in skc_suballocator_create()
88 suballocator->size = (skc_subbuf_size_t)size; in skc_suballocator_create()
89 suballocator->total = 0; in skc_suballocator_create()
91 suballocator->name = name; in skc_suballocator_create()
96 struct skc_suballocator * const suballocator) in skc_suballocator_dispose() argument
98 skc_runtime_host_perm_free(runtime,suballocator->ids); in skc_suballocator_dispose()
99 skc_runtime_host_perm_free(runtime,suballocator->subbufs); in skc_suballocator_dispose()
108 skc_suballocator_subbuf_alloc(struct skc_suballocator * const suballocator, in skc_suballocator_subbuf_alloc() argument
128 skc_subbuf_size_t const size_ru = (skc_subbuf_size_t)SKC_ROUND_UP_POW2(size,suballocator->align); in skc_suballocator_subbuf_alloc()
139 skc_subbuf_id_t * const ids = suballocator->ids; in skc_suballocator_subbuf_alloc()
143 skc_uint avail_rem = suballocator->rem.avail; in skc_suballocator_subbuf_alloc()
144 skc_uint spare_rem = suballocator->rem.spare; in skc_suballocator_subbuf_alloc()
149 struct skc_subbuf * const avail = suballocator->subbufs + avail_id; in skc_suballocator_subbuf_alloc()
155 suballocator->total += size_ru; in skc_suballocator_subbuf_alloc()
160 SKC_SUBALLOCATOR_DEBUG_ALLOC(suballocator,avail_id,size_ru); in skc_suballocator_subbuf_alloc()
168 suballocator->rem.avail = --avail_rem; in skc_suballocator_subbuf_alloc()
174 struct skc_subbuf * const last = suballocator->subbufs + last_id; in skc_suballocator_subbuf_alloc()
180 assert(suballocator->rem.avail > 0); in skc_suballocator_subbuf_alloc()
187 suballocator->total += size_ru; in skc_suballocator_subbuf_alloc()
189 skc_uint spare_idx = suballocator->count - spare_rem; in skc_suballocator_subbuf_alloc()
191 struct skc_subbuf * const spare = suballocator->subbufs + spare_id; in skc_suballocator_subbuf_alloc()
196 suballocator->rem.spare -= 1; in skc_suballocator_subbuf_alloc()
201 SKC_SUBALLOCATOR_DEBUG_ALLOC(suballocator,spare_id,size_ru); in skc_suballocator_subbuf_alloc()
222 assert(suballocator->rem.avail > 0); in skc_suballocator_subbuf_alloc()
238 skc_suballocator_subbuf_free(struct skc_suballocator * const suballocator, in skc_suballocator_subbuf_free() argument
242 struct skc_subbuf * const subbuf = suballocator->subbufs + subbuf_id; in skc_suballocator_subbuf_free()
246 suballocator->total -= subbuf->size; in skc_suballocator_subbuf_free()
248 SKC_SUBALLOCATOR_DEBUG_FREE(suballocator,subbuf_id,subbuf->size); in skc_suballocator_subbuf_free()
283 skc_uint const last_idx = --suballocator->rem.avail; in skc_suballocator_subbuf_free()
286 assert(suballocator->rem.avail > 0); in skc_suballocator_subbuf_free()
290 skc_subbuf_id_t const last_id = suballocator->ids[last_idx]; in skc_suballocator_subbuf_free()
291 struct skc_subbuf * const last = suballocator->subbufs + last_id; in skc_suballocator_subbuf_free()
293 suballocator->ids[next_idx] = last_id; in skc_suballocator_subbuf_free()
297 skc_subbuf_id_t const next_id = (skc_subbuf_id_t)(next - suballocator->subbufs); in skc_suballocator_subbuf_free()
299 skc_uint const spare_rem = suballocator->rem.spare + 2; in skc_suballocator_subbuf_free()
300 skc_uint const spare_idx = suballocator->count - spare_rem; in skc_suballocator_subbuf_free()
302 suballocator->rem.spare = spare_rem; in skc_suballocator_subbuf_free()
303 suballocator->ids[spare_idx + 0] = subbuf_id; in skc_suballocator_subbuf_free()
304 suballocator->ids[spare_idx + 1] = next_id; in skc_suballocator_subbuf_free()
317 assert(suballocator->rem.avail > 0); in skc_suballocator_subbuf_free()
319 suballocator->ids[suballocator->count - ++suballocator->rem.spare] = subbuf_id; in skc_suballocator_subbuf_free()
330 assert(suballocator->rem.avail > 0); in skc_suballocator_subbuf_free()
340 suballocator->ids[suballocator->count - ++suballocator->rem.spare] = subbuf_id; in skc_suballocator_subbuf_free()
344 skc_uint avail_idx = suballocator->rem.avail++; in skc_suballocator_subbuf_free()
351 assert(suballocator->rem.avail > 0); in skc_suballocator_subbuf_free()
353 suballocator->ids[avail_idx] = subbuf_id; in skc_suballocator_subbuf_free()
372 skc_suballocator_optimize(struct skc_suballocator * const suballocator)