Posted by
Luigi Ballabio on
Feb 19, 2014; 2:32pm
URL: http://quantlib.414.s1.nabble.com/multi-threaded-swapvaluation-cpp-tp14958p14992.html
Hello,
in its default configuration, QuantLib is not thread-safe (there's
a number of global objects that you're probably writing to from
different threads and that can cause race conditions). Your program
might work ("might") if you make those globals thread-local; to do
this with VC++, edit <ql/userconfig.hpp>, uncomment the line
//# define QL_ENABLE_SESSIONS
towards the end so that the macro is defined, and recompile both
QuantLib and your program.
Hope this helps,
Luigi
On Wed, Feb 12, 2014 at 1:10 AM, jlee <
[hidden email]> wrote:
> Hi,
> I am trying to calculate fair swap rate and using swapvaluation.cpp from the
> Examples. If I call the fairRate() method several times in a loop it works
> fine. But when I call it using threads I get random errors. I don't think
> it's actually the fairRate() method but part of the creation of the Swap
> object.
>
> I have attached an example from my bigger program but it reproduces the
> error. It's in MSVC++ 2013 and when you start the program, it prompts you
> for the number of threads to use. Usually if you use 10 you'll get the
> error, definitely if you use 20 threads. If you use only 1 thread, it loops
> several times and no errors occur.
>
> Hope this helps as it took awhile to isolate but I've reached the limit of
> my technical skills in debugging it. If you need any more information let me
> know.
>
> ql_test.rar <
http://quantlib.10058.n7.nabble.com/file/n14958/ql_test.rar>
>
>
>
> --
> View this message in context:
http://quantlib.10058.n7.nabble.com/multi-threaded-swapvaluation-cpp-tp14958.html> Sent from the quantlib-dev mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Android apps run on BlackBerry 10
> Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
> Now with support for Jelly Bean, Bluetooth, Mapview and more.
> Get your Android app in front of a whole new audience. Start now.
>
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk> _______________________________________________
> QuantLib-dev mailing list
>
[hidden email]
>
https://lists.sourceforge.net/lists/listinfo/quantlib-dev--
<
https://implementingquantlib.blogspot.com>
<
https://twitter.com/lballabio>
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev