template class xf::fintech::internal::FdBsLvSolverWrapper¶
#include "fd_bs_local_volatility_solver.hpp"
Overview¶
Internal wrapper class to encapsulate the Black-Scholes local volatility solver.
Parameters:
DT | Data Type used for this function |
DT_EQ_TYPE | Integer data type of same width as DT |
N | Discretized spatial grid size |
M | Discretized temporal grid maximum possible size |
template < typename DT, typename DT_EQ_TYPE, unsigned int N, unsigned int M > class FdBsLvSolverWrapper // typedefs typedef struct xf::fintech::internal::FdBsLvSolverWrapper::ParallelDataType ParallelDataType typedef hls::stream <ParallelDataType> ParallelStreamType typedef struct xf::fintech::internal::FdBsLvSolverWrapper::Parallel3DataType Parallel3DataType typedef hls::stream <Parallel3DataType> Parallel3StreamType // structs struct Parallel3DataType struct ParallelDataType // fields static const unsigned int BITS_PER_DATA_TYPE static const unsigned int DATA_ELEMENTS_PER_DDR_WORD
Methods¶
read_vector¶
void read_vector ( const ap_uint <512>* in, DT out [], const unsigned int size )
Read 512-bit DDR bus into array.
Parameters:
in | Pointer to data location in DDR |
out | Array of data as type DT |
size | Size of data region to read (required to be multiple of data elements in DDR) |
write_vector¶
void write_vector ( const DT in [], ap_uint <512>* out, const unsigned int size )
Write array to 512-bit DDR bus.
Parameters:
in | Array of data as type DT |
out | Pointer to data location in DDR |
size | Size of data region to read (required to be multiple of data elements in DDR) |
copy_vector¶
void copy_vector ( const DT in [], DT out [], const unsigned int size )
Copy array.
Parameters:
in | Array of data as type DT |
out | Array of data as type DT |
size | Size of data region to copy |
read_sigma¶
void read_sigma ( const ap_uint <512>* in, ParallelStreamType& sig0, ParallelStreamType& sig1, const unsigned int m )
Read sigma(x,t) from DDR for t=m-1 and t=m.
Parameters:
in | Pointer to start of sigma data location in DDR |
sig0 | sigma vector for t=m-1 |
sig1 | sigma vector for t=m |
m | time-step |
calculateDeltas¶
void calculateDeltas ( const DT* in, DT* out, const unsigned int size )
Calculate difference between consecutive data elements.
Parameters:
in | Array of data as type DT |
out | Array of data as type DT |
size | Size of vector |
stream_to_vector¶
void stream_to_vector ( ParallelStreamType& in, DT out [], unsigned int size )
Convert stream to a vector.
Parameters:
in | Input stream |
out | Output array |
size | Number of data elements to extract from stream |
vector_to_stream¶
void vector_to_stream ( DT in [], ParallelStreamType& out, unsigned int size )
Convert vector to a stream.
Parameters:
in | Input array |
out | Output stream |
size | Vector size |
stream3_to_vector3¶
void stream3_to_vector3 ( Parallel3StreamType& in, DT out [][3], unsigned int size )
Convert stream3 to a vector.
Parameters:
in | Input stream |
out | Output array |
size | Number of data elements to extract from stream |
generate_matrices¶
void generate_matrices ( const DT x [], const DT h [], const DT t [], const DT dt [], ParallelStreamType& sig0, ParallelStreamType& sig1, const DT r [], const DT boundary [], const DT theta, const unsigned int ti, Parallel3StreamType& lmatrix, Parallel3StreamType& rmatrix, ParallelStreamType& discountedBoundary )
Generate the left and right matrices in the Ax=B linear system.
Parameters:
x | Spatial grid |
h | Spatial grid spacings |
t | Temporal grid |
dt | Temporal grid spacings |
sig0 | Volatility vector sig(x) for t-1 |
sig1 | Volatility vector sig(x) for t |
r | Interest rate r(t) |
b | Boundary vector b(x) |
theta | Controls explicit/implicit/Crank-Nicholson |
ti | Time index for which matrices are generated |
lmatix | Left-hand matrix as stream |
rmatix | Right-hand matrix as stream |
discountedBoundary | b(x) vector discounted with r(t) as a stream |
diag3_mult¶
void diag3_mult ( Parallel3StreamType& m, ParallelStreamType& v, ParallelStreamType& u, const unsigned int size )
Multiple array stream by vector stream.
Parameters:
m | Matrix as stream holding 3 data elements |
v | Input vector as stream |
u | Output vector as stream |
size | Vector length |
triDiagSolverPCR¶
void triDiagSolverPCR ( Parallel3StreamType& m, ParallelStreamType& v, DT u [], const unsigned int size )
Solve tridiagonal Mu = v linear system using PCR algorithm.
Parameters:
m | Matrix as stream holding 3 data elements |
v | Input vector as stream |
u | Output solution vector as stream |
size | Vector length |
apply_boundary¶
void apply_boundary ( ParallelStreamType& in, ParallelStreamType& boundary, ParallelStreamType& out, unsigned int size )
Modify vector with boundary conditions (replaces in[0] and in[size-1] with boundary vector)
Parameters:
in | Input vector as stream |
boundary | Boundary vector as stream |
u | Output vector as stream |
size | Vector length |
parallel_block¶
void parallel_block ( ap_uint <512>* sigma, DT x [], DT h [], DT t [], DT dt [], DT r [], DT boundary [], DT theta, unsigned int ti, DT u_in [], DT u_out [] )
Wrapper function to allow parallelization.
Parameters:
x | Spatial grid |
h | Spatial grid spacings |
t | Temporal grid |
dt | Temporal grid spacings |
r | Interest rate r(t) |
b | Boundary vector b(x) |
theta | Controls explicit/implicit/Crank-Nicholson |
ti | Time index for which matrices are generated |
u_in | Input vector at time-step t-1 |
u_out | Output vector at time-step t |