• Aucun résultat trouvé

European Option Princing on a GPU Cluster

N/A
N/A
Protected

Academic year: 2021

Partager "European Option Princing on a GPU Cluster"

Copied!
33
0
0

Texte intégral

(1)

HAL Id: hal-00364242

https://hal-supelec.archives-ouvertes.fr/hal-00364242

Preprint submitted on 25 Feb 2009

HAL is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

European Option Princing on a GPU Cluster

Lokman Abbas-Turki, Stéphane Vialle

To cite this version:

Lokman Abbas-Turki, Stéphane Vialle. European Option Princing on a GPU Cluster. 2009. �hal- 00364242�

(2)

European Option Princing on a

GPU Cluster

(ANR project « GCPMF »)

L. Abbas-Turki – ENPC S. Vialle – SUPELEC & INRIA

With the help of P. Mercier (SUPELEC) and B. Lapeyre (ENPC)

(3)

1 – Objectives

(4)

Objectives

Main objectives and difficulties

Final objective:

Scientific and technical locks:

• Design a parallel algorithm for an European option pricer

on GPU and cluster of GPU,

• Design and implement a right and efficient parallel RNG,

• Find out the right compromise between speedup, size up,

result accuracy and energy consumption

High speed European contract pricing (for hedging)

• using Monte-Carlo computations,

• using a clusters of multi-cores

(GPUs or multi-core CPUs)

(5)

2 – RNG parallelization and

comparison

(6)

RNG parallelization and comparison

Principles

• RNG on CPU vs RNG on GPU

1. Data transfer

2. Faster if Parallel

• Parallel RNGs: two efficient alternatives for GPU

1. Period Splitting

2. Parametrization

(7)

RNG parallelization and comparison

Parallel RNG: PLCG

• Parallelization with parametrization

X

n

= a.X

n-1

% m

• « a » is the parameter

• Chose an « a » for each sub-stream such that:

1.Good parallel independence inter-streams

Michael Mascagni SPRNG

2.Good sequential independence intra-stream

Donald E. Knuth Art of Computer Programming

3.Total period: 2

41

(int 32) and 2

65

(float 64)

(8)

RNG parallelization and comparison

Parallel RNG: CMRG

• Pierre L’Ecuyer: Combination of two MRGs (total period: 2

185

)

Xn = a1*Xn-1 + a2*Xn-2 + a3*Xn-3 % m

X’n = a’1*X’n-1 + a’2*X’n-2 + a’3*X’n-3 % m’

A= A’=

For example, if we want:

• one RNG/trajectory,

• 2

18

trajectories/GPU,

• maximum of 16 = 2

4

GPUs.

IP = 2185/222 = 2163 and X_1 = (X1, X2, X3)T, X’_1 = (X’1, X’2, X’3)T X_i= (AIP)i.X % m X’_i= (A’IP)i.X’ % m’

( )

00a3 10a2 01a1

( )

00a'3 10a'2 01a'1

(9)

RNG parallelization and comparison

Parallel RNG: Results

• Results Accuracy

Strike « K » Real PLCG MC PLCG error CMRG MC CMRG error

80 0.0610 0.0621 0.0023 0.0611 0.0024

90 0.5068 0.5115 0.0078 0.5088 0.0008

100 2.1723 2.1862 0.0178 2.1740 0.0177

110 5.9208 5.9433 0.0299 5.9159 0.0296

120 11.8810 11.9023 0.0407 11.8775 0.0406

(K-ST)+

ST S0 K K

RNG

Machine

Gaussian sample for PLCG generation/

second

Gaussian sample for CMRG generation/

second

CPU 2.24 Kg/s 2.03 Kg/s

GPU 883.58 Kg/s 239.80 Kg/s

• Speedup Results for PRNG

(10)

3 – Parallel algorithm and

implementations

(11)

Parallel algorithm and implementations

Parallel algorithm (1)

Parallel programming paradigms:

Coarse grain: message passing (MPI on PC cluster)

Medium grain: CPU-multithreading (OpenMP on multi-cores)

Fine grain: GPU-multithreading (CUDA on GPU)

Strategy:

• Avoid concurrent input file accesses

• Minimize data transfer between CPU and GPU memories.

• Common algorithm for multi-core-CPU and GPU clusters.

• When limited by the GPU memory:

“size up + speedup”

Asian Pricing on GPU cluster

0 5 10 15 20 25

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Nb of CPU+GPU nodes

T(s)

T-TotalExec(s) T-CalculGPU T-Transfert T-DataBcast T-IO T-CalculComm

106/4 106

106 trajectories

(12)

Parallel algorithm and implementations

Parallel algorithm (2)

PC0 Input

data files

PC1

PC0 PCP-1

PC1

PC0 PCP-1

GPU or CPU cores

PC1

PC0 PCP-1

GPU or CPU cores

PC1

PC0 PCP-1

GPU or CPU cores

PC1

PC0 PCP-1

PC0 Coarse grain

Coarse grain and fine grain Coarse grain and fine grain Coarse grain and fine grain

Coarse grain

1 - Input data reading on P0

2 - Input data broadcast from P0 3 - Parallel and independent RNG initialization

4 - Parallel and independent Monte-Carlo computations 5 - Parallel and independent partial results computation 6 - Partial results reduction on P0 and final price computation 7 – Print results and perfs

(13)

Parallel algorithm and implementations

GPU/CPU code comparison (1)

void ActStock(double sqrtdt) {

int StkIdx, yIdx, xIdx; // Loop indexes

#pragma omp parallel private(StkIdx,yIdx,xIdx) {

for (StkIdx = 0; StkIdx < NbStocks; StkIdx++) { Parameters_t *parPt = &par[StkIdx];

// Process each trajectory

#pragma omp for

for (yIdx = 0; yIdx < Ny; yIdx++)

for (xIdx = 0; xIdx < Nx; xIdx++) { float call;

// - First pass call = ……;

// - The passes that remain

for (int stock = 1; stock <= StkIdx ; stock++) call = ……;

// Copy result in the global GPU memory TabStockCPU[StkIdx][yIdx][xIdx] = call;

} }

} }

OpenMP parallelization on multi-core CPU: split the external loop

float TabStockCPU[NbStocks][Ny][Nx]

(14)

Parallel algorithm and implementations

GPU/CPU code comparison (2)

__global__ void Actual_kernel(void) {

float call, callBis;

// Computes the indexes and copy data into multipro sh. memory int xIdx = threadIdx.x + blockIdx.x*BlockSizeX;

int yIdx = blockIdx.y;

__shared__ float InputLine[Nx];

__shared__ float BrownLine[Nx];

InputLine[xIdx] = TabStockInputGPU[StkIdx][yIdx][xIdx];

GaussLine[xIdx] = TabGaussGPU[0][yIdx][xIdx];

// First pass call = ……;

callBis = call;

// The passes that remain

for (int stock = 1; stock <= StkIdx; stock++) {

GaussLine[xIdx] = TabGaussGPU[stock][yIdx][xIdx];

call = callBis*……;

callBis = call;

}

// Copy result in the global GPU memory

TabStockOutputGPU[StkIdx][yIdx][xIdx] = call;

}

CUDA parallelization on GPU: one kernel work on one trajectory

float TabStockOutputGPU[NbStocks][Ny][Nx]

(15)

Parallel algorithm and implementations

GPU/CPU code comparison (3)

void ActStock(double sqrtdt) {

// GPU thread management variables dim3 Dg, Db;

// Set thread Grid and blocks features

Dg.x = Nx/BlockSizeX; Dg.y = Ny; Dg.z = 1;

Db.x = BlockSizeX; Db.y = 1; Db.z = 1;

// Transfer a float version of the time increment on the GPU float sqrtdtCPU = (float) sqrtdt;

cudaMemcpyToSymbol(sqrtdtGPU,&sqrtdtCPU,sizeof(float),0, cudaMemcpyHostToDevice);

// For each stock: transfer its index on the GPU and compute // its actualization (process all trajectories)

for (int s = 0; s < NbStocks; s++) {

cudaMemcpyToSymbol(StkIdx,&s,sizeof(int),0, cudaMemcpyHostToDevice);

Actual_kernel<<<Dg,Db>>>(); //Run the GPU computation }

}

CUDA parallelization on GPU: one kernel work on one trajectory

float TabStockCPU[NbStocks][Ny][Nx];

float TabStockOutputGPU[NbStocks][Ny][Nx];

Æ Identical data structures for CPU and GPU versions when using one GPU-thread per trajectory

(16)

Parallel algorithm and implementations

Compilation

nvcc --host-compilation C++

-O3 -I/opt/openmpi/include -DOMPI_SKIP_MPICXX -c X.cu nvcc -O3 -L/opt/openmpi/lib

-o pricer X.o Y.o .... -lmpi -lm

OpenMPI + Cuda:

g++ -O3 -fopenmp -I/opt/openmpi/include -c X.cc

g++ -O3 -fopenmp -L/opt/openmpi/lib

-o pricer X.o Y.o ... -lmpi -lm

OpenMPI + OpenMP

This is a basic

C++ code.

Compilation

with CUDA

code is easy.

(17)

4 – Experiments and

performance analysis

(18)

Experiments and performance analysis

Computing perf (1)

Pricing execution time with PLCG

Good scaling on both systems.

Asian Pricer on clusters of GPU and CPU with PLCG

1E+00 1E+01 1E+02 1E+03 1E+04 1E+05

1 10 100 1000 10000

Nb of nodes

Total Exec Time(s)

T-1024x1024-1coreCPU T-512x1024-1coreCPU T-512x512-1coreCPU T-1024x1024-1nodeCPU T-512x1024-1nodeCPU T-512x512-1nodeCPU T-1024x1024-1nodeGPU T-512x1024-1nodeGPU T-512x512-1nodeGPU

(19)

Experiments and performance analysis

Computing perf (2)

Pricing execution time with CMRG

Good scaling on both systems.

GPU time is impacted by the RNG.

Asian Pricer on clusters of GPU and CPU with CMRG

1E+00 1E+01 1E+02 1E+03 1E+04 1E+05

1 10 100 1000 10000

Nb of nodes

Total Exec Time(s)

T-1024x1024-1coreCPU T-512x1024-1coreCPU T-512x512-1coreCPU T-1024x1024-1nodeCPU T-512x1024-1nodeCPU T-512x512-1nodeCPU T-1024x1024-1nodeGPU T-512x1024-1nodeGPU T-512x512-1nodeGPU

(20)

Experiments and performance analysis

Computing perf (3)

Pricing speed with PLCG

Asian Pricer on clusters of GPU and CPU with PLCG

1E+01 1E+02 1E+03 1E+04 1E+05

1 10 100 1000 10000

Nb of nodes

Nb of trajectories/s

NbTraj/s-1024x1024-1coreCPU NbTraj/s-512x1024-1coreCPU NbTraj/s-512x512-1coreCPU NbTraj/s-1024x1024-CPU NbTraj/s-512x1024-CPU NbTraj/s-512x512-CPU NbTraj/s-1024x1024-GPU NbTraj/s-512x1024-GPU NbTraj/s-512x512-GPU

47 Ktraj/s

18 Ktraj/s

Computation speed is independent of the problem size.

(21)

Experiments and performance analysis

Computing perf (4)

Pricing speed with CMRG

Computation speed is independent of the problem size.

GPU computation speed is impacted by the RNG choice.

Asian Pricer on clusters of GPU and CPU with PLCG

1E+01 1E+02 1E+03 1E+04 1E+05

1 10 100 1000 10000

Nb of nodes

Nb of trajectories/s

NbTraj/s-1024x1024-1coreCPU NbTraj/s-512x1024-1coreCPU NbTraj/s-512x512-1coreCPU NbTraj/s-1024x1024-CPU NbTraj/s-512x1024-CPU NbTraj/s-512x512-CPU NbTraj/s-1024x1024-GPU NbTraj/s-512x1024-GPU NbTraj/s-512x512-GPU

35 Ktraj/s

18 Ktraj/s

(22)

Experiments and performance analysis

Computing perf (5)

Pricing speedup with PLCG

With 16 GPU nodes: speedup vs 1-core-CPU reaches 1636, speedup vs 1-node-CPU reaches 707,

speedup vs 256-nodes-CPU cluster reaches 2.83.

Speedup vs 1CPU using PLCG

1E+0 1E+1 1E+2 1E+3 1E+4

1 10 100 1000

Nb of nodes

Speedup

SU-vs1coreCPU-1024x1024-GPU SU-vs1nodeCPU-1024x1024-GPU SU-vs1coreCPU-1024x1024-CPU SU-vs1nodeCPU-1024x1024-CPU

1636 433 707

187

577 249

x 2.83

(23)

Experiments and performance analysis

Computing perf (6)

Pricing speedup with CMRG

Speedup vs 1CPU using CMRG

1E+0 1E+1 1E+2 1E+3 1E+4

1 10 100 1000

Nb of nodes

Speedup

SU-vs1coreCPU-1024x1024-GPU SU-vs1nodeCPU-1024x1024-GPU SU-vs1coreCPU-1024x1024-CPU SU-vs1nodeCPU-1024x1024-CPU

1192 311 515

134

569 247

With 16 GPU nodes: speedup vs 1-core-CPU reaches 1192, speedup vs 1-node-CPU reaches 515,

speedup vs 256-nodes-CPU cluster reaches 2.09.

x 2.09

(24)

Asian Pricer on clusters of GPU and CPU using PLCG

1E+0 1E+1 1E+2 1E+3 1E+4

1 2 4 8 16 32 64 128 256

Nb of nodes

Consummed Watt.h

W.h-1024x1024-CPU W.h-512x1024-CPU W.h-512x512-CPU W.h-1024x1024-GPU W.h-512x1024-GPU W.h-512x512-GPU

Experiments and performance analysis

Energetic perf (1)

Energy consumption with PLCG

Air conditioned has not been considered.

16-nodes GPU cluster consumes 28.3 times less than a 256-nodes CPU cluster.

x28.3 0.016 KWh 0.446 KWh

(25)

Asian Pricer on clusters of GPU and CPU using CMRG

1E+0 1E+1 1E+2 1E+3 1E+4

1 2 4 8 16 32 64 128 256

Nb of nodes

Consummed Watt.h

W.h-1024x1024-CPU W.h-512x1024-CPU W.h-512x512-CPU W.h-1024x1024-GPU W.h-512x1024-GPU W.h-512x512-GPU

Experiments and performance analysis

Energetic perf (2)

Energy consumption with CMRG

0.446 KWh

0.023 KWh x 19.1

Air conditioned has not been considered.

16-nodes GPU cluster consumes 19.1 times less than a 256-nodes CPU cluster.

(26)

Asian Pricer on clusters of GPU and CPU using PLCG

1E-02 1E-01 1E+00 1E+01 1E+02

1 10 100 1000

Nb of nodes

Nb trajectories/J

Traj/s/W-1024x1024-CPU Traj/s/W-512x1024-CPU Traj/s/W-512x512-CPU Traj/s/W-1024x1024-GPU Traj/s/W-512x1024-GPU Traj/s/W-512x512-GPU

Experiments and performance analysis

Energetic perf (3)

Effectiveness of computing energy with PLCG

17.8 traj/J

0.627 traj/J

x 28.3

Currently, air conditioning has not been considered.

Effectiveness of computing energy is 28.3 times higher on the 16-nodes GPU cluster.

(27)

Asian Pricer on clusters of GPU and CPU using CMRG

1E-02 1E-01 1E+00 1E+01 1E+02

1 10 100 1000

Nb of nodes

Nb trajectories/J

Traj/s/W-1024x1024-CPU Traj/s/W-512x1024-CPU Traj/s/W-512x512-CPU Traj/s/W-1024x1024-GPU Traj/s/W-512x1024-GPU Traj/s/W-512x512-GPU

Experiments and performance analysis

Energetic perf (4)

Effectiveness of computing energy with CMRG

x 19.0 12.4 traj/J

0.653 traj/J

Currently, air conditioning has not been considered.

Effectiveness of computing energy is 19.0 times higher on the 16-nodes GPU cluster.

(28)

GPU cluster is 2.83x28.3 = 80.1 times more efficient

Experiments and performance analysis

Bi-core CPU cluster vs GPU cluster

Global comparison of GPU and CPU clusters

256 bi-core Xeon 3075, RAM 4Go, cache 4Mo

1 CISCO 256-ports switch, gigabit-eth

16 bi-core Intel E8200, RAM 4Go, cache 6Mo Asus GeForce 8800 GT

1 DELL 24-ports switch, gigabit-eth

58.70s

464.3Wh

Benchmark : 1024x1024 trajectories

40 stocks European contract pricing RNG: PLCG

20.72s

16.4Wh

Speedup = 2.83

Saving = 28.3

(29)

5 – Conclusion and

perspectives

(30)

Conclusion & Perspectives

Developments:

• OpenMPI + CUDA + “C+” were compatible.

• Learning CUDA + all dev ≈ 3 weeks (2 people).

• Debug on GPU was hard.

Performances:

• Good scaling

• GPU cluster computes faster

• GPU cluster consumes less energy

• Too high quality RNG is harmful

• PLCG + 16-node GPU cluster

Æ 1636 times faster than 1-core CPU

Æ 2.8 times faster than 256-node CPU cluster

Æ consumes 28.3 times less than 256-node CPU cluster

Next steps:

• Experiment others Monte-Carlo simulations

• Design algorithm with better perf & mixed perf (speedup x energy saving)

(31)

European Option Pricing on a GPU

Cluster

(ANR project « GCPMF »)

Questions ?

(32)
(33)

Building a cluster of GPUs

Hardware choice

Product model: EN8800GT/G/HTDP/512M

• Multiprocessors: 14

• Stream processors: 112

• Core clock: 600 MHz

• Memory clock: 900 MHz

• Memory amount: 512 MB

• Memory interface: 256-bit

• Memory bandwidth: 57.6 GB/sec

• Texture fill rate: 33.6 billion/sec

GPU on each node: ASUS GeForce 8800 GT

Asynchronous communications and

Cuda 1.1 supported

CPU on each node: 1 processor dual-cores Intel E8200, 2.66 GHz front side bus:1333MHz

RAM : 4Go DDR3, cache : 6Mo

Références

Documents relatifs

Execution time of our PDE solver on a 100 × 100 × 100 problem, with the heterogeneous GPU cluster, with synchronous (left) and asynchronous (right)

Abstract We study the impact of asynchronism on parallel it- erative algorithms in the particular context of local clusters of workstations including GPUs.. The application test is

instead of Cutting Plane Method (CPM) may obtain more quick convergence speed, it becomes less effective when dealing with the large-scale training data sets; on the other hand,

In order to automate shared memory removal, shared memory and global memory indexing functions must be the same for each CUDA thread and only depend on compile-time constants and

In the CPU/GPU hybrid computing environment, the cost of sending short message between two nodes can be predicted as o s1 + l +o r1 ( LogP), where l is the latency of communi-

In contrary to these approaches, we concern a domain-specific problem where it is necessary to solve the generalized eigenvalues problem for a large number of small matrices

Thunis, X &amp; Schauss, M 1988, 'Quelques réflexions à propos du Code européen de bonne conduite en matière de paiement électronique', Droit de l'Informatique et des Télécoms,