Author: post
Date: 2010-06-28 22:04:06 +0200 (Mon, 28 Jun 2010)
New Revision: 3449

Modified:
   trunk/plugins/dcp/dcp.c
   trunk/plugins/dcp/dcp.h
Log:
DCP: Preload all lookup data to L1 cache prior to starting processing.

Modified: trunk/plugins/dcp/dcp.c
===================================================================
--- trunk/plugins/dcp/dcp.c     2010-06-27 12:02:18 UTC (rev 3448)
+++ trunk/plugins/dcp/dcp.c     2010-06-28 20:04:06 UTC (rev 3449)
@@ -43,6 +43,7 @@
 static RS_MATRIX3 find_xyz_to_camera(RSDcp *dcp, const RS_xy_COORD *white_xy, 
RS_MATRIX3 *forward_matrix);
 static void set_white_xy(RSDcp *dcp, const RS_xy_COORD *xy);
 static void precalc(RSDcp *dcp);
+static void pre_cache_tables(RSDcp *dcp);
 static void render(ThreadInfo* t);
 static void read_profile(RSDcp *dcp, RSDcpFile *dcp_file);
 static void free_dcp_profile(RSDcp *dcp);
@@ -390,6 +391,7 @@
        ThreadInfo* t = _thread_info;
        RS_IMAGE16 *tmp = t->tmp;
 
+       pre_cache_tables(t->dcp);
        if (tmp->pixelsize == 4  && (rs_detect_cpu_features() & 
RS_CPU_FLAG_SSE2))
        {
                if (render_SSE2(t))
@@ -875,7 +877,48 @@
 
 }
 
+static void 
+pre_cache_tables(RSDcp *dcp)
+{
+       int i;
+       gfloat unused = 0;
+       const int cache_line_bytes = 64;
 
+       /* Preloads cache with lookup data */
+       if (!dcp->curve_is_flat)
+       {
+               for (i = 0; i < 257; i+=(cache_line_bytes/sizeof(gfloat)))
+                       unused = dcp->curve_samples[i];
+       }
+
+       if (dcp->tone_curve_lut) 
+       {
+               for (i = 0; i < 1025; i+=(cache_line_bytes/sizeof(gfloat)))
+                       unused = dcp->tone_curve_lut[i];
+       }
+
+       if (dcp->huesatmap)
+       {
+               int num = dcp->huesatmap->hue_divisions * 
dcp->huesatmap->sat_divisions * dcp->huesatmap->val_divisions;
+               num = num * sizeof(RS_VECTOR3) / sizeof(gfloat);
+               gfloat *data = (gfloat*)dcp->huesatmap->deltas;
+               for (i = 0; i < num; i+=(cache_line_bytes/sizeof(gfloat)))
+                       unused = data[i];
+       }
+
+       if (dcp->looktable)
+       {
+               int num = dcp->looktable->hue_divisions * 
dcp->looktable->sat_divisions * dcp->looktable->val_divisions;
+               num = num * sizeof(RS_VECTOR3) / sizeof(gfloat);
+               gfloat *data = (gfloat*)dcp->looktable->deltas;
+               for (i = 0; i < num; i+=(cache_line_bytes/sizeof(gfloat)))
+                       unused = data[i];
+       }
+
+       /* This is needed so the optimizer doesn't believe the value is unused 
*/
+       dcp->junk_value = unused;
+}
+
 static void
 render(ThreadInfo* t)
 {

Modified: trunk/plugins/dcp/dcp.h
===================================================================
--- trunk/plugins/dcp/dcp.h     2010-06-27 12:02:18 UTC (rev 3448)
+++ trunk/plugins/dcp/dcp.h     2010-06-28 20:04:06 UTC (rev 3449)
@@ -105,6 +105,7 @@
        PrecalcHSM *looktable_precalc;
        void* _huesatmap_precalc_unaligned;
        void* _looktable_precalc_unaligned;
+       gfloat junk_value;
 };
 
 struct _RSDcpClass {


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to