cholesky decomposition teodora aleksi ć, 391/2012
DESCRIPTION
C implementation Each element of the resulting matrix is calculated with one of these two equations. Using them we can assemble the C code. for (int i = 0; i < n; i++) for (int j = 0; j < (i+1); j++) { double sum = a[i][j]; for (int k = 0; k < j; k++) sum -= l[i][k] * l[j][k]; if(i == j){ l[i][j] = sqrt(sum); } else{ l[i][j] = sum / l[i][i]; } 3/12TRANSCRIPT
CholeskydecompositionTeodora Aleksić, 391/2012
Cholesky decomposition
◎ Cholesky factorization is a decomposition of a symmetric, positive-definite matrix (A) into a lower triangular matrix (L)
◎ It is mainly used for solutions of linear equations and Monte Carlo simulations
2/12
𝐴=(1 1 11 2 21 2 3) 𝐿=(1 0 0
1 1 01 1 1)
C implementation
Each element of the resulting matrix is calculated with one of these two equations.Using them we can assemble the C code.
for (int i = 0; i < n; i++) for (int j = 0; j < (i+1); j++) { double sum = a[i][j]; for (int k = 0; k < j; k++) sum -= l[i][k] * l[j][k];
if(i == j){ l[i][j] = sqrt(sum); } else{ l[i][j] = sum / l[i][i]; }}
3/12
Maxeler implementation challenges
◎ Our output matrix also serves as our input matrix
◎ An alternate solution to the square root◎ Overcoming the barrier between regular
Java types and DFE
4/12
L_Test matrix as our matrix L
Since we are comparing the C and Maxeler implementation, we can use the result of the C
decomposition as our input for the Maxeler calculation.
5/12
Possible solutions
Square rootThere are more ways to calculate the square root of a number than just the standard sqrt function.
Predicting our loopsWe can predict the lengths of our loops instead having them depend on our DFE variables.
DFEVar res1 = sum / 2;DFEVar temp = res1;
do{ temp = res1; res1 = (temp + (sum / temp)) / 2;}while((temp - res1) != zero)
DFEVar res1 = sum / 2;DFEVar temp = res1;
for(int k = 0; k < N; ++k){ ... ...}
6/12
7/12
Final Kernel graph
Possible improvements
So far, our stream went through the entire input and output matrix.
We can improve our performancesby only calculating those elements that matter to us.
2 3
6A =
1
9
54
7 8
8/12
Cholesky decompositio
nIs it a good
algorithm for Maxeler?
9/12
“I have not failed. I've just found
10,000 ways that won't work.
Thomas A. Edison
10/12
References
This presentations was made using the following resources:
◎ Milutinovic, V., Salom, J., Trifunovic, N., Giorgi, R., “Guide to DataFlow SuperComputing”, Springer, 2015.
◎ Milutinovic, V., et al., “Paradigm Shift in SuperComputing: DataFlow vs. ControlFlow”, Journal of Big Data, 2015.
◎ Hurson, A., Milutinovic, V., editors, “DataFlow Processing”, Elsevier, 2015.◎ Wikipedia.org, “Cholesky decomposition”, 2002., Available:
https://en.wikipedia.org/wiki/Cholesky_decomposition [Accessed: 26-Jan-2016].◎ Bishop, J., “Linear Algebra: Cholesky Decomposition Example”, 2013., Available:
https://www.youtube.com/watch?v=NppyUqgQqd0 [Accessed: 26-Jan-2016]◎ Smith, J., “Cordelia”, Available: http://
www.slidescarnival.com/cordelia-free-presentation-template/216 [Accessed: 30-Jan-2016]
11/12