38
Session 020 WS - Multivariate Scenario Reduction Tool Using R Moderator: Mark M. Yu, FSA, MAAA Presenters: Chin-Mei Yvonne Chueh, ASA, Ph.D. Donald Davendra, Ph.D. Tobias Gummersbach SOA Antitrust Compliance Guidelines SOA Presentation Disclaimer

Multivariate Scenario Reduction Tool Using R...CPU vs GPU • GPU’s have no • memory optimization • pipelining • out-of-order execution • instruction-level parallelization

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Session 020 WS - Multivariate Scenario Reduction Tool Using R

Moderator:

Mark M. Yu, FSA, MAAA

Presenters: Chin-Mei Yvonne Chueh, ASA, Ph.D.

Donald Davendra, Ph.D. Tobias Gummersbach

SOA Antitrust Compliance Guidelines SOA Presentation Disclaimer

High Performance Computing ApplicationDr. DONALD DAVENDRA

Session 20: "Multivariate Scenario Reduction Tool Using R" October 16, 2017

Central Washington University

2

Introduction• Develop a HPC protocol for the Scenario Sampling

model.• Due to extensive computational overhead in a

rolling-model environment, the objective is to reduce time.

• The optimal approach is to use GPU’s in a CUDA environment.

3

GPU Acceleration – why?• GPU provides:

• Dynamic parallelization

• Hundreds of cores

• Thousands of threads

• Cheap(ish)

• Readily available HW

• High Level API

4

CPU vs GPU

A CPU consists of a few cores optimized for sequential serial processing while a GPUhas a massively parallel architecture consisting of thousands of smaller, more efficient cores designed for handling multiple tasks simultaneously.

5

CPU vs GPU • GPU’s have no

• memory optimization• pipelining• out-of-order execution• instruction-level parallelization

• GPU’s are good only for many small parallelization task with minimum memory overheads.

6

CPU vs GPU • Kernels are executed by threads

• A kernel is a simple C program.

• Each thread has it own ID

• Thousands of threads execute

same kernel.

• Threads are grouped into blocks• Threads in a block can synchronize

execution.

• Blocks are grouped in a grid• Blocks are independent

7

CUDA: Compute Unified Device Architecture• Introduced by Nvidia in late 2006.• CUDA is a compiler and toolkit for programming NVIDIA GPUs.• CUDA API extends the C programming language.• Runs on thousands of threads.• It is an scalable model.• Provides:

• express parallelism.• high level abstraction from hardware.

8

Problem: Modified Euclidean Distance

�𝑡𝑡=1

𝑛𝑛

𝑖𝑖𝑡𝑡 − 𝑖𝑖𝑡𝑡𝑃𝑃 2 ⋅ 𝑉𝑉𝑡𝑡

where:

• 𝑖𝑖𝑡𝑡, 𝑡𝑡 = 1,2, … , 𝑛𝑛 - economic scenario path

• 𝑖𝑖𝑡𝑡𝑃𝑃,𝑃𝑃 = 1,2, … ,𝑚𝑚 - pivot• 𝑚𝑚 - number of pivots

• 𝑉𝑉 - weights factor

9

Results 1: Modified Euclidean distance timing

Parameters (GPU) †CPU – time [ms] ‡GPU – time [ms]

256 threads/block 629854.18 2994.36

512 threads/block 629246.31 3791.06

†CPU – IBM Power8‡GPU – Nvidia P100

10,000 samples

10

Results 2: Pivot scenarios

Pivots Intel i7-78000X Nvidia Titan Xp IBM Power8 Nvidia P100

100 2794 81.45 4526.24 34.73

300 12320 215.92 15803.69 97.16

500 27597 349.85 29562.57 167.87

700 47305 492.07 46698.59 243.60

1000 87233 737.17 79435.62 369.27

†All times in [ms]

11

Performance graph of CPU’s vs GPU’s

0

10000

20000

30000

40000

50000

60000

70000

80000

90000

100000

100 200 300 400 500 600 700 800 900 1000

time

[ms]

# pivots

Performance graph of CPU's and GPU's

P100 (ms) TitanXp (ms) IBM (ms) Intel (ms)

12

Performance graph of GPU’s

0

100

200

300

400

500

600

700

800

100 200 300 400 500 600 700 800 900 1000

time

[ms]

# pivots

Performance graph of GPU's

P100 (ms) TitanXp (ms)

13

GPU Accelerated R

• use R GPU packages from CRAN• access the GPU through CUDA libraries and/or CUDA-accelerated programming languages,

including C, C++ and Fortran.

14

Dynamic Linked Library Method• Generate a Dynamic Linked Library (DLL) from the CUDA

codes and incorporate it in R.• Can utilize Visual Studio (VS) 2015, however you can

encounter numerous errors with build settings of 64-bit.• This approach uses CMake run through batch files to

generate a 64-bit CUDA DLL• This is loaded into the R script and called directly.

15

Pro’s and Con’s• As with most systems, the parser (R) is adding significant

overhead to the code.• Data has to be transformed into C syntax for parsing, and

visa-versa to R syntax after function call.• Still execution time is significantly improved over CPU

variants.

16

Results 3: R – CUDA

Pivots Intel i7-78000X Nvidia Titan Xp IBM Power8 Nvidia P100 ‡R - CUDA

100 2794 81.45 4526.24 34.73 10580

300 12320 215.92 15803.69 97.16 9270

500 27597 349.85 29562.57 167.87 9560

700 47305 492.07 46698.59 243.60 9630

1000 87233 737.17 79435.62 369.27 9970

†All times in [ms]‡ R-CUDA was run on the Nvidia Titan Xp

17

Performance graph of CPU’s, GPU’s and R

0

10000

20000

30000

40000

50000

60000

70000

80000

90000

100000

100 200 300 400 500 600 700 800 900 1000

time

[ms]

# pivots

Performance graph of CPU's, GPU's and R

P100 (ms) TitanXp (ms) IBM (ms) Intel (ms) R (ms)

18

Performance graph of GPU’s and R

0

2000

4000

6000

8000

10000

12000

100 200 300 400 500 600 700 800 900 1000

time

[ms]

# pivots

Performance graph of GPU's and R

P100 (ms) TitanXp (ms) R (ms)

19

Objectives• To create a R package for the Scenario Sampling

method.• Incorporated as part of a R tool-chain• Scalable and modifiable• Optimize current approach

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

Presentation Title Would Go Here

The material contained in this presentation has been prepared solely for informational purposes by New England Asset Management, Inc. (“NEAM, Inc.”) and/or New England Asset Management Limited (“NEAM Limited) (collectively, “NEAM”) for theexclusive use of [INSERT COMPANY NAME]. The material is based on sources believed to be reliable and/or from proprietary data developed by NEAM, but we do not represent as to its accuracy or its completeness. This is not an offer to buy or sell anysecurity or financial instrument. Certain assumptions, including tax assumptions, may have been made which have resulted in any returns detailed herein. Changes to the assumptions, including valuations or cash flows of any instrument, may have amaterial impact on any results. Please consult with your tax experts before relying on this material. Past performance results are not necessarily indicative of future performance. This document and its contents are proprietary to NEAM and are not to begiven or discussed with anyone other than employees, directors, trustees or auditors of [INSERT COMPANY NAME] without our prior written consent. NEAM Limited is a subsidiary of NEAM, Inc. NEAM Limited is regulated by the Central Bank of Ireland.NEAM Limited is authorized by the Central Bank of Ireland and subject to limited regulation by the Financial Conduct Authority. Additional information, including details about the extent of our regulation by the Financial Conduct Authority are available fromus on request. NEAM Limited is not registered with the SEC. Because this is intended to be an overview please note that some services described in this presentation may not be available to all clients in certain jurisdictions.

Session 20 Workshop:

Multivariate Scenario Reduction Tool Using R

Tobias Gummersbach

2017 SOA Annual Meeting

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

Welcome!

Common situation: Overwhelmed?

[ Elaine to find a word cloud of tech buzz words, guy cratching his head ]

Finding a solution that works for you…..

2

R

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

Agenda

• Quick audience poll

• Basic R introduction, installation, “must have’s”

• Using R in a corporate environment

3

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

Audience Poll

How familiar are you with “R”?

• I am a real beginner / never used / never heard of R

• I us R to fulfill my day-to-day job

• R expert

4

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

Audience Poll

Stage of “R” implementation in your organization?

• Organization has virtually no R experience

• R installed on local PCs, but no comprehensive R strategy

• Organization develops / has a full R strategy / production environment

5

Introducing R,Basic Installation,“Must Haves”

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

Open Source R

7

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

More Powerful: Microsoft R Open

8

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

RStudio

9

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

Connecting R and Excel: RExcel

10

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

CRAN Task Views

11

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

R “Must-have’s” and how to get started

Sources:

MRO:https://mran.microsoft.com/open/

RStudio:https://www.rstudio.com/

CRAN Task views:https://cran.r-project.org/web/views/

RExcel:http://rcom.univie.ac.at/

Seamless R and C++ Integration:http://www.rcpp.org/

12

R in a corporate environment

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

From Idea to Production

Modelers write “production” code, bypassing the traditional initial development and successive IT re-engineering, testing and de-bugging stage

IT teams set the framework, concentrate on data and result visualization

R can be integrated into various IT architectures with relative ease

Relatively low cost / highly scalable software and hardware solution

14

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

Website Application of R

15

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

The “Cloud”

16

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

Practitioner’s View Takeaways

17

• R very accessible with the typical pro’s and con’s of an open source software

• Relatively steep learning curve but easy to obtain initial results for defined tasks

• Caveat: “Garbage in, Garbage out”, Devil is in the details

• R is extremely powerful and flexible, especially with C++ integration

• R can be implemented at relatively low cost at an organizational level

• Typically no turn-key solution for organizational R integration

Proprietary & Confidential | ©2017 New England Asset Management, Inc. |

Q&A

18

Tobias Gummersbach

New England Asset Management, Inc.

[email protected]