• No results found

Optimization of American option pricing through GPU computing

N/A
N/A
Protected

Academic year: 2022

Share "Optimization of American option pricing through GPU computing"

Copied!
34
0
0

Loading.... (view fulltext now)

Full text

(1)

IN

DEGREE PROJECT TECHNOLOGY, FIRST CYCLE, 15 CREDITS

STOCKHOLM SWEDEN 2017,

Optimization of American option pricing through GPU computing

HADAR GREINSMARK ERIK LINDSTRÖM

KTH ROYAL INSTITUTE OF TECHNOLOGY

SCHOOL OF ARCHITECTURE AND THE BUILT ENVIRONMENT

(2)

Optimization of American option pricing though GPU computing

GREINSMARK, HADAR LINDSTRÖM, ERIK

Bachelor of Technology in Computer Science Date: June 5, 2017

Supervisor: Jens Lagergren Examiner: Örjan Ekeberg

Swedish title: Optimering av prissättning av amerikanska optioner genom GPU-beräkningar

School of Computer Science and Communication

(3)
(4)

iii

Abstract

Over the last decades the market for financial derivatives has grown dramatically to values of global importance. With the digital automa- tion of the markets, programs able to efficiently value financial deriva- tives has become key to market competitiveness and thus garnered considerable interest. This report explores the potential efficiency gains of employing modern technology in GPU computing to price financial options, using the binomial option pricing model. The model is im- plemented using both CPU and GPU hardware and results compared in terms of computational efficiency. According to this thesis, GPU computing can considerably improve option pricing runtimes.

(5)

iv

Sammanfattning

Under de senaste decennierna har marknaden för finansiella derivat- instrument vuxit till värden av global betydelse. Med ökande digita- lisering av marknaden har program som effektivt kan värdera deri- vatinstrument blivit avgörande för konkurrenskraft och därför givits avsevärt intresse. Denna rapport utforskar vilka möjliga ökningar i ef- fektivitet som kan nås genom att använda modern teknik för GPU- beräkningar för att värdera finansiella optioner genom den binomi- ala optionsvärderingsmodellen. Modellen implementeras både med CPU-, och GPU-hårdvara och resultaten jämförs i termer av beräk- ningseffektivitet. Enligt denna studie kan GPU-beräkingar avsevärt förbättra körtider för optionsvärderingar.

(6)

Contents

1 Introduction 1

1.1 Problem definition . . . 1

1.2 Scope and constraints . . . 2

2 Background 3 2.1 Financial options . . . 3

2.2 The binomial method for option pricing . . . 4

2.3 Graphical processing units . . . 6

2.3.1 GPU hardware . . . 6

2.3.2 GPU programming . . . 7

2.3.3 CUDA . . . 8

2.4 Previous research . . . 10

3 Methods 11 3.1 Thesis hardware and programs . . . 11

3.2 Programs and implementations . . . 12

3.3 Benchmarking . . . 15

4 Results 16 5 Discussion 18 5.1 Results analysis . . . 18

5.2 Results discussion . . . 19

5.3 Suggestions for further research . . . 21

6 Conclusions 22

Bibliography 23

v

(7)

A Source code 26

List of Figures

2.1 Binomial tree structure . . . 4 2.2 CUDA memory model . . . 9 4.1 Implementation benchmark charts . . . 17

List of Algorithms

1 Basic binomial tree algorithm . . . 13

vi

(8)

Chapter 1 Introduction

With the dawn of digital information technology global financial mar- ket has increased dramatically in size and transformed in character.

Where historically the financial exchanges has been centered around trading financial assets such as shares or currencies, a market has de- veloped for financial derivative products. These derivatives today form the largest segment of the global financial market, with outstand- ing values many times both the global financial assets or global GDP (Bank of International Settlements 2016; Leibenluft 2008). This new fi- nancial market is increasingly driven by modern computer technology, creating demand for increasingly efficient and competitive computa- tional tools to aid in trading.

Recent years technological advances in parallel computing using graphical processing unit (GPU) hardware offers a high potential for increased computational power, using highly specialized processing clusters able to outperform conventional systems. Despite the technol- ogy’s potential power, deployment has been slow, possibly due to the complexity of the systems. In this report we simulate prices for finan- cial derivatives by using general purpose computing on graphical process- ing units (GPGPU) to achieve efficient simulation times, and identify optimization strategies that can be deployed to better results.

1.1 Problem definition

The thesis investigates what gains in computational efficiency can be made when algorithms for financial option pricing is implemented on

1

(9)

2 CHAPTER 1. INTRODUCTION

the current generation of GPGPU technology as compared to CPU- powered systems, and what optimization methods can be deployed to increase such gains.

1.2 Scope and constraints

To limit the size of the thesis only the binomial option pricing model is specifically treated and used as a representative of modern option pricing algorithms. Though there are several commonly used option pricing models, the binomial method is chosen due to its middle-tier complexity and wide adaptability. The binomial method is more com- plex than a closed formula solution but also more flexible and math- ematically simple enough that it retains most of its characteristics if adapted to a new context, making the results more generally interest- ing.

To further limit the scope of the thesis it specifically treats the pric- ing of American-style financial options. There exist a rich fauna of op- tion styles, the two most common being American and European op- tions. The pricing of European-style options are generally considered effectively solved with the introduction of an efficient closed-form so- lution in the Black-Scholes formula (Black and Scholes 1973), making American options the more interesting targets of further studies.

To ensure the relevance of the thesis it draws on previous research made on option pricing models, and published works on algorithm parallelization and implementation within GPU contexts. The contri- bution of this work is the comparative study of the implementation and the comparison between different levels of optimization of an im- plemented program.

(10)

Chapter 2 Background

This chapter introduces the financial, mathematical and technical con- cepts that forms the theoretical and contextual basis of the thesis. Fi- nancial options are introduced as the target of our studies, the main point of interest being their price dynamics following an underlying asset. The binomial option pricing model is then introduced in gen- eral detail to provide context for the thesis’ experiment, an excellent in-depth description is to be found in Cox, Ross, and Rubinstein (1979).

GPU hardware, programming and tools for GPU computing are then covered to describe the potential and limitations of the technology and provide insight in the technology used to produce the thesis experi- ment results. Previous research is then covered to contextualize the experiment results in contemporary research.

2.1 Financial options

Financial options are contracts that grants the holder the right, but not the obligation, to buy or sell an underlying asset at a fixed price at a later time (Poitras 2009). Financial options are today traded world- wide in large volumes at financial exchanges, and divided into cat- egories depending on the terms under which they can be activated.

The two most common types being European options, that can only be exercised at their expiration date, and American option, that can be exercised at any time up to their expiration (Hull 2017).

The value of an option is derived from how much better a price the holder can get when buying or selling the underlying asset as com-

3

(11)

4 CHAPTER 2. BACKGROUND

Figure 2.1: Binomial tree structure with three steps printed out (Joly- Stroebel 2010).

pared to the current market price, at that time or in the future. The price of options therefore follows the price of the underlying asset, both with their intrinsic value and with a time-dependant premium that comes from the possibility that the option might grow in value before it’s expiration (Williams and Hoffman 2001).

There are several approaches to calculating the expected value of options by forecasting the future development of the underlying asset.

Each of these approaches have different advantages and applications and the most common are the Black-Scholes formula, binomial option pricing formula and Monte Carlo simulations (Katz and McCormick 2005).

2.2 The binomial method for option pricing

The binomial method of option pricing was suggested by Cox, Ross, and Rubinstein (1979) and calculates the value of options from the as-

(12)

CHAPTER 2. BACKGROUND 5

sumption of an arbitrage-free market1. The model considers the life- time of an option in discrete steps and stipulates that the value of the underlying asset must either increase or decrease2 by a set factor in each step. The two possible values at the end of the time-step can then be used to calculate before the time-step, making it possible to calculate the current price at the trees beginning from the expiry-date outcomes at the tree end by starting at expiry and trickling down step- wise to the initial date (Cox, Ross, and Rubinstein 1979).

The model is widely used due to the simplicity of its mathematics, making it easy to understand and modify to depict different specifics of option contracts. While it is not universally applicable, the binomial method is, due to its tree structure, especially suitable to value options that can be exercised before their expiry date, such as American-style options. Though there has been criticisms against the underlying as- sumptions of the models (Merton 1976), it is constantly extended and modified to compensate for revealed faults.

The binomial option pricing method as presented by Cox, Ross, and Rubinstein (1979) could be executed with a computational com- plexity3 of θ(n2) where n are the number of discrete time-steps in the simulation. Since the models underlying binomial distribution con- verges towards a normal distribution as the number of simulation steps increases, the value of Cox-Ross-Rubenstein (CRR) solution converges to the Black-Scholes solution4at linear speed (N−1) by increasing num- ber of simulation steps N .

The binomial option pricing model has since been further devel- oped, especially as the interest of computational efficiency increased as the model was computationally automated. Leisen (1998) showed

1Arbitrage-free meaning that there can not be any market imbalances such that it is possible to capitalize without risk. This assumes that market forces would move in to exploit the arbitrage as soon as it manifested and thus balance it out, a common assumption in economic models.

2The binomial model does not allow the option price to remain unchanged in a time-step. The trinomial models, introduced by Boyle (1986) allows for this third possibility.

3In this thesis computational efficiency is used as described by Knuth (1976).

4The CRR binomial model converges towards the Black-Scholes value in the case of European-style options - options that can not be exercised before their expiry date.

If another kind of option is considered, the Black-Scholes formula must be amended, and this might no longer be the case.

(13)

6 CHAPTER 2. BACKGROUND

that the convergence rate can be increased to a quadratic N−2with the help of Richardson extrapolation. Based of the principles of Cox et al.

it has been proven that the lattice can be substituted by a combinatorial approach and solved in linear θ(n) time (Dai, Liu, and Lyuu 2008).

2.3 Graphical processing units

Graphical processing units are computer processors that evolved to support calculations for rendering5three-dimensional graphics. GPUs are commonly dedicated processors with many cores, specialized to- wards performing large numbers of floating-points operations by means of parallel calculations. (Owens, Luebke, et al. 2007) By virtue of be- ing specialized towards computational efficiency, a top-range GPU can provide many times the computational power of a comparable CPU unit (Owens, Luebke, et al. 2007; Fan et al. 2004; Lee et al. 2010).

2.3.1 GPU hardware

Computer hardware dedicated to rendering computer graphics emerged in the early 1980s, early versions introducing a model for comput- ing called the graphics pipeline to manage the taxing calculations. The model is still in use today through commonly used graphics APIs OpenGL and DirectX and consists of a number of sequential processes to trans- late data structures to two-dimensional images (Himawan and Vach- harajani 2006; Rumpf and Strzodka 2006). The pipeline was initially entirely fixed in its function but has in later years, starting with Nvidia’s GeForce 3 API in 2001 been partially programmable. This has made it possible to use the GPU hardware for general purpose computing (McClanahan 2010; Owens, Luebke, et al. 2007).

The difference in computational power between CPU and GPU units is the result in different specializations. CPU units are designed to be versatile all-round processors, performing in a balanced manner that can serve as the main cluster for an operating system. GPU units are instead designed for computational throughput and fitted with

5In computer graphics, rendering means the translation from the data structures storing a virtual scene to a two-dimensional image that can be displayed on a screen.

(14)

CHAPTER 2. BACKGROUND 7

many computational cores to efficiently solve hard problems by divid- ing them into smaller parts and processing them in parallel (Bridges, Imam, and Mintz 2016). Within Flynn’s taxonomy (Flynn 1966) GPU systems fall into the category of SPMD (same program, multiple data) architectures, an extension of the model that as suggested by Darema (2001) as a subcategory of MIMD architectures. In a modern GPU mul- tiple instances of the program executes in parallel on multiple data steams, but they do not typically execute in lockstep as in a SIMD en- vironment6, but can execute different instructions of the program at the same time (Owens, Houston, et al. 2008). While SPMD-processing has a high potential efficiency due to the large amount of computa- tional power that can be applied to the problem but is also limited in its versatility. If a problem can not be decomposed to fit a SPMD- architecture with many smaller bits of similar data or the problem has to be executed in sequence, many of the available computational cores might be left idle while the SPMD-processor runs on suboptimal ca- pacity.

2.3.2 GPU programming

Constructing programs to be run on a GPU is different from program- ming for a CPU environment. Often when programming high-level languages to be run by a CPU the user rarely have to interact with the underlying hardware since the CPU has layers of abstraction though the operating system. GPUs on the other hand are rarely used to run operating systems but are used as hardware accelerators – dedicated hardware to manage intensive calculations when so directed by the CPU.

For a program to interact with the GPU, a device that can have many architectures and software drivers, standardized APIs are of- ten used to give a uniform interface to the hardware. The program would then be run on the CPU-backed system, termed the host system,

6SPMD (same program, multiple data) is similar to SIMD (same instruction, multi- ple data), but with the crucial difference that the cores does not have to execute the same instruction at the same time, called executing in lockstep. Instead the cores can execute different instructions within the same program in parallel. This increased flexibility has shown to increase the flexibility, but also the efficiency of GPUs as the demands has increased in complexity.

(15)

8 CHAPTER 2. BACKGROUND

and could task the GPU, often termed device, to perform calculations.

These calculations is then given in the form of data copied from the host devices memory and kernels, functions that are then applied to each element in a data stream (Sanders and Kandrot 2010).

The target of GPU programming is commonly to write programs in such a way that as much as possible of the GPUs computational power is utilized. Due to the parallel architecture of GPU devices this means enabling as much as possible of the program to run in parallel and minimizing the numbers of conditionals. While modern GPU devices can handle conditionals on a thread level, they are taxing on the de- vice performance since they can not always be run in parallel (Owens, Houston, et al. 2008).

The most common APIs for GPU calculations are Microsoft’s Di- rectX and the Khronos group’s OpenGL that are widely used for graph- ics calculations. Since the emergence of programmable shaders special frameworks has been developed for GPGPU purposes with the most impactful being Nvidia’s CUDA released in 2007 and the Khronos group’s OpenCL released in 2008. These frameworks provide lan- guages and libraries that allow programmers tools to construct high- level programs for GPGPU environments (Su et al. 2012).

2.3.3 CUDA

Nvidias framework for general-purpose GPU programming is devel- oped and heavily promoted by the company and designed to work only with Nvidia’s own GPU hardware. The framework is built on top of the established C programming language and compiles the code into two parts, ordinary machine code for the CPU and and specially designed byte code called PTX7 for the GPU.

The CUDA framework has a specific memory model for how the program kernels are executed on the GPU with a hierarchy of mem- ories with different scope and persistence. In essence, each thread has access to the local memory and registers of the core it is executed by.

Each thread is part of a larger block of threads that are executed in par-

7PTX means Parallel Thread Execution and consist of a virtual instruction set archi- tecture used to execute the program in parallel. The program’s byte code is trans- lated into the hardware’s machine code before execution, making CUDA code mo- bile over GPU architectures and generations.

(16)

CHAPTER 2. BACKGROUND 9

Figure 2.2: The CUDA memory model (Gupta 2013).

allel batches called warps, each warp being executed in lockstep and chosen by an algorithm to optimize hardware utilization. The num- ber of threads per block varies between GPU cards, high-end hard- ware having a limit of 1024 threads per block. Each block has its own shared memory, as well as access to global, constant and texture mem- ories shared by all blocks. Blocks are important since thread execution can only be synchronized by the GPU within the same block, requir- ing data to be sent back and forth to the CPU to run programs larger than a single thread block, a transfer that is taxing on computational throughput (Nvidia 2017).

The main alternative to CUDA as a GPGPU framework is Khronos group’s OpenCL. Like CUDA, the framework is built around the C programming language and features a special memory model. Where CUDA is restricted to Nvidia hardware, OpenCL is designed to be portable and able to run on most computational hardware (including CPUs). Unbiased comparisons of computational efficiency between the two frameworks is hard to establish since CUDA only runs on Nvidia hardware and there have an unfair advantage in optimization,

(17)

10 CHAPTER 2. BACKGROUND

but CUDA is generally shown to run at least as well as OpenCL on Nvidia systems (Fang, Varbanescu, and Sips 2011; Karimi, Dickson, and Hamze 2010).

2.4 Previous research

Since the introduction of general-purpose GPU computing in 2001, moving option pricing onto GPU systems has been an ongoing re- search area within the wider field of increasing the efficiency of option pricing (Du et al. 2012; Solomon, Thulasiram, and Thulasiraman 2010).

Earlier works on using the binomial option pricing method specifi- cally is comparatively sparse. Zhang, Lei, and Man (2012) suggested a method of dividing the binomial tree into smaller subtrees which are processed in phases by a coordinated CPU-GPU hybrid process for further speedups. A study similar to his was published by Solomon, Thulasiram, and Thulasiraman (2010) who used GPU computing to achieve large gains in efficiency for exotic american-style look-back options.

While academic works are sparse implementations of option pric- ing algorithms can be found in varying quantity and quality published under open-source licenses and blogs within the financial technology sector. Nvidia has also published a number of books and texts con- taining option pricing programs for GPUs in order to promote their product CUDA (see H. Nguyen and Corporation (2008) and Podlozh- nyuk (2008).

(18)

Chapter 3 Methods

This thesis seeks to appraise the efficiency of option pricing models when implemented and executed on GPU hardware. To measure this the binomial tree method as introduced by Cox, Ross, and Rubin- stein (1979) was implemented on comparable CPU and GPU hard- ware. These programs were then executed with varying simulation resolutions and benchmarked.

This thesis also aims to appraise the efficiency of contemporary GPGPU optimization strategies that could be used for option pricing methods. To measure this, multiple additional implementations of the binomial tree method has been made featuring different alterations.

These programs were then executed with different simulation resolu- tions and benchmarked.

3.1 Thesis hardware and programs

The software and hardware used in this thesis was chosen to pro- duce results both indicative of the potential of contemporary tech- nology and applicable to the financial industry. Both software frame- works and hardware has therefore been chosen to be both modern and widely used in industry.

The algorithms in this thesis was both implemented to be executed on CPU and GPU systems. For the GPU programs Nvidia’s frame- work CUDA was used to write the programs. CUDA is together with the most used frameworks for GPGPU programming today and ap- pears as an informal industry standard. Since the CUDA framework

11

(19)

12 CHAPTER 3. METHODS

is built onto the C++ programming language the programs for CPU systems has also been written in C++.

All programs in this thesis was run with the help of the PDC center for high performance computing at KTH. The programs were run in a node within the Tegner supercomputer. The nodes used consists of two Intel Xeon E5-2690 v3 processors, a Nvidia Tesla K80 GPU accel- erator and 512 GB RAM. Both the CPUs and GPU in the nodes were launched as technical top-of-the-line in 2014 and has since been widely used in datacenters and computational arrays in academia and indus- try. The Intel CPU has a computational throughput in the region of 0.5 teraFLOPS1 while the GPU has a computational throughput around 5.5 teraFLOPS.

3.2 Programs and implementations

This experiment contains four implementations of the binomial tree option pricing method. The algorithm chosen is close to the lattice- based model suggested by Cox, Ross, and Rubinstein (1979), but made more efficient with dynamic programming techniques. The algorithm has a quadratic time complexity θ(2n)to the numbers of time-steps n.

The dynamic programming approach makes it more memory efficient than the CRR method, giving it a memory complexity of θ(n2) to the number of time-steps n.

The algorithm used does neither use any extrapolation or other op- timizations in the tree structure to increase rate of convergence. This is since the target of the thesis was to compare the execution times, and improvements to the end-step calculations should not consider- ably impact the comparisons, granted that they are symmetrically im- plemented.

The four implementations used in this thesis is here explained and for brevity labeled as implementations A, B, C, and C.

1FLOPS, or floating point operations per seconds, is the standard measurement of how fast advanced computational hardware can process machine instructions.

(20)

CHAPTER 3. METHODS 13

Algorithm 1:Basic algorithm of Binomial method used in exper- iment

1 S ←stock price

2 K ←strike price

3 n ←tree height

4 qup ← up factor

5 Pup← probability of going up

6 Pdown ← 1 − Pup 7 R ← er×∆T

8 for i ← 0 to n do

9 tree[i] ← max(0, K − S × u2i−n)

10 end

11 for j ← n down to 0 do

12 for k ← 0 to j do

13 b ← Pup×tree[j+1]+Pdown×tree[j]

R 14 e ← K − S × qup2i−n

15 tree[k] ← max(b, e)

16 end

17 end

(21)

14 CHAPTER 3. METHODS

Implementation 1: Base algorithm for the CPU (A)

The program A run on the CPU is a single-threaded implementation of the algorithm using the C++ language. It follows the chosen base algorithm closely without any optimization and acts as a baseline for the benchmark tests in this thesis. In the A-implementation, the tree (see figure 2.1) is constructed and then reduced row-by-row for each of the n steps. The single calculates each value in the rows, the number of which starts at n and is reduced by one for each row, leaving 1 value to be calculated in the last step.

Implementation 2: Base algorithm for the GPU (B)

The program B is the direct correspondent to the implementation A, following the algorithm closely without any further optimizations. The tree is constructed on the CPU and transferred to the global memory of the GPU where it is then reduced. The tree is then reduced row-by- row as in in implementation A, but with the difference that each of the between 1 and n values calculated in each row is calculated in a sepa- rate thread. Since the maximum number of threads in a single block is 1024 using the Tesla K80 GPU, and the maximum number of values in one row equals the number of steps in the simulation, the maximum number of steps n this implementation supports is 1024.

Implementation 3: Improved memory transfer for the GPU (C) C is a modified version of the basic GPU implementation B. The differ- ence between the two programs is that where the binomial tree repre- senting possible futures is constructed using the CPU and then trans- ferred in B, it is constructed directly in the global memory of the GPU in C. This replaces the time spent copying data between the CPU and GPU with the equivalent calculation made by the GPU.

Implementation 4: Improved memory access for the GPU (D)

D is a variation of the program C, where the binomial tree is both con- structed and reduced by the GPU, but instead of working within the GPU global memory, program uses the single thread blocks shared memory. This memory resides closer to the cores and allows for faster

(22)

CHAPTER 3. METHODS 15

communications, but further engraves the maximum number of steps to 1024.

3.3 Benchmarking

Benchmarked runtimes for programs are measured as the difference on the system clock between start of program initialization and end of program termination. This means the runtime includes memory allocation on both CPU and GPU as well as any memory transfer is included in the time. Loading time for initially transferring the appli- cation to system memory or loading system libraries is however not included, as these times are both comparatively insignificant as well as highly dependant on the operating system.

(23)

Chapter 4 Results

The results of the above figures was given though a long-run bench- mark test where the four implementation were test run with varying number of simulation steps. For each multiple of 10 in 0, 10, 20, ..., 1000 the price of an option was calculated 1000 times and the average run- time was admitted as test value. These values were then plotted using Matlab.

As seem in 4.1, the CPU-implementation (A) adhers closely to a quadratic curve, with some spikes around 900 and above. Comparing to the GPU versions, the CPU implementation (A) is more efficient than the GPU version (B) when the number of steps are below 100.

However, the memory allocation and kernel launches comes with an overhead for the GPU implementations that can be seen in the third panel 4.1 where it takes 636 µs for the B-implementation to calculate a 0-step simulation. For the baseline GPU program (B). The overhead corresponds to 88% for the program B runtime at n = 110 that is the breakpoints in efficiency between the CPU (A) and GPU (B) programs, and 30% of the runtime at 1000 steps.

16

(24)

CHAPTER 4. RESULTS 17

Figure 4.1: Benchmarking results of the different programs imple- mented in the thesis experiment. The results were calculated as the average run-rime of 1000 runs for each interval of 10 time-steps be- tween 0 and 1000.

(25)

Chapter 5 Discussion

5.1 Results analysis

Overall, the GPU implementations scale significantly better than the CPU implementation and is more efficient beyond 200 time-steps. It should however be noted that the CPU implementation is naive in comparison to the GPU programs. Since the CPU program is a single- tread implementation the runtime follows a quadratic runtime curve in accordance with the algorithm’s time complexity, but only uses one of the CPU’s twelve cores, and thus only a fraction of the hardware’s potential computational power1. The spikes in runtimes at higher sim- ulation resolutions are likely the results of scheduler interference and can be disregarded.

While the CPU implementation is suboptimal, it outperforms the GPU implementations below 200 time-steps. One reason of this is that the CPU has a higher clock frequency and therefore manages to go through the binomial tree faster than the GPU can synchronize and process the structure. Another reason is the considerable over- head that comes with transferring data between devices and allocat- ing memory on the GPU when launching the GPU program kernels.

In comparison the CPU executes the program directly, with data and code already in place and easily cached due to spatial locality.

1The x86 Haswell processors additionally has support for Advanced Vector Exten- sion 2 - a instruction set developed for high-end processors to aid in SIMD calculations. This could potentially make the processor effective beyond the expectation formed from the number of cores.

18

(26)

CHAPTER 5. DISCUSSION 19

The three GPU implementations differ in running time. The pro- gram C is more efficient than the program B until the region of 650 time-steps, whereafter there are no significant difference n their run- ning times. Both programs B and C scale less efficiently than D, result- ing in a 27% difference in time at 1000 time-steps.

5.2 Results discussion

The result that the GPU implementations are considerably faster than the CPU program is as could be expected from the potential of the respective hardware. Given tat the GPU is a more specialized piece of hardware for computational throughput and fields 11 times the peak FLOPS of the CPU, benchmark results of two ideal programs could be expected to have the same proportion. There are however obstacles to this ratio being reached.

Implementing a program that fully utilizes the power of the CPU is more complex than writing such a program for the GPU. Where the GPU SPMD architecture is designed for high levels of computational throughput, the CPU is designed for a higher degree of flexibility, and would require a high level of skill by the programmer to efficiently im- plement thread synchronization if using conventional programming languages. However, even a suboptimal implementation could poten- tially make the CPU competitive within the range of simulation reso- lutions commonly used in finance.

While the CPU implementation has rooms for improvement, so too does the GPU program. These benchmarks concerns the valuing of a single American-style option, using at first 1000 cores in parallel but for each step in the simulation one thread moves to idling as the tree is shrunk down row by row until only one thread is active in the last step.

Given that the GPU used for benchmarking has almost 5000 cores, these results has the GPU using a small part of it’s capacity throughout the simulation.

If gains in computational efficiency is made on both CPU and GPU implementations, the pattern that the CPU implementation outper- forms the GPU versions at lower number of time-steps while GPU im- plementations has far superior scaling capabilities due to the larger number of computational cores, can expected to hold. When con-

(27)

20 CHAPTER 5. DISCUSSION

cerned with the pricing of a single option, it is likely that using con- ventional CPU hardware is more efficient or on-par with GPU imple- mentation using a conventional number of time-steps (around 200). If a large number of options can be priced in batches, GPU programs will be more far more efficient than CPU implementations even at low simulation resolutions, both due to superior scaling and since the overhead of kernel launches could be split over many options. If the overhead could be discounted, the GPU programs in this thesis would have outperformed the CPU implementation at 30 steps. Batch pricing could additionally enable the GPU to approach optimum throughput through interweaving the pricing of options, allowing the triangular pattern of the algorithms thread usage to be replaced by a more effi- cient pattern.

In the context of batch processing, the optimization techniques em- ployed in this thesis become increasingly relevant. In batch processing the overhead of transferring constructed binomial trees to the GPU de- vice would scale with the number of options. Since our results show that is not less efficient to use the GPU to construct the binomial tree for any simulation resolution, this could be avoided by constructing the trees on the GPU. This method would however limit the number of possible simulation steps to 1024 without considerable changes to the algorithms memory management, likely a acceptable price given the the limit fall far above commonly used simulation resolutions. For simulations above 1024 time-steps the binomial tree would have to be divided into parts and the CPU used to coordinate the simulation us- ing multiple CUDA blocks.

The results show that it is beneficial to program efficiency to use shared memory when possible. The limit of thread block shared mem- ory is commonly 48kb on Nvidia high-end GPU accelerators, and with an algorithm memory complexity of θ(n) floats to n time-steps in sim- ulation, the shared memory size will likely limit the size of batches.

It is not clear from this thesis if launching multiple kernels running limited-size batches would be more efficient than transferring data be- tween the shared and global memories on the GPU.

(28)

CHAPTER 5. DISCUSSION 21

5.3 Suggestions for further research

While the results confirm potential gains in performance when pricing single options, it suggests two directions for further research.

Batch pricing of options needs to be further explored. While the results of this thesis suggests that the demonstrated efficiency gains could be reinforced though distributing the memory overhead over larger batches and utilizing the GPUs capacity more fully, this would need to be tested in practice. As the batch size increases, larger amounts of data would need to be transferred between the host and device sys- tems, and require additional memory management on the GPU, mak- ing results hard to predict.

Where this thesis investigates the scaling of computational efficiency with the number of time-steps in simulations, the exactness of the an- swers is not further treated. As it has been shown that the conver- gence rates of the binomial method can be greatly improved though extrapolation and similar optimizations it could be possible to produce equally accurate results with a lower simulation resolutions. While the general pattern in scaling between CPU and GPU option pricing pro- grams could be expected to hold even with a more complex program, altering the range of appropriate simulation resolutions could signifi- cantly alter the implication of the results found in this study.

(29)

Chapter 6

Conclusions

This study confirms that large efficiency gains in financial option pric- ing can be made through GPU computing. These gains are expected to be greatest when pricing is done in large batches or with high simula- tion resolutions. While not conclusively tested in this survey, it is pos- sible that a multi-threaded program executed on a conventional CPU can perform as well or slightly better than a program executed on a GPU of comparable power when using simulation resolutions around the lower limits of what is commonly used in the financial sector.

The results of this study shows that memory optimization tech- niques by utilizing the memory hierarchy of GPU frameworks and hardware considerably impacts the running times of GPU programs.

By explicitly using lower levels of the memory hierarchy and mini- mizing memory transfer between host and device systems, substantial performance gains can be made.

22

(30)

Bibliography

Bank of International Settlements (2016). Triennial Central Bank Survey of foreign exchange and OTC derivatives market in 2016. Tech. rep.URL: http://www.bis.org/publ/rpfx16.htm.

Black, Fischer and Myron Scholes (1973). “The pricing of options and corporate liabilities”. In: Journal of political economy 81.3, pp. 637–

654.

Boyle, Phelim P (1986). “Option valuation using a three-jump pro- cess”. In: International Options Journal 3.1, pp. 7–12.

Bridges, Robert A, Neena Imam, and Tiffany M Mintz (2016). “Under- standing GPU Power: A Survey of Profiling, Modeling, and Simu- lation Methods”. In: ACM Computing Surveys (CSUR) 49.3, p. 41.

Cox, John C, Stephen A Ross, and Mark Rubinstein (1979). “Option pricing: A simplified approach”. In: Journal of financial Economics 7.3, pp. 229–263.

Dai, Tian-Shyr, Li-Min Liu, and Yuh-Dauh Lyuu (2008). “Linear-time option pricing algorithms by combinatorics”. In: Computers & Math- ematics with Applications 55.9, pp. 2142–2157.

Darema, Frederica (2001). “The spmd model: Past, present and future”.

In: European Parallel Virtual Machine/Message Passing Interface Users’

Group Meeting. Springer, pp. 1–1.

Du, Peng et al. (2012). “From CUDA to OpenCL: Towards a performance- portable solution for multi-platform GPU programming”. In: Par- allel Computing 38.8, pp. 391–407.

Fan, Zhe et al. (2004). “GPU cluster for high performance computing”.

In: Supercomputing, 2004. Proceedings of the ACM/IEEE SC2004 Con- ference. IEEE, pp. 47–47.

Fang, Jianbin, Ana Lucia Varbanescu, and Henk Sips (2011). “A com- prehensive performance comparison of CUDA and OpenCL”. In:

23

(31)

24 BIBLIOGRAPHY

Parallel Processing (ICPP), 2011 International Conference on. IEEE, pp. 216–

225.

Flynn, Michael J (1966). “Very high-speed computing systems”. In: Pro- ceedings of the IEEE 54.12, pp. 1901–1909.

Gupta, Nitin (2013). What is constant memory in CUDA. http://cuda- programming.blogspot.se/2013/01/what-is-constant- memory-in-cuda.html. Blog.

Himawan, Budyanto and Manish Vachharajani (2006). “Deconstruct- ing hardware usage for general purpose computation on GPUs”.

In: Fifth Annual Workshop on Duplicating, Deconstructing, and De- bunking (in conjunction with ISCA-33).

Hull, J.C. (2017). Options, Futures, and Other Derivatives. Pearson Edu- cation.ISBN: 9780134631493.URL: https://books.google.se/

books?id=yfr0DQAAQBAJ.

Joly-Stroebel, Virginie (2010). File:Arbre Binomial Options Reelles.png.

[Online; accessed 02-May-2017].URL: %5Curl%7Bhttps://commons.

wikimedia . org / wiki / File : Arbre _ Binomial _ Options _ Reelles.png%7D.

Karimi, Kamran, Neil G Dickson, and Firas Hamze (2010). “A per- formance comparison of CUDA and OpenCL”. In: arXiv preprint arXiv:1005.2581.

Katz, J. and D. McCormick (2005). Advanced Option Pricing Models. McGraw- Hill Education.ISBN: 9780071454704.URL: https://books.google.

se/books?id=f-yHzG1VFGoC.

Knuth, Donald E (1976). “Big omicron and big omega and big theta”.

In: ACM Sigact News 8.2, pp. 18–24.

Lee, Victor W et al. (2010). “Debunking the 100X GPU vs. CPU myth:

an evaluation of throughput computing on CPU and GPU”. In:

ACM SIGARCH Computer Architecture News 38.3, pp. 451–460.

Leibenluft, Jacon (2008). “596T rillion!”. In: Slate. com, October 15.

Leisen, Dietmar PJ (1998). “Pricing the American put option: A de- tailed convergence analysis for binomial models”. In: Journal of Eco- nomic Dynamics and Control 22.8, pp. 1419–1444.

McClanahan, Chris (2010). “History and evolution of gpu architec- ture”. In: A Survey Paper, p. 9.

(32)

BIBLIOGRAPHY 25

Merton, Robert C (1976). “Option pricing when underlying stock re- turns are discontinuous”. In: Journal of financial economics 3.1-2, pp. 125–

144.

Nguyen, H. and NVIDIA Corporation (2008). GPU Gems 3. Lab Com- panion Series v. 3. Addison-Wesley.ISBN: 9780321515261.URL: https:

//books.google.se/books?id=ylNyQgAACAAJ.

Nvidia (2017). Toolkit Documentation v8.0. http : / / docs . nvidia . com/cuda/index.html.

Owens, John D, Mike Houston, et al. (2008). “GPU computing”. In:

Proceedings of the IEEE 96.5, pp. 879–899.

Owens, John D, David Luebke, et al. (2007). “A survey of general- purpose computation on graphics hardware”. In: Computer graphics forum. Vol. 26. 1. Wiley Online Library, pp. 80–113.

Podlozhnyuk, Victor (2008). Binomial option pricing model.

Poitras, Geoffrey (2009). “The early history of option contracts”. In:

Vinzenz Bronzin’s Option Pricing Models. Springer, pp. 487–518.

Rumpf, Martin and Robert Strzodka (2006). “Graphics processor units:

New prospects for parallel computing”. In: Numerical solution of partial differential equations on parallel computers. Springer, pp. 89–

132.

Sanders, J. and E. Kandrot (2010). CUDA by Example: An Introduction to General-Purpose GPU Programming, Portable Documents. Pearson Education.ISBN: 9780132180139.URL: https://books.google.

se/books?id=49OmnOmTEtQC.

Solomon, Steven, Ruppa K Thulasiram, and Parimala Thulasiraman (2010). “Option Pricing on the GPU”. In: High Performance Comput- ing and Communications (HPCC), 2010 12th IEEE International Con- ference on. IEEE, pp. 289–296.

Su, Ching-Lung et al. (2012). “Overview and comparison of OpenCL and CUDA technology for GPGPU”. In: Circuits and Systems (APC- CAS), 2012 IEEE Asia Pacific Conference on. IEEE, pp. 448–451.

Williams, M. and A. Hoffman (2001). Fundamentals of Options Market.

Fundamentals of Investing. McGraw-Hill Education.ISBN: 9780071379892.

URL: https://books.google.se/books?id=UaSkSoXVse0C.

Zhang, Nan, Chi-Un Lei, and Ka Lok Man (2012). “Binomial American Option Pricing on CPU-GPU Hetergenous System”. In: Engineering Letters 20.3, pp. 279–285.

(33)

Appendix A Source code

Sourcecodes, while too long to be included here, can be found pub- lished at github.com/HadarGreinsmark/gpu-option-pricing.

The benchmarks in this study were produced using the version under commit hdda2fe6e88243c2b1b07ec1d5287e6e6149b146d.

26

(34)

www.kth.se

References

Related documents

Denna del av projektet syftar till att identifiera befintliga metoder som kan användas för att verifiera hur ett material som används för frost eller dränering i tunnlar eller bergrum

In this paper we were given a MATLAB script pricing European call options using the Fokker-Planck equation and the A¨ıt-Sahalia method to circumvent the singular nature of the

Based on all the results obtained from the finite difference method, we can conclude that the price for European call option is convex and increases when the volatility

Alla läromedel täcker även omskärelsen, men denna är dock varierande där läromedel under Lgr80 får det att låta som om kvinnlig omskärelse har stöd i religionen, läromedel

It will be shown how a financial derivative priced with the binomial model satisfies Black-Scholes equation, and how the price of the underlying stock in the binomial model converge

When the option has no expiring date the value of the option does not depend on time but only on the price levels of the underlying asset i.e its derivative with respect to time

The preceding list is non-exhaustive and only shows that there are many, complex ways in which tweets can spread between users and that particular methods of retrieval and

Porter (1979) states that the strongest forces are of the greatest importance in the formulation of strategy and a that a corporate strategist’s goal is to pose their company in such