Lines 201-206
get_heap_ptr(void) {
Link Here
|
201 |
} |
201 |
} |
202 |
} |
202 |
} |
203 |
|
203 |
|
|
|
204 |
// realtime |
205 |
__attribute__((target("s-memrealtime"))) static ulong |
206 |
realtime(void) |
207 |
{ |
208 |
return __builtin_amdgcn_s_memrealtime(); |
209 |
} |
210 |
|
204 |
// The actual number of blocks in a slab with blocks of kind k |
211 |
// The actual number of blocks in a slab with blocks of kind k |
205 |
static uint |
212 |
static uint |
206 |
num_blocks(kind_t k) |
213 |
num_blocks(kind_t k) |
Lines 466-472
new_slab_wait(__global heap_t *hp, kind_t k)
Link Here
|
466 |
uint aid = __ockl_activelane_u32(); |
473 |
uint aid = __ockl_activelane_u32(); |
467 |
if (aid == 0) { |
474 |
if (aid == 0) { |
468 |
ulong expected = AL(&hp->salloc_time[k].value, memory_order_relaxed); |
475 |
ulong expected = AL(&hp->salloc_time[k].value, memory_order_relaxed); |
469 |
ulong now = __ockl_steadyctr_u64(); |
476 |
ulong now = realtime(); |
470 |
ulong dt = now - expected; |
477 |
ulong dt = now - expected; |
471 |
if (dt < SLAB_TICKS) |
478 |
if (dt < SLAB_TICKS) |
472 |
__ockl_rtcwait_u32(SLAB_TICKS - (uint)dt); |
479 |
__ockl_rtcwait_u32(SLAB_TICKS - (uint)dt); |
Lines 480-486
grow_recordable_wait(__global heap_t *hp, kind_t k)
Link Here
|
480 |
uint aid = __ockl_activelane_u32(); |
487 |
uint aid = __ockl_activelane_u32(); |
481 |
if (aid == 0) { |
488 |
if (aid == 0) { |
482 |
ulong expected = AL(&hp->grow_time[k].value, memory_order_relaxed); |
489 |
ulong expected = AL(&hp->grow_time[k].value, memory_order_relaxed); |
483 |
ulong now = __ockl_steadyctr_u64(); |
490 |
ulong now = realtime(); |
484 |
ulong dt = now - expected; |
491 |
ulong dt = now - expected; |
485 |
if (dt < GROW_TICKS) |
492 |
if (dt < GROW_TICKS) |
486 |
__ockl_rtcwait_u32(GROW_TICKS - (uint)dt); |
493 |
__ockl_rtcwait_u32(GROW_TICKS - (uint)dt); |
Lines 540-546
try_grow_num_recordable_slabs(__global heap_t *hp, kind_t k)
Link Here
|
540 |
uint ret = GROW_BUSY; |
547 |
uint ret = GROW_BUSY; |
541 |
if (aid == 0) { |
548 |
if (aid == 0) { |
542 |
ulong expected = AL(&hp->grow_time[k].value, memory_order_relaxed); |
549 |
ulong expected = AL(&hp->grow_time[k].value, memory_order_relaxed); |
543 |
ulong now = __ockl_steadyctr_u64(); |
550 |
ulong now = realtime(); |
544 |
if (now - expected >= GROW_TICKS && |
551 |
if (now - expected >= GROW_TICKS && |
545 |
ACE(&hp->grow_time[k].value, &expected, now, memory_order_relaxed)) |
552 |
ACE(&hp->grow_time[k].value, &expected, now, memory_order_relaxed)) |
546 |
ret = GROW_FAILURE; |
553 |
ret = GROW_FAILURE; |
Lines 687-693
try_allocate_new_slab(__global heap_t *hp, kind_t k)
Link Here
|
687 |
|
694 |
|
688 |
if (aid == 0) { |
695 |
if (aid == 0) { |
689 |
ulong expected = AL(&hp->salloc_time[k].value, memory_order_relaxed); |
696 |
ulong expected = AL(&hp->salloc_time[k].value, memory_order_relaxed); |
690 |
ulong now = __ockl_steadyctr_u64(); |
697 |
ulong now = realtime(); |
691 |
if (now - expected >= SLAB_TICKS && |
698 |
if (now - expected >= SLAB_TICKS && |
692 |
ACE(&hp->salloc_time[k].value, &expected, now, memory_order_relaxed)) |
699 |
ACE(&hp->salloc_time[k].value, &expected, now, memory_order_relaxed)) |
693 |
ret = (__global sdata_t *)0; |
700 |
ret = (__global sdata_t *)0; |