Coding FLAME Algorithms with FLAMElab Example Cholesky factorization
Coding FLAME Algorithms with FLAME@lab Example: Cholesky factorization Robert van de Geijn Department of Computer Sciences, UT-Austin
What is FLAME@lab? • FLAME@lab is the Mscript Application Programming Interface (API) for coding FLAME algorithms. • Mscript is the programming language for Matlab and Octave (which is a public domain version of Matlab).
This tutorial assumes that you have already completed the FLa. Te. X tutorial or that you are at least familiar with the Spark tool
Download paper • Step one: download from http: //www. cs. utexas. edu/users/flame/pubs. html: – Paolo Bientinesi and Robert van de Geijn. " Representing Dense Linear Algebra Algorithms: A Farewell to Indices. " FLAME Working Note #17 The University of Texas at Austin, Department of Computer Sciences. Technical Report TR-2006 -? ? . • Postscript • PDF • (Actually, you just need Figure 6, which also appears on the next slide)
This tutorial will show you how to code the algorithms in Figure 6 with FLAME@lab
Download FLAME@lab • Download the FLAME@lab files by visiting http: //www. cs. utexas. edu/users/flame/book/Downloads/
Translate the Cholesky factorization algorithms to code
Start the Spark tool for generating code skeletons at http: //www. cs. utexas. edu/users/flame/Spark/
Fill in the form
Select FLAME@lab and click “Generate Code”
Click on the right window and Select All
Copy
Paste into your favorite text editor
Translate the update for unblocked variant 1 in Figure 6 into Mscript operations Save the result in a file called “Chol_unb_var 1. m” From Figure 6
Write a simple test routine % B = rand 5 x 5 matrix B = rand( 5, 5 ); Save the result in a file called “test_chol. m” % A is Symmetric Positive Definite A = B * B’ % % % L Use matlab to compute Cholesky factor L. Note that chol( A ) computes U s. t. A = U’ * U so that L = chol( A )’ % Compute Cholesky factor with your implementation. % Note that only lower triangular part is updated! my. L = Chol_unb_var 1( A ) Diff = L – tril( my. L ) % Check the difference
Test your Cholesky factorization (Variant 1) • Assumption: – The FLAME@lab “. m” files are in the same directory as all the files listed below OR you have set the path to where you put them. – You have the following files in the directory • Chol_unb_var 1. m • test_chol. m – Start octave (or Matlab): • octave --traditional • test_chol
The difference is very small, but nonzero due to roundoff errors
Exercises • Before going on, try the following exercises (the answers are in the subsequent slides) – Use the Spark tool to generate a code skeleton for blocked algorithm variant 1 (See Figure 6). Store the result in file “Chol_blk_var 1. m” • Note: to test it, change the obvious call to my. L = Chol_blk_var 1( A, 2 ) so that a block size of 2 is used. – Repeat for unblocked and blocked variants 2
- Slides: 25