> On Thu, Oct 15, 2009 at 12:50:08AM +0200, Andreas Sandberg wrote:
[...]
> > As far as I can tell omp reduction construction would work fine instead.

diff --git a/ufraw_ufraw.c b/ufraw_ufraw.c
index 871889b..ef63870 100644
--- a/ufraw_ufraw.c
+++ b/ufraw_ufraw.c
@@ -908,17 +908,14 @@ no_distortion:
  *
  * Reasonable values for uf->conf->hotpixel are in the range 0.5-10.
  *
- * OpenMP notes
- * ------------
- * The hot pixel count is updated atomically but this is merely for proof
- * of concept: objdump -Sd shows a "lock addl $0x1,0x1f4(%edx) sequence.
- * The algorithm uses pixel values from previous and next row anyway and
- * whether or not pixels are marked makes a difference already.
+ * Note that the algorithm uses pixel values from previous (processed) and
+ * next (unprocessed) row and whether or not pixels are marked makes a
+ * difference for the hot pixel count.
  */
 static void ufraw_shave_hotpixels(ufraw_data *uf, dcraw_image_type *img,
        int width, int height, int colors, unsigned rgbMax)
 {
-    int w, h, c, i;
+    int w, h, c, i, count;
     unsigned delta, t, v, hi;
     dcraw_image_type *p;
 
@@ -926,9 +923,11 @@ static void ufraw_shave_hotpixels(ufraw_data *uf, 
dcraw_image_type *img,
     if (uf->conf->hotpixel <= 0.0)
        return;
     delta = rgbMax / (uf->conf->hotpixel + 1.0);
+    count = 0;
 #ifdef _OPENMP
 #pragma omp parallel for schedule(static,64) default(none) \
   shared(uf,img,width,height,colors,rgbMax,delta) \
+  reduction(+:count) \
   private(h,p,w,c,t,v,hi,i)
 #endif
     for (h = 1; h < height - 1; ++h) {
@@ -970,13 +969,11 @@ static void ufraw_shave_hotpixels(ufraw_data *uf, 
dcraw_image_type *img,
                        memcpy(p[i], p[0], sizeof (p[i]));
                }
                p[0][c] = hi;
-#ifdef _OPENMP
-#pragma omp atomic
-#endif
-               ++uf->hotpixels;
+               ++count;
            }
        }
     }
+    uf->hotpixels = count;
 }
 #endif
 

-- 
Frank

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
ufraw-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ufraw-devel

Reply via email to