[Insight-users] FFTW thread safety

Cory Quammen cquammen at cs.unc.edu
Wed Nov 14 09:53:27 EST 2012


Simon,

Thank you for the patch. I will post a patch based on your patch to
gerrit when I have a moment today, unless someone beats me to it.

Cory

On Wed, Nov 14, 2012 at 9:48 AM, Simon Rit
<simon.rit at creatis.insa-lyon.fr> wrote:
> Hi,
> I have experienced problems with FFTW in ITK 4. I am doing many
> parallel FFT filters, each parallel thread having the piece of the
> image defined by ThreadedGenerateData. This is a filter part of
> www.openrtk.org which code is here:
> https://github.com/SimonRit/RTK/blob/master/code/rtkFFTRampImageFilter.txx
>
> I have originally done that with the code of Gaëtan Lehmann
> (http://www.insight-journal.org/browse/publication/717) but I had to
> fix it then for thread safety. I have now moved to ITK4 but I think
> that the thread safety issue is still here since I have random
> crashes. The problem is that the destroy functions are not protected
> by the mutex although they are not thread safe
> (http://www.fftw.org/doc/Thread-safety.html). So a lock / unlock must
> be added around it in itkFFTWCommon.h.
> The patch is below, let me know what you think.
> Simon
>
> PS: It is also worth of note that I have added a Lock/Unlock in the
> BeforeThreadedGenerateData function of my filter to ensure that the
> mutex is initialized.
>
> The patch:
>
> @@ -351,7 +350,9 @@ public:
>    }
>    static void DestroyPlan(PlanType p)
>    {
> +    FFTWGlobalConfiguration::Lock();
>      fftwf_destroy_plan(p);
> +    FFTWGlobalConfiguration::Unlock();
>    }
>  };
>
> @@ -653,7 +654,9 @@ public:
>    }
>    static void DestroyPlan(PlanType p)
>    {
> +    FFTWGlobalConfiguration::Lock();
>      fftw_destroy_plan(p);
> +    FFTWGlobalConfiguration::Unlock();
>    }
>  };
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users



-- 
Cory Quammen
Research Associate
Department of Computer Science
The University of North Carolina at Chapel Hill


More information about the Insight-users mailing list