Guide
User Manual: Pdf
Open the PDF directly: View PDF
.
Page Count: 7
BLASFEO reference guide
Gianluca Frison
January 6, 2018

Contents
1 Introduction 2
2 BLASFEO implementations 3
3 Matrix and vector data types 4
3.1 blasfeo dmat structure ................................. 4
3.1.1 blasfeo dmat definition............................. 4
3.1.2 blasfeo dmat management ........................... 4
3.1.3 blasfeo dmat packing.............................. 5
3.1.4 blasfeo dmat printing.............................. 5
3.2 blasfeo dvec structure ................................. 5
3.2.1 blasfeo dvec definition............................. 5
3.2.2 blasfeo dvec management ........................... 6
3.2.3 blasfeo dvec packing.............................. 6
3.2.4 blasfeo dvec printing.............................. 6
1
Chapter 1
Introduction
BLASFEO - BLAS For Embedded Optimization.
BLASFEO is a library providing basic linear algebra routines performance-optimized for rather
small matrices (fitting in cache). A detailed introduction to BLASFEO can be found in the ArXiv
paper at the URL
https://arxiv.org/abs/1704.02457
2
Chapter 2
BLASFEO implementations
BLASFEO comes in three implementations:
•reference (RF)
•high-performance (HP)
•wrapper to BLAS and LAPACK (WR)
3

Chapter 3
Matrix and vector data types
The fundamental data types in BLASFEO are the C structures blasfeo dmat and blasfeo dvec,
defining respectively a double-precision matrix and vector (and similarly blasfeo smat and blasfeo sec
for single-precision matrix and vector).
Some structure members are common to all BLASFEO implementations, some others are spe-
cific to some BLASFEO implementation. Therefore, some structure members should be considered
public (typically, the common members), some others should be considered as private (and typi-
cally directly used only from advanced users and targeting specific BLASFEO implementations).
Below only the public members are documented.
3.1 blasfeo dmat structure
The structure blasfeo dmat defines the (double-precision) matrix type in BLASFEO. Structures
and routines for single-precision are analogue.
3.1.1 blasfeo dmat definition
struct blasfeo_dmat
{
int m;
int n;
double *pA;
int memsize;
};
where the structure members are
mnumber of rows in the matrix
nnumber of columns in the matrix
pA pointer to the first element of the matrix
memsize size (in bytes) of the memory referenced by the structure
3.1.2 blasfeo dmat management
void blasfeo_allocate_dmat(int m, int n, struct blasfeo_dmat *sA);
Populates the structure defining a m×nmatrix, referenced by sA and internally dynamically allo-
cated the memory referenced by the structure. The use of this routine is intended for prototype and
off-line use, and it not advised in performance-critical code, where the routine blasfeo create dmat
should be employed instead.
4

void blasfeo_free_dmat(struct blasfeo_dmat *sA);
Frees the memory allocated by the routine blasfeo allocate dmat.
int blasfeo_memsize_dmat(int m, int n);
Computes the size (in bytes) of the memory referenced by the structure defining a m×nmatrix.
The memory has to be externally allocated to use in the blasfeo create dmat routine.
void blasfeo_create_dmat(int m, int n, struct blasfeo_dmat *sA, void *memory);
Populates the structure defining a m×nmatrix, referenced by sA. The memory referenced by
the structure should be allocated externally and provided to the routine using the memory pointer.
It should typically be aligned to 64-byte boundaries (the typical cache line size). The amount of
memory referenced by the structure is computed using the blasfeo memsize dmat routine.
3.1.3 blasfeo dmat packing
void blasfeo_pack_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sA,
int ai, int aj);
void blasfeo_pack_tran_dmat(int m, int n, double *A, int lda, struct blasfeo_dmat *sA,
int ai, int aj);
void blasfeo_unpack_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj,
double *A, int lda);
void blasfeo_unpack_tran_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj,
double *A, int lda);
3.1.4 blasfeo dmat printing
void blasfeo_print_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj);
void blasfeo_print_tran_dmat(int m, int n, struct blasfeo_dmat *sA, int ai, int aj);
3.2 blasfeo dvec structure
The structure blasfeo dvec defines the (double-precision) vector type in BLASFEO. Structures
and routines for single-precision are analogue.
3.2.1 blasfeo dvec definition
struct blasfeo_dvec
{
int m;
double *pa;
int memsize;
};
where the structure members are
mnumber of elements in the vector
pA pointer to the first element of the vector
memsize size (in bytes) of the memory referenced by the structure
5

3.2.2 blasfeo dvec management
void blasfeo_allocate_dvec(int m, struct blasfeo_dvec *sx);
Populates the structure defining a m×1 vector, referenced by sx and internally dynamically allo-
cated the memory referenced by the structure. The use of this routine is intended for prototype and
off-line use, and it not advised in performance-critical code, where the routine blasfeo create dvec
should be employed instead.
void blasfeo_free_dvec(struct blasfeo_dvec *sx);
Frees the memory allocated by the routine blasfeo allocate dvec.
int blasfeo_memsize_dvec(int m);
Computes the size (in bytes) of the memory referenced by the structure defining a m×1 vector.
The memory has to be externally allocated to use in the blasfeo create dvec routine.
void blasfeo_create_dvec(int m, struct blasfeo_dvec *sx, void *memory);
Populates the structure defining a m×1 vector, referenced by sx. The memory referenced by
the structure should be allocated externally and provided to the routine using the memory pointer.
There are no alignment requirements for memory to be used by the vector structure. The amount
of memory referenced by the structure is computed using the blasfeo memsize dvec routine.
3.2.3 blasfeo dvec packing
void blasfeo_pack_dvec(int m, double *x, struct blasfeo_dvec *sx, int xi);
void blasfeo_unpack_dvec(int m, struct blasfeo_dvec *sx, int xi, double *x);
3.2.4 blasfeo dvec printing
void blasfeo_print_dvec(int m, struct blasfeo_dvec *sx, int xi);
void blasfeo_print_tran_dvec(int m, struct blasfeo_dvec *sx, int xi);
6