[Insight-users] FFTW thread safety

Simon Rit simon.rit at creatis.insa-lyon.fr
Wed Nov 14 12:19:09 EST 2012


You're right, this is now useless in ITK4. In the previous version
taken from the insight journal
(https://github.com/SimonRit/RTK/blob/master/utilities/itkfftw/itkFFTWCommon.h)
the instantiation was not protected and, therefore, it was
thread-unsafe. Thanks for the correction,
Simon

On Wed, Nov 14, 2012 at 6:11 PM, Cory Quammen <cquammen at cs.unc.edu> wrote:
> Also, I meant to ask you why adding a Lock/Unlock pair in
> BeforeThreadedGenerateData was necessary. The lock appears to be
> initialized at instantiation, so perhaps it isn't necessary for you to
> do that?
>
> Thanks,
> Cory
>
> On Wed, Nov 14, 2012 at 12:09 PM, Cory Quammen <cquammen at cs.unc.edu> wrote:
>> Simon,
>>
>> I posted a patch to gerrit. You can review it here:
>>
>> http://review.source.kitware.com/#/c/8506/
>>
>> Thanks,
>> Cory
>>
>> On Wed, Nov 14, 2012 at 9:53 AM, Cory Quammen <cquammen at cs.unc.edu> wrote:
>>> 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
>>
>>
>>
>> --
>> Cory Quammen
>> Research Associate
>> Department of Computer Science
>> The University of North Carolina at Chapel Hill
>
>
>
> --
> Cory Quammen
> Research Associate
> Department of Computer Science
> The University of North Carolina at Chapel Hill
> _____________________________________
> 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


More information about the Insight-users mailing list