e_plane_renderer: using openmp when copying the frame buffer. 05/92705/3
authorGwanglim Lee <gl77.lee@samsung.com>
Tue, 18 Oct 2016 08:04:20 +0000 (17:04 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Tue, 18 Oct 2016 08:41:31 +0000 (17:41 +0900)
The openmp can reduce time of memcpy about 30 ~ 50ms on the TM1 target.
Now, it is enabled only in the mobile 32bit target. Other profiles and
architectures should also have this feature after testing.

Change-Id: Ic2655bdbe8e2e348bc9c1081b75278c24f884b01

configure.ac
packaging/enlightenment.spec
src/bin/Makefile.mk
src/bin/e_plane_renderer.c

index c6e27f6..eca2eb6 100755 (executable)
@@ -431,6 +431,24 @@ if test "x${have_wayland}" = "xyes"; then
   fi
 fi
 
+# Check for libgomp
+libgomp=no
+AC_ARG_ENABLE([libgomp],
+  AS_HELP_STRING([--enable-libgomp], [enable libgomp @<:@default=disabled@:>@]),
+  [libgomp=$enableval],
+  [libgomp=no])
+AC_MSG_CHECKING([whether libgomp is enabled])
+AC_MSG_RESULT([${libgomp}])
+
+if test "x$libgomp" != "xno"; then
+    AC_DEFINE([HAVE_LIBGOMP], [1], [Enable libgomp])
+    have_libgomp=yes
+else
+    AC_DEFINE([HAVE_LIBGOMP], [0], [Disable libgomp])
+    have_libgomp=no
+fi
+AM_CONDITIONAL([HAVE_LIBGOMP], [test "x${have_libgomp}" = "xyes"])
+
 # Check for ttrace header files
 PKG_CHECK_MODULES(TTRACE,
                [ttrace],
index 63fecd7..cb7ac8e 100755 (executable)
@@ -8,6 +8,13 @@ Group:          Graphics/EFL
 Source0:        enlightenment-%{version}.tar.bz2
 Source1001:     enlightenment.manifest
 
+# use libgomp only in arm 32bit mobile
+%ifarch %{arm}
+%if "%{?profile}" == "mobile"
+%define LIBGOMP use
+%endif
+%endif
+
 BuildRequires:  eet-tools
 BuildRequires:  pkgconfig(dbus-1)
 BuildRequires:  pkgconfig(dlog)
@@ -40,6 +47,9 @@ BuildRequires:  pkgconfig(tzsh-server)
 BuildRequires:  pkgconfig(cynara-client)
 BuildRequires:  pkgconfig(cynara-creds-socket)
 Requires:       libwayland-extension-server
+%if "%{LIBGOMP}" == "use"
+Requires:       libgomp
+%endif
 
 %description
 Enlightenment is a window manager.
@@ -66,6 +76,9 @@ export LDFLAGS+=" -pie "
       --enable-function-trace \
       --enable-wayland \
       --enable-quick-init \
+%if "%{LIBGOMP}" == "use"
+      --enable-libgomp \
+%endif
       --enable-hwc-multi
 
 make %{?_smp_mflags}
index a46a6e6..39a3f24 100644 (file)
@@ -207,6 +207,9 @@ src/bin/e_policy_wl_display.c \
 src/bin/e_process.c
 
 src_bin_enlightenment_CPPFLAGS = $(E_CPPFLAGS) -DEFL_BETA_API_SUPPORT -DEFL_EO_API_SUPPORT -DE_LOGGING=1 @WAYLAND_CFLAGS@ $(TTRACE_CFLAGS) $(DLOG_CFLAGS) $(POLICY_CFLAGS)
+if HAVE_LIBGOMP
+src_bin_enlightenment_CPPFLAGS += -fopenmp
+endif
 if HAVE_WAYLAND_TBM
 src_bin_enlightenment_CPPFLAGS += @WAYLAND_TBM_CFLAGS@ @ECORE_DRM_CFLAGS@
 if HAVE_REMOTE_SURFACE
@@ -222,6 +225,9 @@ src/bin/e_main.c \
 $(enlightenment_src)
 
 src_bin_enlightenment_LDFLAGS = -export-dynamic
+if HAVE_LIBGOMP
+src_bin_enlightenment_LDFLAGS += -fopenmp
+endif
 src_bin_enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ @WAYLAND_LIBS@ -lm @SHM_OPEN_LIBS@ $(TTRACE_LIBS) $(DLOG_LIBS) $(POLICY_LIBS)
 if HAVE_WAYLAND_TBM
 src_bin_enlightenment_LDADD += @WAYLAND_TBM_LIBS@ @ECORE_DRM_LIBS@
index 1280d22..192a6cc 100644 (file)
@@ -8,6 +8,9 @@
 # include <wayland-tbm-server.h>
 # include <Evas_Engine_GL_Drm.h>
 # include <sys/eventfd.h>
+# if HAVE_LIBGOMP
+# include <omp.h>
+# endif
 
 # define E_PLANE_RENDERER_CLIENT_SURFACE_FLAGS_RESERVED 7777
 
@@ -132,7 +135,53 @@ _e_plane_renderer_client_copied_surface_create(E_Client *ec, Eina_Bool refresh)
      }
 
    /* copy from src to dst */
+#if HAVE_LIBGOMP
+# define LIBGOMP_COPY_THREAD_NUM 4
+   if (src_info.planes[0].size > LIBGOMP_COPY_THREAD_NUM)
+     {
+        size_t step[2];
+        step[0] = src_info.planes[0].size / LIBGOMP_COPY_THREAD_NUM;
+        step[1] = src_info.planes[0].size - (step[0] * (LIBGOMP_COPY_THREAD_NUM - 1));
+
+        omp_set_num_threads(LIBGOMP_COPY_THREAD_NUM);
+        #pragma omp parallel
+        #pragma omp sections
+          {
+             #pragma omp section
+               {
+                  memcpy(dst_info.planes[0].ptr,
+                         src_info.planes[0].ptr,
+                         step[0]);
+               }
+             #pragma omp section
+               {
+                  memcpy(dst_info.planes[0].ptr + step[0],
+                         src_info.planes[0].ptr + step[0],
+                         step[0]);
+               }
+             #pragma omp section
+               {
+                  memcpy(dst_info.planes[0].ptr + (step[0] * 2),
+                         src_info.planes[0].ptr + (step[0] * 2),
+                         step[0]);
+               }
+             #pragma omp section
+               {
+                  memcpy(dst_info.planes[0].ptr + (step[0] * 3),
+                         src_info.planes[0].ptr + (step[0] * 3),
+                         step[1]);
+               }
+          }
+     }
+   else
+     {
+        memcpy(dst_info.planes[0].ptr,
+               src_info.planes[0].ptr,
+               src_info.planes[0].size);
+     }
+#else /* HAVE_LIBGOMP */
    memcpy(dst_info.planes[0].ptr, src_info.planes[0].ptr, src_info.planes[0].size);
+#endif /* end of HAVE_LIBGOMP */
 
    tbm_surface_unmap(new_tsurface);
    tbm_surface_unmap(tsurface);