SERVING THE QUANTITATIVE FINANCE COMMUNITY

  • 1
  • 2
  • 3
  • 4
  • 5
  • 18
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

The ultimate Monte Carlo framework

October 4th, 2011, 7:53 am

Hey all.This thread is aimed at collecting ideas about the Monte Carlo framework we are going to adopt. Guru renorm recently offered to share his code, so we could also start a discussion on that when it comes.I suggest also we have a look at the framework currently implemented in Quantlib -- even if to make it parallel we're probably going towards something quite different.
Last edited by DevonFangs on January 16th, 2012, 11:00 pm, edited 1 time in total.
 
User avatar
lballabio
Posts: 983
Joined: January 19th, 2004, 12:34 pm

The ultimate Monte Carlo framework

October 4th, 2011, 8:54 am

QuoteOriginally posted by: DevonFangsI suggest also we have a look at the framework currently implemented in QuantlibI started describing it in chapter 6 here. I criticise a few parts of it myself, so you also have some more hints about where to differ.
 
User avatar
DevonFangs
Topic Author
Posts: 3004
Joined: November 9th, 2009, 1:49 pm

The ultimate Monte Carlo framework

October 4th, 2011, 8:55 am

Thanks Luigi!
 
User avatar
Alan
Posts: 9804
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

The ultimate Monte Carlo framework

October 4th, 2011, 2:17 pm

I think there are some nice commercial possibilities with the Monte Carlo that should be considered.For example, say the library painlessly supports a remote connection to a GPU server, and some company provides the serverat some reasonable hourly rate. Something like this, but I compile the C/C++I would use it. Anyway, treat it as a feature request.
Last edited by Alan on October 3rd, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
renorm
Posts: 886
Joined: February 11th, 2010, 10:20 pm

The ultimate Monte Carlo framework

October 5th, 2011, 12:50 am

I more or less figured out parallel part, but SIMD part can get very user unfriendly. The main challenge is to shields users from low level coding. Some users can code SSE/AVX directly, but most users can't and don't want to do low level stuff. The challenge is how to make all users happy.
Last edited by renorm on October 4th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

The ultimate Monte Carlo framework

October 5th, 2011, 1:02 am

Out of curiosity, are you doing something along the lines of "Redefining a vector class" or "Making your own vector classes" in 12.3 Explicit vectorization?// Some ideas: http://www.opensimd.com/wiki/Data_typesBTW, which CPU dispatch mechanism (out of those in 13.4 Implementation) have you decided on?// Ref.: "Optimizing software in C++"; http://www.agner.org/optimize/optimizing_cpp.pdf
 
User avatar
Cuchulainn
Posts: 59924
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The ultimate Monte Carlo framework

October 5th, 2011, 8:57 am

QuoteOriginally posted by: PolterOut of curiosity, are you doing something along the lines of "Redefining a vector class" or "Making your own vector classes" in 12.3 Explicit vectorization?// Some ideas: http://www.opensimd.com/wiki/Data_typesBTW, which CPU dispatch mechanism (out of those in 13.4 Implementation) have you decided on?// Ref.: "Optimizing software in C++"; http://www.agner.org/optimize/optimizing_cpp.pdfIn order to be reusable1. Use std::vector as adapted class (? etc.)2. STL algos (accumulate, inner product)3. A real Vector class (in the mathemagical sense)And4. NumericMatrix5. Boost uBLAS, MultirrayGood candidates in MK layers?
Last edited by Cuchulainn on October 4th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 59924
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The ultimate Monte Carlo framework

October 5th, 2011, 10:30 am

QuoteOriginally posted by: outrunregarding 1: how about iterators and algo's? you can bind then to all sorts of storage . The code should work independent of using std::vector, double x[5] etc..yep, no problem STL does it all. No extra work needed.And it is easy to write your own STL-aware containers.I have sussed that stuff out, so give a shout. And C++ 11 lambda functions are very useful.
Last edited by Cuchulainn on October 4th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
frenchX
Posts: 5911
Joined: March 29th, 2010, 6:54 pm

The ultimate Monte Carlo framework

October 5th, 2011, 1:19 pm

Think also about particle simulation for local stochastic volatility calibration. It's a hot topic at the moment.
 
User avatar
renorm
Posts: 886
Joined: February 11th, 2010, 10:20 pm

The ultimate Monte Carlo framework

October 5th, 2011, 5:32 pm

@Polter.No custom data types because STL containers and data types with alignment requirement don't mix well. See how Eigen deals with it. Not pretty.@outrun, Cuchulainn.What we need is the ability to gracefully fall back to SIMD=1. Those who don't want or can't write SIMD code should be able to use the framework and still benefit from multi-threading. Every non-trivial engine that directly exploits SIMD must be accompanied by a scalar version (that is simpler implementation with SIMD=1) for debugging/correctness reasons. Also, SIMD size can change in the future. Right now it is in transition from 4 to 8. Clearly SIMD length must be configurable.
 
User avatar
Cuchulainn
Posts: 59924
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The ultimate Monte Carlo framework

October 5th, 2011, 6:23 pm

Quote@outrun, Cuchulainn.What we need is the ability to gracefully fall back to SIMD=1. Those who don't want or can't write SIMD code should be able to use the framework and still benefit from multi-threading. Every non-trivial engine that directly exploits SIMD must be accompanied by a scalar version (that is simpler implementation with SIMD=1) for debugging/correctness reasons. Also, SIMD size can change in the future. Right now it is in transition from 4 to 8. Clearly SIMD length must be configurable.How is the commonality in code between the different versions? Are there 2 separate code bases? Let's say I want to use my own vector and matrix classes instead. Using Layers and Microkernel this will be taken care of.
Last edited by Cuchulainn on October 4th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
madmax
Posts: 1093
Joined: October 31st, 2003, 9:56 am

The ultimate Monte Carlo framework

October 5th, 2011, 6:42 pm

QuoteOriginally posted by: AlanI think there are some nice commercial possibilities with the Monte Carlo that should be considered.For example, say the library painlessly supports a remote connection to a GPU server, and some company provides the serverat some reasonable hourly rate. Something like this, but I compile the C/C++I would use it. Anyway, treat it as a feature request.Amazon's EC2 has GPU instances. Also, there is Penguin On Demand without virtualization, higher specs.
 
User avatar
Alan
Posts: 9804
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

The ultimate Monte Carlo framework

October 5th, 2011, 7:34 pm

QuoteOriginally posted by: madmaxQuoteOriginally posted by: AlanI think there are some nice commercial possibilities with the Monte Carlo that should be considered.For example, say the library painlessly supports a remote connection to a GPU server, and some company provides the serverat some reasonable hourly rate. Something like this, but I compile the C/C++I would use it. Anyway, treat it as a feature request.Amazon's EC2 has GPU instances. Also, there is Penguin On Demand without virtualization, higher specs.Thanks. Is there a tutorial somewhere for dummies on Windows, say with Visual Studio, showing how to create such AWS GPU instances and link a CUDA C/C++ program to them?
 
User avatar
Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

The ultimate Monte Carlo framework

October 5th, 2011, 9:12 pm

@renorm, Cuchulainn // numerical linear algebra, design & interfaceTo be honest, I like Eigen design (and interface) much more than Boost uBLAS (as someone noticed, uBLAS is the odd one out).Arrays are also much nicer -- http://eigen.tuxfamily.org/dox/TutorialArrayClass.html (esp. coefficient-wise operations, as easy as in MATLAB; note also the distintion between mathematical vectors & matrices and rich-storage arrays) -- but unfortunately only 2-D.Multiarray is also somewhat convoluted, I mean setting the dimensionality with boost::extents and the access using collections when you want to use operator() (and normally you don't want to use operator[] w/ boost::multi_array, afair that was even slower than nested std::vector): boost::array<array_type::index,3> idx = {{0,0,0}}; A(idx) = 3.14;is what I'd call non-trivial, A(0,0,0) = 3.14;would be much more natural (& preferable). I don't think we should go down this path, but I might be wrong, so let's see.The reason I find it problematic is that it's very non-standard, most (if not all) of the other open-source numerical-algebra libraries for C++ that I'm familiar with use operator() in the natural way (even MATLAB or Fortran 90), so using it runs a risk of confusing anyone else besides uBLAS users.@renorm // SIMD, data types, CPU dispatchingOK, I guess I'll wait for your code, then. Am I to assume you're using raw pointers and SIMD intrinsics?As for the CPU dispatch mechanism -- I assume you're not using {Dispatch on every call, Dispatch on first call, Make pointer at initialization} (all have run-time costs), but probably {Load library at initialization, Dispatch at load time, Dispatch at installation time, Use different executables} for decision on whether to use vectorized instructions and the level thereof -- out of curiosity, which one?
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On