# Recipe: The Black-Scholes-Merton Formula Optimization for Intel® Xeon Phi™ Processor

### Introduction

Financial derivative pricing is a cornerstone of quantitative finance. The most common form of financial derivatives is common stock options, which are contracts between two parties regarding buying or selling an asset (specifically shares of stock) at a certain time at an agreed price. The two types of options are calls and puts. A call option gives the holder the right to buy the asset by a certain date for a certain price. A put option gives the holder the right to sell the asset by a certain date for a certain price. The contract price is called the exercise price or strike price. The date in the contract is known as the expiration date or maturity. American options can be exercised at any time before the expiration date. European options can be exercised only on the expiration date.

Typically, the value of an option f, is determined by the following factors:

• S – the current price of the underlying asset
• X – the strike price of the option
• T – the time to the expiration
• σ – the volatility of the underlying asset
• r – the continuously compounded risk-free rate

In their 1973 paper, “The Pricing of Options and Corporate Liabilities,” Fischer Black and Myron Scholes created a mathematical description of financial markets and stock options in frameworks built by researchers from Luis Bachelier to Paul Samuelson. Jack Treynor arrived at partial differential equations, which Robert Merton first referred as Black-Scholes Model.

This PDE has many solutions, corresponding to all the different derivatives with the same underlying asset S. The specific derivative obtained depends on the boundary conditions used while solving this equation. In the case of European call options, the key boundary condition is

fcall = max(S-K, 0) when t=T

In the case of European put options, it is

fput = max(K-S, 0) when t=T

### Black-Scholes-Merton Formula

Shortly after Black-Scholes’s historical paper, Robert Merton was the first one to publish a paper recognizing the significance and coined the term Black-Scholes option pricing model. Merton is also credited with a closed-form solution to the Black-Scholes Equation for European call options c, and the European put option p known as the Black-Scholes-Merton formula.

The function N(x) is the cumulative normal distribution function. It calculates the probability that a variable with a standard normal distribution of Ф(0,1) will be less than x. In most cases, N(x) is approximated using a polynomial function defined as:

### Code Access

The source code for Black-Scholes-Merton formula is maintained by Shuo Li and is available under the BSD 3-Clause Licensing Agreement. The program runs natively on Intel® Xeon Phi™ processors in a single node environment.

### Build and Run Directions

Here are the steps for building the program:

1. Install Intel® Parallel Studio XE 2016 SP 3 on your system.
2. Source the environment variable script file
3. Untar the BlackScholes.tar
4. Type make to build the binaries for Single and Double Precision:
1. For Single Precision processing: BlackScholesSP.knl
2. For Double Precision processing: BlackScholesDP.knl
5. Make sure the host machine is powered by Intel® Xeon Phi™ processors

\$ lscpu

Architecture:                   x86_64

CPU op-mode(s):           32-bit, 64-bit

Byte Order:                     Little Endian

CPU(s):                           272

On-line CPU(s) list:         0-271

Core(s) per socket:         68

Socket(s):                        1

NUMA node(s):                8

Vendor ID:                        GenuineIntel

CPU family:                      6

Model:                               87

Model name:                     Intel(R) Xeon Phi(TM) CPU 7250 @ 1.40GHz

Stepping:                          1

CPU MHz:                        1400.273

BogoMIPS:                        2793.61

Virtualization:                     VT-x

L1d cache:                        32K

L1i cache:                         32K

L2 cache:                         1024K

NUMA node0 CPU(s):     5,6,11,12,17,18,23-25,73-86,135-148,197-210,259-271

NUMA node1 CPU(s):     1,2,7,8,13,14,19,20,43-58,105-120,167-182,229-244

NUMA node2 CPU(s):     3,4,9,10,15,16,21,22,59-72,121-134,183-196,245-258

NUMA node3 CPU(s):     0,26-42,87-104,149-166,211-228For Double Precision processing: BlackScholesDP.kn

6. Make sure the memory mode for Intel® Xeon Phi™ processors is flat

```# syscfg /d biossettings "memory mode"
Memory Mode
===========
Current Value : Flat
---------------------
Possible Values
---------------
Cache : 00
Flat : 01
Hybrid : 02
Auto : 03```
7. Run BlackScholesSP.knl and BlackSchoelsDP.knl under numactl with parameter  –m1.

```[sli@wsl-knl-02 clean]\$ numactl -m1 ./BlackScholesSP.knl
Black-Scholes Formula Single Precision.
Compiler Version  = 16
Release Update    = 3
Build Time        = May 27 2016 17:57:13
Input Dataset     = 160432128
Repetitions       = 1000
Chunk Size        = 64

==========================================
Total Cycles                   = 19090695400
Cycles/OptionPair at thread 0  = 32.37
Time Elapsed                   = 13.6678
Options/sec                    = 23.4759

==========================================
[sli@wsl-knl-02 clean]\$ numactl -m1 ./BlackScholesDP.knl
Black-Scholes Formula Double Precision.
Compiler Version  = 16
Release Update    = 3
Build Time        = May 27 2016 17:57:14
Input Dataset     = 160432128
Repetitions       = 1000
Chunk Size        = 256