Hi Pierre, another alternative is to use TSS (thread safe storage). We have an implementation, based on boost_thread, that was submitted last year to QuantLib by my colleague Riccardo Ghetta (it is currently sitting in git, in the branch “thread-local-singleton”).
If you like to give it a try, you can use the git branch or the attached patch (baseline is QuantLib 1.4) and then uncomment the variable QL_ENABLE_SESSIONS_TSS (if you prefer, I can also send you a zip with the modified files).
With the patch enabled every thread has its private copy of every QL singleton, including the evaluation date.
Hoping this will help,
Giorgio
--
Giorgio Pazmandi
THEMA Consulting
Via Balestra 31/33, CH-6901 Lugano
Tel. +41 (0)91 911 64 64, Fax +41 (0)91 911 64 74
www.themaconsulting.ch
This message (including any attachments) contains confidential and/or proprietary information intended only for the addressee. Any unauthorized disclosure, copying, distribution or reliance on the contents of this information is strictly prohibited and may constitute a violation of law. If you are not the intended recipient, please notify the sender immediately by responding to this e-mail, and delete the message from your system. If you have any questions about this e-mail please notify the sender immediately.
From: Luigi Ballabio [[hidden email]]
Sent: martedì, 18. novembre 2014 12:52
To: Grison PG Pierre (External DEXIA-US)
Cc: [hidden email]
Subject: Re: [Quantlib-users] multi threading in QuantLib
No easy way, unfortunately. The best you can do is to enable per-thread singletons. On Windows, edit ql/userconfig.hpp and uncomment
#define QL_ENABLE_SESSIONS
at the end of the file; on other platforms, run
./configure --enable-sessions
In both cases, you'll have to recompile the library and to provide a function
Integer sessionId();
that returns a unique integer for each thread and that needs to be linked together with the library and your application.
Luigi
On Tue, Nov 4, 2014 at 7:21 PM, Grison PG Pierre (External DEXIA-US) <[hidden email]> wrote:
Hello,
Is there an easy way to deal with multi threading in QuantLib. I encounter the same problem that many people with:
Settings::instance().evaluationDate()
And other similar functions.
Thanks in advance for any help,
Pierre
------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
--
Free forum by Nabble | Disable Popup Ads | Edit this page |