Re: Bootsrapping and multithreading
Posted by
moloko on
URL: http://quantlib.414.s1.nabble.com/Bootsrapping-and-multithreading-tp6026p6030.html
Thanks a lot for your help Luigi ... it's not gonna be a piece of cake, since
the rates are changing : I've got 2 differents curves to bootstrap at the same
time.
Pierre
Selon Luigi Ballabio <
[hidden email]>:
> On Fri, 2008-05-09 at 08:01 -0700, moloko wrote:
> > I've got some crash on my QL lib when 2 threads are calling my boostrap
> > function at the same time.
> >
> > Should I turn QL_ENABLE_SESSIONS to yes and define Integer sessionId(); ?
>
> No, that won't help. But you can work around the problem in a few ways.
>
> If your yield curve is not going to be modified while the threads run
> (i.e., if the underlying quoted rates are not going to change) you can
> force bootstrap before starting the threads. You can do it by calling
> yieldCurve->recalculate(), or any other methods such as
> yieldCurve->discount(0.0). As long as the rates don't change, no further
> bootstrap will be performed.
>
> If your curves are going to be modified (and therefore you need the
> bootstrap to be performed in the threads) you can do a couple of things.
>
> The minimum-effort solution is to instantiate a different copy of the
> curve for each thread. This means that you'll also have to instantiate
> different set of rate helpers; again, one copy of each helper for each
> thread. The good news is that the different copies can share the same
> Quote instances.
>
> If you want to go the full mile, you can make the bootstrap thread-safe.
> I'm no expert, but you'll probably have to code the double-checked
> locking pattern inside LazyObject::calculate(). See the web for details.
>
> Hope this helps,
> Luigi
>
>
> --
>
> Lubarsky's Law of Cybernetic Entomology:
> There is _always_ one more bug.
>
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users