aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauli Nieminen2009-08-29 04:08:57 -0500
committerPauli Nieminen2010-03-17 05:42:21 -0500
commit966c9907c040b4fe4b288b4a9d82598797aee743 (patch)
tree59a9f29ede30ab039a3a4151d2a9b1a9d30796cc /xf86atomic.h
parent21105bc186d188f0bfc2f41c52b4b0ceb6742cf5 (diff)
downloadexternal-libdrm-966c9907c040b4fe4b288b4a9d82598797aee743.tar.gz
external-libdrm-966c9907c040b4fe4b288b4a9d82598797aee743.tar.xz
external-libdrm-966c9907c040b4fe4b288b4a9d82598797aee743.zip
libdrm_radeon: Optimize cs_gem_reloc to do less looping.
bo->referenced_in_cs is checked if bo is already in cs. Adding and removing reference in bo is done with atomic operations to allow parallel access to a bo from multiple contexts. cs->id generation code quarentees there is not duplicated ids which limits number of cs->ids to 32. If there is more cs objects rest will get id 0. V2: - Fix configure to check for atomics operations if libdrm_radeon is only selected. - Make atomic operations private to libdrm. This optimization decreases cs_write_reloc share of torcs profiling from 4.3% to 2.6%. Tested-by: Michel Dänzer <michel@daenzer.net> Signed-off-by: Pauli Nieminen <suokkos@gmail.com>
Diffstat (limited to 'xf86atomic.h')
-rw-r--r--xf86atomic.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/xf86atomic.h b/xf86atomic.h
index de8e220e..854187a0 100644
--- a/xf86atomic.h
+++ b/xf86atomic.h
@@ -50,6 +50,8 @@ typedef struct {
50# define atomic_set(x, val) ((x)->atomic = (val)) 50# define atomic_set(x, val) ((x)->atomic = (val))
51# define atomic_inc(x) ((void) __sync_fetch_and_add (&(x)->atomic, 1)) 51# define atomic_inc(x) ((void) __sync_fetch_and_add (&(x)->atomic, 1))
52# define atomic_dec_and_test(x) (__sync_fetch_and_add (&(x)->atomic, -1) == 1) 52# define atomic_dec_and_test(x) (__sync_fetch_and_add (&(x)->atomic, -1) == 1)
53# define atomic_add(x, v) ((void) __sync_add_and_fetch(&(x)->atomic, (v)))
54# define atomic_dec(x, v) ((void) __sync_sub_and_fetch(&(x)->atomic, (v)))
53# define atomic_cmpxchg(x, oldv, newv) __sync_val_compare_and_swap (&(x)->atomic, oldv, newv) 55# define atomic_cmpxchg(x, oldv, newv) __sync_val_compare_and_swap (&(x)->atomic, oldv, newv)
54 56
55#endif 57#endif
@@ -66,6 +68,8 @@ typedef struct {
66# define atomic_read(x) AO_load_full(&(x)->atomic) 68# define atomic_read(x) AO_load_full(&(x)->atomic)
67# define atomic_set(x, val) AO_store_full(&(x)->atomic, (val)) 69# define atomic_set(x, val) AO_store_full(&(x)->atomic, (val))
68# define atomic_inc(x) ((void) AO_fetch_and_add1_full(&(x)->atomic)) 70# define atomic_inc(x) ((void) AO_fetch_and_add1_full(&(x)->atomic))
71# define atomic_add(x, v) ((void) AO_fetch_and_add_full(&(x)->atomic, (v)))
72# define atomic_dec(x, v) ((void) AO_fetch_and_add_full(&(x)->atomic, -(v)))
69# define atomic_dec_and_test(x) (AO_fetch_and_sub1_full(&(x)->atomic) == 1) 73# define atomic_dec_and_test(x) (AO_fetch_and_sub1_full(&(x)->atomic) == 1)
70# define atomic_cmpxchg(x, oldv, newv) AO_compare_and_swap_full(&(x)->atomic, oldv, newv) 74# define atomic_cmpxchg(x, oldv, newv) AO_compare_and_swap_full(&(x)->atomic, oldv, newv)
71 75
@@ -82,6 +86,8 @@ typedef struct { uint_t atomic; } atomic_t;
82# define atomic_set(x, val) ((x)->atomic = (uint_t)(val)) 86# define atomic_set(x, val) ((x)->atomic = (uint_t)(val))
83# define atomic_inc(x) (atomic_inc_uint (&(x)->atomic)) 87# define atomic_inc(x) (atomic_inc_uint (&(x)->atomic))
84# define atomic_dec_and_test(x) (atomic_dec_uint_nv(&(x)->atomic) == 1) 88# define atomic_dec_and_test(x) (atomic_dec_uint_nv(&(x)->atomic) == 1)
89# define atomic_add(x, v) (atomic_add_uint(&(x)->atomic, (v)))
90# define atomic_dec(x, v) (atomic_dec_uint(&(x)->atomic, (v)))
85# define atomic_cmpxchg(x, oldv, newv) atomic_cas_uint (&(x)->atomic, oldv, newv) 91# define atomic_cmpxchg(x, oldv, newv) atomic_cas_uint (&(x)->atomic, oldv, newv)
86 92
87#endif 93#endif