# Presentation: 076636

## The Lapack for Clusters (LFC) Project

- Piotr Luszczek
**The MathWorks, Inc.**

## LFC: Overview

**Interactive clients**
**Mathematica**
**MATLAB**
**Python**

## LFC: Behind the scenes

- Internet
- Intranet
- Shared memory
- ...

**x = lfc.gesv(A, b)**

**x = b.copy()**
**command('pdgesv', A.id, x.id)**

**send(c_sckt, buf)**

**recv(s_sckt, buf)**

**call pdgesv(A, x)**

**Batch mode bypass**

## LFC: Current functionality

**Linear systems (via factorizations)**
**Cholesky: A = UTU****	****A = LLT**
**Gaussian: PA = LU**
**Least Squares: A = QR**
**Singular- and eigen-value problems**
**A = UΣVT****	****   (thin SVD)**
**AV=VΛ=AHV (symmetric AEP)**
**AV = VΛ****	****(non-symmetric AEP)**
**Norms, condition-number estimates**
**Precision, data types**
**Single, double**
**Real, complex**
**Mixed precision (by upcasting)**

**User data routines**
**Loading/Saving**
**MPI I/O**
**...**
**Generating**
**Plug-ins**
**Moving**
**More to come...**
**Now working on sparse **
**	****matrices support**

## LFC: Design and implementation

**Client logic (Python)**

**Server logic (Python)**

**Jython**

**PLW**

**PLW**

**Prototyping**

**Deployment**

**Java**

** ****C**
** ****MathLink**
** ****MEX**

**beowulf $ python setup.py install**
**beowulf $ mpirun python server.py**

**Pyrex**

**beowulf $ ./configure**
**beowulf $ make**
**beowulf $ make install**
**beowulf $ mpiexec server**

- Network

## LFC: Implemented MATLAB functionality

| Name | Single | Double | S-Complex | D-Complex | Description |
| --- | --- | --- | --- | --- | --- |
| chol |  |  |  |  | Cholesky factorization: LLT, UTU |
| lu |  |  |  |  | LU factorization: PA=LU |
| qr |  |  | -1 | -1 | QR factorization: A = QR |
| qrp | -1 | -1 | -1 | -1 | QR factorization+pivoting: PA=QR |
| Svd |  |  |  |  | Singular-value decomposition: A=UVT |
| Eig | -1 | -1 | -1 | -1 | Eigenvalue problem: AX=X |
| Syev |  |  | n/a | n/a | Symmetric eigenvalue problem |
| Heev | n/a | n/a |  |  | Hermitian eigenvalue problem |
| Diag |  |  |  |  | Diagonal matrix/vector |
| Trans |  |  |  |  | Matrix/vector transpose |
| Herm | n/a | n/a |  |  | Matrix/vector hermitian transpose |
| Norm |  |  |  |  | Matrix/vector norm |
| Cond |  |  |  |  | Condition number estimate |
| Inv | 0 | 0 | 0 | 0 | Explicit matrix inverse |

## Sample LFC code: Linear system solve

**MATLAB with LFC (parallel):**_**	**_**n = lfc(1000);****	****nrhs = 1;****	****A = rand(n);****	****b = rand(n, 1);****	****x = A \ b;****	****r = A*x – b;****	****norm(r, ‘fro’)**
**MATLAB – no LFC (sequential):****	****n = 1000;****	****nrhs = 1;****	****A = rand(n);****	****b = rand(n, 1);****	****x = A \ b;****	****r = A*x – b;****	****norm(r, ‘fro’)**

**Python with LFC (parallel):****	****n = 1000****	****nrhs = 1****	****A = lfc.rand(n)****	****b = lfc.rand(n, 1)****	****x = lfc.solve(A, b)****	****r = A*x – b****	****print r.norm(‘F’)**

## LFC’s C interface: Sequential calls, parallel execution

**In-memory routines**
**LFC_********gels()**
**LFC_********gesv()**
**LFC_********posv()**
**Limitations**
**Data must fit on caller**
**Cluster state functions**
**LFC_hosts_create()**
**LFC_hosts_free()**
**LFC_get_available_CPU()**
**LFC_get_free_memory()**

**Disk-based routines**
**LFC_********gels_file_all()**
**LFC_********gesv_file_all()**
**LFC_********posv****_file_all()**
**Limitations**
**Must pay I/O cost each time**

## LFC’s ease of deployment

**Only one file to download**
**Just type: ./configure && make && make install**

**ScaLAPACK**

**LAPACK**

**BLAS (vendor)**

**PBLAS**

**BLACS**

**MPI**

** ****LFC clients: C, Mathematica, MATLAB, Python**

**BLAS (LFC) **

**serial interface**

**parallel interface**

**global addressing**

**portable**

**local addressing**

**platform specific**

**External**
** ****to LFC**

**External**
** ****to LFC**

## Software technology used by LFC

**Client**
**Python**
**Sockets**
**MATLAB**
**Embedded Java**
**Jython**
**Reuse of Python code**
**C/C++**
**Code:**
**fork()**
**execvp()**
**Shell (implicit)**
**mpirun**
**mpiexec**

**Server**
**Libraries**
**MPI**
**BLAS**
**BLACS**
**LAPACK**
**ScaLAPACK**
**Languages**
**Python**
**Pyrex (C wrappers)**
**PLW**
**Python compiler**
**Translation to C**

## Contact

- Piotr Luszczek
- The MathWorks, Inc.(508) 647-6767luszczek@eecs.utk.edu

- http://icl.cs.utk.edu/lfc/