From f8a314ea075745c244172173391e44c146837b87 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 29 Nov 2024 00:58:33 -0500 Subject: performance: reference counters can use relaxed order when incrementing --- src/core/platform.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/core/platform.h') diff --git a/src/core/platform.h b/src/core/platform.h index 0249e2a0..d2409e5b 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -197,8 +197,6 @@ extern void nni_atomic_sub64(nni_atomic_u64 *, uint64_t); extern uint64_t nni_atomic_get64(nni_atomic_u64 *); extern void nni_atomic_set64(nni_atomic_u64 *, uint64_t); extern uint64_t nni_atomic_swap64(nni_atomic_u64 *, uint64_t); -extern uint64_t nni_atomic_dec64_nv(nni_atomic_u64 *); -extern void nni_atomic_inc64(nni_atomic_u64 *); // nni_atomic_cas64 is a compare and swap. The second argument is the // value to compare against, and the third is the new value. Returns @@ -218,6 +216,11 @@ extern void nni_atomic_sub(nni_atomic_int *, int); extern int nni_atomic_get(nni_atomic_int *); extern void nni_atomic_set(nni_atomic_int *, int); extern int nni_atomic_swap(nni_atomic_int *, int); + +// These versions are tuned for use as reference +// counters. Relaxed order when possible to increase +// reference count, acquire-release order for dropping +// it (where we need to check the value). extern int nni_atomic_dec_nv(nni_atomic_int *); extern void nni_atomic_dec(nni_atomic_int *); extern void nni_atomic_inc(nni_atomic_int *); -- cgit v1.2.3-70-g09d2