Login  Register

Quantlib - multithreading

Posted by Ghorpadkar, Suhas on Dec 20, 2016; 5:41pm
URL: http://quantlib.414.s1.nabble.com/Quantlib-multithreading-tp17934.html

I am working on a custom MonteCarlo simulation and was trying to experiment with multiple threads.

I am aware that Quantlib as such is not thread safe. I have uncommented “define QL_ENABLE_SESSIONS” in userconfig.hpp

and have defined sessionId function at the beginning of my cpp file. I was trying to create QL objects such as YieldTermStructure handles and CalibratedModel inside the function that will called by each thread so that QL objects are not shared by multiple threads and each has a copy of its own. This worked for my Model object but not for YieldTermStructure objects. I had to lock the critical section using mutex as below even though swapCurve and dividendCurve objects are thread local.

I do not understand why. May be I need to return something other than zero in my sessionId() function ?

 

std::lock_guard<std::mutex> lg(mapMutex);

{

                Dr_t = swapCurve->discount(t);

                Dr_T = swapCurve->discount(t + dt);

 

                Dq_t = dividendCurve->discount(t);

                Dq_T = dividendCurve->discount(t + dt);

}

 

Thank you.

............................................................................

For further important information about AllianceBernstein please click here
http://www.abglobal.com/disclaimer/email/disclaimer.html


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users