Skip to contentSkip to conversation

libdrm: Move intel_atomic.h to libdrm core for sharing. (V3)

PATCH In review Pauli Nieminen 3 participants 5 messages Mar 12, 2010 1 message not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 libdrm: Move intel_atomic.h to libdrm core for sharing. (V3)

intel_atomic.h includes very usefull atomic operations for lock free parrallel access of variables. Moving these to core libdrm for code sharing with radeon.

V2: Fix remaining references to intel_atomic.h and libdrm-intel.

V3: Remove useless wrapper header intel_atomic.h

---
 Makefile.am              |    3 +
 configure.ac             |    2 +-
 intel/Makefile.am        |    1 -
 intel/intel_atomic.h     |   93 ----------------------------------------------
 intel/intel_bufmgr_gem.c |    2 +-
 xf86atomic.h             |   93 ++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 98 insertions(+), 96 deletions(-)
 delete mode 100644 intel/intel_atomic.h
 create mode 100644 xf86atomic.h
Makefile.am +3 -0
index ee3ccc7..e434e1d 100644
@@ -61,6 +61,9 @@ libdrm_la_SOURCES =				\
 libdrmincludedir = ${includedir}
 libdrminclude_HEADERS = xf86drm.h xf86drmMode.h
 
+noinst_HEADERS = xf86atomic.h
+
+
 EXTRA_DIST = libdrm.pc.in include/drm/*
 
 copy-headers :
configure.ac +1 -1
index aaa8efa..953a758 100644
@@ -198,7 +198,7 @@ if test "x$INTEL" != "xno"; then
 
     ])
     if test "x$drm_cv_atomic_primitives" = xIntel; then
-	    AC_DEFINE(HAVE_INTEL_ATOMIC_PRIMITIVES, 1,
+	    AC_DEFINE(HAVE_LIBDRM_ATOMIC_PRIMITIVES, 1,
 		      [Enable if your compiler supports the Intel __sync_* atomic primitives])
     fi
     if test "x$drm_cv_atomic_primitives" = "xlibatomic-ops"; then
intel/Makefile.am +0 -1
index 8bb2c6e..9add505 100644
@@ -35,7 +35,6 @@ libdrm_intel_la_LDFLAGS = -version-number 1:0:0 -no-undefined
 libdrm_intel_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @CLOCK_LIB@
 
 libdrm_intel_la_SOURCES = \
-	intel_atomic.h \
 	intel_bufmgr.c \
 	intel_bufmgr_priv.h \
 	intel_bufmgr_fake.c \
intel/intel_atomic.h deleted +0 -93

93 lines not on this page · raw message

intel/intel_bufmgr_gem.c +1 -1
index 8838536..c3b5d6a 100644
@@ -39,6 +39,7 @@
 #endif
 
 #include <xf86drm.h>
+#include <xf86atomic.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -53,7 +54,6 @@
 
 #include "errno.h"
 #include "libdrm_lists.h"
-#include "intel_atomic.h"
 #include "intel_bufmgr.h"
 #include "intel_bufmgr_priv.h"
 #include "intel_chipset.h"
xf86atomic.h new file +93 -0

93 lines not on this page · raw message

Signature · 1 line
1.6.3.3

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

#1 lore raw

PATCH 2/3 libdrm_radeon: Optimize cs_gem_reloc to do less looping. (V2)

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 selected and libdrm_intel is not.
- Make atomic operations private to libdrm_radeon.
- Add warning messages if disabling automaticaly selected libdrm_(radeon|intel)

This optimization decreases cs_write_reloc share of torcs profiling from 4.3% to 2.6%.

---
 configure.ac           |   27 ++++++++---
 radeon/radeon_bo_gem.c |    9 ++++
 radeon/radeon_bo_gem.h |    1 +
 radeon/radeon_cs.c     |    6 ++
 radeon/radeon_cs.h     |    2 +-
 radeon/radeon_cs_gem.c |  123 ++++++++++++++++++++++++++++++++++++------------
 radeon/radeon_cs_int.h |    1 +
 xf86atomic.h           |    6 ++
 8 files changed, 136 insertions(+), 39 deletions(-)
configure.ac +20 -7
index 953a758..374beb3 100644
@@ -56,8 +56,8 @@ AC_ARG_ENABLE(intel,
 
 AC_ARG_ENABLE(radeon,
 	      AS_HELP_STRING([--disable-radeon],
-	      [Enable support for radeon's KMS API (default: enabled)]),
-	      [RADEON=$enableval], [RADEON=yes])
+	      [Enable support for radeon's KMS API (default: auto)]),
+	      [RADEON=$enableval], [RADEON=auto])
 
 AC_ARG_ENABLE(vmwgfx-experimental-api,
 	      AS_HELP_STRING([--enable-vmwgfx-experimental-api],
@@ -173,7 +173,7 @@ if test "x$HAVE_LIBUDEV" = xyes; then
 fi
 AM_CONDITIONAL(HAVE_LIBUDEV, [test "x$HAVE_LIBUDEV" = xyes])
 
-if test "x$INTEL" != "xno"; then
+if test "x$INTEL" != "xno" -o "x$RADEON" != "xno"; then
     # Check for atomic intrinsics
     AC_CACHE_CHECK([for native atomic primitives], drm_cv_atomic_primitives,
     [
@@ -206,13 +206,26 @@ if test "x$INTEL" != "xno"; then
     fi
 
     if test "x$drm_cv_atomic_primitives" = "xnone"; then
-	    if test "x$INTEL" != "xauto"; then
-		    AC_MSG_ERROR([libdrm_intel depends upon atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package, or, failing both of those, disable support for Intel GPUs by passing --disable-intel to ./configure])
-	   else
+           if test "x$INTEL" != "xauto"; then
+                    AC_MSG_ERROR([libdrm_intel depends upon atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package, or, failing both of those, disable support for Intel GPUs by passing --disable-intel to ./configure])
+           else
+                    AC_MSG_WARN([Disabling libdrm_intel. It depends on atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package.])
 		    INTEL=no
 	   fi
+           if test "x$RADEON" != "xauto"; then
+		    AC_MSG_ERROR([libdrm_radeon depends upon atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package, or, failing both of those, disable support for Radeon support by passing --disable-radeon to ./configure])
+	   else
+                    AC_MSG_WARN([Disabling libdrm_radeon. It depends on atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package.])
+		    RADEON=no
+	   fi
+
     else
-	   INTEL=yes
+           if test "x$INTEL" != "xno"; then
+	            INTEL=yes
+           fi
+           if test "x$RADEON" != "xno"; then
+	            RADEON=yes
+           fi
     fi
 fi
 
radeon/radeon_bo_gem.c +9 -0
index bc8058d..081ccb9 100644
@@ -39,6 +39,7 @@
 #include <sys/mman.h>
 #include <errno.h>
 #include "xf86drm.h"
+#include "xf86atomic.h"
 #include "drm.h"
 #include "radeon_drm.h"
 #include "radeon_bo.h"
@@ -49,6 +50,7 @@ struct radeon_bo_gem {
     struct radeon_bo_int base;
     uint32_t            name;
     int                 map_count;
+    atomic_t            reloc_in_cs;
     void *priv_ptr;
 };
 
@@ -80,6 +82,7 @@ static struct radeon_bo *bo_open(struct radeon_bo_manager *bom,
     bo->base.domains = domains;
     bo->base.flags = flags;
     bo->base.ptr = NULL;
+    atomic_set(&bo->reloc_in_cs, 0);
     bo->map_count = 0;
     if (handle) {
         struct drm_gem_open open_arg;
@@ -309,6 +312,12 @@ uint32_t radeon_gem_name_bo(struct radeon_bo *bo)
     return bo_gem->name;
 }
 
+void *radeon_gem_get_reloc_in_cs(struct radeon_bo *bo)
+{
+    struct radeon_bo_gem *bo_gem = (struct radeon_bo_gem*)bo;
+    return &bo_gem->reloc_in_cs;
+}
+
 int radeon_gem_get_kernel_name(struct radeon_bo *bo, uint32_t *name)
 {
     struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
radeon/radeon_bo_gem.h +1 -0
index c56c58e..0af8610 100644
@@ -38,6 +38,7 @@ struct radeon_bo_manager *radeon_bo_manager_gem_ctor(int fd);
 void radeon_bo_manager_gem_dtor(struct radeon_bo_manager *bom);
 
 uint32_t radeon_gem_name_bo(struct radeon_bo *bo);
+void *radeon_gem_get_reloc_in_cs(struct radeon_bo *bo);
 int radeon_gem_set_domain(struct radeon_bo *bo, uint32_t read_domains, uint32_t write_domain);
 int radeon_gem_get_kernel_name(struct radeon_bo *bo, uint32_t *name);
 #endif
radeon/radeon_cs.c +6 -0
index cc9be39..d0e922b 100644
@@ -88,3 +88,9 @@ void radeon_cs_space_set_flush(struct radeon_cs *cs, void (*fn)(void *), void *d
     csi->space_flush_fn = fn;
     csi->space_flush_data = data;
 }
+
+uint32_t radeon_cs_get_id(struct radeon_cs *cs)
+{
+    struct radeon_cs_int *csi = (struct radeon_cs_int *)cs;
+    return csi->id;
+}
radeon/radeon_cs.h +1 -1
index 49d5d9a..7f6ee68 100644
@@ -85,7 +85,7 @@ extern int radeon_cs_write_reloc(struct radeon_cs *cs,
                                  uint32_t read_domain,
                                  uint32_t write_domain,
                                  uint32_t flags);
-
+extern uint32_t radeon_cs_get_id(struct radeon_cs *cs);
 /*
  * add a persistent BO to the list
  * a persistent BO is one that will be referenced across flushes,
radeon/radeon_cs_gem.c +92 -31

178 lines not on this page · raw message

radeon/radeon_cs_int.h +1 -0
index 8ba76bf..6cee574 100644
@@ -28,6 +28,7 @@ struct radeon_cs_int {
     int                         bo_count;
     void                        (*space_flush_fn)(void *);
     void                        *space_flush_data;
+    uint32_t                    id;
 };
 
 /* cs functions */
xf86atomic.h +6 -0
index de8e220..854187a 100644
@@ -50,6 +50,8 @@ typedef struct {
 # define atomic_set(x, val) ((x)->atomic = (val))
 # define atomic_inc(x) ((void) __sync_fetch_and_add (&(x)->atomic, 1))
 # define atomic_dec_and_test(x) (__sync_fetch_and_add (&(x)->atomic, -1) == 1)
+# define atomic_add(x, v) ((void) __sync_add_and_fetch(&(x)->atomic, (v)))
+# define atomic_dec(x, v) ((void) __sync_sub_and_fetch(&(x)->atomic, (v)))
 # define atomic_cmpxchg(x, oldv, newv) __sync_val_compare_and_swap (&(x)->atomic, oldv, newv)
 
 #endif
@@ -66,6 +68,8 @@ typedef struct {
 # define atomic_read(x) AO_load_full(&(x)->atomic)
 # define atomic_set(x, val) AO_store_full(&(x)->atomic, (val))
 # define atomic_inc(x) ((void) AO_fetch_and_add1_full(&(x)->atomic))
+# define atomic_add(x, v) ((void) AO_fetch_and_add_full(&(x)->atomic, (v)))
+# define atomic_dec(x, v) ((void) AO_fetch_and_add_full(&(x)->atomic, -(v)))
 # define atomic_dec_and_test(x) (AO_fetch_and_sub1_full(&(x)->atomic) == 1)
 # define atomic_cmpxchg(x, oldv, newv) AO_compare_and_swap_full(&(x)->atomic, oldv, newv)
 
@@ -82,6 +86,8 @@ typedef struct { uint_t atomic; } atomic_t;
 # define atomic_set(x, val) ((x)->atomic = (uint_t)(val))
 # define atomic_inc(x) (atomic_inc_uint (&(x)->atomic))
 # define atomic_dec_and_test(x) (atomic_dec_uint_nv(&(x)->atomic) == 1)
+# define atomic_add(x, v) (atomic_add_uint(&(x)->atomic, (v)))
+# define atomic_dec(x, v) (atomic_dec_uint(&(x)->atomic, (v)))
 # define atomic_cmpxchg(x, oldv, newv) atomic_cas_uint (&(x)->atomic, oldv, newv)
 
 #endif
Signature · 10 lines
1.6.3.3


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
#2 lore raw

PATCH 3/3 libdrm: Move all noninstalled headers to noinst_HEADERS.

Cleanup make system so that all noninstalled headers are put to noinst_HEADERS. This quarentees that header will be present in tar ball but not installed with make install.

---
 Makefile.am         |    6 +++---
 intel/Makefile.am   |   10 ++++++----
 nouveau/Makefile.am |    4 +++-
 3 files changed, 12 insertions(+), 8 deletions(-)
Makefile.am +3 -3
index e434e1d..61da186 100644
@@ -55,13 +55,13 @@ libdrm_la_SOURCES =				\
 	xf86drmHash.c				\
 	xf86drmRandom.c				\
 	xf86drmSL.c				\
-	xf86drmMode.c				\
-	libdrm_lists.h
+	xf86drmMode.c
 
 libdrmincludedir = ${includedir}
 libdrminclude_HEADERS = xf86drm.h xf86drmMode.h
 
-noinst_HEADERS = xf86atomic.h
+noinst_HEADERS = xf86atomic.h \
+	libdrm_lists.h
 
 
 EXTRA_DIST = libdrm.pc.in include/drm/*
intel/Makefile.am +6 -4
index 9add505..d56b03a 100644
@@ -36,14 +36,16 @@ libdrm_intel_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @CLOCK_LIB@
 
 libdrm_intel_la_SOURCES = \
 	intel_bufmgr.c \
-	intel_bufmgr_priv.h \
 	intel_bufmgr_fake.c \
 	intel_bufmgr_gem.c \
-	intel_chipset.h \
-	mm.c \
-	mm.h
+	mm.c
 
 libdrm_intelincludedir = ${includedir}
 libdrm_intelinclude_HEADERS = intel_bufmgr.h
 
+noinst_HEADERS = \
+	intel_bufmgr_priv.h \
+	intel_chipset.h \
+	mm.h
+
 pkgconfig_DATA = libdrm_intel.pc
nouveau/Makefile.am +3 -1
index 5d759c5..53099eb 100644
@@ -18,7 +18,6 @@ libdrm_nouveau_la_SOURCES = \
 			    nouveau_notifier.c \
 			    nouveau_bo.c \
 			    nouveau_resource.c \
-			    nouveau_private.h \
 			    nouveau_reloc.c
 
 libdrm_nouveaucommonincludedir = ${includedir}/nouveau
@@ -38,5 +37,8 @@ libdrm_nouveauincludedir = ${includedir}/drm
 libdrm_nouveauinclude_HEADERS = \
 				nouveau_drmif.h
 
+noinst_HEADERS = \
+                 nouveau_private.h
+
 pkgconfigdir = @pkgconfigdir@
 pkgconfig_DATA = libdrm_nouveau.pc
Signature · 10 lines
1.6.3.3


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--

A message that is not in the archive (sent off-list or not yet received): 1268398235-21806-3-git-send-email-suokkos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw

Re: [Intel-gfx] [PATCH 3/3] libdrm: Move all noninstalled headers to noinst_HEADERS.

Quoted 77 lines · Pauli Nieminen

Cleanup make system so that all noninstalled headers are put to noinst_HEADERS. This quarentees that header will be present in tar ball but not installed with make install.

---
 Makefile.am         |    6 +++---
 intel/Makefile.am   |   10 ++++++----
 nouveau/Makefile.am |    4 +++-

 3 files changed, 12 insertions(+), 8 deletions(-)
Makefile.am +1 -2
index e434e1d..61da186 100644
@@ -55,13 +55,13 @@ libdrm_la_SOURCES =                         \
        xf86drmHash.c                           \
        xf86drmRandom.c                         \
        xf86drmSL.c                             \
-       xf86drmMode.c                           \
-       libdrm_lists.h
+       xf86drmMode.c
 
  libdrmincludedir = ${includedir}

 libdrminclude_HEADERS = xf86drm.h xf86drmMode.h

Makefile.am +2 -1
-noinst_HEADERS = xf86atomic.h
+noinst_HEADERS = xf86atomic.h \
+       libdrm_lists.h

 EXTRA_DIST = libdrm.pc.in include/drm/*

intel/Makefile.am +1 -4
index 9add505..d56b03a 100644
@@ -36,14 +36,16 @@ libdrm_intel_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @CLOCK_LIB@
 
  libdrm_intel_la_SOURCES = \
        intel_bufmgr.c \
-       intel_bufmgr_priv.h \
        intel_bufmgr_fake.c \
        intel_bufmgr_gem.c \
-       intel_chipset.h \
-       mm.c \
-       mm.h
+       mm.c
 
  libdrm_intelincludedir = ${includedir}

 libdrm_intelinclude_HEADERS = intel_bufmgr.h

intel/Makefile.am +5 -0
+noinst_HEADERS = \
+       intel_bufmgr_priv.h \
+       intel_chipset.h \
+       mm.h
+

 pkgconfig_DATA = libdrm_intel.pc

nouveau/Makefile.am +0 -1
index 5d759c5..53099eb 100644
@@ -18,7 +18,6 @@ libdrm_nouveau_la_SOURCES = \
                            nouveau_notifier.c \
                            nouveau_bo.c \
                            nouveau_resource.c \
-                           nouveau_private.h \

                           nouveau_reloc.c

 libdrm_nouveaucommonincludedir = ${includedir}/nouveau

nouveau/Makefile.am +0 -0
@@ -38,5 +37,8 @@ libdrm_nouveauincludedir = ${includedir}/drm
  libdrm_nouveauinclude_HEADERS = \

                               nouveau_drmif.h

nouveau/Makefile.am +3 -0
+noinst_HEADERS = \
+                 nouveau_private.h
+
Quoted 2 lines

 pkgconfigdir = @pkgconfigdir@
 pkgconfig_DATA = libdrm_nouveau.pc

I don't think this is the best strategy. Having the headers under _SOURCES already means they'll get distributed. The only reason for the separate _HEADERS declarations is if you need to install them.

http://www.gnu.org/software/automake/manual/automake.html#Headers

--
Dan
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

Tested-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] libdrm_radeon: Optimize cs_gem_reloc to do less looping. (V2)

In reply to Pauli Nieminen
Quoted 12 lines · Pauli Nieminen

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 selected and libdrm_intel is not.
- Make atomic operations private to libdrm_radeon.
- Add warning messages if disabling automaticaly selected libdrm_(radeon|intel)

Quoted 4 lines

This optimization decreases cs_write_reloc share of torcs profiling from 4.3% to 2.6%.

Signature · 14 lines
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel