Serving the Quantitative Finance Community

 
User avatar
horacioaliaga
Topic Author
Posts: 0
Joined: August 21st, 2005, 3:30 pm

Mulithreaded 1D PDE solver for black scholes equation

July 1st, 2015, 5:06 pm

Check out my c+11 multithreaded pde solver explicit scheme
 
User avatar
Cuchulainn
Posts: 22926
Joined: July 16th, 2004, 7:38 am

Mulithreaded 1D PDE solver for black scholes equation

July 1st, 2015, 6:24 pm

QuoteOriginally posted by: horacioaliagaCheck out my c+11 multithreaded pde solver explicit schemeThe code runs. What is the speedup? Are you using explicit Euler? // My rather sad remark is that parallel PDE in finance is a Don Quixote adventure.
Last edited by Cuchulainn on June 30th, 2015, 10:00 pm, edited 1 time in total.
 
User avatar
mutley
Posts: 20
Joined: February 9th, 2005, 3:51 pm

Mulithreaded 1D PDE solver for black scholes equation

July 1st, 2015, 7:50 pm

I was surprised at how easy it was getting OpenMP to speed my code up for 2-dim PDE (1 diffusive + 1 aux) - didnt see linear speedup but was about 5-6x faster on 8 threads
 
User avatar
Cuchulainn
Posts: 22926
Joined: July 16th, 2004, 7:38 am

Mulithreaded 1D PDE solver for black scholes equation

July 1st, 2015, 7:51 pm

QuoteOriginally posted by: mutleyI was surprised at how easy it was getting OpenMP to speed my code up for 2-dim PDE (1 diffusive + 1 aux) - didnt see linear speedup but was about 5-6x faster on 8 threadsWere you using ADE? OpenMP is powerful and easy to use. Did you use a combi of sections and loops? cache hits?
Last edited by Cuchulainn on June 30th, 2015, 10:00 pm, edited 1 time in total.
 
User avatar
mutley
Posts: 20
Joined: February 9th, 2005, 3:51 pm

Mulithreaded 1D PDE solver for black scholes equation

July 1st, 2015, 8:28 pm

ADE yes. Gave a each thread a different auxiliary slice to run across so that one thread did all the upwind, downwind and boundary conditions for a given value of the auxiliary variable. Nothing more complex than that - but lovely to see such a performance improvement for little more than one include, a compiler option and a pragma statement.
 
User avatar
Cuchulainn
Posts: 22926
Joined: July 16th, 2004, 7:38 am

Mulithreaded 1D PDE solver for black scholes equation

July 2nd, 2015, 4:43 am

QuoteOriginally posted by: mutleyADE yes. Gave a each thread a different auxiliary slice to run across so that one thread did all the upwind, downwind and boundary conditions for a given value of the auxiliary variable. Nothing more complex than that - but lovely to see such a performance improvement for little more than one include, a compiler option and a pragma statement.I need no convincing :)Nice that I "rediscovered" ADE from the 1950s while almost everyone is obsessed with ADI (which is a Multiplicative Operator Splitting) while ADE is Additive OS.I once derived the scheme for the convective term as well; sometime later I saw that Robers&Weiss did it in 1966 LOL.At the time 2009 I used 2-core (speedup ~ 1) but now 8-core is available and a speedup of 5 is feasible IMO.Trying ADI on GPU is a waste of time IMO.// An Alternating Direction Explicit (ADE) Scheme forTime-Dependent Evolution EquationsShingyu Leung¤ and Stanley OsheryJune 9, 2005AbstractWe propose an explicit finite difference scheme to solve nonlinear time-dependentequations. While applying to linear equations, this scheme is proven to be second or-der accurate in time and unconditionally stable for arbitrary time step size. Unlike theCrank-Nicloson scheme or other implicit schemes, however, this scheme can easily be im-plemented for a wide range of equations. We will give numerical examples to demonstratethe simplicity and the computational effciency of the method.
Last edited by Cuchulainn on July 1st, 2015, 10:00 pm, edited 1 time in total.
 
User avatar
mutley
Posts: 20
Joined: February 9th, 2005, 3:51 pm

Mulithreaded 1D PDE solver for black scholes equation

July 2nd, 2015, 5:36 am

ADI too complex for me.
 
User avatar
Cuchulainn
Posts: 22926
Joined: July 16th, 2004, 7:38 am

Mulithreaded 1D PDE solver for black scholes equation

July 2nd, 2015, 7:04 am

QuoteOriginally posted by: mutleyADI too complex for me.It has too many workarounds. Soviet Splitting is better, somewhat. Almost no one uses Method of Lines (MOL), which is amazing.
Last edited by Cuchulainn on July 1st, 2015, 10:00 pm, edited 1 time in total.
 
User avatar
horacioaliaga
Topic Author
Posts: 0
Joined: August 21st, 2005, 3:30 pm

Mulithreaded 1D PDE solver for black scholes equation

July 2nd, 2015, 12:44 pm

Thanks Cuchu for the replyDo you think they are Don Quixote even for 1D?
 
User avatar
Cuchulainn
Posts: 22926
Joined: July 16th, 2004, 7:38 am

Mulithreaded 1D PDE solver for black scholes equation

July 2nd, 2015, 6:39 pm

QuoteOriginally posted by: horacioaliagaThanks Cuchu for the replyDo you think they are Don Quixote even for 1D?james mutley has produced a good/clear as day response. The only hope is ADE. Why don't you parallelise it with C++11 concurrency and OpenMP. It's a slight modification of your explicit which is not really used because dt = O(h^2).You need to find potential parallelism. For ADE it's very clear.Try it on [8,16] cores.http://papers.ssrn.com/sol3/papers.cfm? ... eID=437etc.// Parallel ADI, Soviet splits and CN not IMO.
Last edited by Cuchulainn on July 1st, 2015, 10:00 pm, edited 1 time in total.
 
User avatar
mutley
Posts: 20
Joined: February 9th, 2005, 3:51 pm

Mulithreaded 1D PDE solver for black scholes equation

July 3rd, 2015, 6:25 am

Can we pair ADE with a dU/dt term that uses central differences? my guess is that this might achieve second order accuracy in time, as well as 2nd order in space from the ADE?
 
User avatar
Cuchulainn
Posts: 22926
Joined: July 16th, 2004, 7:38 am

Mulithreaded 1D PDE solver for black scholes equation

July 3rd, 2015, 7:02 am

QuoteOriginally posted by: mutleyCan we pair ADE with a dU/dt term that uses central differences? my guess is that this might achieve second order accuracy in time, as well as 2nd order in space from the ADE?ADE is already O(dt^2) (?)The point is that the O(dt) terms in the U and V sweeps get knocked out when averging theemSome similar schemes are discussed by Abie Bouwer (James, you might remember I announce MADE a while back).//The Du Fort and Frankel finite difference scheme ... - miragerepository.up.ac.za/handle/2263/28658?show=fullThe Du Fort and Frankel finite difference scheme applied to and adapted for a class of finance problems ... dc.contributor.author, Bouwer, Abraham, en ... dc.description, Dissertation (MSc)--University of Pretoria, 2009. en.//
Last edited by Cuchulainn on July 2nd, 2015, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 22926
Joined: July 16th, 2004, 7:38 am

Mulithreaded 1D PDE solver for black scholes equation

July 3rd, 2015, 7:03 am

QuoteOriginally posted by: horacioaliagaThanks Cuchu for the replyDo you think they are Don Quixote even for 1D?Horacia,You tell me! :) It is your code.What speedup did you get?
Last edited by Cuchulainn on July 2nd, 2015, 10:00 pm, edited 1 time in total.
 
User avatar
mutley
Posts: 20
Joined: February 9th, 2005, 3:51 pm

Mulithreaded 1D PDE solver for black scholes equation

July 3rd, 2015, 7:10 am

ADE is already O(dt^2)? I learn something new each day. I like it even more now - unconditionally stable, easy as pie to code and parallelise, doesn't suffer from spurious oscillations. AND second order in both space and time :)I need to revisit MOL now you mention it. I came across it in your book when i was first looking at FDM. I must admit, at that stage, the mathematical rigour of your book was a little dry for what i was in need of at the time (Paul's 3-part tome, with all its practical examples, was my direct way into FDM). But now i am a more familiar with the different schemes / methods, i will have a look again. You appear to hold MOL in high esteem and that cannot be without reason.
 
User avatar
Cuchulainn
Posts: 22926
Joined: July 16th, 2004, 7:38 am

Mulithreaded 1D PDE solver for black scholes equation

July 3rd, 2015, 8:31 am

QuoteOriginally posted by: mutleyADE is already O(dt^2)? I learn something new each day. I like it even more now - unconditionally stable, easy as pie to code and parallelise, doesn't suffer from spurious oscillations. AND second order in both space and time :)I need to revisit MOL now you mention it. I came across it in your book when i was first looking at FDM. I must admit, at that stage, the mathematical rigour of your book was a little dry for what i was in need of at the time (Paul's 3-part tome, with all its practical examples, was my direct way into FDM). But now i am a more familiar with the different schemes / methods, i will have a look again. You appear to hold MOL in high esteem and that cannot be without reason.I used MOL a lot when I used to write Fortran FEM code for cathode guns (aka tv screens) and nonlinear heat transfer in the late 19th century. So, you discretize in space and then solve ODE using NAG. It has a long history, both as a theoretical mechanism to prove convergence and to get numbers.Instead of mucking around with home-grown time-marching leave it to the experts. ODE is a subfield of numerical analysis.Somehow, MOL is not widely known among quants.
Last edited by Cuchulainn on July 2nd, 2015, 10:00 pm, edited 1 time in total.