SERVING THE QUANTITATIVE FINANCE COMMUNITY

  • 1
  • 3
  • 4
  • 5
  • 6
  • 7
 
User avatar
quartz
Posts: 424
Joined: June 28th, 2005, 12:33 pm

Choice of matrix library and interface

December 2nd, 2011, 3:31 pm

QuoteThe prod(..) is a bit awkward, indeed and probably not portable. My hunch is that * may introduce temporary variables if the user is not careful (d = a*b + c). And I don't know if expression templates would charm numericists.What I like is to use a 'push model' in which the desired result M is modified when we call prod(const input& A, output& M). It means I create M once at a higher level, saves memory stuff.I thought well tested expression templates (+views and cache aware traversal) were one of the main reasons for using an external library... Preallocation forces temporaries in this case too. But I like the idea a lot, possibly in other contexts; there must be techniques to help automate it. Goodbye RAII again :-)
 
User avatar
Cuchulainn
Posts: 60268
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Choice of matrix library and interface

December 2nd, 2011, 3:49 pm

QuoteOriginally posted by: quartzQuoteThe prod(..) is a bit awkward, indeed and probably not portable. My hunch is that * may introduce temporary variables if the user is not careful (d = a*b + c). And I don't know if expression templates would charm numericists.What I like is to use a 'push model' in which the desired result M is modified when we call prod(const input& A, output& M). It means I create M once at a higher level, saves memory stuff.I thought well tested expression templates (+views and cache aware traversal) were one of the main reasons for using an external library... Preallocation forces temporaries in this case too. But I like the idea a lot, possibly in other contexts; there must be techniques to help automate it. Goodbye RAII again :-)This issue of work arrays vs dynamic arrays is important and ongoing since a while, see here A standard here is important? Maybe, off topic, but is Pool an option?
Last edited by Cuchulainn on December 1st, 2011, 11:00 pm, edited 1 time in total.
 
User avatar
karpeev
Posts: 6
Joined: March 15th, 2011, 1:31 pm

Choice of matrix library and interface

December 15th, 2011, 6:31 pm

Hi, I'm an active user (and contributor to) PETSc and I wanted to ask a few questions on what you listed as Cons (always looking to improve the user experience :-))Con - Not much of a users manual:We do have what we consider a good user's manual -- http://www.mcs.anl.gov/petsc/petsc-curr ... manual.pdf. Do you think it can/needs to be improved? If so, how? We are always looking for constructive criticism.Con - Basic vector/matrix math is almost at the level of BLAS calls:It's true that Vec/Mat operations are not as easy as v = 1.0, etc. To some extent this is dictated by the distributed/high-performance nature of the library. And while I wouldn't characterize them as "at the level of BLAS", we are always looking to make the user experience easier.One step in that direction are (what we think as) very nice Python bindings to petsc: http://code.google.com/p/petsc4py/These make many (not all) vector operations easier.Con - Primilary designed for high performance computing (clusters, etc)This is true, but I routinely run PETSc-based applications on my laptop. In fact, this is where most of my codes run :-)Furthermore, we are actively developing GPU and multithreading support.Con - Huge libraryThat may be so, but with diskspace being cheap these days, this isn't much of an impediment. We support shared libraries, dynamic loading and the splitting of our library into small components to alleviate the loading issue,should it arise.Con - Compilation on Windows is extremely difficult or impossibleActually, compilation on Windows, while can be hard, is far from extremely difficult, IMHO. We have many Windows users and provide essentially round-the-clock free and fast support petsc-maint@mcs.anl.govThis is not intended as a criticism, but rather as an attempt at dialog with a potential user :-)Cheers,Dmitry.
 
User avatar
OOglesby
Topic Author
Posts: 42
Joined: August 26th, 2011, 5:34 am

Choice of matrix library and interface

December 18th, 2011, 8:09 am

Dmitry,Most of my comments about PETSc were in the context of financial engineering and development. The primary purpose of my review was a survey of general purpose vector/matrix data types.I am actually very impressed with PETSc's capabilities. My career consists of nonlinear optimization, differential equations, and beginning to include partial differential equations, and PETSc looks great for that. Again, for simply using the matrix data type, the compilation process and extra unused functionality is not worth the effort in my opinion compared to something like ublas or eigen.QuoteCon - Not much of a users manual:I only knew about the reference manual of functions. The user manual that you directed me to looks pretty good. Again for the context of finance, the "simple example" is actually quite complex due to MPI and the PETSc management functions. For software developers that are more familiar with web pages, databases, etc, I think the manual will be much to technical. For engineers and mathematicians, it should be fine.QuoteCon - Basic vector/matrix math is almost at the level of BLAS callsThis is almost a religious argument in the qfcl forum. Some people want very generic loosely coupled functions (BLAS/LAPACK/PetSC). Others want operator overloading so that the code looks as close to mathematics as possible. Bindings to other languages help, but the desired language for the project internals is C/C++.QuoteCon - Primarily designed for high performance computing (clusters, etc)For using PETSc as a basic vector/matrix package, much of the MPI/cluster functionality is overkill.QuoteCon - Huge libraryI was not referring to disk space requirements in this case. I was referring to all of the extra functionality in the package. When all you want is nice vector/matrix representation, then graph coloring, mesh generation, ODE solvers, PDE solvers, very sophisticated large scale linear algebra are mostly dead weight. QuoteCon - Compilation on Windows is extremely difficult or impossibleThis comment was based only on my personal experience. About 2 years ago, I tried compiling under cygwin and had lots of problems with the python build script. Because I want to use other libraries such as LANL Sundials ODE solvers, I had to use cygwin as opposed to MSVC.After reviewing these libraries, the concencus seems to be data type agnostic or to use boost ublas. Feel free to PM me if you want more details or discussion. I would like to see something like PETSc Lite for a more common functionality.
 
User avatar
Cuchulainn
Posts: 60268
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Choice of matrix library and interface

December 18th, 2011, 10:04 am

QuoteI was not referring to disk space requirements in this case. I was referring to all of the extra functionality in the package. When all you want is nice vector/matrix representation, then graph coloring, mesh generation, ODE solvers, PDE solvers, very sophisticated large scale linear algebra are mostly dead weight. A related (general) question is can use part of a library without having to drag in the whole package? For example, if we just want *, + and some norms stuff can I just use this only?
 
User avatar
Cuchulainn
Posts: 60268
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Choice of matrix library and interface

December 18th, 2011, 10:04 am

(double, system created 2 posts...)
Last edited by Cuchulainn on December 17th, 2011, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 60268
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Choice of matrix library and interface

December 19th, 2011, 3:43 pm

Quote@renorm: Sorry, but that isn't very convincing. Can you deliver SVD implementation that is not 50 times slower than MKL?Fair enough. Let's take a benchmark example, yes?Let's take simpler example to test uBLAS to see what the differences are vs MKL, LAPACK.Below I have 2 version for a get it working POC.What is a good test: 50x50, 200x200, etc. OK, at your leisure edit: how does other library code look like (as well)?
Attachments
QRDecomposition.zip
(1.63 KiB) Downloaded 13 times
Last edited by Cuchulainn on December 18th, 2011, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 60268
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Choice of matrix library and interface

December 19th, 2011, 10:27 pm

Stress test case is the Hilbert matrixTest for speed and accuracy (and post-process double check).
 
User avatar
karpeev
Posts: 6
Joined: March 15th, 2011, 1:31 pm

Choice of matrix library and interface

December 20th, 2011, 3:24 pm

Thanks for an exhaustive reply! I'm still trying to get my bearings in the world of quantitative finance, but it would be good to see if/how I/we (PETSc) can contribute.Specifically, I'm trying to understand if/when performance becomes a factor, and how the community deals with that. I understand (correct me, if I'm wrong) that dense linear algebra prevails in quantitative finance, hence the emphasis on BLAS, etc.In that case I would expect to see memory limitations becoming a factor for substantial problem sizes.PETSc was initially developed as a PDE-oriented package with the emphasis on sparse linear algebra and iterative solvers.That is still the case, but we have more support for large-scale dense linear algebra. That's one of the directions we are interested in moving as well,for example, with large-scale rank-revealing QR factorization, better support for least-squares solvers, etc.On the other hand, I keep hearing about "free boundary problems" in quantitative finance and "PDE methods". For those I expect PETSc to be very effective. Maybe quantitative finance is more segmented than I realize and there is no one overarching theme to the computation and,hence, no "one-fits-all" linear algebra library solution here?I understand that usability is very important in this community. It's non-trivial to make usability and high-performance coexist nicely.At this point I feel like the community here emphasizes usability (inferring from your mentioning of operator overloading to make code look like math).Sooner or later, however, I suspect that performance issues will become too important to ignore.I would be very interested in understanding exactly what the performance requirements for the linear algebra in quantitative finance areto see if we can target that performance/usability sweet spot -- possibly along the lines of what you called "PETSc Lite".I want to point out that while the PETSc programming model is based on MPI, there is not need to actually have or build MPI to use PETSc, if only sequential (non-parallel, non-cluster) use is required. For that purpose we have a "stub MPI" called mpiuni (for uniprocessor),which fakes the MPI API in an efficient so that the rest of PETSc can proceed as usual. This is enabled using --with-mpi=0.Even if no high performance is necessary, good iterative algorithms might still be desirable. And as you pointed out, we offer interfaces to manyother packages (e.g., SUNDIALS, although we have greatly improved our native time-integrator support), which might be desirable in its own right.Finally, we are aggressively developing GPU and multicore (pthreads) support, so that high performance is possible without a cluster.Having a discussion on this subject would be great. Since I'm a novice at this forum, however, how does one PM here?Thanks!Dmitry.
 
User avatar
karpeev
Posts: 6
Joined: March 15th, 2011, 1:31 pm

Choice of matrix library and interface

December 20th, 2011, 3:28 pm

I don't see how a "bloated" library is really a drag on the code that uses it: If the library is compiled, the linker will resolve only the necessary symbols, and if the library is all/mostly headers (like BOOST), then the unnecessary code doesn't even get compiled.There are more subtle ways in which a big library becomes a liability:it is usually more difficult to configure/compile. In the case of BOOST, for example, even when no compilationis necessary, the complicated nested templated structure makes parsing error messages EXTREMELY difficultin my experience.Finally, a large compiled library might make the link step a bit slow, but not really noticeably so on any reasonablymodern hardware/OS.
 
User avatar
Cuchulainn
Posts: 60268
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Choice of matrix library and interface

December 20th, 2011, 3:42 pm

QuotePETSc was initially developed as a PDE-oriented package with the emphasis on sparse linear algebra and iterative solvers.That is still the case, but we have more support for large-scale dense linear algebra. That's one of the directions we are interested in moving as well,for example, with large-scale rank-revealing QR factorization, better support for least-squares solvers, etc.On the other hand, I keep hearing about "free boundary problems" in quantitative finance and "PDE methods". For those I expect PETSc to be very effective. Maybe quantitative finance is more segmented than I realize and there is no one overarching theme to the computation and,hence, no "one-fits-all" linear algebra library solution here?PetSc looks like a great library for physical engineering projects and PDEs which are in general more complex than PDE in finance. To show POC feasibility this is a good Test caseIf PetSc can solve this problem then it would be good. I think you need direct solvers for predictability. Does it run with Threads?My main concern is how easy for a quant to use the library.
Last edited by Cuchulainn on December 19th, 2011, 11:00 pm, edited 1 time in total.
 
User avatar
karpeev
Posts: 6
Joined: March 15th, 2011, 1:31 pm

Choice of matrix library and interface

December 20th, 2011, 3:51 pm

Thanks for the test case. As luck would have it, one of the coauthors, Ola Skavhaug, is a good friend (and one time colleague) of mine!I understand the usability concern. I wonder whether performance, too, becomes an issue? For example: "I'd like to solve a much larger problem, but MATLAB (or some equivalent package) runs out of memory." Or "... takes forever!", etc.I'll take a closer look at the test case to get a better feel for this.Dmitry.
 
User avatar
Cuchulainn
Posts: 60268
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Choice of matrix library and interface

December 20th, 2011, 3:53 pm

QuoteThanks for the test case. As luck would have it, one of the coauthors, Ola Skavhaug, is a good friend (and one time colleague) of mine!You're welcome, great! So, when can we expect a test FDM?Let's use C++ (or even C#), Matlab is too slow. FDM must be fast!
Last edited by Cuchulainn on December 19th, 2011, 11:00 pm, edited 1 time in total.
 
User avatar
karpeev
Posts: 6
Joined: March 15th, 2011, 1:31 pm

Choice of matrix library and interface

December 20th, 2011, 3:58 pm

Sorry, my ignorance of the field is showing: what is FDM in this context?Dmitry.
 
User avatar
Cuchulainn
Posts: 60268
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Choice of matrix library and interface

December 20th, 2011, 4:01 pm

FDM == Finite Difference Method
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