Overview

Vitis BLAS Library Provisions

The Vitis™ BLAS Library provides:

  • A fast FPGA-accelerated implementation of the Standard Basic Linear Algebra Subroutines (BLAS)
  • High-level software interfaces written in C, C++ and Python for the ease of use without any additional hardware configurations
  • Low-level hardware interfaces written in HLS for greater flexibility and control 
Vitis Blas Library Matrix Image

Vitis BLAS Library - Functions

Vitis BLAS Library includes the following matrix and vector operation functions:

Functions for matrix operations:

  • General matrix multiplication

Functions for vector operations:

  • Search vector element position
  • Accumulate the magnitude of vector elements
  • Compute the dot product of two vectors
  • Compute a vector-scalar product
  • Compute the Euclidean norm of a vector
  • Swap, Scale, Copy vectors

Functions for matrix-vector operations:

  • General matrix-vector multiplication
  • General banded matrix-vector multiplication
  • Symmetric matrix and vector multiplication
  • Triangular matrix and vector multiplication

Vitis BLAS Library - Function Implementation Types

Vitis BLAS Library provides three types of function implementations, namely L1 primitive functions, L2 kernel functions and L3 software API functions. L1 primitive functions can be leveraged by FPGA hardware developers. L2 kernel functions are built by integrating L1 primitive functions and data movers, which can be called by host codes with XRT Runtime Library. L3 software API functions provide C, C++ and Python function interfaces to allow pure software developers to offload BLAS operations to AMD platforms without additional hardware related configurations. Some functions of the three types are listed in the table below. Note that Vitis BLAS Library currently does not provide any functions running on Versal AI Engine. 

Vitis BLAS Library functions L1 primitive functions
amax, amin: search vector element position
asum: accumulates the magnitude of vector elements
dot: computes the dot product of two vectors
axpy: computes a vector-scalar product and adds to the vector
nrm2: computes the Euclidean norm of a vector
swap, scal, copy: swap, scale or copy vectors
symv: symmetric matrix and vector multiplication
trmv: triangular matrix and vector multiplication
L2 kernel functions
Gemm class: general matrix multiplication
Gemv class: general matrix-vector Multiplication
L3 software API functions
xfblasCreate: initializes the library and creates a handle
xfblasFree: frees memory in FPGA device
xfblasGetMatrix: copies a matrix in FPGA device memory to host
xfblasExecute: starts the kernel and wait until it finishes
Note: Full L3 software API function list and introduction can be found here.

For the detailed differentiation of L1 primitive and L2 kernel functions, please refer to the table below. 

L1 primitive functions

  • Mainly provided for hardware-savvy developers who want to know the underlying implementation logic and make performance optimizations;
  • Always have stream interfaces;
  • Normally implemented for a single computation module;
  • can’t be called by host code directly;

L2 kernel functions

  • Mainly provided for host code developers who know XRT APIs;
  • Always have memory (DDR/HBM) interfaces;
  • Formed by chaining L1 primitive functions with some data mover modules;
  • Host-callable;

L3 Software API functions

  • Mainly provided for pure software engineer;
  • Function parameters are independent of hardware;
  • Normally used for deployment;
  • Host-callable;

Vitis BLAS Library - Organization

Vitis BLAS Library provides three types of function implementations, namely L1 primitive functions, L2 kernel functions and L3 software API functions. L1 primitive functions can be leveraged by FPGA hardware developers. L2 kernel functions are built by integrating L1 primitive functions and data movers, which can be called by host codes with XRT Runtime Library. L3 software API functions provide C, C++ and Python function interfaces to allow pure software developers to offload BLAS operations to AMD platforms without additional hardware related configurations. Some functions of the three types are listed in the table below. Note that Vitis BLAS Library currently does not provide any functions running on Versal AI Engine. 

For L1 sub-directories:

  • include/hw: the header files for primitive functions
  • tests/hw: the top modules including data movers and primitive functions
  • tests/sw: the testbench and infrastructure support for calling primitive functions

For L2 sub-directories:

  • include/hw: the header files for kernel functions
  • include/sw: the host modules for calling kernel functions
  • tests/hw: contains the Makefiles used for building each implemented kernel functions

For L3 sub-directories:

  • include/sw: the header files for software API functions
  • tests/sw: contains the Makefiles used for testing each implemented software API functions
2004720-blas-library-organization

Vitis BLAS Library - Execution in Vitis IDE

The libraries available in the Vitis GitHub repository can be compiled by using either the provided Makefiles for L2 and L3 functions as introduced above or the Vitis IDE. To use the library in the IDE, it must be downloaded as a library template at first, then a new Vitis project must be created by using the template. More information about creating L2 or L3 applications using the library template in Vitis GUI can be found here.

Getting Started