Groovy and GPU : Enhancing pricing performance and quant...

29
Groovy and GPU : Enhancing pricing performance and quant productivity Bram Leenhouwers Senior Architect

Transcript of Groovy and GPU : Enhancing pricing performance and quant...

Page 1: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Groovy and GPU : Enhancing pricing performance and quant productivity

Bram Leenhouwers Senior Architect

Page 2: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Misys at a glance

Who we are

What we offer

A global leader in financial

services software with

4,500+ employees

50+ countries. The broadest and deepest portfolio of financial services software on the

market. Misys solutions cover retail and corporate banking, lending, treasury,

capital markets, investment management and enterprise-wide risk

management Who we serve

2K clients 12 of the top 20

asset managers $ 46 of the world’s

top 50 banks

2 © Misys 2015 19 March, 2015

“We are transforming the global financial services

industry by making financial institutions more

resilient, more efficient and more competitive.”

Page 3: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Our customers and their problem

Speed!

© Misys 2015 19 March, 2015

Page 4: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

© Misys 2015 19 March, 2015

Our solution – FusionFabric

Page 5: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Goal and challenges

5

Run current and future pricing models on GPUs to dramatically speed up processing time for complex trading analytics and risk management calculations

Challenges

Our goal

GPU code is complex to write Requires specific skillset Maintenance and extensibility is often difficult

© Misys 2015 19 March, 2015

Page 6: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Possible solutions

6

Possible solutions

Software engineers Quantitative analysts

Experienced in GPU progamming Less experienced in finance

Experienced in finance Less experienced GPU programming

Each team gains experience in both fields ?

Create an abstraction layer

Migrate legacy code ?

© Misys 2015 19 March, 2015

Fusion parallel processor

Page 7: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Parallel Processing framwork concept

7

Software engineers Quantitative analysts

Build a scripting engine Write pricing models Write payoffs

Translate a groovy script to OpenCL / CUDA / java bytecode

Easy to write and maintain Runs fast

© Misys 2015 19 March, 2015

Page 8: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Parallelization

8

Easy to write and maintain Runs fast

• Price a whole portfolio of deals • Price a deal using multiple market data (Montecarlo) • Price a deal at several dates (PFE)

© Misys 2015 19 March, 2015

Where does the workload come from ?

We separate the logic of the script from its parallelization axis

Page 9: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Framework overview

9

Quantitative analyst perspective

© Misys 2015 19 March, 2015

Page 10: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Script example

10

// Retrieve rate

def rate = data0D(“INTEREST_RATE”, [currency1], fixingDate)

// Compute daycount fraction

def daycount = dayCountFraction(effectiveDate, maturityDate, currency1)

// Compute discount factor

def factor = discountFactor(calculationDate(), maturityDate, basis)

// Compute the price

def price = notional * daycount * (rate - fixedRate) * factor

// return price

return price

Script Deal

{

"currency1": "USD",

"currency2": “EUR",

"fixingDate": "2015-03-17",

"effectiveDate": "2015-03-01",

"maturityDate": "2015-03-01",

"basis": "ACTUAL_360",

"notional": 1000000

}

© Misys 2015 19 March, 2015

Deal axis

Page 11: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Script example

11

// Retrieve rate

def rate = data0D(“INTEREST_RATE”, [currency1], fixingDate)

// Compute daycount fraction

def daycount = dayCountFraction(effectiveDate, maturityDate, currency1)

// Compute discount factor

def factor = discountFactor(calculationDate(), maturityDate, basis)

// Compute the price

def price = notional * daycount * (rate - fixedRate) * factor

// return price

return price

Script Deal

{

"currency1": "USD",

"currency2": “EUR",

"fixingDate": "2015-03-17",

"effectiveDate": "2015-03-01",

"maturityDate": "2015-03-01",

"basis": "ACTUAL_360",

"notional": 1000000

}

Market data axis

© Misys 2015 19 March, 2015

Deal axis

Page 12: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Script example

12

// Retrieve rate

def rate = data0D(“INTEREST_RATE”, [currency1], fixingDate)

// Compute daycount fraction

def daycount = dayCountFraction(effectiveDate, maturityDate, currency1)

// Compute discount factor

def factor = discountFactor(calculationDate(), maturityDate, basis)

// Compute the price

def price = notional * daycount * (rate - fixedRate) * factor

// return price

return price

Script Deal

{

"currency1": "USD",

"currency2": “EUR",

"fixingDate": "2015-03-17",

"effectiveDate": "2015-03-01",

"maturityDate": "2015-03-01",

"basis": "ACTUAL_360",

"notional": 1000000

}

Market data axis

© Misys 2015 19 March, 2015

Deal axis Date axis

Page 13: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Script example

13

// Retrieve rate

def rate = data0D(“INTEREST_RATE”, [currency1], fixingDate)

// Compute daycount fraction

def daycount = dayCountFraction(effectiveDate, maturityDate, currency1)

// Compute discount factor

def factor = discountFactor(calculationDate(), maturityDate, basis)

// Compute the price

def price = notional * daycount * (rate - fixedRate) * factor

// return price

return price

Script Deal

{

"currency1": "USD",

"currency2": “EUR",

"fixingDate": "2015-03-17",

"effectiveDate": "2015-03-01",

"maturityDate": "2015-03-01",

"basis": "ACTUAL_360",

"notional": 1000000

}

Market data axis User defined functions

© Misys 2015 19 March, 2015

Deal axis Date axis

Page 14: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Language syntax highlights

14

Standard flow operators for, while, if, else, switch/case, break, continue…

Static type inference No explicit typing, everything is detected and optimized at compile time Natively supported types : Double, String, Date, Boolean, Array, Matrix, Cubes…

Custom functions Function declaration with typeless parameters

Custom structures Class-like structure definitions

Function pointers Through seamless static templating

Standard library A set of optimized standard functions and algorithms provided by default

© Misys 2015 19 March, 2015

Page 15: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Code demonstration

Page 16: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Framework overview

16

Software engineer perspective

© Misys 2015 19 March, 2015

Page 17: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Framework overview

17

Script Syntax tree

Optimized syntax tree

Open CL code

CUDA code

Java bytecode

Deal Binary deal

Market data

Price

© Misys 2015 19 March, 2015

Page 18: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Precomputation

18

Script Syntax tree Optimized syntax tree

Open CL code

Deal Binary deal

Market data

Price Precomputation

Precalculate everything that is independent from market data and computation date

Done once at deal input / script change

At each market data tick

If you can do it only once, don’t do it every time !

© Misys 2015 19 March, 2015

Page 19: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Precomputation

19

Compute invariants only once

// Retrieve rate

def rate = data0D(“INTEREST_RATE”, [currency], fixingDate)

// Compute daycount fraction

def daycount = dayCountFraction(effectiveDate, maturityDate, currency)

// Compute discount factor

def factor = discountFactor(calculationDate(), maturityDate, basis)

// Compute the price

def price = notional * daycount * (rate - fixedRate) * factor

// return price

return price

Script Precomputation

Not depending on any market data Not depending on calculation date

daycount is precomputed

notional comes from the deal daycount is precomputed

notional * daycount is precomputed

© Misys 2015 19 March, 2015

Page 20: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Migrating from legacy

20

Existing C++ / Java code cannot be magically parallelized… But we can call it during the precomputation phase !

Limitation: the inputs must be independent from market data (The market data will be different for each scenario)

© Misys 2015 19 March, 2015

Page 21: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Migrating from legacy (2)

21

// Retrieve rate, each execution can have a different value

def rate = data0D(“INTEREST_RATE”, [currency], fixingDate)

// Compute daycount fraction

def daycount = dayCountFraction(effectiveDate, maturityDate, currency)

// Compute discount factor

def factor = discountFactor(calculationDate(), maturityDate, basis)

// Compute the price

def price = notional * daycount * (rate - fixedRate) * factor

// return price

return price

Script Precomputation

Not depending on any market data Not depending on calculation date dayCountFraction can be in Java

© Misys 2015 19 March, 2015

Page 22: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Performances

22

The framework takes care of: • Data alignment / Coalescence

• Memory copy

• Optimized occupancy

• Multi GPU

• Float or double precision

• Separation of CPU / GPU execution through precomputation

• …

Optimizing the engine optimizes all existing scripts

© Misys 2015 19 March, 2015

Page 23: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Performance demonstration

Page 24: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Summary

24

Scripting language Easy to code, read and maintain scripts

Same script, multiple use cases Can be used for 3D simulation, Monte carlo pricing, PFE, CVA…

Tools available Debugger, non regression framework

Progressive migration Through the ability to call legacy functions in java or any other native language

Performance Float or double precision and multiple GPU support

© Misys 2015 19 March, 2015

Page 25: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

misys.com Please consider the environment before printing this PowerPoint.

@MisysFS

Misys @ LinkedIn

MisysVideoChannel

Bram Leenhouwers Senior Architect

[email protected]

Page 26: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Code sharing and re-usability

26

Callable option script Vanilla option script

Black Scholes Module HW1F Module Interpolation Module … Modules

Scripts

© Misys 2015 19 March, 2015

Page 27: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Debugging

27 © Misys 2014 19 March, 2015

Execution through Groovy engine

Script

Deal

Market data

Price

Debug mode uses one deal and one market data setup

Allows breakpoints and variable introspection

Page 28: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Benchmark

28 © Misys 2014 19 March, 2015

0.00

5,000,000.00

10,000,000.00

15,000,000.00

20,000,000.00

25,000,000.00

30,000,000.00

35,000,000.00

40,000,000.00

2000 scenarios 5000 scenarios 10000 scenarios

Production client portfolio – Deal mix, PFE run (openCL)

Xeon E3 1620 K20 4 x K20c

Page 29: Groovy and GPU : Enhancing pricing performance and quant ...on-demand.gputechconf.com/gtc/2015/presentation/S5249-Bram... · Groovy and GPU : Enhancing pricing performance and quant

Parallel Processing Framework pillars

29

Unified Single pricing platform within Misys

Versatility Must handle all pricing models, not only vanilla products

Performance GPU based for computation intensive tasks

Adaptability Migration path from existing pricing models

Transparency Easily develop, expose and maintain pricing models

Portability Be hardware / OS / technology agnostic

© Misys 2015 19 March, 2015